diff --git a/.bzrignore b/.bzrignore
index f26e041f3ba622c2fd801d492688da2dcd3701a3..978926c8c370d141c1774db1fb828f65402b3eaf 100644
--- a/.bzrignore
+++ b/.bzrignore
@@ -76,6 +76,9 @@ PENDING/*
 TAGS
 aclocal.m4
 autom4te.cache/*
+autom4te.cache/output.0
+autom4te.cache/requests
+autom4te.cache/traces.0
 bdb/README
 bdb/btree/btree_auto.c
 bdb/build_unix/*
@@ -84,17 +87,21 @@ bdb/build_vxworks/db_int.h
 bdb/build_win32/db.h
 bdb/build_win32/db_archive.dsp
 bdb/build_win32/db_checkpoint.dsp
+bdb/build_win32/db_config.h
+bdb/build_win32/db_cxx.h
 bdb/build_win32/db_deadlock.dsp
 bdb/build_win32/db_dll.dsp
 bdb/build_win32/db_dump.dsp
 bdb/build_win32/db_int.h
 bdb/build_win32/db_java.dsp
 bdb/build_win32/db_load.dsp
+bdb/build_win32/db_perf.dsp
 bdb/build_win32/db_printlog.dsp
 bdb/build_win32/db_recover.dsp
 bdb/build_win32/db_stat.dsp
 bdb/build_win32/db_static.dsp
 bdb/build_win32/db_tcl.dsp
+bdb/build_win32/db_test.dsp
 bdb/build_win32/db_upgrade.dsp
 bdb/build_win32/db_verify.dsp
 bdb/build_win32/ex_access.dsp
@@ -110,9 +117,16 @@ bdb/build_win32/excxx_lock.dsp
 bdb/build_win32/excxx_mpool.dsp
 bdb/build_win32/excxx_tpcb.dsp
 bdb/build_win32/include.tcl
+bdb/build_win32/libdb.def
 bdb/build_win32/libdb.rc
 bdb/db/crdel_auto.c
 bdb/db/db_auto.c
+bdb/dbinc_auto/*.*
+bdb/dbreg/dbreg_auto.c
+bdb/dist/autom4te.cache/*
+bdb/dist/autom4te.cache/output.0
+bdb/dist/autom4te.cache/requests
+bdb/dist/autom4te.cache/traces.0
 bdb/dist/config.hin
 bdb/dist/configure
 bdb/dist/tags
@@ -121,11 +135,17 @@ bdb/dist/template/gen_client_ret
 bdb/dist/template/rec_btree
 bdb/dist/template/rec_crdel
 bdb/dist/template/rec_db
+bdb/dist/template/rec_dbreg
+bdb/dist/template/rec_fileops
 bdb/dist/template/rec_hash
 bdb/dist/template/rec_log
 bdb/dist/template/rec_qam
 bdb/dist/template/rec_txn
+bdb/examples_c/ex_apprec/ex_apprec_auto.c
+bdb/examples_c/ex_apprec/ex_apprec_auto.h
+bdb/examples_c/ex_apprec/ex_apprec_template
 bdb/examples_java
+bdb/fileops/fileops_auto.c
 bdb/hash/hash_auto.c
 bdb/include/btree_auto.h
 bdb/include/btree_ext.h
@@ -154,16 +174,33 @@ bdb/include/tcl_ext.h
 bdb/include/txn_auto.h
 bdb/include/txn_ext.h
 bdb/include/xa_ext.h
+bdb/java/src/com/sleepycat/db/Db.java
+bdb/java/src/com/sleepycat/db/DbBtreeStat.java
 bdb/java/src/com/sleepycat/db/DbConstants.java
+bdb/java/src/com/sleepycat/db/DbHashStat.java
+bdb/java/src/com/sleepycat/db/DbLockStat.java
+bdb/java/src/com/sleepycat/db/DbLogStat.java
+bdb/java/src/com/sleepycat/db/DbMpoolFStat.java
+bdb/java/src/com/sleepycat/db/DbQueueStat.java
+bdb/java/src/com/sleepycat/db/DbRepStat.java
+bdb/java/src/com/sleepycat/db/DbTxnStat.java
+bdb/libdb_java/java_stat_auto.c
+bdb/libdb_java/java_stat_auto.h
 bdb/log/log_auto.c
 bdb/qam/qam_auto.c
 bdb/rpc_client/db_server_clnt.c
 bdb/rpc_client/gen_client.c
+bdb/rpc_server/c/db_server_proc.c
+bdb/rpc_server/c/db_server_proc.sed
+bdb/rpc_server/c/db_server_svc.c
+bdb/rpc_server/c/db_server_xdr.c
+bdb/rpc_server/c/gen_db_server.c
 bdb/rpc_server/db_server.x
 bdb/rpc_server/db_server_proc.sed
 bdb/rpc_server/db_server_svc.c
 bdb/rpc_server/db_server_xdr.c
 bdb/rpc_server/gen_db_server.c
+bdb/test/TESTS
 bdb/test/include.tcl
 bdb/test/logtrack.list
 bdb/txn/txn_auto.c
@@ -197,6 +234,7 @@ configure.lineno
 core
 db-*.*.*
 dbug/user.t
+depcomp
 extra/comp_err
 extra/my_print_defaults
 extra/mysql_install
@@ -212,6 +250,9 @@ include/my_global.h
 include/mysql_version.h
 include/widec.h
 innobase/autom4te.cache/*
+innobase/autom4te.cache/output.0
+innobase/autom4te.cache/requests
+innobase/autom4te.cache/traces.0
 innobase/configure.lineno
 innobase/conftest.s1
 innobase/conftest.subs
@@ -516,3 +557,8 @@ vio/test-ssl
 vio/test-sslclient
 vio/test-sslserver
 vio/viotest-ssl
+bkpull.log
+bkpull.log.2
+bkpull.log.3
+build.log
+sql/safe_to_cache_query.txt
diff --git a/BUILD/Makefile.am b/BUILD/Makefile.am
index 438b3a528cd89ebad60f90dbf8f449700b3c17f2..9c1ab24fde707f5956cff1c7709d83a461534286 100644
--- a/BUILD/Makefile.am
+++ b/BUILD/Makefile.am
@@ -37,7 +37,7 @@ EXTRA_DIST =		FINISH.sh \
 			compile-pentium-pgcc \
 			compile-solaris-sparc \
 			compile-solaris-sparc-debug \
-			compile-solaris-sparc-fortre \
+			compile-solaris-sparc-forte \
 			compile-solaris-sparc-purify
 
 # Don't update the files from bitkeeper
diff --git a/BUILD/compile-pentium-valgrind-max b/BUILD/compile-pentium-valgrind-max
new file mode 100755
index 0000000000000000000000000000000000000000..016b698a970e32bcde7bfce9eeb95d16231abeae
--- /dev/null
+++ b/BUILD/compile-pentium-valgrind-max
@@ -0,0 +1,13 @@
+#! /bin/sh
+
+path=`dirname $0`
+. "$path/SETUP.sh"
+
+extra_flags="$pentium_cflags $debug_cflags -DHAVE_purify"
+c_warnings="$c_warnings $debug_extra_warnings"
+cxx_warnings="$cxx_warnings $debug_extra_warnings"
+extra_configs="$pentium_configs $debug_configs"
+
+extra_configs="$extra_configs --with-berkeley-db --with-innodb --with-embedded-server --with-openssl"
+
+. "$path/FINISH.sh"
diff --git a/BUILD/compile-solaris-sparc-forte b/BUILD/compile-solaris-sparc-forte
new file mode 100755
index 0000000000000000000000000000000000000000..afd106afc678eb2d03f8813d338396df9ba38e3e
--- /dev/null
+++ b/BUILD/compile-solaris-sparc-forte
@@ -0,0 +1,39 @@
+#! /bin/sh
+
+gmake -k clean || true
+/bin/rm -f */.deps/*.P config.cache
+ 
+aclocal && autoheader && aclocal && automake && autoconf
+(cd bdb/dist && sh s_all)
+(cd innobase && aclocal && autoheader && aclocal && automake && autoconf)
+if [ -d gemini ]
+then
+   (cd gemini && aclocal && autoheader && aclocal && automake && autoconf)
+fi
+
+
+# Assume Forte is installed in /opt/SUNWSpro
+
+PATH=/opt/SUNWspro/bin/:$PATH
+
+# For "optimal" code for this computer add -fast to EXTRA
+# To compile 64 bit, add -xarch=v9 to EXTRA_64_BIT
+
+EXTRA_64_BIT="-xarch=v9"	# Remove comment to get 64 bit binaries
+EXTRA="-fast"			# Remove comment to target current machine
+
+#
+# The following should not need to be touched
+#
+
+STD="-mt -D_FORTEC_ $EXTRA $EXTRA_64_BIT"
+ASFLAGS="$EXTRA_64_BIT" \
+CC=cc-5.0 CFLAGS="-Xa -xstrconst $STD" \
+CXX=CC CXXFLAGS="-noex $STD" \
+./configure --prefix=/usr/local/mysql --enable-assembler --with-extra-charsets=complex --enable-thread-safe-client
+
+gmake -j 4
+if [ $? = 0 ]
+then
+  make test
+fi
diff --git a/BUILD/compile-solaris-sparc-fortre b/BUILD/compile-solaris-sparc-fortre
deleted file mode 100755
index dca0412c9798cd11bb12af52cb5db7d1815b608a..0000000000000000000000000000000000000000
--- a/BUILD/compile-solaris-sparc-fortre
+++ /dev/null
@@ -1,19 +0,0 @@
-#! /bin/sh
-
-gmake -k clean || true
-/bin/rm -f */.deps/*.P config.cache
- 
-aclocal && autoheader && aclocal && automake && autoconf
-(cd bdb/dist && sh s_all)
-(cd innobase && aclocal && autoheader && aclocal && automake && autoconf)
-if [ -d gemini ]
-then
-   (cd gemini && aclocal && autoheader && aclocal && automake && autoconf)
-fi
-
-PATH=/opt/SUNWspro/bin/:$PATH
-CC=cc CFLAGS="-Xa -fast -xO4 -native -xstrconst -mt -D_FORTREC_" \
-CXX=CC CXXFLAGS="-noex -xO4 -mt"  \
-./configure --prefix=/usr/local/mysql --enable-assembler --with-extra-charsets=complex --enable-thread-safe-client
-
-gmake -j 4
diff --git a/BitKeeper/etc/config b/BitKeeper/etc/config
index 8305314e51bf85e8d6f848674bf2916ee353b3b5..ea30f368b528b8e92e638b9ae169d93ec2ccad80 100644
--- a/BitKeeper/etc/config
+++ b/BitKeeper/etc/config
@@ -42,7 +42,7 @@ single_host:
 # discovers a problem which requires local intervention.  Please make the
 # contact information accurate so we can support you.
 # 
-contact: Sasha Pachev <sasha@mysql.com> 
+contact: sys@mysql.com
 # 
 # It is very important that this email address is filled out and accurate.
 # If someone converts your repository to open logging (which you may not
@@ -51,7 +51,7 @@ contact: Sasha Pachev <sasha@mysql.com>
 # response from anyone else at your location after 90 days, then open logging
 # will be implicitly approved.
 # 
-email: sasha@mysql.com 
+email: sys@mysql.com 
 # 
 # Add your street address if you like, it is optional.
 # 
diff --git a/BitKeeper/etc/logging_ok b/BitKeeper/etc/logging_ok
index aec1275d516af22d1038ff5b94e463a47772808e..c424926a248f9a0f495b54396258f7cde49f4623 100644
--- a/BitKeeper/etc/logging_ok
+++ b/BitKeeper/etc/logging_ok
@@ -16,6 +16,7 @@ bar@gw.udmsearch.izhnet.ru
 bell@sanja.is.com.ua
 bk@admin.bk
 davida@isil.mysql.com
+gluh@gluh.(none)
 heikki@donna.mysql.fi
 heikki@hundin.mysql.fi
 heikki@rescue.
@@ -41,6 +42,7 @@ miguel@hegel.local
 miguel@light.
 miguel@light.local
 monty@bitch.mysql.fi
+monty@butch.
 monty@donna.mysql.fi
 monty@hundin.mysql.fi
 monty@mashka.mysql.fi
@@ -90,6 +92,7 @@ venu@myvenu.com
 venu@work.mysql.com
 vva@genie.(none)
 walrus@mysql.com
+wax@mysql.com
 worm@altair.is.lan
 zak@balfor.local
 zak@linux.local
diff --git a/Build-tools/Do-compile b/Build-tools/Do-compile
index a29bd99191daf496568c42f0b3021b6365855276..52c1951f48f794893c0f26a0256c05ef883e550a 100755
--- a/Build-tools/Do-compile
+++ b/Build-tools/Do-compile
@@ -8,13 +8,13 @@ use Getopt::Long;
 $opt_distribution=$opt_user=$opt_config_env="";
 $opt_dbd_options=$opt_perl_options=$opt_config_options=$opt_make_options=$opt_suffix="";
 $opt_tmp=$opt_version_suffix="";
-$opt_help=$opt_delete=$opt_debug=$opt_stage=$opt_no_test=$opt_no_perl=$opt_with_low_memory=$opt_fast_benchmark=$opt_static_client=$opt_static_server=$opt_static_perl=$opt_sur=$opt_with_small_disk=$opt_local_perl=$opt_tcpip=$opt_build_thread=$opt_use_old_distribution=$opt_enable_shared=$opt_no_crash_me=$opt_no_strip=0;
+$opt_help=$opt_delete=$opt_debug=$opt_stage=$opt_no_test=$opt_no_perl=$opt_with_low_memory=$opt_fast_benchmark=$opt_static_client=$opt_static_server=$opt_static_perl=$opt_sur=$opt_with_small_disk=$opt_local_perl=$opt_tcpip=$opt_build_thread=$opt_use_old_distribution=$opt_enable_shared=$opt_no_crash_me=$opt_no_strip=$opt_with_debug=0;
 $opt_innodb=$opt_bdb=$opt_raid=$opt_libwrap=0;
 
 GetOptions(
 	"bdb",
 	"build-thread=i",
-	"config-env=s",
+	"config-env=s" => \@config_env,
 	"config-options=s" => \@config_options,
 	"dbd-options=s",
 	"debug",
@@ -45,6 +45,7 @@ GetOptions(
 	"use-old-distribution",
 	"user=s",
 	"version-suffix=s",
+	"with-debug",
 	"with-low-memory",
 	"with-other-libc=s",
 	"with-small-disk",
@@ -53,11 +54,6 @@ GetOptions(
 usage() if ($opt_help);
 usage() if (!$opt_distribution);
 
-if ($opt_bdb && $opt_version_suffix eq "")
-{
-  $opt_version_suffix="-max";
-}
-
 if (@make_options > 0)
 {
 	chomp(@make_options);
@@ -70,6 +66,18 @@ if (@config_options > 0)
 	$opt_config_options= join(" ", @config_options);
 }
 
+if (@config_env > 0)
+{
+	chomp(@config_env);
+	$opt_config_env= join(" ", @config_env);
+}
+
+if (@config_env > 0)
+{
+	chomp(@config_env);
+	$opt_config_env= join(" ", @config_env);
+}
+
 chomp($host=`hostname`);
 $full_host_name=$host;
 $connect_option= ($opt_tcpip ? "--host=$host" : "");
@@ -208,6 +216,7 @@ if ($opt_stage <= 1)
   $opt_config_options.= " --disable-shared" if (!$opt_enable_shared); # Default for binary versions
   $opt_config_options.= " --with-berkeley-db" if ($opt_bdb);
   $opt_config_options.= " --with-client-ldflags=-all-static" if ($opt_static_client);
+	$opt_config_options.= " --with-debug" if ($opt_with_debug);
   $opt_config_options.= " --with-libwrap" if ($opt_libwrap);
   $opt_config_options.= " --with-low-memory" if ($opt_with_low_memory);
   $opt_config_options.= " --with-mysqld-ldflags=-all-static" if ($opt_static_server);
@@ -258,7 +267,7 @@ if ($opt_stage <= 3)
   log_system("rm -fr mysql-3* mysql-4* $pwd/$host/*.tar.gz");
   log_system("nm -n sql/mysqld | gzip -9 -v 2>&1 > sql/mysqld.sym.gz | cat");
 
-  $flags.= "--no-strip" if ($opt_no_strip);
+  $flags.= "--no-strip" if ($opt_no_strip || $opt_with_debug);
   check_system("scripts/make_binary_distribution --tmp=$opt_tmp --suffix=$opt_suffix $flags",".tar.gz created");
   safe_system("mv mysql*.tar.gz $pwd/$host");
   if (-f "client/.libs/mysqladmin")
@@ -381,13 +390,15 @@ if ($opt_stage <= 9 && !$opt_no_test)
   log_system("rm -f output/*");
   $tmp= $opt_fast_benchmark ? "--fast --user root --small-test" : "";
   check_system("perl ./run-all-tests --log --die-on-errors $connect_option $tmp","RUN-mysql");
+	# Run additional fast test with dynamic-row tables
+  check_system("perl ./run-all-tests --log --suffix=\"_dynamic_rows\" --die-on-errors $connect_option --fast --user=root --small-test --create-options=\"row_format=dynamic\"","RUN-mysql");
   if ($opt_innodb)
   {
-    check_system("perl ./run-all-tests --log --suffix=\"_innodb\" --die-on-errors $connect_option $tmp --create-option=\"type=innodb\"","RUN-mysql");
+    check_system("perl ./run-all-tests --log --suffix=\"_innodb\" --die-on-errors $connect_option $tmp --create-options=\"type=innodb\"","RUN-mysql");
   }
   if ($opt_bdb)
   {
-    check_system("perl ./run-all-tests --log --suffix=\"_bdb\" --die-on-errors $connect_option $tmp --create-option=\"type=bdb\"","RUN-mysql");
+    check_system("perl ./run-all-tests --log --suffix=\"_bdb\" --die-on-errors $connect_option $tmp --create-options=\"type=bdb\"","RUN-mysql");
   }
 }
 
@@ -498,6 +509,9 @@ If user is empty then no mail is sent.
 --version-suffix suffix
 Set name suffix (e.g. 'com' or '-max') for a distribution
 
+--with-debug
+Build binaries with debug information (implies "--no-strip")
+
 --with-low-memory
 Use less memory when compiling.
 
@@ -528,7 +542,7 @@ sub abort
     print TMP "To: $email\n";
     print TMP "Subject: $ver$opt_version_suffix compilation failed\n\n";
     close TMP;
-    system("tail -40 $log > $log.mail");
+    system("tail -n 40 $log > $log.mail");
     system("cat $mail_header_file $log.mail | $sendmail -t -f $email");
     unlink($mail_header_file);
     unlink("$log.mail");
@@ -604,7 +618,7 @@ sub which
   my(@progs)=@_;
   foreach $prog (@progs)
   {
-    chomp($found=`which $prog | head -1`);
+    chomp($found=`which $prog | head -n 1`);
     if ($? == 0 && $found ne "" && index($found," ") == -1)
     {
       $found =~ s|/+|/|g;	# Make nicer output
diff --git a/Docs/internals.texi b/Docs/internals.texi
index 871e51c50bdd4196d507294691ae8e7f47634ecc..7e364774e3909e05d5978573aa0e7b76370ee23c 100644
--- a/Docs/internals.texi
+++ b/Docs/internals.texi
@@ -1,5 +1,5 @@
 \input texinfo  @c -*-texinfo-*-
-@c Copyright 2002 MySQL AB, TcX AB, Detron HB and Monty Program KB
+@c Copyright 2002 MySQL AB
 @c
 @c %**start of header
 @setfilename internals.info
@@ -545,6 +545,8 @@ Print query.
 * basic packets::               
 * communication::               
 * fieldtype codes::             
+* protocol functions::          
+* protocol version 2::          
 @end menu
 
 @node raw packet without compression, raw packet with compression, protocol, protocol
@@ -755,7 +757,7 @@ For details, see @file{sql/net_pkg.cc::send_ok()}.
 		n data
 		
  
-@node fieldtype codes,  , communication, protocol
+@node fieldtype codes, protocol functions, communication, protocol
 @section Fieldtype Codes
 
 @example
@@ -779,6 +781,797 @@ Time            03 08 00 00     |01 0B                  |03 00 00 00
 Date            03 0A 00 00     |01 0A                  |03 00 00 00
 @end example
 
+@node protocol functions, protocol version 2, fieldtype codes, protocol
+@section Functions used to implement the protocol
+
+This should be merged with the above one and changed to texi format
+
+Raw packets
+-----------
+
+- The my_net_xxxx() functions handles the packaging of a stream of data
+  into a raw packet that contains a packet number, length and data.
+
+- This is implemented for the server in sql/net_serv.cc.
+  The client file, libmysql/net.c, is symlinked to this file
+
+The important functions are:
+
+my_net_write()		Store a packet (= # number of bytes) to be sent
+net_flush()		Send the packets stored in the buffer
+net_write_command()	Send a command (1 byte) + packet to the server.
+my_net_read()		Read a packet
+
+
+Include files
+-------------
+
+- include/mysql.h is included by all MySQL clients.  It includes the
+  MYSQL and MYSQL_RES structures.
+- include/mysql_com.h is include by mysql.h and mysql_priv.h (the
+  server) and includes a lot of common functions and structures to
+  handle the client/server protocol.
+
+
+Packets from server to client:
+-----------------------------
+
+sql/net_pkg.cc:
+
+ - Sending of error packets
+ - Sending of OK packets (= end of data)
+ - Storing of values in a packet
+
+
+sql/sql_base.cc:
+
+ - Function send_fields() sends the field description to the client.
+
+sql/sql_show.cc:
+
+ - Sends results for a lot of SHOW commands, including:
+   SHOW DATABASES [like 'wildcard']
+   SHOW TABLES    [like 'wildcard']
+
+
+Packets from client to server:
+------------------------------
+
+This is done in libmysql/libmysql.c
+
+The important ones are:
+
+- mysql_real_connect()		Connects to a mysqld server
+- mysql_real_query()		Sends a query to the server and
+				reads the ok packet or columns header.
+- mysql_store_result()		Read a result set from the server to memory
+- mysql_use_result()		Read a result set row by row from the server.
+
+- net_safe_read()		Read a packet from the server with
+				error handling.
+- net_field_length()		Reads the length of a packet string.
+- simple_command()		Sends a command/query to the server.
+
+
+
+Connecting to mysqld (the MySQL server)
+---------------------------------------
+
+- On the client side: libmysql/libmysql.c::mysql_real_connect().
+- On the server side: sql/sql_parse.cc::check_connections()
+
+The packets sent during a connection are as follows
+
+Server:  Send greeting package (includes server capabilites, server
+	 version and a random string of bytes to be used to scramble
+	 the password.
+Client:  Sends package with client capabilites, user name, scrambled
+	 password, database name
+
+Server:  Sends ok package or error package.
+
+Client:  If init command specified, send it t the server and read
+	 ok/error package.
+
+
+Password functions
+------------------
+
+The passwords are scrambled to a random number and are stored in hex
+format on the server.
+
+The password handling is done in sql/password.c. The important
+function is 'scramble()', which takes the a password in clear text
+and uses this to 'encrypt' the random string sent by the server
+to a new message.
+
+The encrypted message is sent to the server which uses the stored
+random number password to encrypt the random string sent to the
+client. If this is equal to the new message the client sends to the
+server then the password is accepted.
+
+@node protocol version 2,  , protocol functions, protocol
+@section Another description of the protocol
+
+This should be merged with the above one and changed to texi format.
+
+*****************************
+*
+* PROTOCOL OVERVIEW
+*
+*****************************
+
+The MySQL protocol is relatively simple, and is designed for high performance 
+through minimisation of overhead, and extensibility through versioning and 
+options flags. It is a request-response protocol, and does not allow 
+multitasking or multiplexing over a single connection. There are two packet
+formats, 'raw' and 'compressed' (which is used when both client and
+server support zlib compression, and the client requests that data be
+compressed):
+
+* RAW PACKET, shorter than 16 M *
+
++-----------------------------------------------+
+| Packet Length | Packet no     | Data          |
+| 3 Bytes       | 1 Byte        | n Bytes       |
++-----------------------------------------------+
+^                               ^
+|          'HEADER'             |
++-------------------------------+
+
+
+ * Packet Length: Calculated with int3store. See include/global.h for 
+                  details. The basic computation is length = byte1 + 
+                  (256 * byte2) + (256 * 256 * byte3). The max packetsize 
+                  can be 16 MB.
+
+ * Packet no:     The packet number is incremented for each sent packet.
+                  The first packet for each query from the client
+		  starts with 0.
+
+ * Data:          Specific to the operation being performed. Most often
+                  used to send string data, such as a SQL query.
+
+* COMPRESSED PACKET *
+
++---------------------------------------------------+-----------------+
+| Packet Length | Packet no | Uncomp. Packet Length | Compressed Data |
+| 3 Bytes       | 1 Byte    | 3 Bytes               | n bytes         |
++---------------------------------------------------+-----------------+
+^                                                   ^
+|                   'HEADER'                        |
++---------------------------------------------------+
+ 
+ * Packet Length: Calculated with int3store. See include/my_global.h for 
+                  details. The basic computation is length = byte1 + 
+                  (256 * byte2) + (256 * 256 * byte3). The max packetsize 
+                  can be 16 MB.
+
+ * Packet no:     The packet number is incremented for each sent packet.
+                  The first packet starts with 0.
+
+ * Uncomp. Packet Length: The length of the original, uncompressed packet
+   If this is zero then the data is not compressed.
+   
+ * Compressed Data: The original packet, compressed with zlib compression
+
+
+When using the compressed protocol, the client/server will only compress
+send packets where the new packet is smaller than the not compressed one.
+In other words, some packets may be compressed while others will not.
+
+The 'compressed data' is one or more packets in *RAW PACKET* format.
+
+*****************************
+*
+* FLOW OF EVENTS
+*
+*****************************
+
+To understand how a client communicates with a MySQL server, it is easiest 
+to start with a high-level flow of events. Each event section will then be 
+followed by details of the exact contents of each type of packet involved
+in the event flow.
+
+*                          *
+* CONNECTION ESTABLISHMENT *
+*                          *
+
+Clients connect to the server via a TCP/IP socket (port 3306 by default), a 
+Unix Domain Socket, or named pipes (on Windows). Once connected, the 
+following connection establishment sequence is followed:
+
++--------+                                                           +--------+
+| Client |                                                           | Server |
++--------+                                                           +--------+
+    |                                                                     |
+    |    Handshake initialisation, including MySQL server version,        |
+    |    protocol version and options supported, as well as the seed      |
+    |    for the password hash                                            |
+    |                                                                     |
+    |   <--------------------------------------------------------------   |
+    |                                                                     |
+    |    Client options supported, max packet size for client             |
+    |    username, password crypted with seed from server, database       |
+    |    name.                                                            |
+    |                                                                     |
+    |   -------------------------------------------------------------->   |
+    |                                                                     |
+    |    'OK' packet if authentication succeeds, 'ERROR' packet if        |
+    |    authentication fails.                                            |
+    |                                                                     |
+    |   <--------------------------------------------------------------   |
+    |                                                                     |
+
+
+
+* HANDSHAKE INITIALISATION PACKET *
+
+
++--------------------------------------------------------------------+
+| Header        | Prot. Version | Server Version String | 0x00       |  
+|               | 1 Byte        | n bytes		| 1 byte     |
+|--------------------------------------------------------------------|
+| Thread Number | Crypt Seed | 0x00    | CLIENT_xxx options          |
+|               |            |         | supported by server         |
+| 4 Bytes       | 8 Bytes    | 1 Byte  | 2 Bytes                     |
+|--------------------------------------------------------------------|
+| Server charset no.  | Server status variables | 0x00 padding       |
+| 1 Byte              | 2 Bytes                 | 13 bytes           |
++--------------------------------------------------------------------+
+
+ * Protocol version (currently '10')
+ * Server Version String (e.g. '4.0.5-beta-log').  Can be any length as
+   it's followed by a 0 byte.
+ * Thread Number - ID of server thread handling this connection
+ * Crypt seed - seed used to crypt password in auth packet from client
+ * CLIENT_xxx options - see include/mysql_com.h
+ * Server charset no. - Index of charset in use by server
+ * Server status variables - see include/mysql_com.h
+ * The padding bytes are reserverd for future extensions to the protocol
+
+* CLIENT AUTH PACKET *
+
+
++--------------------------------------------------------------------+
+| Header        | CLIENT_xxx options supported | max_allowed_packet  |
+|               | by client                    | for client          |
+|               | 2 Bytes                      | 3 bytes             |
+|--------------------------------------------------------------------|
+| User Name | 0x00   | Crypted Password | 0x00   | Database Name     |
+| n Bytes   | 1 Byte | 8 Bytes          | 1 Byte | n Bytes           |
+|--------------------------------------------------------------------|
+| 0x00                                                               |
+| 1 Byte                                                             |
++--------------------------------------------------------------------+
+
+ * CLIENT_xxx options that this client supports:
+
+#define CLIENT_LONG_PASSWORD    1       /* new more secure passwords */
+#define CLIENT_FOUND_ROWS       2       /* Found instead of affected rows */
+#define CLIENT_LONG_FLAG        4       /* Get all column flags */
+#define CLIENT_CONNECT_WITH_DB  8       /* One can specify db on connect */
+#define CLIENT_NO_SCHEMA        16      /* Don't allow database.table.column */
+#define CLIENT_COMPRESS         32      /* Can use compression protocol */
+#define CLIENT_ODBC             64      /* Odbc client */
+#define CLIENT_LOCAL_FILES      128     /* Can use LOAD DATA LOCAL */
+#define CLIENT_IGNORE_SPACE     256     /* Ignore spaces before '(' */
+#define CLIENT_INTERACTIVE      1024    /* This is an interactive client */
+#define CLIENT_SSL              2048     /* Switch to SSL after handshake */
+#define CLIENT_IGNORE_SIGPIPE   4096     /* IGNORE sigpipes */
+#define CLIENT_TRANSACTIONS     8192    /* Client knows about transactions */
+
+ * max_allowed_packet for the client (in 'int3store' form)
+ * User Name - user to authenticate as.  Is followed by a null byte.
+ * Crypted Password - password crypted with seed given in packet from
+                      server, see scramble() in sql/password.c
+ * Database name (optional) - initial database to use once connected
+   Is followed by a null byte
+
+At the end of every client/server exchange there is either an 'OK' packet
+or an 'ERROR' packet sent from the server. To determine whether a packet is
+an 'OK' packet, or an 'ERROR' packet, check if the first byte (after the 
+header) is 0xFF. If it has the value of 0xFF, the packet is an 'ERROR'
+packet.
+
+
+* OK PACKET *
+
+For details, see sql/net_pkg.cc::send_ok()
+
++-----------------------------------------------+
+| Header        | No of Rows    | Affected Rows |
+|               | 1 Byte        | 1-9 Byte      |
+|-----------------------------------------------|
+| ID (last_insert_id)   | Status | Length       |
+| 1-9 Byte              | 2 Byte | 1-9 Byte     |
+|-----------------------------------------------|
+| Messagetext                                   |
+| n Byte                                        |
++-----------------------------------------------+
+
+ * Number of rows, always 0 
+ * Affected rows
+ * ID (last_insert_id) - value for auto_increment column (if any) 
+ * Status (usually 0)
+
+In general, in the MySQL protocol, fields in a packet that that 
+represent numeric data, such as lengths, that are labeled as '1-9' 
+bytes can be decoded by the following logic:
+
+	If the first byte is '251', the
+        corresponding column value is NULL (only appropriate in 
+        'ROW DATA' packets).
+
+	If the first byte is '252', the value stored can be read
+        from the following 2 bytes as a 16-bit integer.
+                
+
+        If the first byte is '253' the value stored can be read
+        from the following 4 bytes as a 32-bit long integer
+
+          
+        If the first byte is '254', the value stored can be read
+        from the following 8 bytes as a 64-byte long
+                
+	Otherwise (values 0-250), the value stored is the value of the
+	first byte itself.
+
+
+If the OK-packet includes a message:
+
+ * Length of message
+ * Message Text
+
+
+* ERROR PACKET *
+
++-----------------------------------------------+
+| Header        | Status code   | Error no      |
+|               | 1 Byte        | 2 Byte        |
+|-----------------------------------------------|
+| Messagetext                          |        |
+| n Byte                               |        |
++-----------------------------------------------+
+
+ * Status code (0xFF = ERROR)
+ * Error number (is only sent to 3.23 and newer clients)
+ * Error message text (ends at end of packet)
+
+Note that the error message is not null terminated.
+The client code can however assume that the packet ends with a null
+as my_net_read() will always add an end-null to all read packets to
+make things easier for the client.
+
+Example:
+
+Packet dump of client connecting to server:
+
++------------------------- Protocol Version (10)
+|
+|  +---------------------- Server Version String (0x00 terminated)
+|  |
+|  |
+0a 34 2e 30 2e 35 2d 62     . 4 . 0 . 5 - b 
+65 74 61 2d 6c 6f 67 00     e t a - l o g . 
+15 00 00 00 2b 5a 65 6c     . . . . + Z e l 
+ |           |
+ |           +------------ First 4 bytes of crypt seed
+ | 
+ +------------------------ Thread Number
+
++------------------------- Last 4 bytes of crypt seed
+|
+|                +-------- CLIENT_XXX Options supported by server
+|                |
+|              +-+--+ +--- Server charset index
+|              |    | |
+6f 69 41 46 00 2c 28 08     o i A F . , ( . 
+02 00 00 00 00 00 00 00     . . . . . . . . 
+|  |
+|  +---------------------- 0x00 padding begins
+|
++------------------------- Server status (0x02 = 
+                           SERVER_STATUS_AUTOCOMMIT)
+
+00 00 00 00 00 00 00 00     . . . . . . . . 
+
+* Client Authentication Response (Username 'test', no database
+  selected) *
+
+    +--------------------- Packet Length (0x13 = 19 bytes)
+    |
+    |     +--------------- Packet Sequence #
+    |     |
+    |     |   +----------- CLIENT_XXX Options supported by client 
+          |   |
++---+---+ | +-+-+
+|       | | |   |
+13 00 00 01 03 00 1e 00     . . . . . . . . 
+00 74 65 73 74 00 48 5e     . t e s t . H ^
+   |          |   |
+   +----+-----+   +------- Scrambled password, 0x00 terminated
+        |
+        +----------------- Username, 0x00 terminated
+  
+57 4a 4e 41 4a 4e 00 00     W J N A J N . . 
+00                          . 
+
+
+>From this point on, the server waits for 'commands' from the client
+which include queries, database shutdown, quit, change user, etc (see
+the COM_xxxx values in include/mysql_com.h for the latest 
+command codes). 
+
+*                    *
+* COMMAND PROCESSING *
+*                    *
+
++--------+                                                           +--------+
+| Client |                                                           | Server |
++--------+                                                           +--------+
+    |                                                                     |
+    |    A command packet, with a command code, and string data           |
+    |    when appropriate (e.g. a query), (see the COM_xxxx values        |
+    |    in include/mysql_com.h for the command codes)                    |
+    |                                                                     |
+    |   -------------------------------------------------------------->   |
+    |                                                                     |
+    |    A 'RESULT' packet if the command completed successfully,         |
+    |    an 'ERROR' packet if the command failed. 'RESULT' packets        |
+    |    take different forms (see the details following this chart)      |
+    |    depending on whether or not the command returns rows.            |
+    |                                                                     |
+    |   <--------------------------------------------------------------   |
+    |                                                                     |
+    |    n 'FIELD PACKET's (if rows are returned)                         |
+    |                                                                     |
+    |   <--------------------------------------------------------------   |
+    |                                                                     |
+    |    'LAST DATA' packet                                               |
+    |                                                                     |
+    |   <--------------------------------------------------------------   |
+    |                                                                     |
+    |    n 'ROW PACKET's (if rows are returned)                           |
+    |                                                                     |
+    |   <--------------------------------------------------------------   |
+    |                                                                     |
+    |    'LAST DATA' packet                                               |
+    |                                                                     |
+    |   <--------------------------------------------------------------   |
+    |                                                                     |
+
+
+* Command Packet *
+
++------------------------------------------------------+
+| Header        | Command type | Query (if applicable) |
+|               | 1 Byte       | n Bytes               |
++------------------------------------------------------+
+
+ * Command type:  (e.g.0x03 = query, see the COM_xxxx values in 
+                   include/mysql_com.h)
+ * Query (if applicable)
+
+Note that my_net_read() null-terminates all packets on the
+receiving side of the channel to make it easier for the code
+examining the packets.
+
+The current command codes are:
+
+   0x00   COM_SLEEP
+   0x01   COM_QUIT
+   0x02   COM_INIT_DB
+   0x03   COM_QUERY
+   0x04   COM_FIELD_LIST
+   0x05   COM_CREATE_DB
+   0x06   COM_DROP_DB
+   0x07   COM_REFRESH
+   0x08   COM_SHUTDOWN
+   0x09   COM_STATISTICS
+   0x0a   COM_PROCESS_INFO
+   0x0b   COM_CONNECT
+   0x0c   COM_PROCESS_KILL
+   0x0d   COM_DEBUG
+   0x0e   COM_PING
+   0x0f   COM_TIME
+   0x10   COM_DELAYED_INSERT
+   0x11   COM_CHANGE_USER
+   0x12   COM_BINLOG_DUMP
+   0x13   COM_TABLE_DUMP 
+   0x14   COM_CONNECT_OUT
+   0x15   COM_REGISTER_SLAVE
+
+* Result Packet *
+
+Result packet for a command returning _no_ rows:
+
++-----------------------------------------------+
+| Header        | Field Count   | Affected Rows |
+|               | 1-9 Bytes     | 1-9 Bytes     |
+|-----------------------------------------------|
+| ID (last_insert_id)   | Server Status         |
+| 1-9 Bytes             | 2 Bytes               |
++-----------------------------------------------+
+
+ * Field Count: Has value of '0' for commands returning _no_ rows
+ * Affected rows: Count of rows affected by INSERT/UPDATE/DELETE, etc.
+ * ID: value of auto_increment column in row (if any).  0 if 
+ * Server Status: Usually 0
+
+Result packet for a command returning rows:
+
++-------------------------------+
+| Header        | Field Count   |
+|               | 1-9 Bytes     |
++-------------------------------+
+
+ * Field Count: number of columns/fields in result set,
+                 (packed with net_store_length() in sql/net_pkg.cc)
+
+This is followed by as many packets as the number of fields ('Field Count')
+that contain the metadata for each column/field (see unpack_fields() in 
+libmysql/libmysql.c):
+
+
+* FIELD PACKET *
+
++-----------------------------------------------+
+| Header        | Table Name		        |
+|               | length-coded-string           |
+|-----------------------------------------------|
+| Field Name					|
+| length-code-string				|
+|-----------------------------------------------|
+| Display length of field
+| length-coded-binary (4 bytes)			|
+|-----------------------------------------------|
+| Field Type (enum_field_types in mysql_com.h)  |
+| length-coded-binary (2 bytes)			|
+|-----------------------------------------------|
+| Field Flags	                | Decimal Places|
+| length-coded-binary (3 bytes) | 1 Byte        |
++--------------+-------------+------------------+
+
+ * A length coded string is a string where we first have a packet
+   length (1-9 bytes, packed_with net_store_length()) followed
+   by a string.
+ * A length coded binary is a length (1 byte) followed by an integer
+   value in low-byte-first order.  For the moment this type is always
+   fixed length in this packet.
+
+ * Table Name - the name of the table the column comes from
+ * Field Name - the name of the column/field
+ * Display length of field - length of field
+ * Field Type - Type of field, see enum_field_types in 
+                include/mysql_com.h
+
+   Current field types are:
+
+      0x00   FIELD_TYPE_DECIMAL 
+      0x01   FIELD_TYPE_TINY
+      0x02   FIELD_TYPE_SHORT  
+      0x03   FIELD_TYPE_LONG
+      0x04   FIELD_TYPE_FLOAT  
+      0x05   FIELD_TYPE_DOUBLE
+      0x06   FIELD_TYPE_NULL
+      0x07   FIELD_TYPE_TIMESTAMP
+      0x08   FIELD_TYPE_LONGLONG
+      0x09   FIELD_TYPE_INT24
+      0x0a   FIELD_TYPE_DATE   
+      0x0b   FIELD_TYPE_TIME
+      0x0c   FIELD_TYPE_DATETIME
+      0x0d   FIELD_TYPE_YEAR
+      0x0e   FIELD_TYPE_NEWDATE
+      0xf7   FIELD_TYPE_ENUM
+      0xf8   FIELD_TYPE_SET
+      0xf9   FIELD_TYPE_TINY_BLOB
+      0xfa   FIELD_TYPE_MEDIUM_BLOB
+      0xfb   FIELD_TYPE_LONG_BLOB
+      0xfc   FIELD_TYPE_BLOB
+      0xfd   FIELD_TYPE_VAR_STRING
+      0xfe   FIELD_TYPE_STRING
+      0xff   FIELD_TYPE_GEOMETRY
+
+ * Field Flags - NOT_NULL_FLAG, PRI_KEY_FLAG, xxx_FLAG in 
+                 include/mysql_com.h
+
+
+Note that the packet format in 4.1 has slightly changed to allow more values.
+
+
+* ROW PACKET *
+
++-----------------------------------------------+
+| Header        | Data Length   | Column Data   | ....for each column
+|               | 1-9 Bytes     | n Bytes       |
++-----------------------------------------------+
+
+ * Data Length: (packed with net_store_length() in sql/net_pkg.cc)
+                
+		If 'Data Length' == 0, this is an 'ERROR PACKET'.
+		
+ * Column Data: String representation of data. MySQL always sends result set
+                data as strings.
+
+* LAST DATA PACKET *
+
+Packet length is < 9 bytes, and first byte is 0xFE
+
++--------+
+| 0xFE   |
+| 1 Byte |
++--------+
+
+Examples:
+
+***********
+*
+* INITDB Command
+*
+***********
+
+A client issuing an 'INITDB' (select the database to use) command,
+followed by an 'OK' packet with no rows and no affected rows from
+the server:
+
+* INITDB (select database to use) 'COMMAND' Packet *
+
+    +--------------------- Packet Length (5 bytes)
+    |
+    |     +--------------- Packet Sequence #
+    |     |
+    |     |  +------------ Command # (INITDB = 0x02)
+          |  |
++---+---+ |  | +---------- Beginning of query data
+|       | |  | |
+05 00 00 00 02 74 65 73     . . . . . t e s 
+74                          t 
+
+* 'OK' Packet with no rows, and no rows affected *
+
+    +--------------------- Packet Length (3 bytes)
+    |
+    |     +--------------- Packet Sequence #
+    |     | 
++---+---+ |
+|       | |
+03 00 00 01 00 00 00        . . . . . . .
+
+
+***********
+*
+* SELECT query example
+*
+***********
+
+Client issuing a 'SELECT *' query on the following table:
+
+    CREATE TABLE number_test (minBigInt bigint, 
+                              maxBigInt bigint, 
+                              testBigInt bigint)
+
+* 'COMMAND' Packet with QUERY (select ...) *
+
+    +--------------------- Packet Length (26)
+    |
+    |     +--------------- Packet Sequence #
+    |     |
+    |     |  +------------ Command # (QUERY = 0x03)
+          |  |
++---+---+ |  | +---------- Beginning of query data
+|       | |  | |
+1a 00 00 00 03 53 45 4c     . . . . . S E L 
+45 43 54 20 2a 20 66 72     E C T . * . f r 
+6f 6d 20 6e 75 6d 62 65     o m . n u m b e 
+72 5f 74 65 73 74           r _ t e s t 
+
+
+and receiving an 'OK' packet with a 'FIELD COUNT' of 3
+
+
+* 'OK' Packet with 3 fields *
+
+    +--------------------- Packet Length (3 bytes)
+    |
+    |     +--------------- Packet Sequence #
+    |     | 
++---+---+ |
+|       | |
+01 00 00 01 03              . . . . . 
+
+Followed immediately by 3 'FIELD' Packets. Note, the individual packets 
+are delimitted by =======, so that all fields can be annotated in the first
+'FIELD' packet example:
+
+=============================================================
+
+    +--------------------- Packet Length (0x1f = 31 bytes)
+    |
+    |     +--------------- Packet Sequence #
+    |     | 
+    |     |  +------------ Block Length (0x0b = 11 bytes)
+    |     |  |   
++---+---+ |  |  +--------- Table Name (11 bytes long)
+|       | |  |  |
+1f 00 00 02 0b 6e 75 6d     . . . . . n u m  
+62 65 72 5f 74 65 73 74     b e r _ t e s t 
+
+ +------------------------ Block Length (9 bytes)
+ |
+ |  +--------------------- Column Name (9 bytes long)
+ |  |
+09 6d 69 6e 42 69 67 49     . m i n B i g I     
+6e 74 03 14 00 00 01 08     n t . . . . . .
+       | |       | |  |
+       | +---+---+ |  +--- Field Type (0x08 = FIELD_TYPE_LONGLONG)
+       |     |     |
+       |     |     +------ Block Length (1)
+       |     |
+       |     +--------------- Display Length (0x14 = 20 chars)
+       |
+       +------------------ Block Length (3)
+
+ +------------------------ Block Length (2)
+ |
+ |   +-------------------- Field Flags (0 - no flags set)
+ |   | 
+ | +---+  +--------------- Decimal Places (0)
+ | |   |  |
+02 00 00 00                 . . . .                                  
+
+=============================================================
+
+'FIELD' packet for the 'number_Test.maxBigInt' column
+
+1f 00 00 03 0b 6e 75 6d     . . . . . n u m
+62 65 72 5f 74 65 73 74     b e r _ t e s t
+09 6d 61 78 42 69 67 49     . m a x B i g I
+6e 74 03 14 00 00 01 08     n t . . . . . .
+02 00 00 00                 . . . .
+        
+=============================================================                    
+
+'FIELD' packet for the 'number_test.testBigInt' column
+
+20 00 00 04 0b 6e 75 6d     . . . . . n u m
+62 65 72 5f 74 65 73 74     b e r _ t e s t 
+0a 74 65 73 74 42 69 67     . t e st B i g
+49 6e 74 03 14 00 00 01     I n t . . . . .
+08 02 00 00 00              . . . . .
+============================================================= 
+
+Followed immediately by one 'LAST DATA' packet:
+
+fe 00                       . .
+
+Followed immediately by 'n' row packets (in this case, only
+one packet is sent from the server, for simplicity's sake):
+
+
+    +--------------------- Packet Length (0x52 = 82 bytes)
+    |
+    |     +--------------- Packet Sequence #
+    |     | 
+    |     |  +------------ Data Length (0x14 = 20 bytes)
+    |     |  |   
++---+---+ |  |  +--------- String Data '-9223372036854775808'
+|       | |  |  |          (repeat Data Length/Data sequence)
+
+52 00 00 06 14 2d 39 32     . . . . . - 9 2
+32 33 33 37 32 30 33 36     2 3 3 7 2 0 3 6
+38 35 34 37 37 35 38 30     8 5 4 7 7 5 8 0
+38 13 39 32 32 33 33 37     8 . 9 2 2 3 3 7
+32 30 33 36 38 35 34 37     2 0 3 6 8 5 4 7
+37 35 38 30 37 0a 36 31     7 5 8 0 7 . 6 1
+34 37 34 38 33 36 34 37     4 7 4 8 3 6 4 7
+
+Followed immediately by one 'LAST DATA' packet:
+
+fe 00                       . .
+
+
+
 @c The Index was empty, and ugly, so I removed it. (jcole, Sep 7, 2000)
 
 @c @node Index
@@ -786,6 +1579,276 @@ Date            03 0A 00 00     |01 0A                  |03 00 00 00
 
 @c @printindex fn
 
+@node 4.1 protocol,,,
+@subchapter MySQL 4.1 protocol
+
+@node 4.1 protocol changes,,,
+@section Changes to 4.0 protocol in 4.1
+
+All basic package handling is identical to 4.0. When communication
+with an old 4.0 or 3.x client we will use the old protocol.
+
+The new things that we support with 4.1 are:
+
+@itemize @bullet
+@item
+Warnings
+@item
+Prepared statements
+@item
+Binary protocol (will be much faster than the current protocol that
+converts everything to strings)
+@end itemize
+
+
+What has changed in 4.1 are:
+
+@itemize @bullet
+@item
+A lot of new field information (database, real table name etc)
+@item
+The 'ok' packet has more status fields
+@item
+The 'end' packet (send last for each result set) now contains some
+extra information
+@item
+New protocol for prepared statements.  In this case all parameters and
+results will sent as binary (low-byte-first).
+@end itemize
+
+
+@node 4.1 field package,,,
+@section 4.1 field description package
+
+The field description package is sent as a response to a query that
+contains a result set.  It can be distinguished from a ok package by
+the fact that the first byte can't be 0 for a field package.
+@xref {4.1 ok package}.
+
+The header package has the following structure:
+
+@multitable @columnfractions .10 .90
+@item Size @tab Comment
+@item 1-9  @tab Number of columns in result set (never 0)
+@item 1-9  @tab Extra information sent be some command (SHOW COLUMNS
+uses this to send the number of rows in the table)
+@end multitable
+
+This package is always followed by a field description set.
+@xref{4.1 field desc}.
+
+@node 4.1 field desc,,,
+@section 4.1 field description result set
+
+The field description result set contains the meta info for a result set.
+
+@multitable @columnfractions .20 .80
+@item Type   @tab Comment
+@item string @tab Database name
+@item string @tab Table name alias (or table name if no alias)
+@item string @tab Real table name
+@item string @tab Alias for column name (or column name if not used)
+@item 3 byte int @tab Length of column definition
+@item 1 byte int @tab Enum value for field type
+@item 3 byte int @tab 2 byte column flags (NOT_NULL_FLAG etc..) + 1 byte number of decimals.
+@item string int @tab Default value, only set when using mysql_list_fields().
+@end multitable
+
+
+@node 4.1 ok package,,,
+@section 4.1 ok package
+
+The ok package is the first that is sent as an response for a query
+that didn't return a result set.
+
+The ok package has the following structure:
+
+@multitable @columnfractions .10 .90
+@item Size @tab Comment
+@item 1	  @tab  0 ; Marker for ok package
+@item 1-9 @tab	Affected rows
+@item 1-9 @tab  Last insert id (0 if one wasn't used)
+@item 2   @tab  Server status; Can be used by client to check if we are inside an transaction
+@item 2	  @tab  Warning count
+@item 1-9 @tab  Message length (optional)
+@item xxx @tab  Message (optional)
+@end multitable
+
+Size 1-9 means that the parameter is packed in to 1-9 bytes depending on
+the value.  (See function sql/net_pkg.cc::net_store_length).
+
+The message is optional.  For example for multi line INSERT it
+contains a string for how many rows was inserted / deleted.
+
+
+@node 4.1 end package,,,
+@section 4.1 end package
+
+The end package is sent as the last package for
+
+@itemize @bullet
+@item
+End of field information
+@item
+End of parameter type information
+@item
+End of result set
+@end itemize
+
+The end package has the following structure:
+
+@multitable @columnfractions .10 .90
+@item Size @tab Comment
+@item 1	   @tab 254  ; Marker for EOF package
+@item 2	   @tab Warning count
+@item 2	   @tab Status flags (For flags like SERVER_STATUS_MORE_RESULTS)
+@end multitable
+
+Note that a normal package may start with byte 254, which means
+'length stored in 9 bytes'.  One can different between these cases
+by checking the packet length < 9 bytes (in which case it's and end
+packet).
+
+
+@node 4.1 error package
+@section 4.1 error package.
+
+The error package is sent when something goes wrong.
+The error package has the following structure:
+
+@multitable @columnfractions .10 .90
+@item Size  @tab Comment
+@item 1	    @tab 255  Error package marker
+@item 1-255 @tab Null terminated error message
+@end multitable
+
+The client/server protocol is designed in such a way that a package
+can only start with 255 if it's an error package.
+
+
+@node 4.1 prep init,,,
+@section 4.1 prepared statement init package
+
+This is the return package when one sends a query with the COM_PREPARE
+command.
+
+@multitable @columnfractions .10 .90
+@item Size @tab Comment
+@item 4	   @tab Statement handler id
+@item 2	   @tab Number of columns in result set
+@item 2	   @tab Number of parameters in query
+@end multitable
+
+After this, there is a packet that contains the following for each
+parameter in the query:
+
+@multitable @columnfractions .10 .90
+@item Size @tab Comment
+@item 2	@tab Enum value for field type. (MYSQL_TYPE_UNKNOWN if not known)
+@item 2 @tab 2 byte column flags (NOT_NULL_FLAG etc)
+@item 1 @tab Number of decimals
+@item 4 @tab Max column length.
+@end itemize
+
+Note that the above is not yet in 4.1 but will be added this month.
+
+As MySQL can have a parameter 'anywhere' it will in many cases not be
+able to provide the optimal information for all parameters.
+
+If number of columns, in the header package, is not 0 then the
+prepared statement will contain a result set. In this case the package
+is followed by a field description result set. @xref{4.1 field descr}.
+
+
+@node 4.1 long data,,,
+@section 4.1 long data handling
+
+This is used by mysql_send_long_data() to set any parameter to a string
+value.  One can call mysql_send_long_data() multiple times for the
+same parameter; The server will concatenate the results to a one big
+string.
+
+The server will not require an end package for the string.
+mysql_send_long_data() is responsible updating a flag that all data
+has been sent. (Ie;  That the last call to mysql_send_long_data() has
+the 'last_data' flag set).
+
+This package is sent from client -> server:
+
+@multitable @columnfractions .10 .90
+@item Size @tab Comment
+@item 4	@tab Statement handler
+@item 2 @tab Parameter number
+@item 2 @tab Type of parameter  (not used at this point)
+@item # @tab data (Rest of package)
+@end itemize
+
+The server will NOT send an @code{ok} or @code{error} package in
+responce for this.  If there is any errors (like to big string), one
+will get the error when calling execute.
+
+@node 4.1 execute,,,
+@section 4.1 execute
+
+On execute we send all parameters to the server in a COM_EXECUTE
+package.
+
+The package contains the following information:
+
+@multitable @columnfractions .30 .70
+@item Size @tab Comment
+@item (param_count+7)/8 @tab Null bit map
+@item 1	   @tab new_parameter_bound flag.  Is set to 1 for first
+execute or if one has rebound the parameters.
+@item 2*param_count     @tab Type of parameters (only given if new_parameter_bound flag is 1)
+@item #    @tab Parameter data, repeated for each parameter that are
+NOT NULL and not used with mysql_send_long_data().
+@end itemize
+
+The null-bit-map is for all parameters (including parameters sent with
+'mysql_send_long_data). If parameter 0 is NULL, then bit 0 in the
+null-bit-map should be 1 (ie:  first byte should be 1)
+
+The parameters are stored the following ways:
+
+@multitable @columnfractions .20 .10 .70
+@item Type    @tab Size @tab Comment
+@item tynyint @tab 1	@tab One byte integer
+@item short   @tab 2	@tab
+@item int     @tab 4	@tab
+@item longlong @tab 8	@tab
+@item float   @tab 4	@tab
+@item double  @tab 8	@tab
+@item string  @tab 1-9 + # @tab Packed string length + string
+@end multitable
+
+The result for this will be either an ok package or a binary result
+set.
+
+@node 4.1 binary result,,,
+@section 4.1 binary result set
+
+A binary result are sent the following way.
+
+For each result row:
+
+@itemize
+@item
+null bit map with first two bits set to 01 (bit 0,1 value 1)
+@item
+parameter data, repeated for each not null parameter.
+@end itemize
+
+The idea with the reserving two bits in the null map is that we can
+use standard error (first byte 255) and ok packages (first byte 0)
+to end a result sets.
+
+Except that the null-bit-map is shifted two steps, the server is
+sending the data to the client the same way that the server is sending
+bound parameters to the client.  The server is always sending the data
+as type given for 'column type' for respective column.  It's up to the
+client to convert the parameter to the requested type.
+
 @node Fulltext Search,  , protocol, Top
 @chapter Fulltext Search in MySQL
 
@@ -794,10 +1857,10 @@ fulltext search algorithms.
 Now it's just unsorted notes.
 
 @menu
-* Weighting in boolean mode::  
+* Weighting in boolean mode::   
 @end menu
 
-@node Weighting in boolean mode, , , Fulltext Search
+@node Weighting in boolean mode,  , Fulltext Search, Fulltext Search
 @section Weighting in boolean mode
 
 The basic idea is as follows: in expression
diff --git a/Docs/manual.texi b/Docs/manual.texi
index c39da1e37d141c14f94859bba8400c9eac04f735..283ad00d80fbc97b5c95c2f80a178fd7a58b1d6c 100644
--- a/Docs/manual.texi
+++ b/Docs/manual.texi
@@ -8202,6 +8202,10 @@ The following startup variables/options have been renamed:
 The startup options @code{record_buffer}, @code{sort_buffer} and
 @code{warnings} will still work in MySQL 4.0 but are deprecated.
 @item
+The mysqld option @code{--safe_show_database} doesn't work anymore.  One
+should instead give the @code{SHOW DATABASES} privileges to everyone that
+need to see all databases.
+@item
 The following SQL variables have changed name.
 @c arjen note: New table, not yet measured for O'Reilly/DocBook.
 @multitable @columnfractions .50 .50
@@ -19879,7 +19883,6 @@ differ somewhat:
 | query_cache_limit               | 1048576                      |
 | query_cache_size                | 0                            |
 | query_cache_type                | ON                           |
-| safe_show_database              | OFF                          |
 | server_id                       | 0                            |
 | slave_net_timeout               | 3600                         |
 | skip_external_locking           | ON                           |
@@ -20314,7 +20317,8 @@ This may be set (only numeric) to
 Don't show databases for which the user doesn't have any database or
 table privileges. This can improve security if you're concerned about
 people being able to see what databases other users have. See also
-@code{skip_show_database}.
+@code{skip_show_database}.  This option is deprecated as one should instead
+use the @code{SHOW DATABASES} privilege instead.
 
 @item @code{server_id}
 The value of the @code{--server-id} option.
@@ -20327,7 +20331,7 @@ Is ON if we only allow local (socket) connections.
 
 @item @code{skip_show_database}
 This prevents people from doing @code{SHOW DATABASES} if they don't have
-the @code{PROCESS} privilege. This can improve security if you're
+the @code{SHOW DATABASE} privilege. This can improve security if you're
 concerned about people being able to see what databases other users
 have. See also @code{safe_show_database}.
 
@@ -23506,17 +23510,21 @@ will be logged in the execution order.
 Updates to non-transactional tables are stored in the binary log
 immediately after execution.  For transactional tables such as @code{BDB}
 or @code{InnoDB} tables, all updates (@code{UPDATE}, @code{DELETE}
-or @code{INSERT}) that change tables are cached until a @code{COMMIT}.
+or @code{INSERT}) that change tables are cached until a @code{COMMIT} command
+is sent to the server. At this point mysqld writes the whole transaction to
+the binary log before the @code{COMMIT} is executed.
 Every thread will, on start, allocate a buffer of @code{binlog_cache_size}
 to buffer queries.  If a query is bigger than this, the thread will open
-a temporary file to handle the bigger cache.  The temporary file will
+a temporary file to store the transcation.  The temporary file will
 be deleted when the thread ends.
 
-The @code{max_binlog_cache_size} can be used to restrict the total size used
-to cache a multi-query transaction.
+The @code{max_binlog_cache_size} (default 4G) can be used to restrict
+the total size used to cache a multi-query transaction.  If a transaction is
+bigger than this it will fail and roll back.
 
 If you are using the update or binary log, concurrent inserts will
-not work together with @code{CREATE ... SELECT} and @code{INSERT ... SELECT}.
+be converted to normal inserts when using @code{CREATE ... SELECT} and
+@code{INSERT ... SELECT}.
 This is to ensure that you can recreate an exact copy of your tables by
 applying the log on a backup.
 
@@ -23683,7 +23691,7 @@ started}, your slaves may fail.
 
 Please see the following table for an indication of master-slave
 compatibility between different versions. With regard to version 4.0,
-we recommend using same version on both sides.
+we recommend using at least 4.0.4 on both sides.
 
 @c FIX arjen 2002-07-17 new table, not yet measured for XML/DocBook.
 @multitable @columnfractions .10 .15 .15 .10 .10 .10
@@ -24350,7 +24358,7 @@ may be used with @code{IO_THREAD} and @code{SQL_THREAD} options. (Slave)
  @tab Re-enables update logging if the user has the @code{SUPER} privilege.
  Ignored otherwise. (Master)
 
-@item @code{GLOBAL SET SQL_SLAVE_SKIP_COUNTER=n}
+@item @code{SET GLOBAL SQL_SLAVE_SKIP_COUNTER=n}
  @tab Skip the next @code{n} events from the master. Only valid when
 the slave thread is not running, otherwise, gives an error. Useful for
 recovering from replication glitches.
@@ -25510,7 +25518,7 @@ temporary table to hold the result.  This typically happens if you do an
 @code{ORDER BY} on a different column set than you did a @code{GROUP
 BY} on.
 
-@item Where used
+@item Using where (was @code{where used})
 A @code{WHERE} clause will be used to restrict which rows will be
 matched against the next table or sent to the client.  If you don't have
 this information and the table is of type @code{ALL} or @code{index},
@@ -25670,7 +25678,7 @@ Executing the @code{EXPLAIN} statement again produces this result:
 
 @example
 table type   possible_keys   key     key_len ref         rows    Extra
-tt    ALL    AssignedPC,ClientID,ActualPC NULL NULL NULL 3872    where used
+tt    ALL    AssignedPC,ClientID,ActualPC NULL NULL NULL 3872    Using where
 do    ALL    PRIMARY         NULL    NULL    NULL        2135
       range checked for each record (key map: 1)
 et_1  ALL    PRIMARY         NULL    NULL    NULL        74
@@ -25696,7 +25704,7 @@ Now @code{EXPLAIN} produces the output shown here:
 @example
 table type   possible_keys   key      key_len ref           rows Extra
 et    ALL    PRIMARY         NULL     NULL    NULL          74
-tt    ref    AssignedPC,     ActualPC 15      et.EMPLOYID   52   where used
+tt    ref    AssignedPC,     ActualPC 15      et.EMPLOYID   52   Using where
              ClientID,
              ActualPC
 et_1  eq_ref PRIMARY         PRIMARY  15      tt.AssignedPC 1
@@ -25719,7 +25727,7 @@ Now the join is perfect, and @code{EXPLAIN} produces this result:
 
 @example
 table type   possible_keys key     key_len ref           rows Extra
-tt    ALL    AssignedPC    NULL    NULL    NULL          3872 where used
+tt    ALL    AssignedPC    NULL    NULL    NULL          3872 Using where
              ClientID,
              ActualPC
 et    eq_ref PRIMARY       PRIMARY 15      tt.ActualPC   1
@@ -28868,7 +28876,6 @@ and if you can use @code{GLOBAL} or @code{SESSION} with them.
 @item read_buffer_size @tab num @tab GLOBAL | SESSION
 @item read_rnd_buffer_size @tab num @tab GLOBAL | SESSION
 @item rpl_recovery_rank @tab num @tab GLOBAL
-@item safe_show_database @tab bool @tab GLOBAL
 @item server_id @tab num @tab GLOBAL
 @item slave_compressed_protocol @tab bool @tab GLOBAL
 @item slave_net_timeout @tab num @tab GLOBAL
@@ -38698,8 +38705,8 @@ SUM_OVER_ALL_KEYS(max_length_of_key + sizeof(char*) * 2)
 * Table and index::             Table and Index Structures
 * File space management::       File Space Management and Disk I/O
 * Error handling::              Error Handling
-* InnoDB change history::       InnoDB Change History
 * InnoDB restrictions::         Restrictions on InnoDB Tables
+* InnoDB change history::       InnoDB Change History
 * InnoDB contact information::  InnoDB Contact Information.
 @end menu
 
@@ -50735,6 +50742,7 @@ this means that the version has not yet been released!
 @c Please don't add a new version here without also updating ../configure.in!
 
 @menu
+* News-4.1.x::                  
 * News-4.0.x::                  Changes in release 4.0.x (Beta)
 * News-3.23.x::                 Changes in release 3.23.x (Stable)
 * News-3.22.x::                 Changes in release 3.22.x (Older; Still supported)
@@ -50744,7 +50752,77 @@ this means that the version has not yet been released!
 @end menu
 
 
-@node News-4.0.x, News-3.23.x, News, News
+@node News-4.1.x, News-4.0.x, News, News
+@appendixsec Changes in release 4.1.x (Alpha)
+
+@cindex changes, version 4.1
+
+Version 4.1 of the MySQL server includes many enhancements and new features:
+
+@itemize @bullet
+@item
+Sub selects: @code{SELECT * from t1 where t1.a=(SELECT t2.b FROM t2)}.
+@item
+Character sets to be defined per column, table and database.
+@item
+Unicode (UTF8) support.
+@item
+Derived tables: @code{SELECT a from t1, (select * from t2) WHERE t1.a=t2.a}
+@item
+@code{BTREE} index on @code{HEAP} tables.
+@item
+Support for GIS (Geometrical data).
+@item
+@code{SHOW WARNINGS}; Shows warnings for the last command.
+@end itemize
+
+For a full list of changes, please refer to the changelog sections for
+each individual 4.1.x release.
+
+@menu
+* News-4.1.0::                  
+@end menu
+
+@node News-4.1.0,  , News-4.1.x, News-4.1.x
+@appendixsubsec Changes in release 4.1.0
+@itemize
+@item
+One can specify many temporary directories to be used in a round-robin
+fasion with:  @code{--tmpdir=dirname1:dirname2:dirname3}.
+@item
+Sub selects: @code{SELECT * from t1 where t1.a=(SELECT t2.b FROM t2)}.
+@item
+Character sets to be defined per column, table and database.
+@item
+Unicode (UTF8) support.
+@item
+Derived tables: @code{SELECT a from t1, (select * from t2) WHERE t1.a=t2.a}
+@item
+@code{BTREE} index on @code{HEAP} tables.
+@item
+Faster embedded server.
+@item
+One can add a comment per column in @code{CREATE TABLE}.
+@item
+@code{SHOW FULL COLUMNS FROM table_name} shows column comments.
+@item
+@code{ALTER DATABASE}.
+@item
+Support for GIS (Geometrical data).
+@item
+@code{SHOW WARNINGS}; Shows warnings from the last command.
+@item
+One can specify a column type for a colum in @code{CREATE TABLE
+... SELECT} by defining the column in the @code{CREATE} part
+
+@example
+CREATE TABLE foo (a tinyint not null) SELECT b+1 AS 'a' FROM bar;
+@end example
+
+@end itemize
+
+
+@node News-4.0.x, News-3.23.x, News-4.1.x, News
 @appendixsec Changes in release 4.0.x (Beta)
 
 @cindex changes, version 4.0
@@ -50815,6 +50893,19 @@ each individual 4.0.x release.
 @appendixsubsec Changes in release 4.0.5
 @itemize
 @item
+When one uses the @code{--open-files-limit=#} option to @code{mysqld_safe}
+it's now passed on to @code{mysqld}
+@item
+Fixed that @code{GROUP BY} on columns that may have a @code{NULL} value
+doesn't always use disk based temporary tables.
+@item
+Changed output from @code{EXPLAIN} from @code{'where used'} to
+@code{'Using where'} to make it more in line with other output.
+@item
+Removed variable @code{safe_show_database} as it was not used anymore.
+@item
+Read @code{--des-key-file} relative to database directory.
+@item
 Small code improvement in multi-table updates
 @item
 Fixed a newly introduced bug that caused @code{ORDER BY ... LIMIT #}
@@ -51680,6 +51771,11 @@ not yet 100% confident in this code.
 @appendixsubsec Changes in release 3.23.54
 @itemize
 @item
+Allow one to start multiple MySQL servers on windows (code backported
+from 4.0.2).
+@item
+Fixed that @code{--core-file} works on Linux (at least on kernel 2.4.18).
+@item
 Fixed a problem with BDB and @code{ALTER TABLE}.
 @item
 Fixed reference to freed memory when doing complicated @code{GROUP BY
@@ -51765,6 +51861,11 @@ Changed initialisation of @code{RND()} to make it less predicatable.
 Fixed problem with @code{GROUP BY} on result with expression that created a
 @code{BLOB} field.
 @item
+Fixed problem with @code{GROUP BY} on columns that have NULL values.  To
+solve this we now create an MyISAM temporary table when doing a group by
+on a possible NULL item.  In MySQL 4.0.5 we can again use in memory HEAP
+tables for this case.
+@item
 Fixed problem with privilege tables when downgrading from 4.0.2 to 3.23.
 @item
 Fixed thread bug in @code{SLAVE START}, @code{SLAVE STOP} and automatic repair
@@ -52506,8 +52607,9 @@ long as @code{server-id} is set and valid @file{master.info} is present.
 Partial updates (terminated with kill) are now logged with a special error
 code to the binary log. Slave will refuse to execute them if the error code
 indicates the update was terminated abnormally, and will have to be recovered
-with @code{SET SQL_SLAVE_SKIP_COUNTER=1; SLAVE START} after a manual sanity
-check/correction of data integrity.
+with @code{SET SQL_SLAVE_SKIP_COUNTER=1; SLAVE START} after a manual
+sanity check/correction of data integrity.  Update: In 4.0.3 and above
+you have to use @code{SET GLOBAL}.
 @item
 Fixed bug that erroneously logged a drop of internal temporary table
 on thread termination to the binary log -- this bug affected replication.
diff --git a/acconfig.h b/acconfig.h
index cf276d0b8483a73ba4638863817ae338258070ec..e969a635a5bb00510ec6615dd055d0618cee4979 100644
--- a/acconfig.h
+++ b/acconfig.h
@@ -274,7 +274,7 @@
 #undef SPRINTF_RETURNS_INT
 #undef SPRINTF_RETURNS_GARBAGE
 
-/* Needed to get large file supportat HPUX 10.20 */
+/* Needed to get large file support on HPUX 10.20 */
 #undef __STDC_EXT__
 
 #undef STACK_DIRECTION
diff --git a/acinclude.m4 b/acinclude.m4
index e94304649fb6c3db54594c0bdefcba38a91a628e..7190593af275b7ea44ca54cb0cd72641c57934a7 100644
--- a/acinclude.m4
+++ b/acinclude.m4
@@ -1190,5 +1190,142 @@ dnl ---------------------------------------------------------------------------
 dnl END OF MYSQL_CHECK_INNODB SECTION
 dnl ---------------------------------------------------------------------------
 
+dnl By default, many hosts won't let programs access large files;
+dnl one must use special compiler options to get large-file access to work.
+dnl For more details about this brain damage please see:
+dnl http://www.sas.com/standards/large.file/x_open.20Mar96.html
+
+dnl Written by Paul Eggert <eggert@twinsun.com>.
+
+dnl Internal subroutine of AC_SYS_LARGEFILE.
+dnl AC_SYS_LARGEFILE_FLAGS(FLAGSNAME)
+AC_DEFUN(AC_SYS_LARGEFILE_FLAGS,
+  [AC_CACHE_CHECK([for $1 value to request large file support],
+     ac_cv_sys_largefile_$1,
+     [if ($GETCONF LFS_$1) >conftest.1 2>conftest.2 && test ! -s conftest.2
+      then
+        ac_cv_sys_largefile_$1=`cat conftest.1`
+      else
+	ac_cv_sys_largefile_$1=no
+	ifelse($1, CFLAGS,
+	  [case "$host_os" in
+	   # HP-UX 10.20 requires -D__STDC_EXT__ with gcc 2.95.1.
+changequote(, )dnl
+	   hpux10.[2-9][0-9]* | hpux1[1-9]* | hpux[2-9][0-9]*)
+changequote([, ])dnl
+	     if test "$GCC" = yes; then
+	       ac_cv_sys_largefile_CFLAGS=-D__STDC_EXT__
+	     fi
+	     ;;
+	   # IRIX 6.2 and later require cc -n32.
+changequote(, )dnl
+	   irix6.[2-9]* | irix6.1[0-9]* | irix[7-9].* | irix[1-9][0-9]*)
+changequote([, ])dnl
+	     if test "$GCC" != yes; then
+	       ac_cv_sys_largefile_CFLAGS=-n32
+	     fi
+	   esac
+	   if test "$ac_cv_sys_largefile_CFLAGS" != no; then
+	     ac_save_CC="$CC"
+	     CC="$CC $ac_cv_sys_largefile_CFLAGS"
+	     AC_TRY_LINK(, , , ac_cv_sys_largefile_CFLAGS=no)
+	     CC="$ac_save_CC"
+	   fi])
+      fi
+      rm -f conftest*])])
+
+dnl Internal subroutine of AC_SYS_LARGEFILE.
+dnl AC_SYS_LARGEFILE_SPACE_APPEND(VAR, VAL)
+AC_DEFUN(AC_SYS_LARGEFILE_SPACE_APPEND,
+  [case $2 in
+   no) ;;
+   ?*)
+     case "[$]$1" in
+     '') $1=$2 ;;
+     *) $1=[$]$1' '$2 ;;
+     esac ;;
+   esac])
+
+dnl Internal subroutine of AC_SYS_LARGEFILE.
+dnl AC_SYS_LARGEFILE_MACRO_VALUE(C-MACRO, CACHE-VAR, COMMENT, CODE-TO-SET-DEFAULT)
+AC_DEFUN(AC_SYS_LARGEFILE_MACRO_VALUE,
+  [AC_CACHE_CHECK([for $1], $2,
+     [$2=no
+changequote(, )dnl
+      for ac_flag in $ac_cv_sys_largefile_CFLAGS no; do
+	case "$ac_flag" in
+	-D$1)
+	  $2=1 ;;
+	-D$1=*)
+	  $2=`expr " $ac_flag" : '[^=]*=\(.*\)'` ;;
+	esac
+      done
+      $4
+changequote([, ])dnl
+      ])
+   if test "[$]$2" != no; then
+     AC_DEFINE_UNQUOTED([$1], [$]$2, [$3])
+   fi])
+
+AC_DEFUN(MYSQL_SYS_LARGEFILE,
+  [AC_REQUIRE([AC_CANONICAL_HOST])
+  AC_ARG_ENABLE(largefile,
+     [  --disable-largefile     Omit support for large files])
+   if test "$enable_largefile" != no; then
+     AC_CHECK_TOOL(GETCONF, getconf)
+     AC_SYS_LARGEFILE_FLAGS(CFLAGS)
+     AC_SYS_LARGEFILE_FLAGS(LDFLAGS)
+     AC_SYS_LARGEFILE_FLAGS(LIBS)
+
+     for ac_flag in $ac_cv_sys_largefile_CFLAGS no; do
+       case "$ac_flag" in
+       no) ;;
+       -D_FILE_OFFSET_BITS=*) ;;
+       -D_LARGEFILE_SOURCE | -D_LARGEFILE_SOURCE=*) ;;
+       -D_LARGE_FILES | -D_LARGE_FILES=*) ;;
+       -D?* | -I?*)
+	 AC_SYS_LARGEFILE_SPACE_APPEND(CPPFLAGS, "$ac_flag") ;;
+       *)
+	 AC_SYS_LARGEFILE_SPACE_APPEND(CFLAGS, "$ac_flag") ;;
+       esac
+     done
+     AC_SYS_LARGEFILE_SPACE_APPEND(LDFLAGS, "$ac_cv_sys_largefile_LDFLAGS")
+     AC_SYS_LARGEFILE_SPACE_APPEND(LIBS, "$ac_cv_sys_largefile_LIBS")
+
+     AC_SYS_LARGEFILE_MACRO_VALUE(_FILE_OFFSET_BITS,
+       ac_cv_sys_file_offset_bits,
+       [Number of bits in a file offset, on hosts where this is settable.],
+       [case "$host_os" in
+	# HP-UX 10.20 and later
+	hpux10.[2-9][0-9]* | hpux1[1-9]* | hpux[2-9][0-9]*)
+	  ac_cv_sys_file_offset_bits=64 ;;
+	# We can't declare _FILE_OFFSET_BITS here as this will cause
+	# compile errors as AC_PROG_CC adds include files in confdefs.h
+	# We solve this (until autoconf is fixed) by instead declaring it
+	# as define instead
+	solaris2.[8,9])
+	  CFLAGS="$CFLAGS -D_FILE_OFFSET_BITS=64"
+	  CXXFLAGS="$CXXFLAGS -D_FILE_OFFSET_BITS=64"
+	  ac_cv_sys_file_offset_bits=no ;;
+	esac])
+     AC_SYS_LARGEFILE_MACRO_VALUE(_LARGEFILE_SOURCE,
+       ac_cv_sys_largefile_source,
+       [Define to make fseeko etc. visible, on some hosts.],
+       [case "$host_os" in
+	# HP-UX 10.20 and later
+	hpux10.[2-9][0-9]* | hpux1[1-9]* | hpux[2-9][0-9]*)
+	  ac_cv_sys_largefile_source=1 ;;
+	esac])
+     AC_SYS_LARGEFILE_MACRO_VALUE(_LARGE_FILES,
+       ac_cv_sys_large_files,
+       [Define for large files, on AIX-style hosts.],
+       [case "$host_os" in
+	# AIX 4.2 and later
+	aix4.[2-9]* | aix4.1[0-9]* | aix[5-9].* | aix[1-9][0-9]*)
+	  ac_cv_sys_large_files=1 ;;
+	esac])
+   fi
+  ])
+
 dnl ---------------------------------------------------------------------------
 
diff --git a/bdb/build_vxworks/BerkeleyDB.wpj b/bdb/build_vxworks/BerkeleyDB.wpj
deleted file mode 100644
index 45b15a62687ade088e19bc490c29bcf2b8e2a42c..0000000000000000000000000000000000000000
--- a/bdb/build_vxworks/BerkeleyDB.wpj
+++ /dev/null
@@ -1,3506 +0,0 @@
-Document file - DO NOT EDIT
-
-<BEGIN> BUILD_PENTIUM_debug_BUILDRULE
-BerkeleyDB.out
-<END>
-
-<BEGIN> BUILD_PENTIUM_debug_MACRO_AR
-ar386
-<END>
-
-<BEGIN> BUILD_PENTIUM_debug_MACRO_ARCHIVE
-$(PRJ_DIR)/PENTIUMgnu/BerkeleyDB_sim.a
-<END>
-
-<BEGIN> BUILD_PENTIUM_debug_MACRO_AS
-cc386
-<END>
-
-<BEGIN> BUILD_PENTIUM_debug_MACRO_CC
-cc386
-<END>
-
-<BEGIN> BUILD_PENTIUM_debug_MACRO_CFLAGS
--g \
-	-mpentium \
-	-ansi \
-	-nostdinc \
-	-DRW_MULTI_THREAD \
-	-D_REENTRANT \
-	-fvolatile \
-	-nostdlib \
-	-fno-builtin \
-	-fno-defer-pop \
-	-I. \
-	-I$(WIND_BASE)/target/h \
-	-DCPU=PENTIUM \
-	-O0 \
-	-I$(PRJ_DIR) \
-	-I$(PRJ_DIR)/.. \
-	-DDIAGNOSTIC \
-	-DDEBUG
-<END>
-
-<BEGIN> BUILD_PENTIUM_debug_MACRO_CFLAGS_AS
--g \
-	-mpentium \
-	-ansi \
-	-nostdinc \
-	-fvolatile \
-	-nostdlib \
-	-fno-builtin \
-	-fno-defer-pop \
-	-P \
-	-x \
-	assembler-with-cpp \
-	-I. \
-	-I$(WIND_BASE)/target/h \
-	-DCPU=PENTIUM
-<END>
-
-<BEGIN> BUILD_PENTIUM_debug_MACRO_CPP
-cc386 -E -P -xc
-<END>
-
-<BEGIN> BUILD_PENTIUM_debug_MACRO_LD
-ld386
-<END>
-
-<BEGIN> BUILD_PENTIUM_debug_MACRO_LDFLAGS
--X -N
-<END>
-
-<BEGIN> BUILD_PENTIUM_debug_MACRO_LD_PARTIAL_FLAGS
--X -r
-<END>
-
-<BEGIN> BUILD_PENTIUM_debug_MACRO_NM
-nm386 -g
-<END>
-
-<BEGIN> BUILD_PENTIUM_debug_MACRO_OPTION_DEFINE_MACRO
--D
-<END>
-
-<BEGIN> BUILD_PENTIUM_debug_MACRO_OPTION_INCLUDE_DIR
--I
-<END>
-
-<BEGIN> BUILD_PENTIUM_debug_MACRO_POST_BUILD_RULE
-
-<END>
-
-<BEGIN> BUILD_PENTIUM_debug_MACRO_PRJ_LIBS
-
-<END>
-
-<BEGIN> BUILD_PENTIUM_debug_MACRO_SIZE
-size386
-<END>
-
-<BEGIN> BUILD_PENTIUM_debug_RO_DEPEND_PATH
-{$(WIND_BASE)/target/h/} \
-	{$(WIND_BASE)/target/src/} \
-	{$(WIND_BASE)/target/config/}
-<END>
-
-<BEGIN> BUILD_PENTIUM_debug_TC
-::tc_PENTIUMgnu
-<END>
-
-<BEGIN> BUILD_PENTIUM_release_BUILDRULE
-BerkeleyDB.out
-<END>
-
-<BEGIN> BUILD_PENTIUM_release_MACRO_AR
-ar386
-<END>
-
-<BEGIN> BUILD_PENTIUM_release_MACRO_ARCHIVE
-$(PRJ_DIR)/PENTIUMgnu/BerkeleyDB_sim.a
-<END>
-
-<BEGIN> BUILD_PENTIUM_release_MACRO_AS
-cc386
-<END>
-
-<BEGIN> BUILD_PENTIUM_release_MACRO_CC
-cc386
-<END>
-
-<BEGIN> BUILD_PENTIUM_release_MACRO_CFLAGS
--mpentium \
-	-ansi \
-	-nostdinc \
-	-DRW_MULTI_THREAD \
-	-D_REENTRANT \
-	-fvolatile \
-	-nostdlib \
-	-fno-builtin \
-	-fno-defer-pop \
-	-I. \
-	-I$(WIND_BASE)/target/h \
-	-DCPU=PENTIUM \
-	-O2 \
-	-I$(PRJ_DIR) \
-	-I$(PRJ_DIR)/.. 
-<END>
-
-<BEGIN> BUILD_PENTIUM_release_MACRO_CFLAGS_AS
--g \
-	-mpentium \
-	-ansi \
-	-nostdinc \
-	-fvolatile \
-	-nostdlib \
-	-fno-builtin \
-	-fno-defer-pop \
-	-P \
-	-x \
-	assembler-with-cpp \
-	-I. \
-	-I$(WIND_BASE)/target/h \
-	-DCPU=PENTIUM
-<END>
-
-<BEGIN> BUILD_PENTIUM_release_MACRO_CPP
-cc386 -E -P -xc
-<END>
-
-<BEGIN> BUILD_PENTIUM_release_MACRO_LD
-ld386
-<END>
-
-<BEGIN> BUILD_PENTIUM_release_MACRO_LDDEPS
-
-<END>
-
-<BEGIN> BUILD_PENTIUM_release_MACRO_LDFLAGS
--X -N
-<END>
-
-<BEGIN> BUILD_PENTIUM_release_MACRO_LD_PARTIAL_FLAGS
--X -r
-<END>
-
-<BEGIN> BUILD_PENTIUM_release_MACRO_NM
-nm386 -g
-<END>
-
-<BEGIN> BUILD_PENTIUM_release_MACRO_OPTION_DEFINE_MACRO
--D
-<END>
-
-<BEGIN> BUILD_PENTIUM_release_MACRO_OPTION_INCLUDE_DIR
--I
-<END>
-
-<BEGIN> BUILD_PENTIUM_release_MACRO_POST_BUILD_RULE
-
-<END>
-
-<BEGIN> BUILD_PENTIUM_release_MACRO_PRJ_LIBS
-
-<END>
-
-<BEGIN> BUILD_PENTIUM_release_MACRO_SIZE
-size386
-<END>
-
-<BEGIN> BUILD_PENTIUM_release_RO_DEPEND_PATH
-{$(WIND_BASE)/target/h/} \
-	{$(WIND_BASE)/target/src/} \
-	{$(WIND_BASE)/target/config/}
-<END>
-
-<BEGIN> BUILD_PENTIUM_release_TC
-::tc_PENTIUMgnu
-<END>
-
-<BEGIN> BUILD_RULE_BerkeleyDB.out
-
-<END>
-
-<BEGIN> BUILD_RULE_BerkeleyDB_sim.out
-
-<END>
-
-<BEGIN> BUILD_RULE_archive
-
-<END>
-
-<BEGIN> BUILD_RULE_objects
-
-<END>
-
-<BEGIN> BUILD__CURRENT
-PENTIUM_debug
-<END>
-
-<BEGIN> BUILD__LIST
-PENTIUM_release PENTIUM_debug
-<END>
-
-<BEGIN> CORE_INFO_TYPE
-::prj_vxApp
-<END>
-
-<BEGIN> CORE_INFO_VERSION
-2.0
-<END>
-
-<BEGIN> FILE_$(PRJ_DIR)/../btree/bt_compare.c_dependDone
-TRUE
-<END>
-
-<BEGIN> FILE_$(PRJ_DIR)/../btree/bt_compare.c_dependencies
-$(PRJ_DIR)/db_config.h \
-	$(PRJ_DIR)/db_int.h \
-	$(PRJ_DIR)/db.h
-<END>
-
-<BEGIN> FILE_$(PRJ_DIR)/../btree/bt_compare.c_objects
-bt_compare.o
-<END>
-
-<BEGIN> FILE_$(PRJ_DIR)/../btree/bt_compare.c_tool
-C/C++ compiler
-<END>
-
-<BEGIN> FILE_$(PRJ_DIR)/../btree/bt_conv.c_dependDone
-TRUE
-<END>
-
-<BEGIN> FILE_$(PRJ_DIR)/../btree/bt_conv.c_dependencies
-$(PRJ_DIR)/db_config.h \
-	$(PRJ_DIR)/db_int.h \
-	$(PRJ_DIR)/db.h
-<END>
-
-<BEGIN> FILE_$(PRJ_DIR)/../btree/bt_conv.c_objects
-bt_conv.o
-<END>
-
-<BEGIN> FILE_$(PRJ_DIR)/../btree/bt_conv.c_tool
-C/C++ compiler
-<END>
-
-<BEGIN> FILE_$(PRJ_DIR)/../btree/bt_curadj.c_dependDone
-TRUE
-<END>
-
-<BEGIN> FILE_$(PRJ_DIR)/../btree/bt_curadj.c_dependencies
-$(PRJ_DIR)/db_config.h \
-	$(PRJ_DIR)/db_int.h \
-	$(PRJ_DIR)/db.h
-<END>
-
-<BEGIN> FILE_$(PRJ_DIR)/../btree/bt_curadj.c_objects
-bt_curadj.o
-<END>
-
-<BEGIN> FILE_$(PRJ_DIR)/../btree/bt_curadj.c_tool
-C/C++ compiler
-<END>
-
-<BEGIN> FILE_$(PRJ_DIR)/../btree/bt_cursor.c_dependDone
-TRUE
-<END>
-
-<BEGIN> FILE_$(PRJ_DIR)/../btree/bt_cursor.c_dependencies
-$(PRJ_DIR)/db_config.h \
-	$(PRJ_DIR)/db_int.h \
-	$(PRJ_DIR)/db.h
-<END>
-
-<BEGIN> FILE_$(PRJ_DIR)/../btree/bt_cursor.c_objects
-bt_cursor.o
-<END>
-
-<BEGIN> FILE_$(PRJ_DIR)/../btree/bt_cursor.c_tool
-C/C++ compiler
-<END>
-
-<BEGIN> FILE_$(PRJ_DIR)/../btree/bt_delete.c_dependDone
-TRUE
-<END>
-
-<BEGIN> FILE_$(PRJ_DIR)/../btree/bt_delete.c_dependencies
-$(PRJ_DIR)/db_config.h \
-	$(PRJ_DIR)/db_int.h \
-	$(PRJ_DIR)/db.h
-<END>
-
-<BEGIN> FILE_$(PRJ_DIR)/../btree/bt_delete.c_objects
-bt_delete.o
-<END>
-
-<BEGIN> FILE_$(PRJ_DIR)/../btree/bt_delete.c_tool
-C/C++ compiler
-<END>
-
-<BEGIN> FILE_$(PRJ_DIR)/../btree/bt_method.c_dependDone
-TRUE
-<END>
-
-<BEGIN> FILE_$(PRJ_DIR)/../btree/bt_method.c_dependencies
-$(PRJ_DIR)/db_config.h \
-	$(PRJ_DIR)/db_int.h \
-	$(PRJ_DIR)/db.h
-<END>
-
-<BEGIN> FILE_$(PRJ_DIR)/../btree/bt_method.c_objects
-bt_method.o
-<END>
-
-<BEGIN> FILE_$(PRJ_DIR)/../btree/bt_method.c_tool
-C/C++ compiler
-<END>
-
-<BEGIN> FILE_$(PRJ_DIR)/../btree/bt_open.c_dependDone
-TRUE
-<END>
-
-<BEGIN> FILE_$(PRJ_DIR)/../btree/bt_open.c_dependencies
-$(PRJ_DIR)/db_config.h \
-	$(PRJ_DIR)/db_int.h \
-	$(PRJ_DIR)/db.h
-<END>
-
-<BEGIN> FILE_$(PRJ_DIR)/../btree/bt_open.c_objects
-bt_open.o
-<END>
-
-<BEGIN> FILE_$(PRJ_DIR)/../btree/bt_open.c_tool
-C/C++ compiler
-<END>
-
-<BEGIN> FILE_$(PRJ_DIR)/../btree/bt_put.c_dependDone
-TRUE
-<END>
-
-<BEGIN> FILE_$(PRJ_DIR)/../btree/bt_put.c_dependencies
-$(PRJ_DIR)/db_config.h \
-	$(PRJ_DIR)/db_int.h \
-	$(PRJ_DIR)/db.h
-<END>
-
-<BEGIN> FILE_$(PRJ_DIR)/../btree/bt_put.c_objects
-bt_put.o
-<END>
-
-<BEGIN> FILE_$(PRJ_DIR)/../btree/bt_put.c_tool
-C/C++ compiler
-<END>
-
-<BEGIN> FILE_$(PRJ_DIR)/../btree/bt_rec.c_dependDone
-TRUE
-<END>
-
-<BEGIN> FILE_$(PRJ_DIR)/../btree/bt_rec.c_dependencies
-$(PRJ_DIR)/db_config.h \
-	$(PRJ_DIR)/db_int.h \
-	$(PRJ_DIR)/db.h
-<END>
-
-<BEGIN> FILE_$(PRJ_DIR)/../btree/bt_rec.c_objects
-bt_rec.o
-<END>
-
-<BEGIN> FILE_$(PRJ_DIR)/../btree/bt_rec.c_tool
-C/C++ compiler
-<END>
-
-<BEGIN> FILE_$(PRJ_DIR)/../btree/bt_reclaim.c_dependDone
-TRUE
-<END>
-
-<BEGIN> FILE_$(PRJ_DIR)/../btree/bt_reclaim.c_dependencies
-$(PRJ_DIR)/db_config.h \
-	$(PRJ_DIR)/db_int.h \
-	$(PRJ_DIR)/db.h
-<END>
-
-<BEGIN> FILE_$(PRJ_DIR)/../btree/bt_reclaim.c_objects
-bt_reclaim.o
-<END>
-
-<BEGIN> FILE_$(PRJ_DIR)/../btree/bt_reclaim.c_tool
-C/C++ compiler
-<END>
-
-<BEGIN> FILE_$(PRJ_DIR)/../btree/bt_recno.c_dependDone
-TRUE
-<END>
-
-<BEGIN> FILE_$(PRJ_DIR)/../btree/bt_recno.c_dependencies
-$(PRJ_DIR)/db_config.h \
-	$(PRJ_DIR)/db_int.h \
-	$(PRJ_DIR)/db.h
-<END>
-
-<BEGIN> FILE_$(PRJ_DIR)/../btree/bt_recno.c_objects
-bt_recno.o
-<END>
-
-<BEGIN> FILE_$(PRJ_DIR)/../btree/bt_recno.c_tool
-C/C++ compiler
-<END>
-
-<BEGIN> FILE_$(PRJ_DIR)/../btree/bt_rsearch.c_dependDone
-TRUE
-<END>
-
-<BEGIN> FILE_$(PRJ_DIR)/../btree/bt_rsearch.c_dependencies
-$(PRJ_DIR)/db_config.h \
-	$(PRJ_DIR)/db_int.h \
-	$(PRJ_DIR)/db.h
-<END>
-
-<BEGIN> FILE_$(PRJ_DIR)/../btree/bt_rsearch.c_objects
-bt_rsearch.o
-<END>
-
-<BEGIN> FILE_$(PRJ_DIR)/../btree/bt_rsearch.c_tool
-C/C++ compiler
-<END>
-
-<BEGIN> FILE_$(PRJ_DIR)/../btree/bt_search.c_dependDone
-TRUE
-<END>
-
-<BEGIN> FILE_$(PRJ_DIR)/../btree/bt_search.c_dependencies
-$(PRJ_DIR)/db_config.h \
-	$(PRJ_DIR)/db_int.h \
-	$(PRJ_DIR)/db.h
-<END>
-
-<BEGIN> FILE_$(PRJ_DIR)/../btree/bt_search.c_objects
-bt_search.o
-<END>
-
-<BEGIN> FILE_$(PRJ_DIR)/../btree/bt_search.c_tool
-C/C++ compiler
-<END>
-
-<BEGIN> FILE_$(PRJ_DIR)/../btree/bt_split.c_dependDone
-TRUE
-<END>
-
-<BEGIN> FILE_$(PRJ_DIR)/../btree/bt_split.c_dependencies
-$(PRJ_DIR)/db_config.h \
-	$(PRJ_DIR)/db_int.h \
-	$(PRJ_DIR)/db.h
-<END>
-
-<BEGIN> FILE_$(PRJ_DIR)/../btree/bt_split.c_objects
-bt_split.o
-<END>
-
-<BEGIN> FILE_$(PRJ_DIR)/../btree/bt_split.c_tool
-C/C++ compiler
-<END>
-
-<BEGIN> FILE_$(PRJ_DIR)/../btree/bt_stat.c_dependDone
-TRUE
-<END>
-
-<BEGIN> FILE_$(PRJ_DIR)/../btree/bt_stat.c_dependencies
-$(PRJ_DIR)/db_config.h \
-	$(PRJ_DIR)/db_int.h \
-	$(PRJ_DIR)/db.h
-<END>
-
-<BEGIN> FILE_$(PRJ_DIR)/../btree/bt_stat.c_objects
-bt_stat.o
-<END>
-
-<BEGIN> FILE_$(PRJ_DIR)/../btree/bt_stat.c_tool
-C/C++ compiler
-<END>
-
-<BEGIN> FILE_$(PRJ_DIR)/../btree/bt_upgrade.c_dependDone
-TRUE
-<END>
-
-<BEGIN> FILE_$(PRJ_DIR)/../btree/bt_upgrade.c_dependencies
-$(PRJ_DIR)/db_config.h \
-	$(PRJ_DIR)/db_int.h \
-	$(PRJ_DIR)/db.h
-<END>
-
-<BEGIN> FILE_$(PRJ_DIR)/../btree/bt_upgrade.c_objects
-bt_upgrade.o
-<END>
-
-<BEGIN> FILE_$(PRJ_DIR)/../btree/bt_upgrade.c_tool
-C/C++ compiler
-<END>
-
-<BEGIN> FILE_$(PRJ_DIR)/../btree/bt_verify.c_dependDone
-TRUE
-<END>
-
-<BEGIN> FILE_$(PRJ_DIR)/../btree/bt_verify.c_dependencies
-$(PRJ_DIR)/db_config.h \
-	$(PRJ_DIR)/db_int.h \
-	$(PRJ_DIR)/db.h
-<END>
-
-<BEGIN> FILE_$(PRJ_DIR)/../btree/bt_verify.c_objects
-bt_verify.o
-<END>
-
-<BEGIN> FILE_$(PRJ_DIR)/../btree/bt_verify.c_tool
-C/C++ compiler
-<END>
-
-<BEGIN> FILE_$(PRJ_DIR)/../btree/btree_auto.c_dependDone
-TRUE
-<END>
-
-<BEGIN> FILE_$(PRJ_DIR)/../btree/btree_auto.c_dependencies
-$(PRJ_DIR)/db_config.h \
-	$(PRJ_DIR)/db_int.h \
-	$(PRJ_DIR)/db.h
-<END>
-
-<BEGIN> FILE_$(PRJ_DIR)/../btree/btree_auto.c_objects
-btree_auto.o
-<END>
-
-<BEGIN> FILE_$(PRJ_DIR)/../btree/btree_auto.c_tool
-C/C++ compiler
-<END>
-
-<BEGIN> FILE_$(PRJ_DIR)/../clib/getopt.c_dependDone
-TRUE
-<END>
-
-<BEGIN> FILE_$(PRJ_DIR)/../clib/getopt.c_dependencies
-$(PRJ_DIR)/db_config.h \
-	$(PRJ_DIR)/db_int.h \
-	$(PRJ_DIR)/db.h
-<END>
-
-<BEGIN> FILE_$(PRJ_DIR)/../clib/getopt.c_objects
-getopt.o
-<END>
-
-<BEGIN> FILE_$(PRJ_DIR)/../clib/getopt.c_tool
-C/C++ compiler
-<END>
-
-<BEGIN> FILE_$(PRJ_DIR)/../clib/snprintf.c_dependDone
-TRUE
-<END>
-
-<BEGIN> FILE_$(PRJ_DIR)/../clib/snprintf.c_dependencies
-$(PRJ_DIR)/db_config.h \
-	$(PRJ_DIR)/db_int.h \
-	$(PRJ_DIR)/db.h
-<END>
-
-<BEGIN> FILE_$(PRJ_DIR)/../clib/snprintf.c_objects
-snprintf.o
-<END>
-
-<BEGIN> FILE_$(PRJ_DIR)/../clib/snprintf.c_tool
-C/C++ compiler
-<END>
-
-<BEGIN> FILE_$(PRJ_DIR)/../clib/strcasecmp.c_dependDone
-TRUE
-<END>
-
-<BEGIN> FILE_$(PRJ_DIR)/../clib/strcasecmp.c_dependencies
-$(PRJ_DIR)/db_config.h \
-	$(PRJ_DIR)/db_int.h \
-	$(PRJ_DIR)/db.h
-<END>
-
-<BEGIN> FILE_$(PRJ_DIR)/../clib/strcasecmp.c_objects
-strcasecmp.o
-<END>
-
-<BEGIN> FILE_$(PRJ_DIR)/../clib/strcasecmp.c_tool
-C/C++ compiler
-<END>
-
-<BEGIN> FILE_$(PRJ_DIR)/../clib/strdup.c_dependDone
-TRUE
-<END>
-
-<BEGIN> FILE_$(PRJ_DIR)/../clib/strdup.c_dependencies
-$(PRJ_DIR)/db_config.h \
-	$(PRJ_DIR)/db_int.h \
-	$(PRJ_DIR)/db.h
-<END>
-
-<BEGIN> FILE_$(PRJ_DIR)/../clib/strdup.c_objects
-strdup.o
-<END>
-
-<BEGIN> FILE_$(PRJ_DIR)/../clib/strdup.c_tool
-C/C++ compiler
-<END>
-
-<BEGIN> FILE_$(PRJ_DIR)/../clib/vsnprintf.c_dependDone
-TRUE
-<END>
-
-<BEGIN> FILE_$(PRJ_DIR)/../clib/vsnprintf.c_dependencies
-$(PRJ_DIR)/db_config.h \
-	$(PRJ_DIR)/db_int.h \
-	$(PRJ_DIR)/db.h
-<END>
-
-<BEGIN> FILE_$(PRJ_DIR)/../clib/vsnprintf.c_objects
-vsnprintf.o
-<END>
-
-<BEGIN> FILE_$(PRJ_DIR)/../clib/vsnprintf.c_tool
-C/C++ compiler
-<END>
-
-<BEGIN> FILE_$(PRJ_DIR)/../common/db_byteorder.c_dependDone
-TRUE
-<END>
-
-<BEGIN> FILE_$(PRJ_DIR)/../common/db_byteorder.c_dependencies
-$(PRJ_DIR)/db_config.h \
-	$(PRJ_DIR)/db_int.h \
-	$(PRJ_DIR)/db.h
-<END>
-
-<BEGIN> FILE_$(PRJ_DIR)/../common/db_byteorder.c_objects
-db_byteorder.o
-<END>
-
-<BEGIN> FILE_$(PRJ_DIR)/../common/db_byteorder.c_tool
-C/C++ compiler
-<END>
-
-<BEGIN> FILE_$(PRJ_DIR)/../common/db_err.c_dependDone
-TRUE
-<END>
-
-<BEGIN> FILE_$(PRJ_DIR)/../common/db_err.c_dependencies
-$(PRJ_DIR)/db_config.h \
-	$(PRJ_DIR)/db_int.h \
-	$(PRJ_DIR)/db.h
-<END>
-
-<BEGIN> FILE_$(PRJ_DIR)/../common/db_err.c_objects
-db_err.o
-<END>
-
-<BEGIN> FILE_$(PRJ_DIR)/../common/db_err.c_tool
-C/C++ compiler
-<END>
-
-<BEGIN> FILE_$(PRJ_DIR)/../common/db_getlong.c_dependDone
-TRUE
-<END>
-
-<BEGIN> FILE_$(PRJ_DIR)/../common/db_getlong.c_dependencies
-$(PRJ_DIR)/db_config.h \
-	$(PRJ_DIR)/db_int.h \
-	$(PRJ_DIR)/db.h
-<END>
-
-<BEGIN> FILE_$(PRJ_DIR)/../common/db_getlong.c_objects
-db_getlong.o
-<END>
-
-<BEGIN> FILE_$(PRJ_DIR)/../common/db_getlong.c_tool
-C/C++ compiler
-<END>
-
-<BEGIN> FILE_$(PRJ_DIR)/../common/db_idspace.c_dependDone
-TRUE
-<END>
-
-<BEGIN> FILE_$(PRJ_DIR)/../common/db_idspace.c_dependencies
-$(PRJ_DIR)/db_config.h \
-	$(PRJ_DIR)/db_int.h \
-	$(PRJ_DIR)/db.h
-<END>
-
-<BEGIN> FILE_$(PRJ_DIR)/../common/db_idspace.c_objects
-db_idspace.o
-<END>
-
-<BEGIN> FILE_$(PRJ_DIR)/../common/db_idspace.c_tool
-C/C++ compiler
-<END>
-
-<BEGIN> FILE_$(PRJ_DIR)/../common/db_log2.c_dependDone
-TRUE
-<END>
-
-<BEGIN> FILE_$(PRJ_DIR)/../common/db_log2.c_dependencies
-$(PRJ_DIR)/db_config.h \
-	$(PRJ_DIR)/db_int.h \
-	$(PRJ_DIR)/db.h
-<END>
-
-<BEGIN> FILE_$(PRJ_DIR)/../common/db_log2.c_objects
-db_log2.o
-<END>
-
-<BEGIN> FILE_$(PRJ_DIR)/../common/db_log2.c_tool
-C/C++ compiler
-<END>
-
-<BEGIN> FILE_$(PRJ_DIR)/../common/util_arg.c_dependDone
-TRUE
-<END>
-
-<BEGIN> FILE_$(PRJ_DIR)/../common/util_arg.c_dependencies
-$(PRJ_DIR)/db_config.h \
-	$(PRJ_DIR)/db_int.h \
-	$(PRJ_DIR)/db.h
-<END>
-
-<BEGIN> FILE_$(PRJ_DIR)/../common/util_arg.c_objects
-util_arg.o
-<END>
-
-<BEGIN> FILE_$(PRJ_DIR)/../common/util_arg.c_tool
-C/C++ compiler
-<END>
-
-<BEGIN> FILE_$(PRJ_DIR)/../common/util_cache.c_dependDone
-TRUE
-<END>
-
-<BEGIN> FILE_$(PRJ_DIR)/../common/util_cache.c_dependencies
-$(PRJ_DIR)/db_config.h \
-	$(PRJ_DIR)/db_int.h \
-	$(PRJ_DIR)/db.h
-<END>
-
-<BEGIN> FILE_$(PRJ_DIR)/../common/util_cache.c_objects
-util_cache.o
-<END>
-
-<BEGIN> FILE_$(PRJ_DIR)/../common/util_cache.c_tool
-C/C++ compiler
-<END>
-
-<BEGIN> FILE_$(PRJ_DIR)/../common/util_log.c_dependDone
-TRUE
-<END>
-
-<BEGIN> FILE_$(PRJ_DIR)/../common/util_log.c_dependencies
-$(PRJ_DIR)/db_config.h \
-	$(PRJ_DIR)/db_int.h \
-	$(PRJ_DIR)/db.h
-<END>
-
-<BEGIN> FILE_$(PRJ_DIR)/../common/util_log.c_objects
-util_log.o
-<END>
-
-<BEGIN> FILE_$(PRJ_DIR)/../common/util_log.c_tool
-C/C++ compiler
-<END>
-
-<BEGIN> FILE_$(PRJ_DIR)/../common/util_sig.c_dependDone
-TRUE
-<END>
-
-<BEGIN> FILE_$(PRJ_DIR)/../common/util_sig.c_dependencies
-$(PRJ_DIR)/db_config.h \
-	$(PRJ_DIR)/db_int.h \
-	$(PRJ_DIR)/db.h
-<END>
-
-<BEGIN> FILE_$(PRJ_DIR)/../common/util_sig.c_objects
-util_sig.o
-<END>
-
-<BEGIN> FILE_$(PRJ_DIR)/../common/util_sig.c_tool
-C/C++ compiler
-<END>
-
-<BEGIN> FILE_$(PRJ_DIR)/../db/crdel_auto.c_dependDone
-TRUE
-<END>
-
-<BEGIN> FILE_$(PRJ_DIR)/../db/crdel_auto.c_dependencies
-$(PRJ_DIR)/db_config.h \
-	$(PRJ_DIR)/db_int.h \
-	$(PRJ_DIR)/db.h
-<END>
-
-<BEGIN> FILE_$(PRJ_DIR)/../db/crdel_auto.c_objects
-crdel_auto.o
-<END>
-
-<BEGIN> FILE_$(PRJ_DIR)/../db/crdel_auto.c_tool
-C/C++ compiler
-<END>
-
-<BEGIN> FILE_$(PRJ_DIR)/../db/crdel_rec.c_dependDone
-TRUE
-<END>
-
-<BEGIN> FILE_$(PRJ_DIR)/../db/crdel_rec.c_dependencies
-$(PRJ_DIR)/db_config.h \
-	$(PRJ_DIR)/db_int.h \
-	$(PRJ_DIR)/db.h
-<END>
-
-<BEGIN> FILE_$(PRJ_DIR)/../db/crdel_rec.c_objects
-crdel_rec.o
-<END>
-
-<BEGIN> FILE_$(PRJ_DIR)/../db/crdel_rec.c_tool
-C/C++ compiler
-<END>
-
-<BEGIN> FILE_$(PRJ_DIR)/../db/db.c_dependDone
-TRUE
-<END>
-
-<BEGIN> FILE_$(PRJ_DIR)/../db/db.c_dependencies
-$(PRJ_DIR)/db_config.h \
-	$(PRJ_DIR)/db_int.h \
-	$(PRJ_DIR)/db.h
-<END>
-
-<BEGIN> FILE_$(PRJ_DIR)/../db/db.c_objects
-db.o
-<END>
-
-<BEGIN> FILE_$(PRJ_DIR)/../db/db.c_tool
-C/C++ compiler
-<END>
-
-<BEGIN> FILE_$(PRJ_DIR)/../db/db_am.c_dependDone
-TRUE
-<END>
-
-<BEGIN> FILE_$(PRJ_DIR)/../db/db_am.c_dependencies
-$(PRJ_DIR)/db_config.h \
-	$(PRJ_DIR)/db_int.h \
-	$(PRJ_DIR)/db.h
-<END>
-
-<BEGIN> FILE_$(PRJ_DIR)/../db/db_am.c_objects
-db_am.o
-<END>
-
-<BEGIN> FILE_$(PRJ_DIR)/../db/db_am.c_tool
-C/C++ compiler
-<END>
-
-<BEGIN> FILE_$(PRJ_DIR)/../db/db_auto.c_dependDone
-TRUE
-<END>
-
-<BEGIN> FILE_$(PRJ_DIR)/../db/db_auto.c_dependencies
-$(PRJ_DIR)/db_config.h \
-	$(PRJ_DIR)/db_int.h \
-	$(PRJ_DIR)/db.h
-<END>
-
-<BEGIN> FILE_$(PRJ_DIR)/../db/db_auto.c_objects
-db_auto.o
-<END>
-
-<BEGIN> FILE_$(PRJ_DIR)/../db/db_auto.c_tool
-C/C++ compiler
-<END>
-
-<BEGIN> FILE_$(PRJ_DIR)/../db/db_cam.c_dependDone
-TRUE
-<END>
-
-<BEGIN> FILE_$(PRJ_DIR)/../db/db_cam.c_dependencies
-$(PRJ_DIR)/db_config.h \
-	$(PRJ_DIR)/db_int.h \
-	$(PRJ_DIR)/db.h
-<END>
-
-<BEGIN> FILE_$(PRJ_DIR)/../db/db_cam.c_objects
-db_cam.o
-<END>
-
-<BEGIN> FILE_$(PRJ_DIR)/../db/db_cam.c_tool
-C/C++ compiler
-<END>
-
-<BEGIN> FILE_$(PRJ_DIR)/../db/db_conv.c_dependDone
-TRUE
-<END>
-
-<BEGIN> FILE_$(PRJ_DIR)/../db/db_conv.c_dependencies
-$(PRJ_DIR)/db_config.h \
-	$(PRJ_DIR)/db_int.h \
-	$(PRJ_DIR)/db.h
-<END>
-
-<BEGIN> FILE_$(PRJ_DIR)/../db/db_conv.c_objects
-db_conv.o
-<END>
-
-<BEGIN> FILE_$(PRJ_DIR)/../db/db_conv.c_tool
-C/C++ compiler
-<END>
-
-<BEGIN> FILE_$(PRJ_DIR)/../db/db_dispatch.c_dependDone
-TRUE
-<END>
-
-<BEGIN> FILE_$(PRJ_DIR)/../db/db_dispatch.c_dependencies
-$(PRJ_DIR)/db_config.h \
-	$(PRJ_DIR)/db_int.h \
-	$(PRJ_DIR)/db.h
-<END>
-
-<BEGIN> FILE_$(PRJ_DIR)/../db/db_dispatch.c_objects
-db_dispatch.o
-<END>
-
-<BEGIN> FILE_$(PRJ_DIR)/../db/db_dispatch.c_tool
-C/C++ compiler
-<END>
-
-<BEGIN> FILE_$(PRJ_DIR)/../db/db_dup.c_dependDone
-TRUE
-<END>
-
-<BEGIN> FILE_$(PRJ_DIR)/../db/db_dup.c_dependencies
-$(PRJ_DIR)/db_config.h \
-	$(PRJ_DIR)/db_int.h \
-	$(PRJ_DIR)/db.h
-<END>
-
-<BEGIN> FILE_$(PRJ_DIR)/../db/db_dup.c_objects
-db_dup.o
-<END>
-
-<BEGIN> FILE_$(PRJ_DIR)/../db/db_dup.c_tool
-C/C++ compiler
-<END>
-
-<BEGIN> FILE_$(PRJ_DIR)/../db/db_iface.c_dependDone
-TRUE
-<END>
-
-<BEGIN> FILE_$(PRJ_DIR)/../db/db_iface.c_dependencies
-$(PRJ_DIR)/db_config.h \
-	$(PRJ_DIR)/db_int.h \
-	$(PRJ_DIR)/db.h
-<END>
-
-<BEGIN> FILE_$(PRJ_DIR)/../db/db_iface.c_objects
-db_iface.o
-<END>
-
-<BEGIN> FILE_$(PRJ_DIR)/../db/db_iface.c_tool
-C/C++ compiler
-<END>
-
-<BEGIN> FILE_$(PRJ_DIR)/../db/db_join.c_dependDone
-TRUE
-<END>
-
-<BEGIN> FILE_$(PRJ_DIR)/../db/db_join.c_dependencies
-$(PRJ_DIR)/db_config.h \
-	$(PRJ_DIR)/db_int.h \
-	$(PRJ_DIR)/db.h
-<END>
-
-<BEGIN> FILE_$(PRJ_DIR)/../db/db_join.c_objects
-db_join.o
-<END>
-
-<BEGIN> FILE_$(PRJ_DIR)/../db/db_join.c_tool
-C/C++ compiler
-<END>
-
-<BEGIN> FILE_$(PRJ_DIR)/../db/db_meta.c_dependDone
-TRUE
-<END>
-
-<BEGIN> FILE_$(PRJ_DIR)/../db/db_meta.c_dependencies
-$(PRJ_DIR)/db_config.h \
-	$(PRJ_DIR)/db_int.h \
-	$(PRJ_DIR)/db.h
-<END>
-
-<BEGIN> FILE_$(PRJ_DIR)/../db/db_meta.c_objects
-db_meta.o
-<END>
-
-<BEGIN> FILE_$(PRJ_DIR)/../db/db_meta.c_tool
-C/C++ compiler
-<END>
-
-<BEGIN> FILE_$(PRJ_DIR)/../db/db_method.c_dependDone
-TRUE
-<END>
-
-<BEGIN> FILE_$(PRJ_DIR)/../db/db_method.c_dependencies
-$(PRJ_DIR)/db_config.h \
-	$(PRJ_DIR)/db_int.h \
-	$(PRJ_DIR)/db.h
-<END>
-
-<BEGIN> FILE_$(PRJ_DIR)/../db/db_method.c_objects
-db_method.o
-<END>
-
-<BEGIN> FILE_$(PRJ_DIR)/../db/db_method.c_tool
-C/C++ compiler
-<END>
-
-<BEGIN> FILE_$(PRJ_DIR)/../db/db_open.c_dependDone
-TRUE
-<END>
-
-<BEGIN> FILE_$(PRJ_DIR)/../db/db_open.c_dependencies
-$(PRJ_DIR)/db_config.h \
-	$(PRJ_DIR)/db_int.h \
-	$(PRJ_DIR)/db.h
-<END>
-
-<BEGIN> FILE_$(PRJ_DIR)/../db/db_open.c_objects
-db_open.o
-<END>
-
-<BEGIN> FILE_$(PRJ_DIR)/../db/db_open.c_tool
-C/C++ compiler
-<END>
-
-<BEGIN> FILE_$(PRJ_DIR)/../db/db_overflow.c_dependDone
-TRUE
-<END>
-
-<BEGIN> FILE_$(PRJ_DIR)/../db/db_overflow.c_dependencies
-$(PRJ_DIR)/db_config.h \
-	$(PRJ_DIR)/db_int.h \
-	$(PRJ_DIR)/db.h
-<END>
-
-<BEGIN> FILE_$(PRJ_DIR)/../db/db_overflow.c_objects
-db_overflow.o
-<END>
-
-<BEGIN> FILE_$(PRJ_DIR)/../db/db_overflow.c_tool
-C/C++ compiler
-<END>
-
-<BEGIN> FILE_$(PRJ_DIR)/../db/db_pr.c_dependDone
-TRUE
-<END>
-
-<BEGIN> FILE_$(PRJ_DIR)/../db/db_pr.c_dependencies
-$(PRJ_DIR)/db_config.h \
-	$(PRJ_DIR)/db_int.h \
-	$(PRJ_DIR)/db.h
-<END>
-
-<BEGIN> FILE_$(PRJ_DIR)/../db/db_pr.c_objects
-db_pr.o
-<END>
-
-<BEGIN> FILE_$(PRJ_DIR)/../db/db_pr.c_tool
-C/C++ compiler
-<END>
-
-<BEGIN> FILE_$(PRJ_DIR)/../db/db_rec.c_dependDone
-TRUE
-<END>
-
-<BEGIN> FILE_$(PRJ_DIR)/../db/db_rec.c_dependencies
-$(PRJ_DIR)/db_config.h \
-	$(PRJ_DIR)/db_int.h \
-	$(PRJ_DIR)/db.h
-<END>
-
-<BEGIN> FILE_$(PRJ_DIR)/../db/db_rec.c_objects
-db_rec.o
-<END>
-
-<BEGIN> FILE_$(PRJ_DIR)/../db/db_rec.c_tool
-C/C++ compiler
-<END>
-
-<BEGIN> FILE_$(PRJ_DIR)/../db/db_reclaim.c_dependDone
-TRUE
-<END>
-
-<BEGIN> FILE_$(PRJ_DIR)/../db/db_reclaim.c_dependencies
-$(PRJ_DIR)/db_config.h \
-	$(PRJ_DIR)/db_int.h \
-	$(PRJ_DIR)/db.h
-<END>
-
-<BEGIN> FILE_$(PRJ_DIR)/../db/db_reclaim.c_objects
-db_reclaim.o
-<END>
-
-<BEGIN> FILE_$(PRJ_DIR)/../db/db_reclaim.c_tool
-C/C++ compiler
-<END>
-
-<BEGIN> FILE_$(PRJ_DIR)/../db/db_remove.c_dependDone
-TRUE
-<END>
-
-<BEGIN> FILE_$(PRJ_DIR)/../db/db_remove.c_dependencies
-$(PRJ_DIR)/db_config.h \
-	$(PRJ_DIR)/db_int.h \
-	$(PRJ_DIR)/db.h
-<END>
-
-<BEGIN> FILE_$(PRJ_DIR)/../db/db_remove.c_objects
-db_remove.o
-<END>
-
-<BEGIN> FILE_$(PRJ_DIR)/../db/db_remove.c_tool
-C/C++ compiler
-<END>
-
-<BEGIN> FILE_$(PRJ_DIR)/../db/db_rename.c_dependDone
-TRUE
-<END>
-
-<BEGIN> FILE_$(PRJ_DIR)/../db/db_rename.c_dependencies
-$(PRJ_DIR)/db_config.h \
-	$(PRJ_DIR)/db_int.h \
-	$(PRJ_DIR)/db.h
-<END>
-
-<BEGIN> FILE_$(PRJ_DIR)/../db/db_rename.c_objects
-db_rename.o
-<END>
-
-<BEGIN> FILE_$(PRJ_DIR)/../db/db_rename.c_tool
-C/C++ compiler
-<END>
-
-<BEGIN> FILE_$(PRJ_DIR)/../db/db_ret.c_dependDone
-TRUE
-<END>
-
-<BEGIN> FILE_$(PRJ_DIR)/../db/db_ret.c_dependencies
-$(PRJ_DIR)/db_config.h \
-	$(PRJ_DIR)/db_int.h \
-	$(PRJ_DIR)/db.h
-<END>
-
-<BEGIN> FILE_$(PRJ_DIR)/../db/db_ret.c_objects
-db_ret.o
-<END>
-
-<BEGIN> FILE_$(PRJ_DIR)/../db/db_ret.c_tool
-C/C++ compiler
-<END>
-
-<BEGIN> FILE_$(PRJ_DIR)/../db/db_truncate.c_dependDone
-TRUE
-<END>
-
-<BEGIN> FILE_$(PRJ_DIR)/../db/db_truncate.c_dependencies
-$(PRJ_DIR)/db_config.h \
-	$(PRJ_DIR)/db_int.h \
-	$(PRJ_DIR)/db.h
-<END>
-
-<BEGIN> FILE_$(PRJ_DIR)/../db/db_truncate.c_objects
-db_truncate.o
-<END>
-
-<BEGIN> FILE_$(PRJ_DIR)/../db/db_truncate.c_tool
-C/C++ compiler
-<END>
-
-<BEGIN> FILE_$(PRJ_DIR)/../db/db_upg.c_dependDone
-TRUE
-<END>
-
-<BEGIN> FILE_$(PRJ_DIR)/../db/db_upg.c_dependencies
-$(PRJ_DIR)/db_config.h \
-	$(PRJ_DIR)/db_int.h \
-	$(PRJ_DIR)/db.h
-<END>
-
-<BEGIN> FILE_$(PRJ_DIR)/../db/db_upg.c_objects
-db_upg.o
-<END>
-
-<BEGIN> FILE_$(PRJ_DIR)/../db/db_upg.c_tool
-C/C++ compiler
-<END>
-
-<BEGIN> FILE_$(PRJ_DIR)/../db/db_upg_opd.c_dependDone
-TRUE
-<END>
-
-<BEGIN> FILE_$(PRJ_DIR)/../db/db_upg_opd.c_dependencies
-$(PRJ_DIR)/db_config.h \
-	$(PRJ_DIR)/db_int.h \
-	$(PRJ_DIR)/db.h
-<END>
-
-<BEGIN> FILE_$(PRJ_DIR)/../db/db_upg_opd.c_objects
-db_upg_opd.o
-<END>
-
-<BEGIN> FILE_$(PRJ_DIR)/../db/db_upg_opd.c_tool
-C/C++ compiler
-<END>
-
-<BEGIN> FILE_$(PRJ_DIR)/../db/db_vrfy.c_dependDone
-TRUE
-<END>
-
-<BEGIN> FILE_$(PRJ_DIR)/../db/db_vrfy.c_dependencies
-$(PRJ_DIR)/db_config.h \
-	$(PRJ_DIR)/db_int.h \
-	$(PRJ_DIR)/db.h
-<END>
-
-<BEGIN> FILE_$(PRJ_DIR)/../db/db_vrfy.c_objects
-db_vrfy.o
-<END>
-
-<BEGIN> FILE_$(PRJ_DIR)/../db/db_vrfy.c_tool
-C/C++ compiler
-<END>
-
-<BEGIN> FILE_$(PRJ_DIR)/../db/db_vrfyutil.c_dependDone
-TRUE
-<END>
-
-<BEGIN> FILE_$(PRJ_DIR)/../db/db_vrfyutil.c_dependencies
-$(PRJ_DIR)/db_config.h \
-	$(PRJ_DIR)/db_int.h \
-	$(PRJ_DIR)/db.h
-<END>
-
-<BEGIN> FILE_$(PRJ_DIR)/../db/db_vrfyutil.c_objects
-db_vrfyutil.o
-<END>
-
-<BEGIN> FILE_$(PRJ_DIR)/../db/db_vrfyutil.c_tool
-C/C++ compiler
-<END>
-
-<BEGIN> FILE_$(PRJ_DIR)/../dbreg/dbreg.c_dependDone
-TRUE
-<END>
-
-<BEGIN> FILE_$(PRJ_DIR)/../dbreg/dbreg.c_dependencies
-$(PRJ_DIR)/db_config.h \
-	$(PRJ_DIR)/db_int.h \
-	$(PRJ_DIR)/db.h
-<END>
-
-<BEGIN> FILE_$(PRJ_DIR)/../dbreg/dbreg.c_objects
-dbreg.o
-<END>
-
-<BEGIN> FILE_$(PRJ_DIR)/../dbreg/dbreg.c_tool
-C/C++ compiler
-<END>
-
-<BEGIN> FILE_$(PRJ_DIR)/../dbreg/dbreg_auto.c_dependDone
-TRUE
-<END>
-
-<BEGIN> FILE_$(PRJ_DIR)/../dbreg/dbreg_auto.c_dependencies
-$(PRJ_DIR)/db_config.h \
-	$(PRJ_DIR)/db_int.h \
-	$(PRJ_DIR)/db.h
-<END>
-
-<BEGIN> FILE_$(PRJ_DIR)/../dbreg/dbreg_auto.c_objects
-dbreg_auto.o
-<END>
-
-<BEGIN> FILE_$(PRJ_DIR)/../dbreg/dbreg_auto.c_tool
-C/C++ compiler
-<END>
-
-<BEGIN> FILE_$(PRJ_DIR)/../dbreg/dbreg_rec.c_dependDone
-TRUE
-<END>
-
-<BEGIN> FILE_$(PRJ_DIR)/../dbreg/dbreg_rec.c_dependencies
-$(PRJ_DIR)/db_config.h \
-	$(PRJ_DIR)/db_int.h \
-	$(PRJ_DIR)/db.h
-<END>
-
-<BEGIN> FILE_$(PRJ_DIR)/../dbreg/dbreg_rec.c_objects
-dbreg_rec.o
-<END>
-
-<BEGIN> FILE_$(PRJ_DIR)/../dbreg/dbreg_rec.c_tool
-C/C++ compiler
-<END>
-
-<BEGIN> FILE_$(PRJ_DIR)/../dbreg/dbreg_util.c_dependDone
-TRUE
-<END>
-
-<BEGIN> FILE_$(PRJ_DIR)/../dbreg/dbreg_util.c_dependencies
-$(PRJ_DIR)/db_config.h \
-	$(PRJ_DIR)/db_int.h \
-	$(PRJ_DIR)/db.h
-<END>
-
-<BEGIN> FILE_$(PRJ_DIR)/../dbreg/dbreg_util.c_objects
-dbreg_util.o
-<END>
-
-<BEGIN> FILE_$(PRJ_DIR)/../dbreg/dbreg_util.c_tool
-C/C++ compiler
-<END>
-
-<BEGIN> FILE_$(PRJ_DIR)/../env/db_salloc.c_dependDone
-TRUE
-<END>
-
-<BEGIN> FILE_$(PRJ_DIR)/../env/db_salloc.c_dependencies
-$(PRJ_DIR)/db_config.h \
-	$(PRJ_DIR)/db_int.h \
-	$(PRJ_DIR)/db.h
-<END>
-
-<BEGIN> FILE_$(PRJ_DIR)/../env/db_salloc.c_objects
-db_salloc.o
-<END>
-
-<BEGIN> FILE_$(PRJ_DIR)/../env/db_salloc.c_tool
-C/C++ compiler
-<END>
-
-<BEGIN> FILE_$(PRJ_DIR)/../env/db_shash.c_dependDone
-TRUE
-<END>
-
-<BEGIN> FILE_$(PRJ_DIR)/../env/db_shash.c_dependencies
-$(PRJ_DIR)/db_config.h \
-	$(PRJ_DIR)/db_int.h \
-	$(PRJ_DIR)/db.h
-<END>
-
-<BEGIN> FILE_$(PRJ_DIR)/../env/db_shash.c_objects
-db_shash.o
-<END>
-
-<BEGIN> FILE_$(PRJ_DIR)/../env/db_shash.c_tool
-C/C++ compiler
-<END>
-
-<BEGIN> FILE_$(PRJ_DIR)/../env/env_file.c_dependDone
-TRUE
-<END>
-
-<BEGIN> FILE_$(PRJ_DIR)/../env/env_file.c_dependencies
-$(PRJ_DIR)/db_config.h \
-	$(PRJ_DIR)/db_int.h \
-	$(PRJ_DIR)/db.h
-<END>
-
-<BEGIN> FILE_$(PRJ_DIR)/../env/env_file.c_objects
-env_file.o
-<END>
-
-<BEGIN> FILE_$(PRJ_DIR)/../env/env_file.c_tool
-C/C++ compiler
-<END>
-
-<BEGIN> FILE_$(PRJ_DIR)/../env/env_method.c_dependDone
-TRUE
-<END>
-
-<BEGIN> FILE_$(PRJ_DIR)/../env/env_method.c_dependencies
-$(PRJ_DIR)/db_config.h \
-	$(PRJ_DIR)/db_int.h \
-	$(PRJ_DIR)/db.h
-<END>
-
-<BEGIN> FILE_$(PRJ_DIR)/../env/env_method.c_objects
-env_method.o
-<END>
-
-<BEGIN> FILE_$(PRJ_DIR)/../env/env_method.c_tool
-C/C++ compiler
-<END>
-
-<BEGIN> FILE_$(PRJ_DIR)/../env/env_open.c_dependDone
-TRUE
-<END>
-
-<BEGIN> FILE_$(PRJ_DIR)/../env/env_open.c_dependencies
-$(PRJ_DIR)/db_config.h \
-	$(PRJ_DIR)/db_int.h \
-	$(PRJ_DIR)/db.h
-<END>
-
-<BEGIN> FILE_$(PRJ_DIR)/../env/env_open.c_objects
-env_open.o
-<END>
-
-<BEGIN> FILE_$(PRJ_DIR)/../env/env_open.c_tool
-C/C++ compiler
-<END>
-
-<BEGIN> FILE_$(PRJ_DIR)/../env/env_recover.c_dependDone
-TRUE
-<END>
-
-<BEGIN> FILE_$(PRJ_DIR)/../env/env_recover.c_dependencies
-$(PRJ_DIR)/db_config.h \
-	$(PRJ_DIR)/db_int.h \
-	$(PRJ_DIR)/db.h
-<END>
-
-<BEGIN> FILE_$(PRJ_DIR)/../env/env_recover.c_objects
-env_recover.o
-<END>
-
-<BEGIN> FILE_$(PRJ_DIR)/../env/env_recover.c_tool
-C/C++ compiler
-<END>
-
-<BEGIN> FILE_$(PRJ_DIR)/../env/env_region.c_dependDone
-TRUE
-<END>
-
-<BEGIN> FILE_$(PRJ_DIR)/../env/env_region.c_dependencies
-$(PRJ_DIR)/db_config.h \
-	$(PRJ_DIR)/db_int.h \
-	$(PRJ_DIR)/db.h
-<END>
-
-<BEGIN> FILE_$(PRJ_DIR)/../env/env_region.c_objects
-env_region.o
-<END>
-
-<BEGIN> FILE_$(PRJ_DIR)/../env/env_region.c_tool
-C/C++ compiler
-<END>
-
-<BEGIN> FILE_$(PRJ_DIR)/../fileops/fileops_auto.c_dependDone
-TRUE
-<END>
-
-<BEGIN> FILE_$(PRJ_DIR)/../fileops/fileops_auto.c_dependencies
-$(PRJ_DIR)/db_config.h \
-	$(PRJ_DIR)/db_int.h \
-	$(PRJ_DIR)/db.h
-<END>
-
-<BEGIN> FILE_$(PRJ_DIR)/../fileops/fileops_auto.c_objects
-fileops_auto.o
-<END>
-
-<BEGIN> FILE_$(PRJ_DIR)/../fileops/fileops_auto.c_tool
-C/C++ compiler
-<END>
-
-<BEGIN> FILE_$(PRJ_DIR)/../fileops/fop_basic.c_dependDone
-TRUE
-<END>
-
-<BEGIN> FILE_$(PRJ_DIR)/../fileops/fop_basic.c_dependencies
-$(PRJ_DIR)/db_config.h \
-	$(PRJ_DIR)/db_int.h \
-	$(PRJ_DIR)/db.h
-<END>
-
-<BEGIN> FILE_$(PRJ_DIR)/../fileops/fop_basic.c_objects
-fop_basic.o
-<END>
-
-<BEGIN> FILE_$(PRJ_DIR)/../fileops/fop_basic.c_tool
-C/C++ compiler
-<END>
-
-<BEGIN> FILE_$(PRJ_DIR)/../fileops/fop_rec.c_dependDone
-TRUE
-<END>
-
-<BEGIN> FILE_$(PRJ_DIR)/../fileops/fop_rec.c_dependencies
-$(PRJ_DIR)/db_config.h \
-	$(PRJ_DIR)/db_int.h \
-	$(PRJ_DIR)/db.h
-<END>
-
-<BEGIN> FILE_$(PRJ_DIR)/../fileops/fop_rec.c_objects
-fop_rec.o
-<END>
-
-<BEGIN> FILE_$(PRJ_DIR)/../fileops/fop_rec.c_tool
-C/C++ compiler
-<END>
-
-<BEGIN> FILE_$(PRJ_DIR)/../fileops/fop_util.c_dependDone
-TRUE
-<END>
-
-<BEGIN> FILE_$(PRJ_DIR)/../fileops/fop_util.c_dependencies
-$(PRJ_DIR)/db_config.h \
-	$(PRJ_DIR)/db_int.h \
-	$(PRJ_DIR)/db.h
-<END>
-
-<BEGIN> FILE_$(PRJ_DIR)/../fileops/fop_util.c_objects
-fop_util.o
-<END>
-
-<BEGIN> FILE_$(PRJ_DIR)/../fileops/fop_util.c_tool
-C/C++ compiler
-<END>
-
-<BEGIN> FILE_$(PRJ_DIR)/../hash/hash.c_dependDone
-TRUE
-<END>
-
-<BEGIN> FILE_$(PRJ_DIR)/../hash/hash.c_dependencies
-$(PRJ_DIR)/db_config.h \
-	$(PRJ_DIR)/db_int.h \
-	$(PRJ_DIR)/db.h
-<END>
-
-<BEGIN> FILE_$(PRJ_DIR)/../hash/hash.c_objects
-hash.o
-<END>
-
-<BEGIN> FILE_$(PRJ_DIR)/../hash/hash.c_tool
-C/C++ compiler
-<END>
-
-<BEGIN> FILE_$(PRJ_DIR)/../hash/hash_auto.c_dependDone
-TRUE
-<END>
-
-<BEGIN> FILE_$(PRJ_DIR)/../hash/hash_auto.c_dependencies
-$(PRJ_DIR)/db_config.h \
-	$(PRJ_DIR)/db_int.h \
-	$(PRJ_DIR)/db.h
-<END>
-
-<BEGIN> FILE_$(PRJ_DIR)/../hash/hash_auto.c_objects
-hash_auto.o
-<END>
-
-<BEGIN> FILE_$(PRJ_DIR)/../hash/hash_auto.c_tool
-C/C++ compiler
-<END>
-
-<BEGIN> FILE_$(PRJ_DIR)/../hash/hash_conv.c_dependDone
-TRUE
-<END>
-
-<BEGIN> FILE_$(PRJ_DIR)/../hash/hash_conv.c_dependencies
-$(PRJ_DIR)/db_config.h \
-	$(PRJ_DIR)/db_int.h \
-	$(PRJ_DIR)/db.h
-<END>
-
-<BEGIN> FILE_$(PRJ_DIR)/../hash/hash_conv.c_objects
-hash_conv.o
-<END>
-
-<BEGIN> FILE_$(PRJ_DIR)/../hash/hash_conv.c_tool
-C/C++ compiler
-<END>
-
-<BEGIN> FILE_$(PRJ_DIR)/../hash/hash_dup.c_dependDone
-TRUE
-<END>
-
-<BEGIN> FILE_$(PRJ_DIR)/../hash/hash_dup.c_dependencies
-$(PRJ_DIR)/db_config.h \
-	$(PRJ_DIR)/db_int.h \
-	$(PRJ_DIR)/db.h
-<END>
-
-<BEGIN> FILE_$(PRJ_DIR)/../hash/hash_dup.c_objects
-hash_dup.o
-<END>
-
-<BEGIN> FILE_$(PRJ_DIR)/../hash/hash_dup.c_tool
-C/C++ compiler
-<END>
-
-<BEGIN> FILE_$(PRJ_DIR)/../hash/hash_func.c_dependDone
-TRUE
-<END>
-
-<BEGIN> FILE_$(PRJ_DIR)/../hash/hash_func.c_dependencies
-$(PRJ_DIR)/db_config.h \
-	$(PRJ_DIR)/db_int.h \
-	$(PRJ_DIR)/db.h
-<END>
-
-<BEGIN> FILE_$(PRJ_DIR)/../hash/hash_func.c_objects
-hash_func.o
-<END>
-
-<BEGIN> FILE_$(PRJ_DIR)/../hash/hash_func.c_tool
-C/C++ compiler
-<END>
-
-<BEGIN> FILE_$(PRJ_DIR)/../hash/hash_meta.c_dependDone
-TRUE
-<END>
-
-<BEGIN> FILE_$(PRJ_DIR)/../hash/hash_meta.c_dependencies
-$(PRJ_DIR)/db_config.h \
-	$(PRJ_DIR)/db_int.h \
-	$(PRJ_DIR)/db.h
-<END>
-
-<BEGIN> FILE_$(PRJ_DIR)/../hash/hash_meta.c_objects
-hash_meta.o
-<END>
-
-<BEGIN> FILE_$(PRJ_DIR)/../hash/hash_meta.c_tool
-C/C++ compiler
-<END>
-
-<BEGIN> FILE_$(PRJ_DIR)/../hash/hash_method.c_dependDone
-TRUE
-<END>
-
-<BEGIN> FILE_$(PRJ_DIR)/../hash/hash_method.c_dependencies
-$(PRJ_DIR)/db_config.h \
-	$(PRJ_DIR)/db_int.h \
-	$(PRJ_DIR)/db.h
-<END>
-
-<BEGIN> FILE_$(PRJ_DIR)/../hash/hash_method.c_objects
-hash_method.o
-<END>
-
-<BEGIN> FILE_$(PRJ_DIR)/../hash/hash_method.c_tool
-C/C++ compiler
-<END>
-
-<BEGIN> FILE_$(PRJ_DIR)/../hash/hash_open.c_dependDone
-TRUE
-<END>
-
-<BEGIN> FILE_$(PRJ_DIR)/../hash/hash_open.c_dependencies
-$(PRJ_DIR)/db_config.h \
-	$(PRJ_DIR)/db_int.h \
-	$(PRJ_DIR)/db.h
-<END>
-
-<BEGIN> FILE_$(PRJ_DIR)/../hash/hash_open.c_objects
-hash_open.o
-<END>
-
-<BEGIN> FILE_$(PRJ_DIR)/../hash/hash_open.c_tool
-C/C++ compiler
-<END>
-
-<BEGIN> FILE_$(PRJ_DIR)/../hash/hash_page.c_dependDone
-TRUE
-<END>
-
-<BEGIN> FILE_$(PRJ_DIR)/../hash/hash_page.c_dependencies
-$(PRJ_DIR)/db_config.h \
-	$(PRJ_DIR)/db_int.h \
-	$(PRJ_DIR)/db.h
-<END>
-
-<BEGIN> FILE_$(PRJ_DIR)/../hash/hash_page.c_objects
-hash_page.o
-<END>
-
-<BEGIN> FILE_$(PRJ_DIR)/../hash/hash_page.c_tool
-C/C++ compiler
-<END>
-
-<BEGIN> FILE_$(PRJ_DIR)/../hash/hash_rec.c_dependDone
-TRUE
-<END>
-
-<BEGIN> FILE_$(PRJ_DIR)/../hash/hash_rec.c_dependencies
-$(PRJ_DIR)/db_config.h \
-	$(PRJ_DIR)/db_int.h \
-	$(PRJ_DIR)/db.h
-<END>
-
-<BEGIN> FILE_$(PRJ_DIR)/../hash/hash_rec.c_objects
-hash_rec.o
-<END>
-
-<BEGIN> FILE_$(PRJ_DIR)/../hash/hash_rec.c_tool
-C/C++ compiler
-<END>
-
-<BEGIN> FILE_$(PRJ_DIR)/../hash/hash_reclaim.c_dependDone
-TRUE
-<END>
-
-<BEGIN> FILE_$(PRJ_DIR)/../hash/hash_reclaim.c_dependencies
-$(PRJ_DIR)/db_config.h \
-	$(PRJ_DIR)/db_int.h \
-	$(PRJ_DIR)/db.h
-<END>
-
-<BEGIN> FILE_$(PRJ_DIR)/../hash/hash_reclaim.c_objects
-hash_reclaim.o
-<END>
-
-<BEGIN> FILE_$(PRJ_DIR)/../hash/hash_reclaim.c_tool
-C/C++ compiler
-<END>
-
-<BEGIN> FILE_$(PRJ_DIR)/../hash/hash_stat.c_dependDone
-TRUE
-<END>
-
-<BEGIN> FILE_$(PRJ_DIR)/../hash/hash_stat.c_dependencies
-$(PRJ_DIR)/db_config.h \
-	$(PRJ_DIR)/db_int.h \
-	$(PRJ_DIR)/db.h
-<END>
-
-<BEGIN> FILE_$(PRJ_DIR)/../hash/hash_stat.c_objects
-hash_stat.o
-<END>
-
-<BEGIN> FILE_$(PRJ_DIR)/../hash/hash_stat.c_tool
-C/C++ compiler
-<END>
-
-<BEGIN> FILE_$(PRJ_DIR)/../hash/hash_upgrade.c_dependDone
-TRUE
-<END>
-
-<BEGIN> FILE_$(PRJ_DIR)/../hash/hash_upgrade.c_dependencies
-$(PRJ_DIR)/db_config.h \
-	$(PRJ_DIR)/db_int.h \
-	$(PRJ_DIR)/db.h
-<END>
-
-<BEGIN> FILE_$(PRJ_DIR)/../hash/hash_upgrade.c_objects
-hash_upgrade.o
-<END>
-
-<BEGIN> FILE_$(PRJ_DIR)/../hash/hash_upgrade.c_tool
-C/C++ compiler
-<END>
-
-<BEGIN> FILE_$(PRJ_DIR)/../hash/hash_verify.c_dependDone
-TRUE
-<END>
-
-<BEGIN> FILE_$(PRJ_DIR)/../hash/hash_verify.c_dependencies
-$(PRJ_DIR)/db_config.h \
-	$(PRJ_DIR)/db_int.h \
-	$(PRJ_DIR)/db.h
-<END>
-
-<BEGIN> FILE_$(PRJ_DIR)/../hash/hash_verify.c_objects
-hash_verify.o
-<END>
-
-<BEGIN> FILE_$(PRJ_DIR)/../hash/hash_verify.c_tool
-C/C++ compiler
-<END>
-
-<BEGIN> FILE_$(PRJ_DIR)/../hmac/hmac.c_dependDone
-TRUE
-<END>
-
-<BEGIN> FILE_$(PRJ_DIR)/../hmac/hmac.c_dependencies
-$(PRJ_DIR)/db_config.h \
-	$(PRJ_DIR)/db_int.h \
-	$(PRJ_DIR)/db.h
-<END>
-
-<BEGIN> FILE_$(PRJ_DIR)/../hmac/hmac.c_objects
-hmac.o
-<END>
-
-<BEGIN> FILE_$(PRJ_DIR)/../hmac/hmac.c_tool
-C/C++ compiler
-<END>
-
-<BEGIN> FILE_$(PRJ_DIR)/../hmac/sha1.c_dependDone
-TRUE
-<END>
-
-<BEGIN> FILE_$(PRJ_DIR)/../hmac/sha1.c_dependencies
-$(PRJ_DIR)/db_config.h \
-	$(PRJ_DIR)/db_int.h \
-	$(PRJ_DIR)/db.h
-<END>
-
-<BEGIN> FILE_$(PRJ_DIR)/../hmac/sha1.c_objects
-sha1.o
-<END>
-
-<BEGIN> FILE_$(PRJ_DIR)/../hmac/sha1.c_tool
-C/C++ compiler
-<END>
-
-<BEGIN> FILE_$(PRJ_DIR)/../hsearch/hsearch.c_dependDone
-TRUE
-<END>
-
-<BEGIN> FILE_$(PRJ_DIR)/../hsearch/hsearch.c_dependencies
-$(PRJ_DIR)/db_config.h \
-	$(PRJ_DIR)/db_int.h \
-	$(PRJ_DIR)/db.h
-<END>
-
-<BEGIN> FILE_$(PRJ_DIR)/../hsearch/hsearch.c_objects
-hsearch.o
-<END>
-
-<BEGIN> FILE_$(PRJ_DIR)/../hsearch/hsearch.c_tool
-C/C++ compiler
-<END>
-
-<BEGIN> FILE_$(PRJ_DIR)/../lock/lock.c_dependDone
-TRUE
-<END>
-
-<BEGIN> FILE_$(PRJ_DIR)/../lock/lock.c_dependencies
-$(PRJ_DIR)/db_config.h \
-	$(PRJ_DIR)/db_int.h \
-	$(PRJ_DIR)/db.h
-<END>
-
-<BEGIN> FILE_$(PRJ_DIR)/../lock/lock.c_objects
-lock.o
-<END>
-
-<BEGIN> FILE_$(PRJ_DIR)/../lock/lock.c_tool
-C/C++ compiler
-<END>
-
-<BEGIN> FILE_$(PRJ_DIR)/../lock/lock_deadlock.c_dependDone
-TRUE
-<END>
-
-<BEGIN> FILE_$(PRJ_DIR)/../lock/lock_deadlock.c_dependencies
-$(PRJ_DIR)/db_config.h \
-	$(PRJ_DIR)/db_int.h \
-	$(PRJ_DIR)/db.h
-<END>
-
-<BEGIN> FILE_$(PRJ_DIR)/../lock/lock_deadlock.c_objects
-lock_deadlock.o
-<END>
-
-<BEGIN> FILE_$(PRJ_DIR)/../lock/lock_deadlock.c_tool
-C/C++ compiler
-<END>
-
-<BEGIN> FILE_$(PRJ_DIR)/../lock/lock_method.c_dependDone
-TRUE
-<END>
-
-<BEGIN> FILE_$(PRJ_DIR)/../lock/lock_method.c_dependencies
-$(PRJ_DIR)/db_config.h \
-	$(PRJ_DIR)/db_int.h \
-	$(PRJ_DIR)/db.h
-<END>
-
-<BEGIN> FILE_$(PRJ_DIR)/../lock/lock_method.c_objects
-lock_method.o
-<END>
-
-<BEGIN> FILE_$(PRJ_DIR)/../lock/lock_method.c_tool
-C/C++ compiler
-<END>
-
-<BEGIN> FILE_$(PRJ_DIR)/../lock/lock_region.c_dependDone
-TRUE
-<END>
-
-<BEGIN> FILE_$(PRJ_DIR)/../lock/lock_region.c_dependencies
-$(PRJ_DIR)/db_config.h \
-	$(PRJ_DIR)/db_int.h \
-	$(PRJ_DIR)/db.h
-<END>
-
-<BEGIN> FILE_$(PRJ_DIR)/../lock/lock_region.c_objects
-lock_region.o
-<END>
-
-<BEGIN> FILE_$(PRJ_DIR)/../lock/lock_region.c_tool
-C/C++ compiler
-<END>
-
-<BEGIN> FILE_$(PRJ_DIR)/../lock/lock_stat.c_dependDone
-TRUE
-<END>
-
-<BEGIN> FILE_$(PRJ_DIR)/../lock/lock_stat.c_dependencies
-$(PRJ_DIR)/db_config.h \
-	$(PRJ_DIR)/db_int.h \
-	$(PRJ_DIR)/db.h
-<END>
-
-<BEGIN> FILE_$(PRJ_DIR)/../lock/lock_stat.c_objects
-lock_stat.o
-<END>
-
-<BEGIN> FILE_$(PRJ_DIR)/../lock/lock_stat.c_tool
-C/C++ compiler
-<END>
-
-<BEGIN> FILE_$(PRJ_DIR)/../lock/lock_util.c_dependDone
-TRUE
-<END>
-
-<BEGIN> FILE_$(PRJ_DIR)/../lock/lock_util.c_dependencies
-$(PRJ_DIR)/db_config.h \
-	$(PRJ_DIR)/db_int.h \
-	$(PRJ_DIR)/db.h
-<END>
-
-<BEGIN> FILE_$(PRJ_DIR)/../lock/lock_util.c_objects
-lock_util.o
-<END>
-
-<BEGIN> FILE_$(PRJ_DIR)/../lock/lock_util.c_tool
-C/C++ compiler
-<END>
-
-<BEGIN> FILE_$(PRJ_DIR)/../log/log.c_dependDone
-TRUE
-<END>
-
-<BEGIN> FILE_$(PRJ_DIR)/../log/log.c_dependencies
-$(PRJ_DIR)/db_config.h \
-	$(PRJ_DIR)/db_int.h \
-	$(PRJ_DIR)/db.h
-<END>
-
-<BEGIN> FILE_$(PRJ_DIR)/../log/log.c_objects
-log.o
-<END>
-
-<BEGIN> FILE_$(PRJ_DIR)/../log/log.c_tool
-C/C++ compiler
-<END>
-
-<BEGIN> FILE_$(PRJ_DIR)/../log/log_archive.c_dependDone
-TRUE
-<END>
-
-<BEGIN> FILE_$(PRJ_DIR)/../log/log_archive.c_dependencies
-$(PRJ_DIR)/db_config.h \
-	$(PRJ_DIR)/db_int.h \
-	$(PRJ_DIR)/db.h
-<END>
-
-<BEGIN> FILE_$(PRJ_DIR)/../log/log_archive.c_objects
-log_archive.o
-<END>
-
-<BEGIN> FILE_$(PRJ_DIR)/../log/log_archive.c_tool
-C/C++ compiler
-<END>
-
-<BEGIN> FILE_$(PRJ_DIR)/../log/log_compare.c_dependDone
-TRUE
-<END>
-
-<BEGIN> FILE_$(PRJ_DIR)/../log/log_compare.c_dependencies
-$(PRJ_DIR)/db_config.h \
-	$(PRJ_DIR)/db_int.h \
-	$(PRJ_DIR)/db.h
-<END>
-
-<BEGIN> FILE_$(PRJ_DIR)/../log/log_compare.c_objects
-log_compare.o
-<END>
-
-<BEGIN> FILE_$(PRJ_DIR)/../log/log_compare.c_tool
-C/C++ compiler
-<END>
-
-<BEGIN> FILE_$(PRJ_DIR)/../log/log_get.c_dependDone
-TRUE
-<END>
-
-<BEGIN> FILE_$(PRJ_DIR)/../log/log_get.c_dependencies
-$(PRJ_DIR)/db_config.h \
-	$(PRJ_DIR)/db_int.h \
-	$(PRJ_DIR)/db.h
-<END>
-
-<BEGIN> FILE_$(PRJ_DIR)/../log/log_get.c_objects
-log_get.o
-<END>
-
-<BEGIN> FILE_$(PRJ_DIR)/../log/log_get.c_tool
-C/C++ compiler
-<END>
-
-<BEGIN> FILE_$(PRJ_DIR)/../log/log_method.c_dependDone
-TRUE
-<END>
-
-<BEGIN> FILE_$(PRJ_DIR)/../log/log_method.c_dependencies
-$(PRJ_DIR)/db_config.h \
-	$(PRJ_DIR)/db_int.h \
-	$(PRJ_DIR)/db.h
-<END>
-
-<BEGIN> FILE_$(PRJ_DIR)/../log/log_method.c_objects
-log_method.o
-<END>
-
-<BEGIN> FILE_$(PRJ_DIR)/../log/log_method.c_tool
-C/C++ compiler
-<END>
-
-<BEGIN> FILE_$(PRJ_DIR)/../log/log_put.c_dependDone
-TRUE
-<END>
-
-<BEGIN> FILE_$(PRJ_DIR)/../log/log_put.c_dependencies
-$(PRJ_DIR)/db_config.h \
-	$(PRJ_DIR)/db_int.h \
-	$(PRJ_DIR)/db.h
-<END>
-
-<BEGIN> FILE_$(PRJ_DIR)/../log/log_put.c_objects
-log_put.o
-<END>
-
-<BEGIN> FILE_$(PRJ_DIR)/../log/log_put.c_tool
-C/C++ compiler
-<END>
-
-<BEGIN> FILE_$(PRJ_DIR)/../mp/mp_alloc.c_dependDone
-TRUE
-<END>
-
-<BEGIN> FILE_$(PRJ_DIR)/../mp/mp_alloc.c_dependencies
-$(PRJ_DIR)/db_config.h \
-	$(PRJ_DIR)/db_int.h \
-	$(PRJ_DIR)/db.h
-<END>
-
-<BEGIN> FILE_$(PRJ_DIR)/../mp/mp_alloc.c_objects
-mp_alloc.o
-<END>
-
-<BEGIN> FILE_$(PRJ_DIR)/../mp/mp_alloc.c_tool
-C/C++ compiler
-<END>
-
-<BEGIN> FILE_$(PRJ_DIR)/../mp/mp_bh.c_dependDone
-TRUE
-<END>
-
-<BEGIN> FILE_$(PRJ_DIR)/../mp/mp_bh.c_dependencies
-$(PRJ_DIR)/db_config.h \
-	$(PRJ_DIR)/db_int.h \
-	$(PRJ_DIR)/db.h
-<END>
-
-<BEGIN> FILE_$(PRJ_DIR)/../mp/mp_bh.c_objects
-mp_bh.o
-<END>
-
-<BEGIN> FILE_$(PRJ_DIR)/../mp/mp_bh.c_tool
-C/C++ compiler
-<END>
-
-<BEGIN> FILE_$(PRJ_DIR)/../mp/mp_fget.c_dependDone
-TRUE
-<END>
-
-<BEGIN> FILE_$(PRJ_DIR)/../mp/mp_fget.c_dependencies
-$(PRJ_DIR)/db_config.h \
-	$(PRJ_DIR)/db_int.h \
-	$(PRJ_DIR)/db.h
-<END>
-
-<BEGIN> FILE_$(PRJ_DIR)/../mp/mp_fget.c_objects
-mp_fget.o
-<END>
-
-<BEGIN> FILE_$(PRJ_DIR)/../mp/mp_fget.c_tool
-C/C++ compiler
-<END>
-
-<BEGIN> FILE_$(PRJ_DIR)/../mp/mp_fopen.c_dependDone
-TRUE
-<END>
-
-<BEGIN> FILE_$(PRJ_DIR)/../mp/mp_fopen.c_dependencies
-$(PRJ_DIR)/db_config.h \
-	$(PRJ_DIR)/db_int.h \
-	$(PRJ_DIR)/db.h
-<END>
-
-<BEGIN> FILE_$(PRJ_DIR)/../mp/mp_fopen.c_objects
-mp_fopen.o
-<END>
-
-<BEGIN> FILE_$(PRJ_DIR)/../mp/mp_fopen.c_tool
-C/C++ compiler
-<END>
-
-<BEGIN> FILE_$(PRJ_DIR)/../mp/mp_fput.c_dependDone
-TRUE
-<END>
-
-<BEGIN> FILE_$(PRJ_DIR)/../mp/mp_fput.c_dependencies
-$(PRJ_DIR)/db_config.h \
-	$(PRJ_DIR)/db_int.h \
-	$(PRJ_DIR)/db.h
-<END>
-
-<BEGIN> FILE_$(PRJ_DIR)/../mp/mp_fput.c_objects
-mp_fput.o
-<END>
-
-<BEGIN> FILE_$(PRJ_DIR)/../mp/mp_fput.c_tool
-C/C++ compiler
-<END>
-
-<BEGIN> FILE_$(PRJ_DIR)/../mp/mp_fset.c_dependDone
-TRUE
-<END>
-
-<BEGIN> FILE_$(PRJ_DIR)/../mp/mp_fset.c_dependencies
-$(PRJ_DIR)/db_config.h \
-	$(PRJ_DIR)/db_int.h \
-	$(PRJ_DIR)/db.h
-<END>
-
-<BEGIN> FILE_$(PRJ_DIR)/../mp/mp_fset.c_objects
-mp_fset.o
-<END>
-
-<BEGIN> FILE_$(PRJ_DIR)/../mp/mp_fset.c_tool
-C/C++ compiler
-<END>
-
-<BEGIN> FILE_$(PRJ_DIR)/../mp/mp_method.c_dependDone
-TRUE
-<END>
-
-<BEGIN> FILE_$(PRJ_DIR)/../mp/mp_method.c_dependencies
-$(PRJ_DIR)/db_config.h \
-	$(PRJ_DIR)/db_int.h \
-	$(PRJ_DIR)/db.h
-<END>
-
-<BEGIN> FILE_$(PRJ_DIR)/../mp/mp_method.c_objects
-mp_method.o
-<END>
-
-<BEGIN> FILE_$(PRJ_DIR)/../mp/mp_method.c_tool
-C/C++ compiler
-<END>
-
-<BEGIN> FILE_$(PRJ_DIR)/../mp/mp_region.c_dependDone
-TRUE
-<END>
-
-<BEGIN> FILE_$(PRJ_DIR)/../mp/mp_region.c_dependencies
-$(PRJ_DIR)/db_config.h \
-	$(PRJ_DIR)/db_int.h \
-	$(PRJ_DIR)/db.h
-<END>
-
-<BEGIN> FILE_$(PRJ_DIR)/../mp/mp_region.c_objects
-mp_region.o
-<END>
-
-<BEGIN> FILE_$(PRJ_DIR)/../mp/mp_region.c_tool
-C/C++ compiler
-<END>
-
-<BEGIN> FILE_$(PRJ_DIR)/../mp/mp_register.c_dependDone
-TRUE
-<END>
-
-<BEGIN> FILE_$(PRJ_DIR)/../mp/mp_register.c_dependencies
-$(PRJ_DIR)/db_config.h \
-	$(PRJ_DIR)/db_int.h \
-	$(PRJ_DIR)/db.h
-<END>
-
-<BEGIN> FILE_$(PRJ_DIR)/../mp/mp_register.c_objects
-mp_register.o
-<END>
-
-<BEGIN> FILE_$(PRJ_DIR)/../mp/mp_register.c_tool
-C/C++ compiler
-<END>
-
-<BEGIN> FILE_$(PRJ_DIR)/../mp/mp_stat.c_dependDone
-TRUE
-<END>
-
-<BEGIN> FILE_$(PRJ_DIR)/../mp/mp_stat.c_dependencies
-$(PRJ_DIR)/db_config.h \
-	$(PRJ_DIR)/db_int.h \
-	$(PRJ_DIR)/db.h
-<END>
-
-<BEGIN> FILE_$(PRJ_DIR)/../mp/mp_stat.c_objects
-mp_stat.o
-<END>
-
-<BEGIN> FILE_$(PRJ_DIR)/../mp/mp_stat.c_tool
-C/C++ compiler
-<END>
-
-<BEGIN> FILE_$(PRJ_DIR)/../mp/mp_sync.c_dependDone
-TRUE
-<END>
-
-<BEGIN> FILE_$(PRJ_DIR)/../mp/mp_sync.c_dependencies
-$(PRJ_DIR)/db_config.h \
-	$(PRJ_DIR)/db_int.h \
-	$(PRJ_DIR)/db.h
-<END>
-
-<BEGIN> FILE_$(PRJ_DIR)/../mp/mp_sync.c_objects
-mp_sync.o
-<END>
-
-<BEGIN> FILE_$(PRJ_DIR)/../mp/mp_sync.c_tool
-C/C++ compiler
-<END>
-
-<BEGIN> FILE_$(PRJ_DIR)/../mp/mp_trickle.c_dependDone
-TRUE
-<END>
-
-<BEGIN> FILE_$(PRJ_DIR)/../mp/mp_trickle.c_dependencies
-$(PRJ_DIR)/db_config.h \
-	$(PRJ_DIR)/db_int.h \
-	$(PRJ_DIR)/db.h
-<END>
-
-<BEGIN> FILE_$(PRJ_DIR)/../mp/mp_trickle.c_objects
-mp_trickle.o
-<END>
-
-<BEGIN> FILE_$(PRJ_DIR)/../mp/mp_trickle.c_tool
-C/C++ compiler
-<END>
-
-<BEGIN> FILE_$(PRJ_DIR)/../mutex/mut_tas.c_dependDone
-TRUE
-<END>
-
-<BEGIN> FILE_$(PRJ_DIR)/../mutex/mut_tas.c_dependencies
-$(PRJ_DIR)/db_config.h \
-	$(PRJ_DIR)/db_int.h \
-	$(PRJ_DIR)/db.h
-<END>
-
-<BEGIN> FILE_$(PRJ_DIR)/../mutex/mut_tas.c_objects
-mut_tas.o
-<END>
-
-<BEGIN> FILE_$(PRJ_DIR)/../mutex/mut_tas.c_tool
-C/C++ compiler
-<END>
-
-<BEGIN> FILE_$(PRJ_DIR)/../mutex/mutex.c_dependDone
-TRUE
-<END>
-
-<BEGIN> FILE_$(PRJ_DIR)/../mutex/mutex.c_dependencies
-$(PRJ_DIR)/db_config.h \
-	$(PRJ_DIR)/db_int.h \
-	$(PRJ_DIR)/db.h
-<END>
-
-<BEGIN> FILE_$(PRJ_DIR)/../mutex/mutex.c_objects
-mutex.o
-<END>
-
-<BEGIN> FILE_$(PRJ_DIR)/../mutex/mutex.c_tool
-C/C++ compiler
-<END>
-
-<BEGIN> FILE_$(PRJ_DIR)/../os/os_alloc.c_dependDone
-TRUE
-<END>
-
-<BEGIN> FILE_$(PRJ_DIR)/../os/os_alloc.c_dependencies
-$(PRJ_DIR)/db_config.h \
-	$(PRJ_DIR)/db_int.h \
-	$(PRJ_DIR)/db.h
-<END>
-
-<BEGIN> FILE_$(PRJ_DIR)/../os/os_alloc.c_objects
-os_alloc.o
-<END>
-
-<BEGIN> FILE_$(PRJ_DIR)/../os/os_alloc.c_tool
-C/C++ compiler
-<END>
-
-<BEGIN> FILE_$(PRJ_DIR)/../os/os_clock.c_dependDone
-TRUE
-<END>
-
-<BEGIN> FILE_$(PRJ_DIR)/../os/os_clock.c_dependencies
-$(PRJ_DIR)/db_config.h \
-	$(PRJ_DIR)/db_int.h \
-	$(PRJ_DIR)/db.h
-<END>
-
-<BEGIN> FILE_$(PRJ_DIR)/../os/os_clock.c_objects
-os_clock.o
-<END>
-
-<BEGIN> FILE_$(PRJ_DIR)/../os/os_clock.c_tool
-C/C++ compiler
-<END>
-
-<BEGIN> FILE_$(PRJ_DIR)/../os/os_dir.c_dependDone
-TRUE
-<END>
-
-<BEGIN> FILE_$(PRJ_DIR)/../os/os_dir.c_dependencies
-$(PRJ_DIR)/db_config.h \
-	$(PRJ_DIR)/db_int.h \
-	$(PRJ_DIR)/db.h
-<END>
-
-<BEGIN> FILE_$(PRJ_DIR)/../os/os_dir.c_objects
-os_dir.o
-<END>
-
-<BEGIN> FILE_$(PRJ_DIR)/../os/os_dir.c_tool
-C/C++ compiler
-<END>
-
-<BEGIN> FILE_$(PRJ_DIR)/../os/os_errno.c_dependDone
-TRUE
-<END>
-
-<BEGIN> FILE_$(PRJ_DIR)/../os/os_errno.c_dependencies
-$(PRJ_DIR)/db_config.h \
-	$(PRJ_DIR)/db_int.h \
-	$(PRJ_DIR)/db.h
-<END>
-
-<BEGIN> FILE_$(PRJ_DIR)/../os/os_errno.c_objects
-os_errno.o
-<END>
-
-<BEGIN> FILE_$(PRJ_DIR)/../os/os_errno.c_tool
-C/C++ compiler
-<END>
-
-<BEGIN> FILE_$(PRJ_DIR)/../os/os_fid.c_dependDone
-TRUE
-<END>
-
-<BEGIN> FILE_$(PRJ_DIR)/../os/os_fid.c_dependencies
-$(PRJ_DIR)/db_config.h \
-	$(PRJ_DIR)/db_int.h \
-	$(PRJ_DIR)/db.h
-<END>
-
-<BEGIN> FILE_$(PRJ_DIR)/../os/os_fid.c_objects
-os_fid.o
-<END>
-
-<BEGIN> FILE_$(PRJ_DIR)/../os/os_fid.c_tool
-C/C++ compiler
-<END>
-
-<BEGIN> FILE_$(PRJ_DIR)/../os/os_fsync.c_dependDone
-TRUE
-<END>
-
-<BEGIN> FILE_$(PRJ_DIR)/../os/os_fsync.c_dependencies
-$(PRJ_DIR)/db_config.h \
-	$(PRJ_DIR)/db_int.h \
-	$(PRJ_DIR)/db.h
-<END>
-
-<BEGIN> FILE_$(PRJ_DIR)/../os/os_fsync.c_objects
-os_fsync.o
-<END>
-
-<BEGIN> FILE_$(PRJ_DIR)/../os/os_fsync.c_tool
-C/C++ compiler
-<END>
-
-<BEGIN> FILE_$(PRJ_DIR)/../os/os_handle.c_dependDone
-TRUE
-<END>
-
-<BEGIN> FILE_$(PRJ_DIR)/../os/os_handle.c_dependencies
-$(PRJ_DIR)/db_config.h \
-	$(PRJ_DIR)/db_int.h \
-	$(PRJ_DIR)/db.h
-<END>
-
-<BEGIN> FILE_$(PRJ_DIR)/../os/os_handle.c_objects
-os_handle.o
-<END>
-
-<BEGIN> FILE_$(PRJ_DIR)/../os/os_handle.c_tool
-C/C++ compiler
-<END>
-
-<BEGIN> FILE_$(PRJ_DIR)/../os/os_id.c_dependDone
-TRUE
-<END>
-
-<BEGIN> FILE_$(PRJ_DIR)/../os/os_id.c_dependencies
-$(PRJ_DIR)/db_config.h \
-	$(PRJ_DIR)/db_int.h \
-	$(PRJ_DIR)/db.h
-<END>
-
-<BEGIN> FILE_$(PRJ_DIR)/../os/os_id.c_objects
-os_id.o
-<END>
-
-<BEGIN> FILE_$(PRJ_DIR)/../os/os_id.c_tool
-C/C++ compiler
-<END>
-
-<BEGIN> FILE_$(PRJ_DIR)/../os/os_method.c_dependDone
-TRUE
-<END>
-
-<BEGIN> FILE_$(PRJ_DIR)/../os/os_method.c_dependencies
-$(PRJ_DIR)/db_config.h \
-	$(PRJ_DIR)/db_int.h \
-	$(PRJ_DIR)/db.h
-<END>
-
-<BEGIN> FILE_$(PRJ_DIR)/../os/os_method.c_objects
-os_method.o
-<END>
-
-<BEGIN> FILE_$(PRJ_DIR)/../os/os_method.c_tool
-C/C++ compiler
-<END>
-
-<BEGIN> FILE_$(PRJ_DIR)/../os/os_oflags.c_dependDone
-TRUE
-<END>
-
-<BEGIN> FILE_$(PRJ_DIR)/../os/os_oflags.c_dependencies
-$(PRJ_DIR)/db_config.h \
-	$(PRJ_DIR)/db_int.h \
-	$(PRJ_DIR)/db.h
-<END>
-
-<BEGIN> FILE_$(PRJ_DIR)/../os/os_oflags.c_objects
-os_oflags.o
-<END>
-
-<BEGIN> FILE_$(PRJ_DIR)/../os/os_oflags.c_tool
-C/C++ compiler
-<END>
-
-<BEGIN> FILE_$(PRJ_DIR)/../os/os_open.c_dependDone
-TRUE
-<END>
-
-<BEGIN> FILE_$(PRJ_DIR)/../os/os_open.c_dependencies
-$(PRJ_DIR)/db_config.h \
-	$(PRJ_DIR)/db_int.h \
-	$(PRJ_DIR)/db.h
-<END>
-
-<BEGIN> FILE_$(PRJ_DIR)/../os/os_open.c_objects
-os_open.o
-<END>
-
-<BEGIN> FILE_$(PRJ_DIR)/../os/os_open.c_tool
-C/C++ compiler
-<END>
-
-<BEGIN> FILE_$(PRJ_DIR)/../os/os_region.c_dependDone
-TRUE
-<END>
-
-<BEGIN> FILE_$(PRJ_DIR)/../os/os_region.c_dependencies
-$(PRJ_DIR)/db_config.h \
-	$(PRJ_DIR)/db_int.h \
-	$(PRJ_DIR)/db.h
-<END>
-
-<BEGIN> FILE_$(PRJ_DIR)/../os/os_region.c_objects
-os_region.o
-<END>
-
-<BEGIN> FILE_$(PRJ_DIR)/../os/os_region.c_tool
-C/C++ compiler
-<END>
-
-<BEGIN> FILE_$(PRJ_DIR)/../os/os_rename.c_dependDone
-TRUE
-<END>
-
-<BEGIN> FILE_$(PRJ_DIR)/../os/os_rename.c_dependencies
-$(PRJ_DIR)/db_config.h \
-	$(PRJ_DIR)/db_int.h \
-	$(PRJ_DIR)/db.h
-<END>
-
-<BEGIN> FILE_$(PRJ_DIR)/../os/os_rename.c_objects
-os_rename.o
-<END>
-
-<BEGIN> FILE_$(PRJ_DIR)/../os/os_rename.c_tool
-C/C++ compiler
-<END>
-
-<BEGIN> FILE_$(PRJ_DIR)/../os/os_root.c_dependDone
-TRUE
-<END>
-
-<BEGIN> FILE_$(PRJ_DIR)/../os/os_root.c_dependencies
-$(PRJ_DIR)/db_config.h \
-	$(PRJ_DIR)/db_int.h \
-	$(PRJ_DIR)/db.h
-<END>
-
-<BEGIN> FILE_$(PRJ_DIR)/../os/os_root.c_objects
-os_root.o
-<END>
-
-<BEGIN> FILE_$(PRJ_DIR)/../os/os_root.c_tool
-C/C++ compiler
-<END>
-
-<BEGIN> FILE_$(PRJ_DIR)/../os/os_rpath.c_dependDone
-TRUE
-<END>
-
-<BEGIN> FILE_$(PRJ_DIR)/../os/os_rpath.c_dependencies
-$(PRJ_DIR)/db_config.h \
-	$(PRJ_DIR)/db_int.h \
-	$(PRJ_DIR)/db.h
-<END>
-
-<BEGIN> FILE_$(PRJ_DIR)/../os/os_rpath.c_objects
-os_rpath.o
-<END>
-
-<BEGIN> FILE_$(PRJ_DIR)/../os/os_rpath.c_tool
-C/C++ compiler
-<END>
-
-<BEGIN> FILE_$(PRJ_DIR)/../os/os_rw.c_dependDone
-TRUE
-<END>
-
-<BEGIN> FILE_$(PRJ_DIR)/../os/os_rw.c_dependencies
-$(PRJ_DIR)/db_config.h \
-	$(PRJ_DIR)/db_int.h \
-	$(PRJ_DIR)/db.h
-<END>
-
-<BEGIN> FILE_$(PRJ_DIR)/../os/os_rw.c_objects
-os_rw.o
-<END>
-
-<BEGIN> FILE_$(PRJ_DIR)/../os/os_rw.c_tool
-C/C++ compiler
-<END>
-
-<BEGIN> FILE_$(PRJ_DIR)/../os/os_seek.c_dependDone
-TRUE
-<END>
-
-<BEGIN> FILE_$(PRJ_DIR)/../os/os_seek.c_dependencies
-$(PRJ_DIR)/db_config.h \
-	$(PRJ_DIR)/db_int.h \
-	$(PRJ_DIR)/db.h
-<END>
-
-<BEGIN> FILE_$(PRJ_DIR)/../os/os_seek.c_objects
-os_seek.o
-<END>
-
-<BEGIN> FILE_$(PRJ_DIR)/../os/os_seek.c_tool
-C/C++ compiler
-<END>
-
-<BEGIN> FILE_$(PRJ_DIR)/../os/os_sleep.c_dependDone
-TRUE
-<END>
-
-<BEGIN> FILE_$(PRJ_DIR)/../os/os_sleep.c_dependencies
-$(PRJ_DIR)/db_config.h \
-	$(PRJ_DIR)/db_int.h \
-	$(PRJ_DIR)/db.h
-<END>
-
-<BEGIN> FILE_$(PRJ_DIR)/../os/os_sleep.c_objects
-os_sleep.o
-<END>
-
-<BEGIN> FILE_$(PRJ_DIR)/../os/os_sleep.c_tool
-C/C++ compiler
-<END>
-
-<BEGIN> FILE_$(PRJ_DIR)/../os/os_spin.c_dependDone
-TRUE
-<END>
-
-<BEGIN> FILE_$(PRJ_DIR)/../os/os_spin.c_dependencies
-$(PRJ_DIR)/db_config.h \
-	$(PRJ_DIR)/db_int.h \
-	$(PRJ_DIR)/db.h
-<END>
-
-<BEGIN> FILE_$(PRJ_DIR)/../os/os_spin.c_objects
-os_spin.o
-<END>
-
-<BEGIN> FILE_$(PRJ_DIR)/../os/os_spin.c_tool
-C/C++ compiler
-<END>
-
-<BEGIN> FILE_$(PRJ_DIR)/../os/os_stat.c_dependDone
-TRUE
-<END>
-
-<BEGIN> FILE_$(PRJ_DIR)/../os/os_stat.c_dependencies
-$(PRJ_DIR)/db_config.h \
-	$(PRJ_DIR)/db_int.h \
-	$(PRJ_DIR)/db.h
-<END>
-
-<BEGIN> FILE_$(PRJ_DIR)/../os/os_stat.c_objects
-os_stat.o
-<END>
-
-<BEGIN> FILE_$(PRJ_DIR)/../os/os_stat.c_tool
-C/C++ compiler
-<END>
-
-<BEGIN> FILE_$(PRJ_DIR)/../os/os_tmpdir.c_dependDone
-TRUE
-<END>
-
-<BEGIN> FILE_$(PRJ_DIR)/../os/os_tmpdir.c_dependencies
-$(PRJ_DIR)/db_config.h \
-	$(PRJ_DIR)/db_int.h \
-	$(PRJ_DIR)/db.h
-<END>
-
-<BEGIN> FILE_$(PRJ_DIR)/../os/os_tmpdir.c_objects
-os_tmpdir.o
-<END>
-
-<BEGIN> FILE_$(PRJ_DIR)/../os/os_tmpdir.c_tool
-C/C++ compiler
-<END>
-
-<BEGIN> FILE_$(PRJ_DIR)/../os/os_unlink.c_dependDone
-TRUE
-<END>
-
-<BEGIN> FILE_$(PRJ_DIR)/../os/os_unlink.c_dependencies
-$(PRJ_DIR)/db_config.h \
-	$(PRJ_DIR)/db_int.h \
-	$(PRJ_DIR)/db.h
-<END>
-
-<BEGIN> FILE_$(PRJ_DIR)/../os/os_unlink.c_objects
-os_unlink.o
-<END>
-
-<BEGIN> FILE_$(PRJ_DIR)/../os/os_unlink.c_tool
-C/C++ compiler
-<END>
-
-<BEGIN> FILE_$(PRJ_DIR)/../os_vxworks/os_vx_abs.c_dependDone
-TRUE
-<END>
-
-<BEGIN> FILE_$(PRJ_DIR)/../os_vxworks/os_vx_abs.c_dependencies
-$(PRJ_DIR)/db_config.h \
-	$(PRJ_DIR)/db_int.h \
-	$(PRJ_DIR)/db.h
-<END>
-
-<BEGIN> FILE_$(PRJ_DIR)/../os_vxworks/os_vx_abs.c_objects
-os_vx_abs.o
-<END>
-
-<BEGIN> FILE_$(PRJ_DIR)/../os_vxworks/os_vx_abs.c_tool
-C/C++ compiler
-<END>
-
-<BEGIN> FILE_$(PRJ_DIR)/../os_vxworks/os_vx_config.c_dependDone
-TRUE
-<END>
-
-<BEGIN> FILE_$(PRJ_DIR)/../os_vxworks/os_vx_config.c_dependencies
-$(PRJ_DIR)/db_config.h \
-	$(PRJ_DIR)/db_int.h \
-	$(PRJ_DIR)/db.h
-<END>
-
-<BEGIN> FILE_$(PRJ_DIR)/../os_vxworks/os_vx_config.c_objects
-os_vx_config.o
-<END>
-
-<BEGIN> FILE_$(PRJ_DIR)/../os_vxworks/os_vx_config.c_tool
-C/C++ compiler
-<END>
-
-<BEGIN> FILE_$(PRJ_DIR)/../os_vxworks/os_vx_map.c_dependDone
-TRUE
-<END>
-
-<BEGIN> FILE_$(PRJ_DIR)/../os_vxworks/os_vx_map.c_dependencies
-$(PRJ_DIR)/db_config.h \
-	$(PRJ_DIR)/db_int.h \
-	$(PRJ_DIR)/db.h
-<END>
-
-<BEGIN> FILE_$(PRJ_DIR)/../os_vxworks/os_vx_map.c_objects
-os_vx_map.o
-<END>
-
-<BEGIN> FILE_$(PRJ_DIR)/../os_vxworks/os_vx_map.c_tool
-C/C++ compiler
-<END>
-
-<BEGIN> FILE_$(PRJ_DIR)/../qam/qam.c_dependDone
-TRUE
-<END>
-
-<BEGIN> FILE_$(PRJ_DIR)/../qam/qam.c_dependencies
-$(PRJ_DIR)/db_config.h \
-	$(PRJ_DIR)/db_int.h \
-	$(PRJ_DIR)/db.h
-<END>
-
-<BEGIN> FILE_$(PRJ_DIR)/../qam/qam.c_objects
-qam.o
-<END>
-
-<BEGIN> FILE_$(PRJ_DIR)/../qam/qam.c_tool
-C/C++ compiler
-<END>
-
-<BEGIN> FILE_$(PRJ_DIR)/../qam/qam_auto.c_dependDone
-TRUE
-<END>
-
-<BEGIN> FILE_$(PRJ_DIR)/../qam/qam_auto.c_dependencies
-$(PRJ_DIR)/db_config.h \
-	$(PRJ_DIR)/db_int.h \
-	$(PRJ_DIR)/db.h
-<END>
-
-<BEGIN> FILE_$(PRJ_DIR)/../qam/qam_auto.c_objects
-qam_auto.o
-<END>
-
-<BEGIN> FILE_$(PRJ_DIR)/../qam/qam_auto.c_tool
-C/C++ compiler
-<END>
-
-<BEGIN> FILE_$(PRJ_DIR)/../qam/qam_conv.c_dependDone
-TRUE
-<END>
-
-<BEGIN> FILE_$(PRJ_DIR)/../qam/qam_conv.c_dependencies
-$(PRJ_DIR)/db_config.h \
-	$(PRJ_DIR)/db_int.h \
-	$(PRJ_DIR)/db.h
-<END>
-
-<BEGIN> FILE_$(PRJ_DIR)/../qam/qam_conv.c_objects
-qam_conv.o
-<END>
-
-<BEGIN> FILE_$(PRJ_DIR)/../qam/qam_conv.c_tool
-C/C++ compiler
-<END>
-
-<BEGIN> FILE_$(PRJ_DIR)/../qam/qam_files.c_dependDone
-TRUE
-<END>
-
-<BEGIN> FILE_$(PRJ_DIR)/../qam/qam_files.c_dependencies
-$(PRJ_DIR)/db_config.h \
-	$(PRJ_DIR)/db_int.h \
-	$(PRJ_DIR)/db.h
-<END>
-
-<BEGIN> FILE_$(PRJ_DIR)/../qam/qam_files.c_objects
-qam_files.o
-<END>
-
-<BEGIN> FILE_$(PRJ_DIR)/../qam/qam_files.c_tool
-C/C++ compiler
-<END>
-
-<BEGIN> FILE_$(PRJ_DIR)/../qam/qam_method.c_dependDone
-TRUE
-<END>
-
-<BEGIN> FILE_$(PRJ_DIR)/../qam/qam_method.c_dependencies
-$(PRJ_DIR)/db_config.h \
-	$(PRJ_DIR)/db_int.h \
-	$(PRJ_DIR)/db.h
-<END>
-
-<BEGIN> FILE_$(PRJ_DIR)/../qam/qam_method.c_objects
-qam_method.o
-<END>
-
-<BEGIN> FILE_$(PRJ_DIR)/../qam/qam_method.c_tool
-C/C++ compiler
-<END>
-
-<BEGIN> FILE_$(PRJ_DIR)/../qam/qam_open.c_dependDone
-TRUE
-<END>
-
-<BEGIN> FILE_$(PRJ_DIR)/../qam/qam_open.c_dependencies
-$(PRJ_DIR)/db_config.h \
-	$(PRJ_DIR)/db_int.h \
-	$(PRJ_DIR)/db.h
-<END>
-
-<BEGIN> FILE_$(PRJ_DIR)/../qam/qam_open.c_objects
-qam_open.o
-<END>
-
-<BEGIN> FILE_$(PRJ_DIR)/../qam/qam_open.c_tool
-C/C++ compiler
-<END>
-
-<BEGIN> FILE_$(PRJ_DIR)/../qam/qam_rec.c_dependDone
-TRUE
-<END>
-
-<BEGIN> FILE_$(PRJ_DIR)/../qam/qam_rec.c_dependencies
-$(PRJ_DIR)/db_config.h \
-	$(PRJ_DIR)/db_int.h \
-	$(PRJ_DIR)/db.h
-<END>
-
-<BEGIN> FILE_$(PRJ_DIR)/../qam/qam_rec.c_objects
-qam_rec.o
-<END>
-
-<BEGIN> FILE_$(PRJ_DIR)/../qam/qam_rec.c_tool
-C/C++ compiler
-<END>
-
-<BEGIN> FILE_$(PRJ_DIR)/../qam/qam_stat.c_dependDone
-TRUE
-<END>
-
-<BEGIN> FILE_$(PRJ_DIR)/../qam/qam_stat.c_dependencies
-$(PRJ_DIR)/db_config.h \
-	$(PRJ_DIR)/db_int.h \
-	$(PRJ_DIR)/db.h
-<END>
-
-<BEGIN> FILE_$(PRJ_DIR)/../qam/qam_stat.c_objects
-qam_stat.o
-<END>
-
-<BEGIN> FILE_$(PRJ_DIR)/../qam/qam_stat.c_tool
-C/C++ compiler
-<END>
-
-<BEGIN> FILE_$(PRJ_DIR)/../qam/qam_upgrade.c_dependDone
-TRUE
-<END>
-
-<BEGIN> FILE_$(PRJ_DIR)/../qam/qam_upgrade.c_dependencies
-$(PRJ_DIR)/db_config.h \
-	$(PRJ_DIR)/db_int.h \
-	$(PRJ_DIR)/db.h
-<END>
-
-<BEGIN> FILE_$(PRJ_DIR)/../qam/qam_upgrade.c_objects
-qam_upgrade.o
-<END>
-
-<BEGIN> FILE_$(PRJ_DIR)/../qam/qam_upgrade.c_tool
-C/C++ compiler
-<END>
-
-<BEGIN> FILE_$(PRJ_DIR)/../qam/qam_verify.c_dependDone
-TRUE
-<END>
-
-<BEGIN> FILE_$(PRJ_DIR)/../qam/qam_verify.c_dependencies
-$(PRJ_DIR)/db_config.h \
-	$(PRJ_DIR)/db_int.h \
-	$(PRJ_DIR)/db.h
-<END>
-
-<BEGIN> FILE_$(PRJ_DIR)/../qam/qam_verify.c_objects
-qam_verify.o
-<END>
-
-<BEGIN> FILE_$(PRJ_DIR)/../qam/qam_verify.c_tool
-C/C++ compiler
-<END>
-
-<BEGIN> FILE_$(PRJ_DIR)/../rep/rep_method.c_dependDone
-TRUE
-<END>
-
-<BEGIN> FILE_$(PRJ_DIR)/../rep/rep_method.c_dependencies
-$(PRJ_DIR)/db_config.h \
-	$(PRJ_DIR)/db_int.h \
-	$(PRJ_DIR)/db.h
-<END>
-
-<BEGIN> FILE_$(PRJ_DIR)/../rep/rep_method.c_objects
-rep_method.o
-<END>
-
-<BEGIN> FILE_$(PRJ_DIR)/../rep/rep_method.c_tool
-C/C++ compiler
-<END>
-
-<BEGIN> FILE_$(PRJ_DIR)/../rep/rep_record.c_dependDone
-TRUE
-<END>
-
-<BEGIN> FILE_$(PRJ_DIR)/../rep/rep_record.c_dependencies
-$(PRJ_DIR)/db_config.h \
-	$(PRJ_DIR)/db_int.h \
-	$(PRJ_DIR)/db.h
-<END>
-
-<BEGIN> FILE_$(PRJ_DIR)/../rep/rep_record.c_objects
-rep_record.o
-<END>
-
-<BEGIN> FILE_$(PRJ_DIR)/../rep/rep_record.c_tool
-C/C++ compiler
-<END>
-
-<BEGIN> FILE_$(PRJ_DIR)/../rep/rep_region.c_dependDone
-TRUE
-<END>
-
-<BEGIN> FILE_$(PRJ_DIR)/../rep/rep_region.c_dependencies
-$(PRJ_DIR)/db_config.h \
-	$(PRJ_DIR)/db_int.h \
-	$(PRJ_DIR)/db.h
-<END>
-
-<BEGIN> FILE_$(PRJ_DIR)/../rep/rep_region.c_objects
-rep_region.o
-<END>
-
-<BEGIN> FILE_$(PRJ_DIR)/../rep/rep_region.c_tool
-C/C++ compiler
-<END>
-
-<BEGIN> FILE_$(PRJ_DIR)/../rep/rep_util.c_dependDone
-TRUE
-<END>
-
-<BEGIN> FILE_$(PRJ_DIR)/../rep/rep_util.c_dependencies
-$(PRJ_DIR)/db_config.h \
-	$(PRJ_DIR)/db_int.h \
-	$(PRJ_DIR)/db.h
-<END>
-
-<BEGIN> FILE_$(PRJ_DIR)/../rep/rep_util.c_objects
-rep_util.o
-<END>
-
-<BEGIN> FILE_$(PRJ_DIR)/../rep/rep_util.c_tool
-C/C++ compiler
-<END>
-
-<BEGIN> FILE_$(PRJ_DIR)/../rpc_client/client.c_dependDone
-TRUE
-<END>
-
-<BEGIN> FILE_$(PRJ_DIR)/../rpc_client/client.c_dependencies
-$(PRJ_DIR)/db_config.h \
-	$(PRJ_DIR)/db_int.h \
-	$(PRJ_DIR)/db.h
-<END>
-
-<BEGIN> FILE_$(PRJ_DIR)/../rpc_client/client.c_objects
-client.o
-<END>
-
-<BEGIN> FILE_$(PRJ_DIR)/../rpc_client/client.c_tool
-C/C++ compiler
-<END>
-
-<BEGIN> FILE_$(PRJ_DIR)/../rpc_client/db_server_clnt.c_dependDone
-TRUE
-<END>
-
-<BEGIN> FILE_$(PRJ_DIR)/../rpc_client/db_server_clnt.c_dependencies
-$(PRJ_DIR)/db_config.h \
-	$(PRJ_DIR)/db_int.h \
-	$(PRJ_DIR)/db.h
-<END>
-
-<BEGIN> FILE_$(PRJ_DIR)/../rpc_client/db_server_clnt.c_objects
-db_server_clnt.o
-<END>
-
-<BEGIN> FILE_$(PRJ_DIR)/../rpc_client/db_server_clnt.c_tool
-C/C++ compiler
-<END>
-
-<BEGIN> FILE_$(PRJ_DIR)/../rpc_client/gen_client.c_dependDone
-TRUE
-<END>
-
-<BEGIN> FILE_$(PRJ_DIR)/../rpc_client/gen_client.c_dependencies
-$(PRJ_DIR)/db_config.h \
-	$(PRJ_DIR)/db_int.h \
-	$(PRJ_DIR)/db.h
-<END>
-
-<BEGIN> FILE_$(PRJ_DIR)/../rpc_client/gen_client.c_objects
-gen_client.o
-<END>
-
-<BEGIN> FILE_$(PRJ_DIR)/../rpc_client/gen_client.c_tool
-C/C++ compiler
-<END>
-
-<BEGIN> FILE_$(PRJ_DIR)/../rpc_client/gen_client_ret.c_dependDone
-TRUE
-<END>
-
-<BEGIN> FILE_$(PRJ_DIR)/../rpc_client/gen_client_ret.c_dependencies
-$(PRJ_DIR)/db_config.h \
-	$(PRJ_DIR)/db_int.h \
-	$(PRJ_DIR)/db.h
-<END>
-
-<BEGIN> FILE_$(PRJ_DIR)/../rpc_client/gen_client_ret.c_objects
-gen_client_ret.o
-<END>
-
-<BEGIN> FILE_$(PRJ_DIR)/../rpc_client/gen_client_ret.c_tool
-C/C++ compiler
-<END>
-
-<BEGIN> FILE_$(PRJ_DIR)/../rpc_server/c/db_server_xdr.c_dependDone
-TRUE
-<END>
-
-<BEGIN> FILE_$(PRJ_DIR)/../rpc_server/c/db_server_xdr.c_dependencies
-$(PRJ_DIR)/db_config.h \
-	$(PRJ_DIR)/db_int.h \
-	$(PRJ_DIR)/db.h
-<END>
-
-<BEGIN> FILE_$(PRJ_DIR)/../rpc_server/c/db_server_xdr.c_objects
-db_server_xdr.o
-<END>
-
-<BEGIN> FILE_$(PRJ_DIR)/../rpc_server/c/db_server_xdr.c_tool
-C/C++ compiler
-<END>
-
-<BEGIN> FILE_$(PRJ_DIR)/../txn/txn.c_dependDone
-TRUE
-<END>
-
-<BEGIN> FILE_$(PRJ_DIR)/../txn/txn.c_dependencies
-$(PRJ_DIR)/db_config.h \
-	$(PRJ_DIR)/db_int.h \
-	$(PRJ_DIR)/db.h
-<END>
-
-<BEGIN> FILE_$(PRJ_DIR)/../txn/txn.c_objects
-txn.o
-<END>
-
-<BEGIN> FILE_$(PRJ_DIR)/../txn/txn.c_tool
-C/C++ compiler
-<END>
-
-<BEGIN> FILE_$(PRJ_DIR)/../txn/txn_auto.c_dependDone
-TRUE
-<END>
-
-<BEGIN> FILE_$(PRJ_DIR)/../txn/txn_auto.c_dependencies
-$(PRJ_DIR)/db_config.h \
-	$(PRJ_DIR)/db_int.h \
-	$(PRJ_DIR)/db.h
-<END>
-
-<BEGIN> FILE_$(PRJ_DIR)/../txn/txn_auto.c_objects
-txn_auto.o
-<END>
-
-<BEGIN> FILE_$(PRJ_DIR)/../txn/txn_auto.c_tool
-C/C++ compiler
-<END>
-
-<BEGIN> FILE_$(PRJ_DIR)/../txn/txn_method.c_dependDone
-TRUE
-<END>
-
-<BEGIN> FILE_$(PRJ_DIR)/../txn/txn_method.c_dependencies
-$(PRJ_DIR)/db_config.h \
-	$(PRJ_DIR)/db_int.h \
-	$(PRJ_DIR)/db.h
-<END>
-
-<BEGIN> FILE_$(PRJ_DIR)/../txn/txn_method.c_objects
-txn_method.o
-<END>
-
-<BEGIN> FILE_$(PRJ_DIR)/../txn/txn_method.c_tool
-C/C++ compiler
-<END>
-
-<BEGIN> FILE_$(PRJ_DIR)/../txn/txn_rec.c_dependDone
-TRUE
-<END>
-
-<BEGIN> FILE_$(PRJ_DIR)/../txn/txn_rec.c_dependencies
-$(PRJ_DIR)/db_config.h \
-	$(PRJ_DIR)/db_int.h \
-	$(PRJ_DIR)/db.h
-<END>
-
-<BEGIN> FILE_$(PRJ_DIR)/../txn/txn_rec.c_objects
-txn_rec.o
-<END>
-
-<BEGIN> FILE_$(PRJ_DIR)/../txn/txn_rec.c_tool
-C/C++ compiler
-<END>
-
-<BEGIN> FILE_$(PRJ_DIR)/../txn/txn_recover.c_dependDone
-TRUE
-<END>
-
-<BEGIN> FILE_$(PRJ_DIR)/../txn/txn_recover.c_dependencies
-$(PRJ_DIR)/db_config.h \
-	$(PRJ_DIR)/db_int.h \
-	$(PRJ_DIR)/db.h
-<END>
-
-<BEGIN> FILE_$(PRJ_DIR)/../txn/txn_recover.c_objects
-txn_recover.o
-<END>
-
-<BEGIN> FILE_$(PRJ_DIR)/../txn/txn_recover.c_tool
-C/C++ compiler
-<END>
-
-<BEGIN> FILE_$(PRJ_DIR)/../txn/txn_region.c_dependDone
-TRUE
-<END>
-
-<BEGIN> FILE_$(PRJ_DIR)/../txn/txn_region.c_dependencies
-$(PRJ_DIR)/db_config.h \
-	$(PRJ_DIR)/db_int.h \
-	$(PRJ_DIR)/db.h
-<END>
-
-<BEGIN> FILE_$(PRJ_DIR)/../txn/txn_region.c_objects
-txn_region.o
-<END>
-
-<BEGIN> FILE_$(PRJ_DIR)/../txn/txn_region.c_tool
-C/C++ compiler
-<END>
-
-<BEGIN> FILE_$(PRJ_DIR)/../txn/txn_stat.c_dependDone
-TRUE
-<END>
-
-<BEGIN> FILE_$(PRJ_DIR)/../txn/txn_stat.c_dependencies
-$(PRJ_DIR)/db_config.h \
-	$(PRJ_DIR)/db_int.h \
-	$(PRJ_DIR)/db.h
-<END>
-
-<BEGIN> FILE_$(PRJ_DIR)/../txn/txn_stat.c_objects
-txn_stat.o
-<END>
-
-<BEGIN> FILE_$(PRJ_DIR)/../txn/txn_stat.c_tool
-C/C++ compiler
-<END>
-
-<BEGIN> FILE_$(PRJ_DIR)/../txn/txn_util.c_dependDone
-TRUE
-<END>
-
-<BEGIN> FILE_$(PRJ_DIR)/../txn/txn_util.c_dependencies
-$(PRJ_DIR)/db_config.h \
-	$(PRJ_DIR)/db_int.h \
-	$(PRJ_DIR)/db.h
-<END>
-
-<BEGIN> FILE_$(PRJ_DIR)/../txn/txn_util.c_objects
-txn_util.o
-<END>
-
-<BEGIN> FILE_$(PRJ_DIR)/../txn/txn_util.c_tool
-C/C++ compiler
-<END>
-
-<BEGIN> FILE_$(PRJ_DIR)/../xa/xa.c_dependDone
-TRUE
-<END>
-
-<BEGIN> FILE_$(PRJ_DIR)/../xa/xa.c_dependencies
-$(PRJ_DIR)/db_config.h \
-	$(PRJ_DIR)/db_int.h \
-	$(PRJ_DIR)/db.h
-<END>
-
-<BEGIN> FILE_$(PRJ_DIR)/../xa/xa.c_objects
-xa.o
-<END>
-
-<BEGIN> FILE_$(PRJ_DIR)/../xa/xa.c_tool
-C/C++ compiler
-<END>
-
-<BEGIN> FILE_$(PRJ_DIR)/../xa/xa_db.c_dependDone
-TRUE
-<END>
-
-<BEGIN> FILE_$(PRJ_DIR)/../xa/xa_db.c_dependencies
-$(PRJ_DIR)/db_config.h \
-	$(PRJ_DIR)/db_int.h \
-	$(PRJ_DIR)/db.h
-<END>
-
-<BEGIN> FILE_$(PRJ_DIR)/../xa/xa_db.c_objects
-xa_db.o
-<END>
-
-<BEGIN> FILE_$(PRJ_DIR)/../xa/xa_db.c_tool
-C/C++ compiler
-<END>
-
-<BEGIN> FILE_$(PRJ_DIR)/../xa/xa_map.c_dependDone
-TRUE
-<END>
-
-<BEGIN> FILE_$(PRJ_DIR)/../xa/xa_map.c_dependencies
-$(PRJ_DIR)/db_config.h \
-	$(PRJ_DIR)/db_int.h \
-	$(PRJ_DIR)/db.h
-<END>
-
-<BEGIN> FILE_$(PRJ_DIR)/../xa/xa_map.c_objects
-xa_map.o
-<END>
-
-<BEGIN> FILE_$(PRJ_DIR)/../xa/xa_map.c_tool
-C/C++ compiler
-<END>
-
-<BEGIN> PROJECT_FILES
-$(PRJ_DIR)/../btree/bt_compare.c \
-	$(PRJ_DIR)/../btree/bt_conv.c \
-	$(PRJ_DIR)/../btree/bt_curadj.c \
-	$(PRJ_DIR)/../btree/bt_cursor.c \
-	$(PRJ_DIR)/../btree/bt_delete.c \
-	$(PRJ_DIR)/../btree/bt_method.c \
-	$(PRJ_DIR)/../btree/bt_open.c \
-	$(PRJ_DIR)/../btree/bt_put.c \
-	$(PRJ_DIR)/../btree/bt_rec.c \
-	$(PRJ_DIR)/../btree/bt_reclaim.c \
-	$(PRJ_DIR)/../btree/bt_recno.c \
-	$(PRJ_DIR)/../btree/bt_rsearch.c \
-	$(PRJ_DIR)/../btree/bt_search.c \
-	$(PRJ_DIR)/../btree/bt_split.c \
-	$(PRJ_DIR)/../btree/bt_stat.c \
-	$(PRJ_DIR)/../btree/bt_upgrade.c \
-	$(PRJ_DIR)/../btree/bt_verify.c \
-	$(PRJ_DIR)/../btree/btree_auto.c \
-	$(PRJ_DIR)/../clib/getopt.c \
-	$(PRJ_DIR)/../clib/snprintf.c \
-	$(PRJ_DIR)/../clib/strcasecmp.c \
-	$(PRJ_DIR)/../clib/strdup.c \
-	$(PRJ_DIR)/../clib/vsnprintf.c \
-	$(PRJ_DIR)/../common/db_byteorder.c \
-	$(PRJ_DIR)/../common/db_err.c \
-	$(PRJ_DIR)/../common/db_getlong.c \
-	$(PRJ_DIR)/../common/db_idspace.c \
-	$(PRJ_DIR)/../common/db_log2.c \
-	$(PRJ_DIR)/../common/util_arg.c \
-	$(PRJ_DIR)/../common/util_cache.c \
-	$(PRJ_DIR)/../common/util_log.c \
-	$(PRJ_DIR)/../common/util_sig.c \
-	$(PRJ_DIR)/../db/crdel_auto.c \
-	$(PRJ_DIR)/../db/crdel_rec.c \
-	$(PRJ_DIR)/../db/db.c \
-	$(PRJ_DIR)/../db/db_am.c \
-	$(PRJ_DIR)/../db/db_auto.c \
-	$(PRJ_DIR)/../db/db_cam.c \
-	$(PRJ_DIR)/../db/db_conv.c \
-	$(PRJ_DIR)/../db/db_dispatch.c \
-	$(PRJ_DIR)/../db/db_dup.c \
-	$(PRJ_DIR)/../db/db_iface.c \
-	$(PRJ_DIR)/../db/db_join.c \
-	$(PRJ_DIR)/../db/db_meta.c \
-	$(PRJ_DIR)/../db/db_method.c \
-	$(PRJ_DIR)/../db/db_open.c \
-	$(PRJ_DIR)/../db/db_overflow.c \
-	$(PRJ_DIR)/../db/db_pr.c \
-	$(PRJ_DIR)/../db/db_rec.c \
-	$(PRJ_DIR)/../db/db_reclaim.c \
-	$(PRJ_DIR)/../db/db_remove.c \
-	$(PRJ_DIR)/../db/db_rename.c \
-	$(PRJ_DIR)/../db/db_ret.c \
-	$(PRJ_DIR)/../db/db_truncate.c \
-	$(PRJ_DIR)/../db/db_upg.c \
-	$(PRJ_DIR)/../db/db_upg_opd.c \
-	$(PRJ_DIR)/../db/db_vrfy.c \
-	$(PRJ_DIR)/../db/db_vrfyutil.c \
-	$(PRJ_DIR)/../dbreg/dbreg.c \
-	$(PRJ_DIR)/../dbreg/dbreg_auto.c \
-	$(PRJ_DIR)/../dbreg/dbreg_rec.c \
-	$(PRJ_DIR)/../dbreg/dbreg_util.c \
-	$(PRJ_DIR)/../env/db_salloc.c \
-	$(PRJ_DIR)/../env/db_shash.c \
-	$(PRJ_DIR)/../env/env_file.c \
-	$(PRJ_DIR)/../env/env_method.c \
-	$(PRJ_DIR)/../env/env_open.c \
-	$(PRJ_DIR)/../env/env_recover.c \
-	$(PRJ_DIR)/../env/env_region.c \
-	$(PRJ_DIR)/../fileops/fileops_auto.c \
-	$(PRJ_DIR)/../fileops/fop_basic.c \
-	$(PRJ_DIR)/../fileops/fop_rec.c \
-	$(PRJ_DIR)/../fileops/fop_util.c \
-	$(PRJ_DIR)/../hash/hash.c \
-	$(PRJ_DIR)/../hash/hash_auto.c \
-	$(PRJ_DIR)/../hash/hash_conv.c \
-	$(PRJ_DIR)/../hash/hash_dup.c \
-	$(PRJ_DIR)/../hash/hash_func.c \
-	$(PRJ_DIR)/../hash/hash_meta.c \
-	$(PRJ_DIR)/../hash/hash_method.c \
-	$(PRJ_DIR)/../hash/hash_open.c \
-	$(PRJ_DIR)/../hash/hash_page.c \
-	$(PRJ_DIR)/../hash/hash_rec.c \
-	$(PRJ_DIR)/../hash/hash_reclaim.c \
-	$(PRJ_DIR)/../hash/hash_stat.c \
-	$(PRJ_DIR)/../hash/hash_upgrade.c \
-	$(PRJ_DIR)/../hash/hash_verify.c \
-	$(PRJ_DIR)/../hmac/hmac.c \
-	$(PRJ_DIR)/../hmac/sha1.c \
-	$(PRJ_DIR)/../hsearch/hsearch.c \
-	$(PRJ_DIR)/../lock/lock.c \
-	$(PRJ_DIR)/../lock/lock_deadlock.c \
-	$(PRJ_DIR)/../lock/lock_method.c \
-	$(PRJ_DIR)/../lock/lock_region.c \
-	$(PRJ_DIR)/../lock/lock_stat.c \
-	$(PRJ_DIR)/../lock/lock_util.c \
-	$(PRJ_DIR)/../log/log.c \
-	$(PRJ_DIR)/../log/log_archive.c \
-	$(PRJ_DIR)/../log/log_compare.c \
-	$(PRJ_DIR)/../log/log_get.c \
-	$(PRJ_DIR)/../log/log_method.c \
-	$(PRJ_DIR)/../log/log_put.c \
-	$(PRJ_DIR)/../mp/mp_alloc.c \
-	$(PRJ_DIR)/../mp/mp_bh.c \
-	$(PRJ_DIR)/../mp/mp_fget.c \
-	$(PRJ_DIR)/../mp/mp_fopen.c \
-	$(PRJ_DIR)/../mp/mp_fput.c \
-	$(PRJ_DIR)/../mp/mp_fset.c \
-	$(PRJ_DIR)/../mp/mp_method.c \
-	$(PRJ_DIR)/../mp/mp_region.c \
-	$(PRJ_DIR)/../mp/mp_register.c \
-	$(PRJ_DIR)/../mp/mp_stat.c \
-	$(PRJ_DIR)/../mp/mp_sync.c \
-	$(PRJ_DIR)/../mp/mp_trickle.c \
-	$(PRJ_DIR)/../mutex/mut_tas.c \
-	$(PRJ_DIR)/../mutex/mutex.c \
-	$(PRJ_DIR)/../os/os_alloc.c \
-	$(PRJ_DIR)/../os/os_clock.c \
-	$(PRJ_DIR)/../os/os_dir.c \
-	$(PRJ_DIR)/../os/os_errno.c \
-	$(PRJ_DIR)/../os/os_fid.c \
-	$(PRJ_DIR)/../os/os_fsync.c \
-	$(PRJ_DIR)/../os/os_handle.c \
-	$(PRJ_DIR)/../os/os_id.c \
-	$(PRJ_DIR)/../os/os_method.c \
-	$(PRJ_DIR)/../os/os_oflags.c \
-	$(PRJ_DIR)/../os/os_open.c \
-	$(PRJ_DIR)/../os/os_region.c \
-	$(PRJ_DIR)/../os/os_rename.c \
-	$(PRJ_DIR)/../os/os_root.c \
-	$(PRJ_DIR)/../os/os_rpath.c \
-	$(PRJ_DIR)/../os/os_rw.c \
-	$(PRJ_DIR)/../os/os_seek.c \
-	$(PRJ_DIR)/../os/os_sleep.c \
-	$(PRJ_DIR)/../os/os_spin.c \
-	$(PRJ_DIR)/../os/os_stat.c \
-	$(PRJ_DIR)/../os/os_tmpdir.c \
-	$(PRJ_DIR)/../os/os_unlink.c \
-	$(PRJ_DIR)/../os_vxworks/os_vx_abs.c \
-	$(PRJ_DIR)/../os_vxworks/os_vx_config.c \
-	$(PRJ_DIR)/../os_vxworks/os_vx_map.c \
-	$(PRJ_DIR)/../qam/qam.c \
-	$(PRJ_DIR)/../qam/qam_auto.c \
-	$(PRJ_DIR)/../qam/qam_conv.c \
-	$(PRJ_DIR)/../qam/qam_files.c \
-	$(PRJ_DIR)/../qam/qam_method.c \
-	$(PRJ_DIR)/../qam/qam_open.c \
-	$(PRJ_DIR)/../qam/qam_rec.c \
-	$(PRJ_DIR)/../qam/qam_stat.c \
-	$(PRJ_DIR)/../qam/qam_upgrade.c \
-	$(PRJ_DIR)/../qam/qam_verify.c \
-	$(PRJ_DIR)/../rep/rep_method.c \
-	$(PRJ_DIR)/../rep/rep_record.c \
-	$(PRJ_DIR)/../rep/rep_region.c \
-	$(PRJ_DIR)/../rep/rep_util.c \
-	$(PRJ_DIR)/../rpc_client/client.c \
-	$(PRJ_DIR)/../rpc_client/db_server_clnt.c \
-	$(PRJ_DIR)/../rpc_client/gen_client.c \
-	$(PRJ_DIR)/../rpc_client/gen_client_ret.c \
-	$(PRJ_DIR)/../rpc_server/c/db_server_xdr.c \
-	$(PRJ_DIR)/../txn/txn.c \
-	$(PRJ_DIR)/../txn/txn_auto.c \
-	$(PRJ_DIR)/../txn/txn_method.c \
-	$(PRJ_DIR)/../txn/txn_rec.c \
-	$(PRJ_DIR)/../txn/txn_recover.c \
-	$(PRJ_DIR)/../txn/txn_region.c \
-	$(PRJ_DIR)/../txn/txn_stat.c \
-	$(PRJ_DIR)/../txn/txn_util.c \
-	$(PRJ_DIR)/../xa/xa.c \
-	$(PRJ_DIR)/../xa/xa_db.c \
-	$(PRJ_DIR)/../xa/xa_map.c
-<END>
-
-<BEGIN> userComments
-BerkeleyDB
-<END>
diff --git a/bdb/build_vxworks/BerkeleyDB/Makefile.custom b/bdb/build_vxworks/BerkeleyDB/Makefile.custom
deleted file mode 100644
index ca781f7b251ef99e49e5fc1859ee6cf3d67c60b0..0000000000000000000000000000000000000000
--- a/bdb/build_vxworks/BerkeleyDB/Makefile.custom
+++ /dev/null
@@ -1,51 +0,0 @@
-#
-# Custom Makefile shell
-#
-# This file may be edited freely, since it will not be regenerated
-# by the project manager.
-#
-# Use this makefile to define rules to make external binaries
-# and deposit them in the $(EXTERNAL_BINARIES_DIR) directory.
-#
-# If you have specified external modules during your component
-# creation, you will find make rules already in place below.
-# You will likely have to edit these to suit your individual
-# build setup.
-#
-# You may wish to use the CPU, BUILD_SPEC or TOOL make variables in
-# your Makefile to support builds for different architectures.  Use
-# the FORCE_EXTERNAL_MAKE phony target to ensure that your external
-# make always runs.
-#
-# The example below assumes that your custom makefile is in the
-# mySourceTree directory, and that the binary file it produces
-# is placed into the $(BUILD_SPEC) sub-directory.
-#
-# EXTERNAL_SOURCE_BASE = /folk/me/mySourceTree
-# EXTERNAL_MODULE = myLibrary.o
-# EXTERNAL_MAKE = make
-#
-# $(EXTERNAL_BINARIES_DIR)/$(EXTERNAL_MODULE) : FORCE_EXTERNAL_MAKE
-#	$(EXTERNAL_MAKE) -C $(EXTERNAL_SOURCE_BASE) \
-#	-f $(EXTERNAL_SOURCE_BASE)/Makefile \
-#	CPU=$(CPU) BUILD_SPEC=$(BUILD_SPEC) $(@F)
-#	$(CP) $(subst /,$(DIRCHAR),$(EXTERNAL_SOURCE_BASE)/$(BUILD_SPEC)/$(@F) $@)
-#
-# If you are not adding your external modules from the component wizard,
-# you will have to include them in your component yourself:
-#
-# From the GUI, you can do this with the Component's 'Add external module'
-# dialog.
-#
-# If you are using the command line, add the module(s) by editing the
-# MODULES line in component.cdf file, e.g.
-#
-# Component INCLUDE_MYCOMPONENT {
-#
-#   MODULES         foo.o goo.o \
-#         myLibrary.o
-#
-
-
-# rules to build custom libraries
-
diff --git a/bdb/build_vxworks/BerkeleyDB/component.cdf b/bdb/build_vxworks/BerkeleyDB/component.cdf
deleted file mode 100755
index 4b3e6f101c321a261d97f92c25aea03ea2dc3976..0000000000000000000000000000000000000000
--- a/bdb/build_vxworks/BerkeleyDB/component.cdf
+++ /dev/null
@@ -1,1220 +0,0 @@
-/* component.cdf - dynamically updated configuration */
-
-/*
- * NOTE: you may edit this file to alter the configuration
- * But all non-configuration information, including comments,
- * will be lost upon rebuilding this project.
- */
-
-/* Component information */
-
-Component INCLUDE_BERKELEYDB {
-	ENTRY_POINTS	ALL_GLOBAL_SYMBOLS
-	MODULES			bt_compare.o \
-			bt_conv.o \
-			bt_curadj.o \
-			bt_cursor.o \
-			bt_delete.o \
-			bt_method.o \
-			bt_open.o \
-			bt_put.o \
-			bt_rec.o \
-			bt_reclaim.o \
-			bt_recno.o \
-			bt_rsearch.o \
-			bt_search.o \
-			bt_split.o \
-			bt_stat.o \
-			bt_upgrade.o \
-			bt_verify.o \
-			btree_auto.o \
-			client.o \
-			crdel_auto.o \
-			crdel_rec.o \
-			db.o \
-			db_am.o \
-			db_auto.o \
-			db_byteorder.o \
-			db_cam.o \
-			db_conv.o \
-			db_dispatch.o \
-			db_dup.o \
-			db_err.o \
-			db_getlong.o \
-			db_idspace.o \
-			db_iface.o \
-			db_join.o \
-			db_log2.o \
-			db_meta.o \
-			db_method.o \
-			db_open.o \
-			db_overflow.o \
-			db_pr.o \
-			db_rec.o \
-			db_reclaim.o \
-			db_remove.o \
-			db_rename.o \
-			db_ret.o \
-			db_salloc.o \
-			db_server_clnt.o \
-			db_server_xdr.o \
-			db_shash.o \
-			db_truncate.o \
-			db_upg.o \
-			db_upg_opd.o \
-			db_vrfy.o \
-			db_vrfyutil.o \
-			dbreg.o \
-			dbreg_auto.o \
-			dbreg_rec.o \
-			dbreg_util.o \
-			env_file.o \
-			env_method.o \
-			env_open.o \
-			env_recover.o \
-			env_region.o \
-			fileops_auto.o \
-			fop_basic.o \
-			fop_rec.o \
-			fop_util.o \
-			gen_client.o \
-			gen_client_ret.o \
-			getopt.o \
-			hash.o \
-			hash_auto.o \
-			hash_conv.o \
-			hash_dup.o \
-			hash_func.o \
-			hash_meta.o \
-			hash_method.o \
-			hash_open.o \
-			hash_page.o \
-			hash_rec.o \
-			hash_reclaim.o \
-			hash_stat.o \
-			hash_upgrade.o \
-			hash_verify.o \
-			hmac.o \
-			hsearch.o \
-			lock.o \
-			lock_deadlock.o \
-			lock_method.o \
-			lock_region.o \
-			lock_stat.o \
-			lock_util.o \
-			log.o \
-			log_archive.o \
-			log_compare.o \
-			log_get.o \
-			log_method.o \
-			log_put.o \
-			mp_alloc.o \
-			mp_bh.o \
-			mp_fget.o \
-			mp_fopen.o \
-			mp_fput.o \
-			mp_fset.o \
-			mp_method.o \
-			mp_region.o \
-			mp_register.o \
-			mp_stat.o \
-			mp_sync.o \
-			mp_trickle.o \
-			mut_tas.o \
-			mutex.o \
-			os_alloc.o \
-			os_clock.o \
-			os_dir.o \
-			os_errno.o \
-			os_fid.o \
-			os_fsync.o \
-			os_handle.o \
-			os_id.o \
-			os_method.o \
-			os_oflags.o \
-			os_open.o \
-			os_region.o \
-			os_rename.o \
-			os_root.o \
-			os_rpath.o \
-			os_rw.o \
-			os_seek.o \
-			os_sleep.o \
-			os_spin.o \
-			os_stat.o \
-			os_tmpdir.o \
-			os_unlink.o \
-			os_vx_abs.o \
-			os_vx_config.o \
-			os_vx_map.o \
-			qam.o \
-			qam_auto.o \
-			qam_conv.o \
-			qam_files.o \
-			qam_method.o \
-			qam_open.o \
-			qam_rec.o \
-			qam_stat.o \
-			qam_upgrade.o \
-			qam_verify.o \
-			rep_method.o \
-			rep_record.o \
-			rep_region.o \
-			rep_util.o \
-			sha1.o \
-			snprintf.o \
-			strcasecmp.o \
-			strdup.o \
-			txn.o \
-			txn_auto.o \
-			txn_method.o \
-			txn_rec.o \
-			txn_recover.o \
-			txn_region.o \
-			txn_stat.o \
-			txn_util.o \
-			util_arg.o \
-			util_cache.o \
-			util_log.o \
-			util_sig.o \
-			vsnprintf.o \
-			xa.o \
-			xa_db.o \
-			xa_map.o
-	NAME		BerkeleyDB
-	PREF_DOMAIN	ANY
-	_INIT_ORDER	usrComponentsInit
-}
-
-/* EntryPoint information */
-
-/* Module information */
-
-Module bt_compare.o {
-
-	NAME		bt_compare.o
-	SRC_PATH_NAME	$(PRJ_DIR)/../../btree/bt_compare.c
-}
-
-Module bt_conv.o {
-
-	NAME		bt_conv.o
-	SRC_PATH_NAME	$(PRJ_DIR)/../../btree/bt_conv.c
-}
-
-Module bt_curadj.o {
-
-	NAME		bt_curadj.o
-	SRC_PATH_NAME	$(PRJ_DIR)/../../btree/bt_curadj.c
-}
-
-Module bt_cursor.o {
-
-	NAME		bt_cursor.o
-	SRC_PATH_NAME	$(PRJ_DIR)/../../btree/bt_cursor.c
-}
-
-Module bt_delete.o {
-
-	NAME		bt_delete.o
-	SRC_PATH_NAME	$(PRJ_DIR)/../../btree/bt_delete.c
-}
-
-Module bt_method.o {
-
-	NAME		bt_method.o
-	SRC_PATH_NAME	$(PRJ_DIR)/../../btree/bt_method.c
-}
-
-Module bt_open.o {
-
-	NAME		bt_open.o
-	SRC_PATH_NAME	$(PRJ_DIR)/../../btree/bt_open.c
-}
-
-Module bt_put.o {
-
-	NAME		bt_put.o
-	SRC_PATH_NAME	$(PRJ_DIR)/../../btree/bt_put.c
-}
-
-Module bt_rec.o {
-
-	NAME		bt_rec.o
-	SRC_PATH_NAME	$(PRJ_DIR)/../../btree/bt_rec.c
-}
-
-Module bt_reclaim.o {
-
-	NAME		bt_reclaim.o
-	SRC_PATH_NAME	$(PRJ_DIR)/../../btree/bt_reclaim.c
-}
-
-Module bt_recno.o {
-
-	NAME		bt_recno.o
-	SRC_PATH_NAME	$(PRJ_DIR)/../../btree/bt_recno.c
-}
-
-Module bt_rsearch.o {
-
-	NAME		bt_rsearch.o
-	SRC_PATH_NAME	$(PRJ_DIR)/../../btree/bt_rsearch.c
-}
-
-Module bt_search.o {
-
-	NAME		bt_search.o
-	SRC_PATH_NAME	$(PRJ_DIR)/../../btree/bt_search.c
-}
-
-Module bt_split.o {
-
-	NAME		bt_split.o
-	SRC_PATH_NAME	$(PRJ_DIR)/../../btree/bt_split.c
-}
-
-Module bt_stat.o {
-
-	NAME		bt_stat.o
-	SRC_PATH_NAME	$(PRJ_DIR)/../../btree/bt_stat.c
-}
-
-Module bt_upgrade.o {
-
-	NAME		bt_upgrade.o
-	SRC_PATH_NAME	$(PRJ_DIR)/../../btree/bt_upgrade.c
-}
-
-Module bt_verify.o {
-
-	NAME		bt_verify.o
-	SRC_PATH_NAME	$(PRJ_DIR)/../../btree/bt_verify.c
-}
-
-Module btree_auto.o {
-
-	NAME		btree_auto.o
-	SRC_PATH_NAME	$(PRJ_DIR)/../../btree/btree_auto.c
-}
-
-Module getopt.o {
-
-	NAME		getopt.o
-	SRC_PATH_NAME	$(PRJ_DIR)/../../clib/getopt.c
-}
-
-Module snprintf.o {
-
-	NAME		snprintf.o
-	SRC_PATH_NAME	$(PRJ_DIR)/../../clib/snprintf.c
-}
-
-Module strcasecmp.o {
-
-	NAME		strcasecmp.o
-	SRC_PATH_NAME	$(PRJ_DIR)/../../clib/strcasecmp.c
-}
-
-Module strdup.o {
-
-	NAME		strdup.o
-	SRC_PATH_NAME	$(PRJ_DIR)/../../clib/strdup.c
-}
-
-Module vsnprintf.o {
-
-	NAME		vsnprintf.o
-	SRC_PATH_NAME	$(PRJ_DIR)/../../clib/vsnprintf.c
-}
-
-Module db_byteorder.o {
-
-	NAME		db_byteorder.o
-	SRC_PATH_NAME	$(PRJ_DIR)/../../common/db_byteorder.c
-}
-
-Module db_err.o {
-
-	NAME		db_err.o
-	SRC_PATH_NAME	$(PRJ_DIR)/../../common/db_err.c
-}
-
-Module db_getlong.o {
-
-	NAME		db_getlong.o
-	SRC_PATH_NAME	$(PRJ_DIR)/../../common/db_getlong.c
-}
-
-Module db_idspace.o {
-
-	NAME		db_idspace.o
-	SRC_PATH_NAME	$(PRJ_DIR)/../../common/db_idspace.c
-}
-
-Module db_log2.o {
-
-	NAME		db_log2.o
-	SRC_PATH_NAME	$(PRJ_DIR)/../../common/db_log2.c
-}
-
-Module util_arg.o {
-
-	NAME		util_arg.o
-	SRC_PATH_NAME	$(PRJ_DIR)/../../common/util_arg.c
-}
-
-Module util_cache.o {
-
-	NAME		util_cache.o
-	SRC_PATH_NAME	$(PRJ_DIR)/../../common/util_cache.c
-}
-
-Module util_log.o {
-
-	NAME		util_log.o
-	SRC_PATH_NAME	$(PRJ_DIR)/../../common/util_log.c
-}
-
-Module util_sig.o {
-
-	NAME		util_sig.o
-	SRC_PATH_NAME	$(PRJ_DIR)/../../common/util_sig.c
-}
-
-Module crdel_auto.o {
-
-	NAME		crdel_auto.o
-	SRC_PATH_NAME	$(PRJ_DIR)/../../db/crdel_auto.c
-}
-
-Module crdel_rec.o {
-
-	NAME		crdel_rec.o
-	SRC_PATH_NAME	$(PRJ_DIR)/../../db/crdel_rec.c
-}
-
-Module db.o {
-
-	NAME		db.o
-	SRC_PATH_NAME	$(PRJ_DIR)/../../db/db.c
-}
-
-Module db_am.o {
-
-	NAME		db_am.o
-	SRC_PATH_NAME	$(PRJ_DIR)/../../db/db_am.c
-}
-
-Module db_auto.o {
-
-	NAME		db_auto.o
-	SRC_PATH_NAME	$(PRJ_DIR)/../../db/db_auto.c
-}
-
-Module db_cam.o {
-
-	NAME		db_cam.o
-	SRC_PATH_NAME	$(PRJ_DIR)/../../db/db_cam.c
-}
-
-Module db_conv.o {
-
-	NAME		db_conv.o
-	SRC_PATH_NAME	$(PRJ_DIR)/../../db/db_conv.c
-}
-
-Module db_dispatch.o {
-
-	NAME		db_dispatch.o
-	SRC_PATH_NAME	$(PRJ_DIR)/../../db/db_dispatch.c
-}
-
-Module db_dup.o {
-
-	NAME		db_dup.o
-	SRC_PATH_NAME	$(PRJ_DIR)/../../db/db_dup.c
-}
-
-Module db_iface.o {
-
-	NAME		db_iface.o
-	SRC_PATH_NAME	$(PRJ_DIR)/../../db/db_iface.c
-}
-
-Module db_join.o {
-
-	NAME		db_join.o
-	SRC_PATH_NAME	$(PRJ_DIR)/../../db/db_join.c
-}
-
-Module db_meta.o {
-
-	NAME		db_meta.o
-	SRC_PATH_NAME	$(PRJ_DIR)/../../db/db_meta.c
-}
-
-Module db_method.o {
-
-	NAME		db_method.o
-	SRC_PATH_NAME	$(PRJ_DIR)/../../db/db_method.c
-}
-
-Module db_open.o {
-
-	NAME		db_open.o
-	SRC_PATH_NAME	$(PRJ_DIR)/../../db/db_open.c
-}
-
-Module db_overflow.o {
-
-	NAME		db_overflow.o
-	SRC_PATH_NAME	$(PRJ_DIR)/../../db/db_overflow.c
-}
-
-Module db_pr.o {
-
-	NAME		db_pr.o
-	SRC_PATH_NAME	$(PRJ_DIR)/../../db/db_pr.c
-}
-
-Module db_rec.o {
-
-	NAME		db_rec.o
-	SRC_PATH_NAME	$(PRJ_DIR)/../../db/db_rec.c
-}
-
-Module db_reclaim.o {
-
-	NAME		db_reclaim.o
-	SRC_PATH_NAME	$(PRJ_DIR)/../../db/db_reclaim.c
-}
-
-Module db_remove.o {
-
-	NAME		db_remove.o
-	SRC_PATH_NAME	$(PRJ_DIR)/../../db/db_remove.c
-}
-
-Module db_rename.o {
-
-	NAME		db_rename.o
-	SRC_PATH_NAME	$(PRJ_DIR)/../../db/db_rename.c
-}
-
-Module db_ret.o {
-
-	NAME		db_ret.o
-	SRC_PATH_NAME	$(PRJ_DIR)/../../db/db_ret.c
-}
-
-Module db_truncate.o {
-
-	NAME		db_truncate.o
-	SRC_PATH_NAME	$(PRJ_DIR)/../../db/db_truncate.c
-}
-
-Module db_upg.o {
-
-	NAME		db_upg.o
-	SRC_PATH_NAME	$(PRJ_DIR)/../../db/db_upg.c
-}
-
-Module db_upg_opd.o {
-
-	NAME		db_upg_opd.o
-	SRC_PATH_NAME	$(PRJ_DIR)/../../db/db_upg_opd.c
-}
-
-Module db_vrfy.o {
-
-	NAME		db_vrfy.o
-	SRC_PATH_NAME	$(PRJ_DIR)/../../db/db_vrfy.c
-}
-
-Module db_vrfyutil.o {
-
-	NAME		db_vrfyutil.o
-	SRC_PATH_NAME	$(PRJ_DIR)/../../db/db_vrfyutil.c
-}
-
-Module dbreg.o {
-
-	NAME		dbreg.o
-	SRC_PATH_NAME	$(PRJ_DIR)/../../dbreg/dbreg.c
-}
-
-Module dbreg_auto.o {
-
-	NAME		dbreg_auto.o
-	SRC_PATH_NAME	$(PRJ_DIR)/../../dbreg/dbreg_auto.c
-}
-
-Module dbreg_rec.o {
-
-	NAME		dbreg_rec.o
-	SRC_PATH_NAME	$(PRJ_DIR)/../../dbreg/dbreg_rec.c
-}
-
-Module dbreg_util.o {
-
-	NAME		dbreg_util.o
-	SRC_PATH_NAME	$(PRJ_DIR)/../../dbreg/dbreg_util.c
-}
-
-Module db_salloc.o {
-
-	NAME		db_salloc.o
-	SRC_PATH_NAME	$(PRJ_DIR)/../../env/db_salloc.c
-}
-
-Module db_shash.o {
-
-	NAME		db_shash.o
-	SRC_PATH_NAME	$(PRJ_DIR)/../../env/db_shash.c
-}
-
-Module env_file.o {
-
-	NAME		env_file.o
-	SRC_PATH_NAME	$(PRJ_DIR)/../../env/env_file.c
-}
-
-Module env_method.o {
-
-	NAME		env_method.o
-	SRC_PATH_NAME	$(PRJ_DIR)/../../env/env_method.c
-}
-
-Module env_open.o {
-
-	NAME		env_open.o
-	SRC_PATH_NAME	$(PRJ_DIR)/../../env/env_open.c
-}
-
-Module env_recover.o {
-
-	NAME		env_recover.o
-	SRC_PATH_NAME	$(PRJ_DIR)/../../env/env_recover.c
-}
-
-Module env_region.o {
-
-	NAME		env_region.o
-	SRC_PATH_NAME	$(PRJ_DIR)/../../env/env_region.c
-}
-
-Module fileops_auto.o {
-
-	NAME		fileops_auto.o
-	SRC_PATH_NAME	$(PRJ_DIR)/../../fileops/fileops_auto.c
-}
-
-Module fop_basic.o {
-
-	NAME		fop_basic.o
-	SRC_PATH_NAME	$(PRJ_DIR)/../../fileops/fop_basic.c
-}
-
-Module fop_rec.o {
-
-	NAME		fop_rec.o
-	SRC_PATH_NAME	$(PRJ_DIR)/../../fileops/fop_rec.c
-}
-
-Module fop_util.o {
-
-	NAME		fop_util.o
-	SRC_PATH_NAME	$(PRJ_DIR)/../../fileops/fop_util.c
-}
-
-Module hash.o {
-
-	NAME		hash.o
-	SRC_PATH_NAME	$(PRJ_DIR)/../../hash/hash.c
-}
-
-Module hash_auto.o {
-
-	NAME		hash_auto.o
-	SRC_PATH_NAME	$(PRJ_DIR)/../../hash/hash_auto.c
-}
-
-Module hash_conv.o {
-
-	NAME		hash_conv.o
-	SRC_PATH_NAME	$(PRJ_DIR)/../../hash/hash_conv.c
-}
-
-Module hash_dup.o {
-
-	NAME		hash_dup.o
-	SRC_PATH_NAME	$(PRJ_DIR)/../../hash/hash_dup.c
-}
-
-Module hash_func.o {
-
-	NAME		hash_func.o
-	SRC_PATH_NAME	$(PRJ_DIR)/../../hash/hash_func.c
-}
-
-Module hash_meta.o {
-
-	NAME		hash_meta.o
-	SRC_PATH_NAME	$(PRJ_DIR)/../../hash/hash_meta.c
-}
-
-Module hash_method.o {
-
-	NAME		hash_method.o
-	SRC_PATH_NAME	$(PRJ_DIR)/../../hash/hash_method.c
-}
-
-Module hash_open.o {
-
-	NAME		hash_open.o
-	SRC_PATH_NAME	$(PRJ_DIR)/../../hash/hash_open.c
-}
-
-Module hash_page.o {
-
-	NAME		hash_page.o
-	SRC_PATH_NAME	$(PRJ_DIR)/../../hash/hash_page.c
-}
-
-Module hash_rec.o {
-
-	NAME		hash_rec.o
-	SRC_PATH_NAME	$(PRJ_DIR)/../../hash/hash_rec.c
-}
-
-Module hash_reclaim.o {
-
-	NAME		hash_reclaim.o
-	SRC_PATH_NAME	$(PRJ_DIR)/../../hash/hash_reclaim.c
-}
-
-Module hash_stat.o {
-
-	NAME		hash_stat.o
-	SRC_PATH_NAME	$(PRJ_DIR)/../../hash/hash_stat.c
-}
-
-Module hash_upgrade.o {
-
-	NAME		hash_upgrade.o
-	SRC_PATH_NAME	$(PRJ_DIR)/../../hash/hash_upgrade.c
-}
-
-Module hash_verify.o {
-
-	NAME		hash_verify.o
-	SRC_PATH_NAME	$(PRJ_DIR)/../../hash/hash_verify.c
-}
-
-Module hmac.o {
-
-	NAME		hmac.o
-	SRC_PATH_NAME	$(PRJ_DIR)/../../hmac/hmac.c
-}
-
-Module sha1.o {
-
-	NAME		sha1.o
-	SRC_PATH_NAME	$(PRJ_DIR)/../../hmac/sha1.c
-}
-
-Module hsearch.o {
-
-	NAME		hsearch.o
-	SRC_PATH_NAME	$(PRJ_DIR)/../../hsearch/hsearch.c
-}
-
-Module lock.o {
-
-	NAME		lock.o
-	SRC_PATH_NAME	$(PRJ_DIR)/../../lock/lock.c
-}
-
-Module lock_deadlock.o {
-
-	NAME		lock_deadlock.o
-	SRC_PATH_NAME	$(PRJ_DIR)/../../lock/lock_deadlock.c
-}
-
-Module lock_method.o {
-
-	NAME		lock_method.o
-	SRC_PATH_NAME	$(PRJ_DIR)/../../lock/lock_method.c
-}
-
-Module lock_region.o {
-
-	NAME		lock_region.o
-	SRC_PATH_NAME	$(PRJ_DIR)/../../lock/lock_region.c
-}
-
-Module lock_stat.o {
-
-	NAME		lock_stat.o
-	SRC_PATH_NAME	$(PRJ_DIR)/../../lock/lock_stat.c
-}
-
-Module lock_util.o {
-
-	NAME		lock_util.o
-	SRC_PATH_NAME	$(PRJ_DIR)/../../lock/lock_util.c
-}
-
-Module log.o {
-
-	NAME		log.o
-	SRC_PATH_NAME	$(PRJ_DIR)/../../log/log.c
-}
-
-Module log_archive.o {
-
-	NAME		log_archive.o
-	SRC_PATH_NAME	$(PRJ_DIR)/../../log/log_archive.c
-}
-
-Module log_compare.o {
-
-	NAME		log_compare.o
-	SRC_PATH_NAME	$(PRJ_DIR)/../../log/log_compare.c
-}
-
-Module log_get.o {
-
-	NAME		log_get.o
-	SRC_PATH_NAME	$(PRJ_DIR)/../../log/log_get.c
-}
-
-Module log_method.o {
-
-	NAME		log_method.o
-	SRC_PATH_NAME	$(PRJ_DIR)/../../log/log_method.c
-}
-
-Module log_put.o {
-
-	NAME		log_put.o
-	SRC_PATH_NAME	$(PRJ_DIR)/../../log/log_put.c
-}
-
-Module mp_alloc.o {
-
-	NAME		mp_alloc.o
-	SRC_PATH_NAME	$(PRJ_DIR)/../../mp/mp_alloc.c
-}
-
-Module mp_bh.o {
-
-	NAME		mp_bh.o
-	SRC_PATH_NAME	$(PRJ_DIR)/../../mp/mp_bh.c
-}
-
-Module mp_fget.o {
-
-	NAME		mp_fget.o
-	SRC_PATH_NAME	$(PRJ_DIR)/../../mp/mp_fget.c
-}
-
-Module mp_fopen.o {
-
-	NAME		mp_fopen.o
-	SRC_PATH_NAME	$(PRJ_DIR)/../../mp/mp_fopen.c
-}
-
-Module mp_fput.o {
-
-	NAME		mp_fput.o
-	SRC_PATH_NAME	$(PRJ_DIR)/../../mp/mp_fput.c
-}
-
-Module mp_fset.o {
-
-	NAME		mp_fset.o
-	SRC_PATH_NAME	$(PRJ_DIR)/../../mp/mp_fset.c
-}
-
-Module mp_method.o {
-
-	NAME		mp_method.o
-	SRC_PATH_NAME	$(PRJ_DIR)/../../mp/mp_method.c
-}
-
-Module mp_region.o {
-
-	NAME		mp_region.o
-	SRC_PATH_NAME	$(PRJ_DIR)/../../mp/mp_region.c
-}
-
-Module mp_register.o {
-
-	NAME		mp_register.o
-	SRC_PATH_NAME	$(PRJ_DIR)/../../mp/mp_register.c
-}
-
-Module mp_stat.o {
-
-	NAME		mp_stat.o
-	SRC_PATH_NAME	$(PRJ_DIR)/../../mp/mp_stat.c
-}
-
-Module mp_sync.o {
-
-	NAME		mp_sync.o
-	SRC_PATH_NAME	$(PRJ_DIR)/../../mp/mp_sync.c
-}
-
-Module mp_trickle.o {
-
-	NAME		mp_trickle.o
-	SRC_PATH_NAME	$(PRJ_DIR)/../../mp/mp_trickle.c
-}
-
-Module mut_tas.o {
-
-	NAME		mut_tas.o
-	SRC_PATH_NAME	$(PRJ_DIR)/../../mutex/mut_tas.c
-}
-
-Module mutex.o {
-
-	NAME		mutex.o
-	SRC_PATH_NAME	$(PRJ_DIR)/../../mutex/mutex.c
-}
-
-Module os_alloc.o {
-
-	NAME		os_alloc.o
-	SRC_PATH_NAME	$(PRJ_DIR)/../../os/os_alloc.c
-}
-
-Module os_clock.o {
-
-	NAME		os_clock.o
-	SRC_PATH_NAME	$(PRJ_DIR)/../../os/os_clock.c
-}
-
-Module os_dir.o {
-
-	NAME		os_dir.o
-	SRC_PATH_NAME	$(PRJ_DIR)/../../os/os_dir.c
-}
-
-Module os_errno.o {
-
-	NAME		os_errno.o
-	SRC_PATH_NAME	$(PRJ_DIR)/../../os/os_errno.c
-}
-
-Module os_fid.o {
-
-	NAME		os_fid.o
-	SRC_PATH_NAME	$(PRJ_DIR)/../../os/os_fid.c
-}
-
-Module os_fsync.o {
-
-	NAME		os_fsync.o
-	SRC_PATH_NAME	$(PRJ_DIR)/../../os/os_fsync.c
-}
-
-Module os_handle.o {
-
-	NAME		os_handle.o
-	SRC_PATH_NAME	$(PRJ_DIR)/../../os/os_handle.c
-}
-
-Module os_id.o {
-
-	NAME		os_id.o
-	SRC_PATH_NAME	$(PRJ_DIR)/../../os/os_id.c
-}
-
-Module os_method.o {
-
-	NAME		os_method.o
-	SRC_PATH_NAME	$(PRJ_DIR)/../../os/os_method.c
-}
-
-Module os_oflags.o {
-
-	NAME		os_oflags.o
-	SRC_PATH_NAME	$(PRJ_DIR)/../../os/os_oflags.c
-}
-
-Module os_open.o {
-
-	NAME		os_open.o
-	SRC_PATH_NAME	$(PRJ_DIR)/../../os/os_open.c
-}
-
-Module os_region.o {
-
-	NAME		os_region.o
-	SRC_PATH_NAME	$(PRJ_DIR)/../../os/os_region.c
-}
-
-Module os_rename.o {
-
-	NAME		os_rename.o
-	SRC_PATH_NAME	$(PRJ_DIR)/../../os/os_rename.c
-}
-
-Module os_root.o {
-
-	NAME		os_root.o
-	SRC_PATH_NAME	$(PRJ_DIR)/../../os/os_root.c
-}
-
-Module os_rpath.o {
-
-	NAME		os_rpath.o
-	SRC_PATH_NAME	$(PRJ_DIR)/../../os/os_rpath.c
-}
-
-Module os_rw.o {
-
-	NAME		os_rw.o
-	SRC_PATH_NAME	$(PRJ_DIR)/../../os/os_rw.c
-}
-
-Module os_seek.o {
-
-	NAME		os_seek.o
-	SRC_PATH_NAME	$(PRJ_DIR)/../../os/os_seek.c
-}
-
-Module os_sleep.o {
-
-	NAME		os_sleep.o
-	SRC_PATH_NAME	$(PRJ_DIR)/../../os/os_sleep.c
-}
-
-Module os_spin.o {
-
-	NAME		os_spin.o
-	SRC_PATH_NAME	$(PRJ_DIR)/../../os/os_spin.c
-}
-
-Module os_stat.o {
-
-	NAME		os_stat.o
-	SRC_PATH_NAME	$(PRJ_DIR)/../../os/os_stat.c
-}
-
-Module os_tmpdir.o {
-
-	NAME		os_tmpdir.o
-	SRC_PATH_NAME	$(PRJ_DIR)/../../os/os_tmpdir.c
-}
-
-Module os_unlink.o {
-
-	NAME		os_unlink.o
-	SRC_PATH_NAME	$(PRJ_DIR)/../../os/os_unlink.c
-}
-
-Module os_vx_abs.o {
-
-	NAME		os_vx_abs.o
-	SRC_PATH_NAME	$(PRJ_DIR)/../../os_vxworks/os_vx_abs.c
-}
-
-Module os_vx_config.o {
-
-	NAME		os_vx_config.o
-	SRC_PATH_NAME	$(PRJ_DIR)/../../os_vxworks/os_vx_config.c
-}
-
-Module os_vx_map.o {
-
-	NAME		os_vx_map.o
-	SRC_PATH_NAME	$(PRJ_DIR)/../../os_vxworks/os_vx_map.c
-}
-
-Module qam.o {
-
-	NAME		qam.o
-	SRC_PATH_NAME	$(PRJ_DIR)/../../qam/qam.c
-}
-
-Module qam_auto.o {
-
-	NAME		qam_auto.o
-	SRC_PATH_NAME	$(PRJ_DIR)/../../qam/qam_auto.c
-}
-
-Module qam_conv.o {
-
-	NAME		qam_conv.o
-	SRC_PATH_NAME	$(PRJ_DIR)/../../qam/qam_conv.c
-}
-
-Module qam_files.o {
-
-	NAME		qam_files.o
-	SRC_PATH_NAME	$(PRJ_DIR)/../../qam/qam_files.c
-}
-
-Module qam_method.o {
-
-	NAME		qam_method.o
-	SRC_PATH_NAME	$(PRJ_DIR)/../../qam/qam_method.c
-}
-
-Module qam_open.o {
-
-	NAME		qam_open.o
-	SRC_PATH_NAME	$(PRJ_DIR)/../../qam/qam_open.c
-}
-
-Module qam_rec.o {
-
-	NAME		qam_rec.o
-	SRC_PATH_NAME	$(PRJ_DIR)/../../qam/qam_rec.c
-}
-
-Module qam_stat.o {
-
-	NAME		qam_stat.o
-	SRC_PATH_NAME	$(PRJ_DIR)/../../qam/qam_stat.c
-}
-
-Module qam_upgrade.o {
-
-	NAME		qam_upgrade.o
-	SRC_PATH_NAME	$(PRJ_DIR)/../../qam/qam_upgrade.c
-}
-
-Module qam_verify.o {
-
-	NAME		qam_verify.o
-	SRC_PATH_NAME	$(PRJ_DIR)/../../qam/qam_verify.c
-}
-
-Module rep_method.o {
-
-	NAME		rep_method.o
-	SRC_PATH_NAME	$(PRJ_DIR)/../../rep/rep_method.c
-}
-
-Module rep_record.o {
-
-	NAME		rep_record.o
-	SRC_PATH_NAME	$(PRJ_DIR)/../../rep/rep_record.c
-}
-
-Module rep_region.o {
-
-	NAME		rep_region.o
-	SRC_PATH_NAME	$(PRJ_DIR)/../../rep/rep_region.c
-}
-
-Module rep_util.o {
-
-	NAME		rep_util.o
-	SRC_PATH_NAME	$(PRJ_DIR)/../../rep/rep_util.c
-}
-
-Module client.o {
-
-	NAME		client.o
-	SRC_PATH_NAME	$(PRJ_DIR)/../../rpc_client/client.c
-}
-
-Module db_server_clnt.o {
-
-	NAME		db_server_clnt.o
-	SRC_PATH_NAME	$(PRJ_DIR)/../../rpc_client/db_server_clnt.c
-}
-
-Module gen_client.o {
-
-	NAME		gen_client.o
-	SRC_PATH_NAME	$(PRJ_DIR)/../../rpc_client/gen_client.c
-}
-
-Module gen_client_ret.o {
-
-	NAME		gen_client_ret.o
-	SRC_PATH_NAME	$(PRJ_DIR)/../../rpc_client/gen_client_ret.c
-}
-
-Module db_server_xdr.o {
-
-	NAME		db_server_xdr.o
-	SRC_PATH_NAME	$(PRJ_DIR)/../../rpc_server/c/db_server_xdr.c
-}
-
-Module txn.o {
-
-	NAME		txn.o
-	SRC_PATH_NAME	$(PRJ_DIR)/../../txn/txn.c
-}
-
-Module txn_auto.o {
-
-	NAME		txn_auto.o
-	SRC_PATH_NAME	$(PRJ_DIR)/../../txn/txn_auto.c
-}
-
-Module txn_method.o {
-
-	NAME		txn_method.o
-	SRC_PATH_NAME	$(PRJ_DIR)/../../txn/txn_method.c
-}
-
-Module txn_rec.o {
-
-	NAME		txn_rec.o
-	SRC_PATH_NAME	$(PRJ_DIR)/../../txn/txn_rec.c
-}
-
-Module txn_recover.o {
-
-	NAME		txn_recover.o
-	SRC_PATH_NAME	$(PRJ_DIR)/../../txn/txn_recover.c
-}
-
-Module txn_region.o {
-
-	NAME		txn_region.o
-	SRC_PATH_NAME	$(PRJ_DIR)/../../txn/txn_region.c
-}
-
-Module txn_stat.o {
-
-	NAME		txn_stat.o
-	SRC_PATH_NAME	$(PRJ_DIR)/../../txn/txn_stat.c
-}
-
-Module txn_util.o {
-
-	NAME		txn_util.o
-	SRC_PATH_NAME	$(PRJ_DIR)/../../txn/txn_util.c
-}
-
-Module xa.o {
-
-	NAME		xa.o
-	SRC_PATH_NAME	$(PRJ_DIR)/../../xa/xa.c
-}
-
-Module xa_db.o {
-
-	NAME		xa_db.o
-	SRC_PATH_NAME	$(PRJ_DIR)/../../xa/xa_db.c
-}
-
-Module xa_map.o {
-
-	NAME		xa_map.o
-	SRC_PATH_NAME	$(PRJ_DIR)/../../xa/xa_map.c
-}
-
-/* Parameter information */
-
diff --git a/bdb/build_vxworks/BerkeleyDB/component.wpj b/bdb/build_vxworks/BerkeleyDB/component.wpj
deleted file mode 100755
index 3207bb293e89aa62e9f2528949cae01b6db33a4e..0000000000000000000000000000000000000000
--- a/bdb/build_vxworks/BerkeleyDB/component.wpj
+++ /dev/null
@@ -1,6764 +0,0 @@
-Document file - DO NOT EDIT
-
-<BEGIN> CORE_INFO_TYPE
-::prj_component
-<END>
-
-<BEGIN> CORE_INFO_VERSION
-AE1.0
-<END>
-
-<BEGIN> BUILD__CURRENT
-PENTIUM2gnu.debug
-<END>
-
-<BEGIN> BUILD_PENTIUM2gnu.debug_CURRENT_TARGET
-default
-<END>
-
-<BEGIN> BUILD_PENTIUM2gnu.debug_DEFAULTFORCPU
-0
-<END>
-
-<BEGIN> BUILD_PENTIUM2gnu.debug_FILE_$(PRJ_DIR)/../../btree/bt_compare.c_infoTags
-toolMacro objects
-<END>
-
-<BEGIN> BUILD_PENTIUM2gnu.debug_FILE_$(PRJ_DIR)/../../btree/bt_compare.c_objects
-bt_compare.o
-<END>
-
-<BEGIN> BUILD_PENTIUM2gnu.debug_FILE_$(PRJ_DIR)/../../btree/bt_compare.c_toolMacro
-CC
-<END>
-
-<BEGIN> BUILD_PENTIUM2gnu.debug_FILE_$(PRJ_DIR)/../../btree/bt_conv.c_infoTags
-toolMacro objects
-<END>
-
-<BEGIN> BUILD_PENTIUM2gnu.debug_FILE_$(PRJ_DIR)/../../btree/bt_conv.c_objects
-bt_conv.o
-<END>
-
-<BEGIN> BUILD_PENTIUM2gnu.debug_FILE_$(PRJ_DIR)/../../btree/bt_conv.c_toolMacro
-CC
-<END>
-
-<BEGIN> BUILD_PENTIUM2gnu.debug_FILE_$(PRJ_DIR)/../../btree/bt_curadj.c_infoTags
-toolMacro objects
-<END>
-
-<BEGIN> BUILD_PENTIUM2gnu.debug_FILE_$(PRJ_DIR)/../../btree/bt_curadj.c_objects
-bt_curadj.o
-<END>
-
-<BEGIN> BUILD_PENTIUM2gnu.debug_FILE_$(PRJ_DIR)/../../btree/bt_curadj.c_toolMacro
-CC
-<END>
-
-<BEGIN> BUILD_PENTIUM2gnu.debug_FILE_$(PRJ_DIR)/../../btree/bt_cursor.c_infoTags
-toolMacro objects
-<END>
-
-<BEGIN> BUILD_PENTIUM2gnu.debug_FILE_$(PRJ_DIR)/../../btree/bt_cursor.c_objects
-bt_cursor.o
-<END>
-
-<BEGIN> BUILD_PENTIUM2gnu.debug_FILE_$(PRJ_DIR)/../../btree/bt_cursor.c_toolMacro
-CC
-<END>
-
-<BEGIN> BUILD_PENTIUM2gnu.debug_FILE_$(PRJ_DIR)/../../btree/bt_delete.c_infoTags
-toolMacro objects
-<END>
-
-<BEGIN> BUILD_PENTIUM2gnu.debug_FILE_$(PRJ_DIR)/../../btree/bt_delete.c_objects
-bt_delete.o
-<END>
-
-<BEGIN> BUILD_PENTIUM2gnu.debug_FILE_$(PRJ_DIR)/../../btree/bt_delete.c_toolMacro
-CC
-<END>
-
-<BEGIN> BUILD_PENTIUM2gnu.debug_FILE_$(PRJ_DIR)/../../btree/bt_method.c_infoTags
-toolMacro objects
-<END>
-
-<BEGIN> BUILD_PENTIUM2gnu.debug_FILE_$(PRJ_DIR)/../../btree/bt_method.c_objects
-bt_method.o
-<END>
-
-<BEGIN> BUILD_PENTIUM2gnu.debug_FILE_$(PRJ_DIR)/../../btree/bt_method.c_toolMacro
-CC
-<END>
-
-<BEGIN> BUILD_PENTIUM2gnu.debug_FILE_$(PRJ_DIR)/../../btree/bt_open.c_infoTags
-toolMacro objects
-<END>
-
-<BEGIN> BUILD_PENTIUM2gnu.debug_FILE_$(PRJ_DIR)/../../btree/bt_open.c_objects
-bt_open.o
-<END>
-
-<BEGIN> BUILD_PENTIUM2gnu.debug_FILE_$(PRJ_DIR)/../../btree/bt_open.c_toolMacro
-CC
-<END>
-
-<BEGIN> BUILD_PENTIUM2gnu.debug_FILE_$(PRJ_DIR)/../../btree/bt_put.c_infoTags
-toolMacro objects
-<END>
-
-<BEGIN> BUILD_PENTIUM2gnu.debug_FILE_$(PRJ_DIR)/../../btree/bt_put.c_objects
-bt_put.o
-<END>
-
-<BEGIN> BUILD_PENTIUM2gnu.debug_FILE_$(PRJ_DIR)/../../btree/bt_put.c_toolMacro
-CC
-<END>
-
-<BEGIN> BUILD_PENTIUM2gnu.debug_FILE_$(PRJ_DIR)/../../btree/bt_rec.c_infoTags
-toolMacro objects
-<END>
-
-<BEGIN> BUILD_PENTIUM2gnu.debug_FILE_$(PRJ_DIR)/../../btree/bt_rec.c_objects
-bt_rec.o
-<END>
-
-<BEGIN> BUILD_PENTIUM2gnu.debug_FILE_$(PRJ_DIR)/../../btree/bt_rec.c_toolMacro
-CC
-<END>
-
-<BEGIN> BUILD_PENTIUM2gnu.debug_FILE_$(PRJ_DIR)/../../btree/bt_reclaim.c_infoTags
-toolMacro objects
-<END>
-
-<BEGIN> BUILD_PENTIUM2gnu.debug_FILE_$(PRJ_DIR)/../../btree/bt_reclaim.c_objects
-bt_reclaim.o
-<END>
-
-<BEGIN> BUILD_PENTIUM2gnu.debug_FILE_$(PRJ_DIR)/../../btree/bt_reclaim.c_toolMacro
-CC
-<END>
-
-<BEGIN> BUILD_PENTIUM2gnu.debug_FILE_$(PRJ_DIR)/../../btree/bt_recno.c_infoTags
-toolMacro objects
-<END>
-
-<BEGIN> BUILD_PENTIUM2gnu.debug_FILE_$(PRJ_DIR)/../../btree/bt_recno.c_objects
-bt_recno.o
-<END>
-
-<BEGIN> BUILD_PENTIUM2gnu.debug_FILE_$(PRJ_DIR)/../../btree/bt_recno.c_toolMacro
-CC
-<END>
-
-<BEGIN> BUILD_PENTIUM2gnu.debug_FILE_$(PRJ_DIR)/../../btree/bt_rsearch.c_infoTags
-toolMacro objects
-<END>
-
-<BEGIN> BUILD_PENTIUM2gnu.debug_FILE_$(PRJ_DIR)/../../btree/bt_rsearch.c_objects
-bt_rsearch.o
-<END>
-
-<BEGIN> BUILD_PENTIUM2gnu.debug_FILE_$(PRJ_DIR)/../../btree/bt_rsearch.c_toolMacro
-CC
-<END>
-
-<BEGIN> BUILD_PENTIUM2gnu.debug_FILE_$(PRJ_DIR)/../../btree/bt_search.c_infoTags
-toolMacro objects
-<END>
-
-<BEGIN> BUILD_PENTIUM2gnu.debug_FILE_$(PRJ_DIR)/../../btree/bt_search.c_objects
-bt_search.o
-<END>
-
-<BEGIN> BUILD_PENTIUM2gnu.debug_FILE_$(PRJ_DIR)/../../btree/bt_search.c_toolMacro
-CC
-<END>
-
-<BEGIN> BUILD_PENTIUM2gnu.debug_FILE_$(PRJ_DIR)/../../btree/bt_split.c_infoTags
-toolMacro objects
-<END>
-
-<BEGIN> BUILD_PENTIUM2gnu.debug_FILE_$(PRJ_DIR)/../../btree/bt_split.c_objects
-bt_split.o
-<END>
-
-<BEGIN> BUILD_PENTIUM2gnu.debug_FILE_$(PRJ_DIR)/../../btree/bt_split.c_toolMacro
-CC
-<END>
-
-<BEGIN> BUILD_PENTIUM2gnu.debug_FILE_$(PRJ_DIR)/../../btree/bt_stat.c_infoTags
-toolMacro objects
-<END>
-
-<BEGIN> BUILD_PENTIUM2gnu.debug_FILE_$(PRJ_DIR)/../../btree/bt_stat.c_objects
-bt_stat.o
-<END>
-
-<BEGIN> BUILD_PENTIUM2gnu.debug_FILE_$(PRJ_DIR)/../../btree/bt_stat.c_toolMacro
-CC
-<END>
-
-<BEGIN> BUILD_PENTIUM2gnu.debug_FILE_$(PRJ_DIR)/../../btree/bt_upgrade.c_infoTags
-toolMacro objects
-<END>
-
-<BEGIN> BUILD_PENTIUM2gnu.debug_FILE_$(PRJ_DIR)/../../btree/bt_upgrade.c_objects
-bt_upgrade.o
-<END>
-
-<BEGIN> BUILD_PENTIUM2gnu.debug_FILE_$(PRJ_DIR)/../../btree/bt_upgrade.c_toolMacro
-CC
-<END>
-
-<BEGIN> BUILD_PENTIUM2gnu.debug_FILE_$(PRJ_DIR)/../../btree/bt_verify.c_infoTags
-toolMacro objects
-<END>
-
-<BEGIN> BUILD_PENTIUM2gnu.debug_FILE_$(PRJ_DIR)/../../btree/bt_verify.c_objects
-bt_verify.o
-<END>
-
-<BEGIN> BUILD_PENTIUM2gnu.debug_FILE_$(PRJ_DIR)/../../btree/bt_verify.c_toolMacro
-CC
-<END>
-
-<BEGIN> BUILD_PENTIUM2gnu.debug_FILE_$(PRJ_DIR)/../../btree/btree_auto.c_infoTags
-toolMacro objects
-<END>
-
-<BEGIN> BUILD_PENTIUM2gnu.debug_FILE_$(PRJ_DIR)/../../btree/btree_auto.c_objects
-btree_auto.o
-<END>
-
-<BEGIN> BUILD_PENTIUM2gnu.debug_FILE_$(PRJ_DIR)/../../btree/btree_auto.c_toolMacro
-CC
-<END>
-
-<BEGIN> BUILD_PENTIUM2gnu.debug_FILE_$(PRJ_DIR)/../../clib/getopt.c_infoTags
-toolMacro objects
-<END>
-
-<BEGIN> BUILD_PENTIUM2gnu.debug_FILE_$(PRJ_DIR)/../../clib/getopt.c_objects
-getopt.o
-<END>
-
-<BEGIN> BUILD_PENTIUM2gnu.debug_FILE_$(PRJ_DIR)/../../clib/getopt.c_toolMacro
-CC
-<END>
-
-<BEGIN> BUILD_PENTIUM2gnu.debug_FILE_$(PRJ_DIR)/../../clib/snprintf.c_infoTags
-toolMacro objects
-<END>
-
-<BEGIN> BUILD_PENTIUM2gnu.debug_FILE_$(PRJ_DIR)/../../clib/snprintf.c_objects
-snprintf.o
-<END>
-
-<BEGIN> BUILD_PENTIUM2gnu.debug_FILE_$(PRJ_DIR)/../../clib/snprintf.c_toolMacro
-CC
-<END>
-
-<BEGIN> BUILD_PENTIUM2gnu.debug_FILE_$(PRJ_DIR)/../../clib/strcasecmp.c_infoTags
-toolMacro objects
-<END>
-
-<BEGIN> BUILD_PENTIUM2gnu.debug_FILE_$(PRJ_DIR)/../../clib/strcasecmp.c_objects
-strcasecmp.o
-<END>
-
-<BEGIN> BUILD_PENTIUM2gnu.debug_FILE_$(PRJ_DIR)/../../clib/strcasecmp.c_toolMacro
-CC
-<END>
-
-<BEGIN> BUILD_PENTIUM2gnu.debug_FILE_$(PRJ_DIR)/../../clib/strdup.c_infoTags
-toolMacro objects
-<END>
-
-<BEGIN> BUILD_PENTIUM2gnu.debug_FILE_$(PRJ_DIR)/../../clib/strdup.c_objects
-strdup.o
-<END>
-
-<BEGIN> BUILD_PENTIUM2gnu.debug_FILE_$(PRJ_DIR)/../../clib/strdup.c_toolMacro
-CC
-<END>
-
-<BEGIN> BUILD_PENTIUM2gnu.debug_FILE_$(PRJ_DIR)/../../clib/vsnprintf.c_infoTags
-toolMacro objects
-<END>
-
-<BEGIN> BUILD_PENTIUM2gnu.debug_FILE_$(PRJ_DIR)/../../clib/vsnprintf.c_objects
-vsnprintf.o
-<END>
-
-<BEGIN> BUILD_PENTIUM2gnu.debug_FILE_$(PRJ_DIR)/../../clib/vsnprintf.c_toolMacro
-CC
-<END>
-
-<BEGIN> BUILD_PENTIUM2gnu.debug_FILE_$(PRJ_DIR)/../../common/db_byteorder.c_infoTags
-toolMacro objects
-<END>
-
-<BEGIN> BUILD_PENTIUM2gnu.debug_FILE_$(PRJ_DIR)/../../common/db_byteorder.c_objects
-db_byteorder.o
-<END>
-
-<BEGIN> BUILD_PENTIUM2gnu.debug_FILE_$(PRJ_DIR)/../../common/db_byteorder.c_toolMacro
-CC
-<END>
-
-<BEGIN> BUILD_PENTIUM2gnu.debug_FILE_$(PRJ_DIR)/../../common/db_err.c_infoTags
-toolMacro objects
-<END>
-
-<BEGIN> BUILD_PENTIUM2gnu.debug_FILE_$(PRJ_DIR)/../../common/db_err.c_objects
-db_err.o
-<END>
-
-<BEGIN> BUILD_PENTIUM2gnu.debug_FILE_$(PRJ_DIR)/../../common/db_err.c_toolMacro
-CC
-<END>
-
-<BEGIN> BUILD_PENTIUM2gnu.debug_FILE_$(PRJ_DIR)/../../common/db_getlong.c_infoTags
-toolMacro objects
-<END>
-
-<BEGIN> BUILD_PENTIUM2gnu.debug_FILE_$(PRJ_DIR)/../../common/db_getlong.c_objects
-db_getlong.o
-<END>
-
-<BEGIN> BUILD_PENTIUM2gnu.debug_FILE_$(PRJ_DIR)/../../common/db_getlong.c_toolMacro
-CC
-<END>
-
-<BEGIN> BUILD_PENTIUM2gnu.debug_FILE_$(PRJ_DIR)/../../common/db_idspace.c_infoTags
-toolMacro objects
-<END>
-
-<BEGIN> BUILD_PENTIUM2gnu.debug_FILE_$(PRJ_DIR)/../../common/db_idspace.c_objects
-db_idspace.o
-<END>
-
-<BEGIN> BUILD_PENTIUM2gnu.debug_FILE_$(PRJ_DIR)/../../common/db_idspace.c_toolMacro
-CC
-<END>
-
-<BEGIN> BUILD_PENTIUM2gnu.debug_FILE_$(PRJ_DIR)/../../common/db_log2.c_infoTags
-toolMacro objects
-<END>
-
-<BEGIN> BUILD_PENTIUM2gnu.debug_FILE_$(PRJ_DIR)/../../common/db_log2.c_objects
-db_log2.o
-<END>
-
-<BEGIN> BUILD_PENTIUM2gnu.debug_FILE_$(PRJ_DIR)/../../common/db_log2.c_toolMacro
-CC
-<END>
-
-<BEGIN> BUILD_PENTIUM2gnu.debug_FILE_$(PRJ_DIR)/../../common/util_arg.c_infoTags
-toolMacro objects
-<END>
-
-<BEGIN> BUILD_PENTIUM2gnu.debug_FILE_$(PRJ_DIR)/../../common/util_arg.c_objects
-util_arg.o
-<END>
-
-<BEGIN> BUILD_PENTIUM2gnu.debug_FILE_$(PRJ_DIR)/../../common/util_arg.c_toolMacro
-CC
-<END>
-
-<BEGIN> BUILD_PENTIUM2gnu.debug_FILE_$(PRJ_DIR)/../../common/util_cache.c_infoTags
-toolMacro objects
-<END>
-
-<BEGIN> BUILD_PENTIUM2gnu.debug_FILE_$(PRJ_DIR)/../../common/util_cache.c_objects
-util_cache.o
-<END>
-
-<BEGIN> BUILD_PENTIUM2gnu.debug_FILE_$(PRJ_DIR)/../../common/util_cache.c_toolMacro
-CC
-<END>
-
-<BEGIN> BUILD_PENTIUM2gnu.debug_FILE_$(PRJ_DIR)/../../common/util_log.c_infoTags
-toolMacro objects
-<END>
-
-<BEGIN> BUILD_PENTIUM2gnu.debug_FILE_$(PRJ_DIR)/../../common/util_log.c_objects
-util_log.o
-<END>
-
-<BEGIN> BUILD_PENTIUM2gnu.debug_FILE_$(PRJ_DIR)/../../common/util_log.c_toolMacro
-CC
-<END>
-
-<BEGIN> BUILD_PENTIUM2gnu.debug_FILE_$(PRJ_DIR)/../../common/util_sig.c_infoTags
-toolMacro objects
-<END>
-
-<BEGIN> BUILD_PENTIUM2gnu.debug_FILE_$(PRJ_DIR)/../../common/util_sig.c_objects
-util_sig.o
-<END>
-
-<BEGIN> BUILD_PENTIUM2gnu.debug_FILE_$(PRJ_DIR)/../../common/util_sig.c_toolMacro
-CC
-<END>
-
-<BEGIN> BUILD_PENTIUM2gnu.debug_FILE_$(PRJ_DIR)/../../db/crdel_auto.c_infoTags
-toolMacro objects
-<END>
-
-<BEGIN> BUILD_PENTIUM2gnu.debug_FILE_$(PRJ_DIR)/../../db/crdel_auto.c_objects
-crdel_auto.o
-<END>
-
-<BEGIN> BUILD_PENTIUM2gnu.debug_FILE_$(PRJ_DIR)/../../db/crdel_auto.c_toolMacro
-CC
-<END>
-
-<BEGIN> BUILD_PENTIUM2gnu.debug_FILE_$(PRJ_DIR)/../../db/crdel_rec.c_infoTags
-toolMacro objects
-<END>
-
-<BEGIN> BUILD_PENTIUM2gnu.debug_FILE_$(PRJ_DIR)/../../db/crdel_rec.c_objects
-crdel_rec.o
-<END>
-
-<BEGIN> BUILD_PENTIUM2gnu.debug_FILE_$(PRJ_DIR)/../../db/crdel_rec.c_toolMacro
-CC
-<END>
-
-<BEGIN> BUILD_PENTIUM2gnu.debug_FILE_$(PRJ_DIR)/../../db/db.c_infoTags
-toolMacro objects
-<END>
-
-<BEGIN> BUILD_PENTIUM2gnu.debug_FILE_$(PRJ_DIR)/../../db/db.c_objects
-db.o
-<END>
-
-<BEGIN> BUILD_PENTIUM2gnu.debug_FILE_$(PRJ_DIR)/../../db/db.c_toolMacro
-CC
-<END>
-
-<BEGIN> BUILD_PENTIUM2gnu.debug_FILE_$(PRJ_DIR)/../../db/db_am.c_infoTags
-toolMacro objects
-<END>
-
-<BEGIN> BUILD_PENTIUM2gnu.debug_FILE_$(PRJ_DIR)/../../db/db_am.c_objects
-db_am.o
-<END>
-
-<BEGIN> BUILD_PENTIUM2gnu.debug_FILE_$(PRJ_DIR)/../../db/db_am.c_toolMacro
-CC
-<END>
-
-<BEGIN> BUILD_PENTIUM2gnu.debug_FILE_$(PRJ_DIR)/../../db/db_auto.c_infoTags
-toolMacro objects
-<END>
-
-<BEGIN> BUILD_PENTIUM2gnu.debug_FILE_$(PRJ_DIR)/../../db/db_auto.c_objects
-db_auto.o
-<END>
-
-<BEGIN> BUILD_PENTIUM2gnu.debug_FILE_$(PRJ_DIR)/../../db/db_auto.c_toolMacro
-CC
-<END>
-
-<BEGIN> BUILD_PENTIUM2gnu.debug_FILE_$(PRJ_DIR)/../../db/db_cam.c_infoTags
-toolMacro objects
-<END>
-
-<BEGIN> BUILD_PENTIUM2gnu.debug_FILE_$(PRJ_DIR)/../../db/db_cam.c_objects
-db_cam.o
-<END>
-
-<BEGIN> BUILD_PENTIUM2gnu.debug_FILE_$(PRJ_DIR)/../../db/db_cam.c_toolMacro
-CC
-<END>
-
-<BEGIN> BUILD_PENTIUM2gnu.debug_FILE_$(PRJ_DIR)/../../db/db_conv.c_infoTags
-toolMacro objects
-<END>
-
-<BEGIN> BUILD_PENTIUM2gnu.debug_FILE_$(PRJ_DIR)/../../db/db_conv.c_objects
-db_conv.o
-<END>
-
-<BEGIN> BUILD_PENTIUM2gnu.debug_FILE_$(PRJ_DIR)/../../db/db_conv.c_toolMacro
-CC
-<END>
-
-<BEGIN> BUILD_PENTIUM2gnu.debug_FILE_$(PRJ_DIR)/../../db/db_dispatch.c_infoTags
-toolMacro objects
-<END>
-
-<BEGIN> BUILD_PENTIUM2gnu.debug_FILE_$(PRJ_DIR)/../../db/db_dispatch.c_objects
-db_dispatch.o
-<END>
-
-<BEGIN> BUILD_PENTIUM2gnu.debug_FILE_$(PRJ_DIR)/../../db/db_dispatch.c_toolMacro
-CC
-<END>
-
-<BEGIN> BUILD_PENTIUM2gnu.debug_FILE_$(PRJ_DIR)/../../db/db_dup.c_infoTags
-toolMacro objects
-<END>
-
-<BEGIN> BUILD_PENTIUM2gnu.debug_FILE_$(PRJ_DIR)/../../db/db_dup.c_objects
-db_dup.o
-<END>
-
-<BEGIN> BUILD_PENTIUM2gnu.debug_FILE_$(PRJ_DIR)/../../db/db_dup.c_toolMacro
-CC
-<END>
-
-<BEGIN> BUILD_PENTIUM2gnu.debug_FILE_$(PRJ_DIR)/../../db/db_iface.c_infoTags
-toolMacro objects
-<END>
-
-<BEGIN> BUILD_PENTIUM2gnu.debug_FILE_$(PRJ_DIR)/../../db/db_iface.c_objects
-db_iface.o
-<END>
-
-<BEGIN> BUILD_PENTIUM2gnu.debug_FILE_$(PRJ_DIR)/../../db/db_iface.c_toolMacro
-CC
-<END>
-
-<BEGIN> BUILD_PENTIUM2gnu.debug_FILE_$(PRJ_DIR)/../../db/db_join.c_infoTags
-toolMacro objects
-<END>
-
-<BEGIN> BUILD_PENTIUM2gnu.debug_FILE_$(PRJ_DIR)/../../db/db_join.c_objects
-db_join.o
-<END>
-
-<BEGIN> BUILD_PENTIUM2gnu.debug_FILE_$(PRJ_DIR)/../../db/db_join.c_toolMacro
-CC
-<END>
-
-<BEGIN> BUILD_PENTIUM2gnu.debug_FILE_$(PRJ_DIR)/../../db/db_meta.c_infoTags
-toolMacro objects
-<END>
-
-<BEGIN> BUILD_PENTIUM2gnu.debug_FILE_$(PRJ_DIR)/../../db/db_meta.c_objects
-db_meta.o
-<END>
-
-<BEGIN> BUILD_PENTIUM2gnu.debug_FILE_$(PRJ_DIR)/../../db/db_meta.c_toolMacro
-CC
-<END>
-
-<BEGIN> BUILD_PENTIUM2gnu.debug_FILE_$(PRJ_DIR)/../../db/db_method.c_infoTags
-toolMacro objects
-<END>
-
-<BEGIN> BUILD_PENTIUM2gnu.debug_FILE_$(PRJ_DIR)/../../db/db_method.c_objects
-db_method.o
-<END>
-
-<BEGIN> BUILD_PENTIUM2gnu.debug_FILE_$(PRJ_DIR)/../../db/db_method.c_toolMacro
-CC
-<END>
-
-<BEGIN> BUILD_PENTIUM2gnu.debug_FILE_$(PRJ_DIR)/../../db/db_open.c_infoTags
-toolMacro objects
-<END>
-
-<BEGIN> BUILD_PENTIUM2gnu.debug_FILE_$(PRJ_DIR)/../../db/db_open.c_objects
-db_open.o
-<END>
-
-<BEGIN> BUILD_PENTIUM2gnu.debug_FILE_$(PRJ_DIR)/../../db/db_open.c_toolMacro
-CC
-<END>
-
-<BEGIN> BUILD_PENTIUM2gnu.debug_FILE_$(PRJ_DIR)/../../db/db_overflow.c_infoTags
-toolMacro objects
-<END>
-
-<BEGIN> BUILD_PENTIUM2gnu.debug_FILE_$(PRJ_DIR)/../../db/db_overflow.c_objects
-db_overflow.o
-<END>
-
-<BEGIN> BUILD_PENTIUM2gnu.debug_FILE_$(PRJ_DIR)/../../db/db_overflow.c_toolMacro
-CC
-<END>
-
-<BEGIN> BUILD_PENTIUM2gnu.debug_FILE_$(PRJ_DIR)/../../db/db_pr.c_infoTags
-toolMacro objects
-<END>
-
-<BEGIN> BUILD_PENTIUM2gnu.debug_FILE_$(PRJ_DIR)/../../db/db_pr.c_objects
-db_pr.o
-<END>
-
-<BEGIN> BUILD_PENTIUM2gnu.debug_FILE_$(PRJ_DIR)/../../db/db_pr.c_toolMacro
-CC
-<END>
-
-<BEGIN> BUILD_PENTIUM2gnu.debug_FILE_$(PRJ_DIR)/../../db/db_rec.c_infoTags
-toolMacro objects
-<END>
-
-<BEGIN> BUILD_PENTIUM2gnu.debug_FILE_$(PRJ_DIR)/../../db/db_rec.c_objects
-db_rec.o
-<END>
-
-<BEGIN> BUILD_PENTIUM2gnu.debug_FILE_$(PRJ_DIR)/../../db/db_rec.c_toolMacro
-CC
-<END>
-
-<BEGIN> BUILD_PENTIUM2gnu.debug_FILE_$(PRJ_DIR)/../../db/db_reclaim.c_infoTags
-toolMacro objects
-<END>
-
-<BEGIN> BUILD_PENTIUM2gnu.debug_FILE_$(PRJ_DIR)/../../db/db_reclaim.c_objects
-db_reclaim.o
-<END>
-
-<BEGIN> BUILD_PENTIUM2gnu.debug_FILE_$(PRJ_DIR)/../../db/db_reclaim.c_toolMacro
-CC
-<END>
-
-<BEGIN> BUILD_PENTIUM2gnu.debug_FILE_$(PRJ_DIR)/../../db/db_remove.c_infoTags
-toolMacro objects
-<END>
-
-<BEGIN> BUILD_PENTIUM2gnu.debug_FILE_$(PRJ_DIR)/../../db/db_remove.c_objects
-db_remove.o
-<END>
-
-<BEGIN> BUILD_PENTIUM2gnu.debug_FILE_$(PRJ_DIR)/../../db/db_remove.c_toolMacro
-CC
-<END>
-
-<BEGIN> BUILD_PENTIUM2gnu.debug_FILE_$(PRJ_DIR)/../../db/db_rename.c_infoTags
-toolMacro objects
-<END>
-
-<BEGIN> BUILD_PENTIUM2gnu.debug_FILE_$(PRJ_DIR)/../../db/db_rename.c_objects
-db_rename.o
-<END>
-
-<BEGIN> BUILD_PENTIUM2gnu.debug_FILE_$(PRJ_DIR)/../../db/db_rename.c_toolMacro
-CC
-<END>
-
-<BEGIN> BUILD_PENTIUM2gnu.debug_FILE_$(PRJ_DIR)/../../db/db_ret.c_infoTags
-toolMacro objects
-<END>
-
-<BEGIN> BUILD_PENTIUM2gnu.debug_FILE_$(PRJ_DIR)/../../db/db_ret.c_objects
-db_ret.o
-<END>
-
-<BEGIN> BUILD_PENTIUM2gnu.debug_FILE_$(PRJ_DIR)/../../db/db_ret.c_toolMacro
-CC
-<END>
-
-<BEGIN> BUILD_PENTIUM2gnu.debug_FILE_$(PRJ_DIR)/../../db/db_truncate.c_infoTags
-toolMacro objects
-<END>
-
-<BEGIN> BUILD_PENTIUM2gnu.debug_FILE_$(PRJ_DIR)/../../db/db_truncate.c_objects
-db_truncate.o
-<END>
-
-<BEGIN> BUILD_PENTIUM2gnu.debug_FILE_$(PRJ_DIR)/../../db/db_truncate.c_toolMacro
-CC
-<END>
-
-<BEGIN> BUILD_PENTIUM2gnu.debug_FILE_$(PRJ_DIR)/../../db/db_upg.c_infoTags
-toolMacro objects
-<END>
-
-<BEGIN> BUILD_PENTIUM2gnu.debug_FILE_$(PRJ_DIR)/../../db/db_upg.c_objects
-db_upg.o
-<END>
-
-<BEGIN> BUILD_PENTIUM2gnu.debug_FILE_$(PRJ_DIR)/../../db/db_upg.c_toolMacro
-CC
-<END>
-
-<BEGIN> BUILD_PENTIUM2gnu.debug_FILE_$(PRJ_DIR)/../../db/db_upg_opd.c_infoTags
-toolMacro objects
-<END>
-
-<BEGIN> BUILD_PENTIUM2gnu.debug_FILE_$(PRJ_DIR)/../../db/db_upg_opd.c_objects
-db_upg_opd.o
-<END>
-
-<BEGIN> BUILD_PENTIUM2gnu.debug_FILE_$(PRJ_DIR)/../../db/db_upg_opd.c_toolMacro
-CC
-<END>
-
-<BEGIN> BUILD_PENTIUM2gnu.debug_FILE_$(PRJ_DIR)/../../db/db_vrfy.c_infoTags
-toolMacro objects
-<END>
-
-<BEGIN> BUILD_PENTIUM2gnu.debug_FILE_$(PRJ_DIR)/../../db/db_vrfy.c_objects
-db_vrfy.o
-<END>
-
-<BEGIN> BUILD_PENTIUM2gnu.debug_FILE_$(PRJ_DIR)/../../db/db_vrfy.c_toolMacro
-CC
-<END>
-
-<BEGIN> BUILD_PENTIUM2gnu.debug_FILE_$(PRJ_DIR)/../../db/db_vrfyutil.c_infoTags
-toolMacro objects
-<END>
-
-<BEGIN> BUILD_PENTIUM2gnu.debug_FILE_$(PRJ_DIR)/../../db/db_vrfyutil.c_objects
-db_vrfyutil.o
-<END>
-
-<BEGIN> BUILD_PENTIUM2gnu.debug_FILE_$(PRJ_DIR)/../../db/db_vrfyutil.c_toolMacro
-CC
-<END>
-
-<BEGIN> BUILD_PENTIUM2gnu.debug_FILE_$(PRJ_DIR)/../../dbreg/dbreg.c_infoTags
-toolMacro objects
-<END>
-
-<BEGIN> BUILD_PENTIUM2gnu.debug_FILE_$(PRJ_DIR)/../../dbreg/dbreg.c_objects
-dbreg.o
-<END>
-
-<BEGIN> BUILD_PENTIUM2gnu.debug_FILE_$(PRJ_DIR)/../../dbreg/dbreg.c_toolMacro
-CC
-<END>
-
-<BEGIN> BUILD_PENTIUM2gnu.debug_FILE_$(PRJ_DIR)/../../dbreg/dbreg_auto.c_infoTags
-toolMacro objects
-<END>
-
-<BEGIN> BUILD_PENTIUM2gnu.debug_FILE_$(PRJ_DIR)/../../dbreg/dbreg_auto.c_objects
-dbreg_auto.o
-<END>
-
-<BEGIN> BUILD_PENTIUM2gnu.debug_FILE_$(PRJ_DIR)/../../dbreg/dbreg_auto.c_toolMacro
-CC
-<END>
-
-<BEGIN> BUILD_PENTIUM2gnu.debug_FILE_$(PRJ_DIR)/../../dbreg/dbreg_rec.c_infoTags
-toolMacro objects
-<END>
-
-<BEGIN> BUILD_PENTIUM2gnu.debug_FILE_$(PRJ_DIR)/../../dbreg/dbreg_rec.c_objects
-dbreg_rec.o
-<END>
-
-<BEGIN> BUILD_PENTIUM2gnu.debug_FILE_$(PRJ_DIR)/../../dbreg/dbreg_rec.c_toolMacro
-CC
-<END>
-
-<BEGIN> BUILD_PENTIUM2gnu.debug_FILE_$(PRJ_DIR)/../../dbreg/dbreg_util.c_infoTags
-toolMacro objects
-<END>
-
-<BEGIN> BUILD_PENTIUM2gnu.debug_FILE_$(PRJ_DIR)/../../dbreg/dbreg_util.c_objects
-dbreg_util.o
-<END>
-
-<BEGIN> BUILD_PENTIUM2gnu.debug_FILE_$(PRJ_DIR)/../../dbreg/dbreg_util.c_toolMacro
-CC
-<END>
-
-<BEGIN> BUILD_PENTIUM2gnu.debug_FILE_$(PRJ_DIR)/../../env/db_salloc.c_infoTags
-toolMacro objects
-<END>
-
-<BEGIN> BUILD_PENTIUM2gnu.debug_FILE_$(PRJ_DIR)/../../env/db_salloc.c_objects
-db_salloc.o
-<END>
-
-<BEGIN> BUILD_PENTIUM2gnu.debug_FILE_$(PRJ_DIR)/../../env/db_salloc.c_toolMacro
-CC
-<END>
-
-<BEGIN> BUILD_PENTIUM2gnu.debug_FILE_$(PRJ_DIR)/../../env/db_shash.c_infoTags
-toolMacro objects
-<END>
-
-<BEGIN> BUILD_PENTIUM2gnu.debug_FILE_$(PRJ_DIR)/../../env/db_shash.c_objects
-db_shash.o
-<END>
-
-<BEGIN> BUILD_PENTIUM2gnu.debug_FILE_$(PRJ_DIR)/../../env/db_shash.c_toolMacro
-CC
-<END>
-
-<BEGIN> BUILD_PENTIUM2gnu.debug_FILE_$(PRJ_DIR)/../../env/env_file.c_infoTags
-toolMacro objects
-<END>
-
-<BEGIN> BUILD_PENTIUM2gnu.debug_FILE_$(PRJ_DIR)/../../env/env_file.c_objects
-env_file.o
-<END>
-
-<BEGIN> BUILD_PENTIUM2gnu.debug_FILE_$(PRJ_DIR)/../../env/env_file.c_toolMacro
-CC
-<END>
-
-<BEGIN> BUILD_PENTIUM2gnu.debug_FILE_$(PRJ_DIR)/../../env/env_method.c_infoTags
-toolMacro objects
-<END>
-
-<BEGIN> BUILD_PENTIUM2gnu.debug_FILE_$(PRJ_DIR)/../../env/env_method.c_objects
-env_method.o
-<END>
-
-<BEGIN> BUILD_PENTIUM2gnu.debug_FILE_$(PRJ_DIR)/../../env/env_method.c_toolMacro
-CC
-<END>
-
-<BEGIN> BUILD_PENTIUM2gnu.debug_FILE_$(PRJ_DIR)/../../env/env_open.c_infoTags
-toolMacro objects
-<END>
-
-<BEGIN> BUILD_PENTIUM2gnu.debug_FILE_$(PRJ_DIR)/../../env/env_open.c_objects
-env_open.o
-<END>
-
-<BEGIN> BUILD_PENTIUM2gnu.debug_FILE_$(PRJ_DIR)/../../env/env_open.c_toolMacro
-CC
-<END>
-
-<BEGIN> BUILD_PENTIUM2gnu.debug_FILE_$(PRJ_DIR)/../../env/env_recover.c_infoTags
-toolMacro objects
-<END>
-
-<BEGIN> BUILD_PENTIUM2gnu.debug_FILE_$(PRJ_DIR)/../../env/env_recover.c_objects
-env_recover.o
-<END>
-
-<BEGIN> BUILD_PENTIUM2gnu.debug_FILE_$(PRJ_DIR)/../../env/env_recover.c_toolMacro
-CC
-<END>
-
-<BEGIN> BUILD_PENTIUM2gnu.debug_FILE_$(PRJ_DIR)/../../env/env_region.c_infoTags
-toolMacro objects
-<END>
-
-<BEGIN> BUILD_PENTIUM2gnu.debug_FILE_$(PRJ_DIR)/../../env/env_region.c_objects
-env_region.o
-<END>
-
-<BEGIN> BUILD_PENTIUM2gnu.debug_FILE_$(PRJ_DIR)/../../env/env_region.c_toolMacro
-CC
-<END>
-
-<BEGIN> BUILD_PENTIUM2gnu.debug_FILE_$(PRJ_DIR)/../../fileops/fileops_auto.c_infoTags
-toolMacro objects
-<END>
-
-<BEGIN> BUILD_PENTIUM2gnu.debug_FILE_$(PRJ_DIR)/../../fileops/fileops_auto.c_objects
-fileops_auto.o
-<END>
-
-<BEGIN> BUILD_PENTIUM2gnu.debug_FILE_$(PRJ_DIR)/../../fileops/fileops_auto.c_toolMacro
-CC
-<END>
-
-<BEGIN> BUILD_PENTIUM2gnu.debug_FILE_$(PRJ_DIR)/../../fileops/fop_basic.c_infoTags
-toolMacro objects
-<END>
-
-<BEGIN> BUILD_PENTIUM2gnu.debug_FILE_$(PRJ_DIR)/../../fileops/fop_basic.c_objects
-fop_basic.o
-<END>
-
-<BEGIN> BUILD_PENTIUM2gnu.debug_FILE_$(PRJ_DIR)/../../fileops/fop_basic.c_toolMacro
-CC
-<END>
-
-<BEGIN> BUILD_PENTIUM2gnu.debug_FILE_$(PRJ_DIR)/../../fileops/fop_rec.c_infoTags
-toolMacro objects
-<END>
-
-<BEGIN> BUILD_PENTIUM2gnu.debug_FILE_$(PRJ_DIR)/../../fileops/fop_rec.c_objects
-fop_rec.o
-<END>
-
-<BEGIN> BUILD_PENTIUM2gnu.debug_FILE_$(PRJ_DIR)/../../fileops/fop_rec.c_toolMacro
-CC
-<END>
-
-<BEGIN> BUILD_PENTIUM2gnu.debug_FILE_$(PRJ_DIR)/../../fileops/fop_util.c_infoTags
-toolMacro objects
-<END>
-
-<BEGIN> BUILD_PENTIUM2gnu.debug_FILE_$(PRJ_DIR)/../../fileops/fop_util.c_objects
-fop_util.o
-<END>
-
-<BEGIN> BUILD_PENTIUM2gnu.debug_FILE_$(PRJ_DIR)/../../fileops/fop_util.c_toolMacro
-CC
-<END>
-
-<BEGIN> BUILD_PENTIUM2gnu.debug_FILE_$(PRJ_DIR)/../../hash/hash.c_infoTags
-toolMacro objects
-<END>
-
-<BEGIN> BUILD_PENTIUM2gnu.debug_FILE_$(PRJ_DIR)/../../hash/hash.c_objects
-hash.o
-<END>
-
-<BEGIN> BUILD_PENTIUM2gnu.debug_FILE_$(PRJ_DIR)/../../hash/hash.c_toolMacro
-CC
-<END>
-
-<BEGIN> BUILD_PENTIUM2gnu.debug_FILE_$(PRJ_DIR)/../../hash/hash_auto.c_infoTags
-toolMacro objects
-<END>
-
-<BEGIN> BUILD_PENTIUM2gnu.debug_FILE_$(PRJ_DIR)/../../hash/hash_auto.c_objects
-hash_auto.o
-<END>
-
-<BEGIN> BUILD_PENTIUM2gnu.debug_FILE_$(PRJ_DIR)/../../hash/hash_auto.c_toolMacro
-CC
-<END>
-
-<BEGIN> BUILD_PENTIUM2gnu.debug_FILE_$(PRJ_DIR)/../../hash/hash_conv.c_infoTags
-toolMacro objects
-<END>
-
-<BEGIN> BUILD_PENTIUM2gnu.debug_FILE_$(PRJ_DIR)/../../hash/hash_conv.c_objects
-hash_conv.o
-<END>
-
-<BEGIN> BUILD_PENTIUM2gnu.debug_FILE_$(PRJ_DIR)/../../hash/hash_conv.c_toolMacro
-CC
-<END>
-
-<BEGIN> BUILD_PENTIUM2gnu.debug_FILE_$(PRJ_DIR)/../../hash/hash_dup.c_infoTags
-toolMacro objects
-<END>
-
-<BEGIN> BUILD_PENTIUM2gnu.debug_FILE_$(PRJ_DIR)/../../hash/hash_dup.c_objects
-hash_dup.o
-<END>
-
-<BEGIN> BUILD_PENTIUM2gnu.debug_FILE_$(PRJ_DIR)/../../hash/hash_dup.c_toolMacro
-CC
-<END>
-
-<BEGIN> BUILD_PENTIUM2gnu.debug_FILE_$(PRJ_DIR)/../../hash/hash_func.c_infoTags
-toolMacro objects
-<END>
-
-<BEGIN> BUILD_PENTIUM2gnu.debug_FILE_$(PRJ_DIR)/../../hash/hash_func.c_objects
-hash_func.o
-<END>
-
-<BEGIN> BUILD_PENTIUM2gnu.debug_FILE_$(PRJ_DIR)/../../hash/hash_func.c_toolMacro
-CC
-<END>
-
-<BEGIN> BUILD_PENTIUM2gnu.debug_FILE_$(PRJ_DIR)/../../hash/hash_meta.c_infoTags
-toolMacro objects
-<END>
-
-<BEGIN> BUILD_PENTIUM2gnu.debug_FILE_$(PRJ_DIR)/../../hash/hash_meta.c_objects
-hash_meta.o
-<END>
-
-<BEGIN> BUILD_PENTIUM2gnu.debug_FILE_$(PRJ_DIR)/../../hash/hash_meta.c_toolMacro
-CC
-<END>
-
-<BEGIN> BUILD_PENTIUM2gnu.debug_FILE_$(PRJ_DIR)/../../hash/hash_method.c_infoTags
-toolMacro objects
-<END>
-
-<BEGIN> BUILD_PENTIUM2gnu.debug_FILE_$(PRJ_DIR)/../../hash/hash_method.c_objects
-hash_method.o
-<END>
-
-<BEGIN> BUILD_PENTIUM2gnu.debug_FILE_$(PRJ_DIR)/../../hash/hash_method.c_toolMacro
-CC
-<END>
-
-<BEGIN> BUILD_PENTIUM2gnu.debug_FILE_$(PRJ_DIR)/../../hash/hash_open.c_infoTags
-toolMacro objects
-<END>
-
-<BEGIN> BUILD_PENTIUM2gnu.debug_FILE_$(PRJ_DIR)/../../hash/hash_open.c_objects
-hash_open.o
-<END>
-
-<BEGIN> BUILD_PENTIUM2gnu.debug_FILE_$(PRJ_DIR)/../../hash/hash_open.c_toolMacro
-CC
-<END>
-
-<BEGIN> BUILD_PENTIUM2gnu.debug_FILE_$(PRJ_DIR)/../../hash/hash_page.c_infoTags
-toolMacro objects
-<END>
-
-<BEGIN> BUILD_PENTIUM2gnu.debug_FILE_$(PRJ_DIR)/../../hash/hash_page.c_objects
-hash_page.o
-<END>
-
-<BEGIN> BUILD_PENTIUM2gnu.debug_FILE_$(PRJ_DIR)/../../hash/hash_page.c_toolMacro
-CC
-<END>
-
-<BEGIN> BUILD_PENTIUM2gnu.debug_FILE_$(PRJ_DIR)/../../hash/hash_rec.c_infoTags
-toolMacro objects
-<END>
-
-<BEGIN> BUILD_PENTIUM2gnu.debug_FILE_$(PRJ_DIR)/../../hash/hash_rec.c_objects
-hash_rec.o
-<END>
-
-<BEGIN> BUILD_PENTIUM2gnu.debug_FILE_$(PRJ_DIR)/../../hash/hash_rec.c_toolMacro
-CC
-<END>
-
-<BEGIN> BUILD_PENTIUM2gnu.debug_FILE_$(PRJ_DIR)/../../hash/hash_reclaim.c_infoTags
-toolMacro objects
-<END>
-
-<BEGIN> BUILD_PENTIUM2gnu.debug_FILE_$(PRJ_DIR)/../../hash/hash_reclaim.c_objects
-hash_reclaim.o
-<END>
-
-<BEGIN> BUILD_PENTIUM2gnu.debug_FILE_$(PRJ_DIR)/../../hash/hash_reclaim.c_toolMacro
-CC
-<END>
-
-<BEGIN> BUILD_PENTIUM2gnu.debug_FILE_$(PRJ_DIR)/../../hash/hash_stat.c_infoTags
-toolMacro objects
-<END>
-
-<BEGIN> BUILD_PENTIUM2gnu.debug_FILE_$(PRJ_DIR)/../../hash/hash_stat.c_objects
-hash_stat.o
-<END>
-
-<BEGIN> BUILD_PENTIUM2gnu.debug_FILE_$(PRJ_DIR)/../../hash/hash_stat.c_toolMacro
-CC
-<END>
-
-<BEGIN> BUILD_PENTIUM2gnu.debug_FILE_$(PRJ_DIR)/../../hash/hash_upgrade.c_infoTags
-toolMacro objects
-<END>
-
-<BEGIN> BUILD_PENTIUM2gnu.debug_FILE_$(PRJ_DIR)/../../hash/hash_upgrade.c_objects
-hash_upgrade.o
-<END>
-
-<BEGIN> BUILD_PENTIUM2gnu.debug_FILE_$(PRJ_DIR)/../../hash/hash_upgrade.c_toolMacro
-CC
-<END>
-
-<BEGIN> BUILD_PENTIUM2gnu.debug_FILE_$(PRJ_DIR)/../../hash/hash_verify.c_infoTags
-toolMacro objects
-<END>
-
-<BEGIN> BUILD_PENTIUM2gnu.debug_FILE_$(PRJ_DIR)/../../hash/hash_verify.c_objects
-hash_verify.o
-<END>
-
-<BEGIN> BUILD_PENTIUM2gnu.debug_FILE_$(PRJ_DIR)/../../hash/hash_verify.c_toolMacro
-CC
-<END>
-
-<BEGIN> BUILD_PENTIUM2gnu.debug_FILE_$(PRJ_DIR)/../../hmac/hmac.c_infoTags
-toolMacro objects
-<END>
-
-<BEGIN> BUILD_PENTIUM2gnu.debug_FILE_$(PRJ_DIR)/../../hmac/hmac.c_objects
-hmac.o
-<END>
-
-<BEGIN> BUILD_PENTIUM2gnu.debug_FILE_$(PRJ_DIR)/../../hmac/hmac.c_toolMacro
-CC
-<END>
-
-<BEGIN> BUILD_PENTIUM2gnu.debug_FILE_$(PRJ_DIR)/../../hmac/sha1.c_infoTags
-toolMacro objects
-<END>
-
-<BEGIN> BUILD_PENTIUM2gnu.debug_FILE_$(PRJ_DIR)/../../hmac/sha1.c_objects
-sha1.o
-<END>
-
-<BEGIN> BUILD_PENTIUM2gnu.debug_FILE_$(PRJ_DIR)/../../hmac/sha1.c_toolMacro
-CC
-<END>
-
-<BEGIN> BUILD_PENTIUM2gnu.debug_FILE_$(PRJ_DIR)/../../hsearch/hsearch.c_infoTags
-toolMacro objects
-<END>
-
-<BEGIN> BUILD_PENTIUM2gnu.debug_FILE_$(PRJ_DIR)/../../hsearch/hsearch.c_objects
-hsearch.o
-<END>
-
-<BEGIN> BUILD_PENTIUM2gnu.debug_FILE_$(PRJ_DIR)/../../hsearch/hsearch.c_toolMacro
-CC
-<END>
-
-<BEGIN> BUILD_PENTIUM2gnu.debug_FILE_$(PRJ_DIR)/../../lock/lock.c_infoTags
-toolMacro objects
-<END>
-
-<BEGIN> BUILD_PENTIUM2gnu.debug_FILE_$(PRJ_DIR)/../../lock/lock.c_objects
-lock.o
-<END>
-
-<BEGIN> BUILD_PENTIUM2gnu.debug_FILE_$(PRJ_DIR)/../../lock/lock.c_toolMacro
-CC
-<END>
-
-<BEGIN> BUILD_PENTIUM2gnu.debug_FILE_$(PRJ_DIR)/../../lock/lock_deadlock.c_infoTags
-toolMacro objects
-<END>
-
-<BEGIN> BUILD_PENTIUM2gnu.debug_FILE_$(PRJ_DIR)/../../lock/lock_deadlock.c_objects
-lock_deadlock.o
-<END>
-
-<BEGIN> BUILD_PENTIUM2gnu.debug_FILE_$(PRJ_DIR)/../../lock/lock_deadlock.c_toolMacro
-CC
-<END>
-
-<BEGIN> BUILD_PENTIUM2gnu.debug_FILE_$(PRJ_DIR)/../../lock/lock_method.c_infoTags
-toolMacro objects
-<END>
-
-<BEGIN> BUILD_PENTIUM2gnu.debug_FILE_$(PRJ_DIR)/../../lock/lock_method.c_objects
-lock_method.o
-<END>
-
-<BEGIN> BUILD_PENTIUM2gnu.debug_FILE_$(PRJ_DIR)/../../lock/lock_method.c_toolMacro
-CC
-<END>
-
-<BEGIN> BUILD_PENTIUM2gnu.debug_FILE_$(PRJ_DIR)/../../lock/lock_region.c_infoTags
-toolMacro objects
-<END>
-
-<BEGIN> BUILD_PENTIUM2gnu.debug_FILE_$(PRJ_DIR)/../../lock/lock_region.c_objects
-lock_region.o
-<END>
-
-<BEGIN> BUILD_PENTIUM2gnu.debug_FILE_$(PRJ_DIR)/../../lock/lock_region.c_toolMacro
-CC
-<END>
-
-<BEGIN> BUILD_PENTIUM2gnu.debug_FILE_$(PRJ_DIR)/../../lock/lock_stat.c_infoTags
-toolMacro objects
-<END>
-
-<BEGIN> BUILD_PENTIUM2gnu.debug_FILE_$(PRJ_DIR)/../../lock/lock_stat.c_objects
-lock_stat.o
-<END>
-
-<BEGIN> BUILD_PENTIUM2gnu.debug_FILE_$(PRJ_DIR)/../../lock/lock_stat.c_toolMacro
-CC
-<END>
-
-<BEGIN> BUILD_PENTIUM2gnu.debug_FILE_$(PRJ_DIR)/../../lock/lock_util.c_infoTags
-toolMacro objects
-<END>
-
-<BEGIN> BUILD_PENTIUM2gnu.debug_FILE_$(PRJ_DIR)/../../lock/lock_util.c_objects
-lock_util.o
-<END>
-
-<BEGIN> BUILD_PENTIUM2gnu.debug_FILE_$(PRJ_DIR)/../../lock/lock_util.c_toolMacro
-CC
-<END>
-
-<BEGIN> BUILD_PENTIUM2gnu.debug_FILE_$(PRJ_DIR)/../../log/log.c_infoTags
-toolMacro objects
-<END>
-
-<BEGIN> BUILD_PENTIUM2gnu.debug_FILE_$(PRJ_DIR)/../../log/log.c_objects
-log.o
-<END>
-
-<BEGIN> BUILD_PENTIUM2gnu.debug_FILE_$(PRJ_DIR)/../../log/log.c_toolMacro
-CC
-<END>
-
-<BEGIN> BUILD_PENTIUM2gnu.debug_FILE_$(PRJ_DIR)/../../log/log_archive.c_infoTags
-toolMacro objects
-<END>
-
-<BEGIN> BUILD_PENTIUM2gnu.debug_FILE_$(PRJ_DIR)/../../log/log_archive.c_objects
-log_archive.o
-<END>
-
-<BEGIN> BUILD_PENTIUM2gnu.debug_FILE_$(PRJ_DIR)/../../log/log_archive.c_toolMacro
-CC
-<END>
-
-<BEGIN> BUILD_PENTIUM2gnu.debug_FILE_$(PRJ_DIR)/../../log/log_compare.c_infoTags
-toolMacro objects
-<END>
-
-<BEGIN> BUILD_PENTIUM2gnu.debug_FILE_$(PRJ_DIR)/../../log/log_compare.c_objects
-log_compare.o
-<END>
-
-<BEGIN> BUILD_PENTIUM2gnu.debug_FILE_$(PRJ_DIR)/../../log/log_compare.c_toolMacro
-CC
-<END>
-
-<BEGIN> BUILD_PENTIUM2gnu.debug_FILE_$(PRJ_DIR)/../../log/log_get.c_infoTags
-toolMacro objects
-<END>
-
-<BEGIN> BUILD_PENTIUM2gnu.debug_FILE_$(PRJ_DIR)/../../log/log_get.c_objects
-log_get.o
-<END>
-
-<BEGIN> BUILD_PENTIUM2gnu.debug_FILE_$(PRJ_DIR)/../../log/log_get.c_toolMacro
-CC
-<END>
-
-<BEGIN> BUILD_PENTIUM2gnu.debug_FILE_$(PRJ_DIR)/../../log/log_method.c_infoTags
-toolMacro objects
-<END>
-
-<BEGIN> BUILD_PENTIUM2gnu.debug_FILE_$(PRJ_DIR)/../../log/log_method.c_objects
-log_method.o
-<END>
-
-<BEGIN> BUILD_PENTIUM2gnu.debug_FILE_$(PRJ_DIR)/../../log/log_method.c_toolMacro
-CC
-<END>
-
-<BEGIN> BUILD_PENTIUM2gnu.debug_FILE_$(PRJ_DIR)/../../log/log_put.c_infoTags
-toolMacro objects
-<END>
-
-<BEGIN> BUILD_PENTIUM2gnu.debug_FILE_$(PRJ_DIR)/../../log/log_put.c_objects
-log_put.o
-<END>
-
-<BEGIN> BUILD_PENTIUM2gnu.debug_FILE_$(PRJ_DIR)/../../log/log_put.c_toolMacro
-CC
-<END>
-
-<BEGIN> BUILD_PENTIUM2gnu.debug_FILE_$(PRJ_DIR)/../../mp/mp_alloc.c_infoTags
-toolMacro objects
-<END>
-
-<BEGIN> BUILD_PENTIUM2gnu.debug_FILE_$(PRJ_DIR)/../../mp/mp_alloc.c_objects
-mp_alloc.o
-<END>
-
-<BEGIN> BUILD_PENTIUM2gnu.debug_FILE_$(PRJ_DIR)/../../mp/mp_alloc.c_toolMacro
-CC
-<END>
-
-<BEGIN> BUILD_PENTIUM2gnu.debug_FILE_$(PRJ_DIR)/../../mp/mp_bh.c_infoTags
-toolMacro objects
-<END>
-
-<BEGIN> BUILD_PENTIUM2gnu.debug_FILE_$(PRJ_DIR)/../../mp/mp_bh.c_objects
-mp_bh.o
-<END>
-
-<BEGIN> BUILD_PENTIUM2gnu.debug_FILE_$(PRJ_DIR)/../../mp/mp_bh.c_toolMacro
-CC
-<END>
-
-<BEGIN> BUILD_PENTIUM2gnu.debug_FILE_$(PRJ_DIR)/../../mp/mp_fget.c_infoTags
-toolMacro objects
-<END>
-
-<BEGIN> BUILD_PENTIUM2gnu.debug_FILE_$(PRJ_DIR)/../../mp/mp_fget.c_objects
-mp_fget.o
-<END>
-
-<BEGIN> BUILD_PENTIUM2gnu.debug_FILE_$(PRJ_DIR)/../../mp/mp_fget.c_toolMacro
-CC
-<END>
-
-<BEGIN> BUILD_PENTIUM2gnu.debug_FILE_$(PRJ_DIR)/../../mp/mp_fopen.c_infoTags
-toolMacro objects
-<END>
-
-<BEGIN> BUILD_PENTIUM2gnu.debug_FILE_$(PRJ_DIR)/../../mp/mp_fopen.c_objects
-mp_fopen.o
-<END>
-
-<BEGIN> BUILD_PENTIUM2gnu.debug_FILE_$(PRJ_DIR)/../../mp/mp_fopen.c_toolMacro
-CC
-<END>
-
-<BEGIN> BUILD_PENTIUM2gnu.debug_FILE_$(PRJ_DIR)/../../mp/mp_fput.c_infoTags
-toolMacro objects
-<END>
-
-<BEGIN> BUILD_PENTIUM2gnu.debug_FILE_$(PRJ_DIR)/../../mp/mp_fput.c_objects
-mp_fput.o
-<END>
-
-<BEGIN> BUILD_PENTIUM2gnu.debug_FILE_$(PRJ_DIR)/../../mp/mp_fput.c_toolMacro
-CC
-<END>
-
-<BEGIN> BUILD_PENTIUM2gnu.debug_FILE_$(PRJ_DIR)/../../mp/mp_fset.c_infoTags
-toolMacro objects
-<END>
-
-<BEGIN> BUILD_PENTIUM2gnu.debug_FILE_$(PRJ_DIR)/../../mp/mp_fset.c_objects
-mp_fset.o
-<END>
-
-<BEGIN> BUILD_PENTIUM2gnu.debug_FILE_$(PRJ_DIR)/../../mp/mp_fset.c_toolMacro
-CC
-<END>
-
-<BEGIN> BUILD_PENTIUM2gnu.debug_FILE_$(PRJ_DIR)/../../mp/mp_method.c_infoTags
-toolMacro objects
-<END>
-
-<BEGIN> BUILD_PENTIUM2gnu.debug_FILE_$(PRJ_DIR)/../../mp/mp_method.c_objects
-mp_method.o
-<END>
-
-<BEGIN> BUILD_PENTIUM2gnu.debug_FILE_$(PRJ_DIR)/../../mp/mp_method.c_toolMacro
-CC
-<END>
-
-<BEGIN> BUILD_PENTIUM2gnu.debug_FILE_$(PRJ_DIR)/../../mp/mp_region.c_infoTags
-toolMacro objects
-<END>
-
-<BEGIN> BUILD_PENTIUM2gnu.debug_FILE_$(PRJ_DIR)/../../mp/mp_region.c_objects
-mp_region.o
-<END>
-
-<BEGIN> BUILD_PENTIUM2gnu.debug_FILE_$(PRJ_DIR)/../../mp/mp_region.c_toolMacro
-CC
-<END>
-
-<BEGIN> BUILD_PENTIUM2gnu.debug_FILE_$(PRJ_DIR)/../../mp/mp_register.c_infoTags
-toolMacro objects
-<END>
-
-<BEGIN> BUILD_PENTIUM2gnu.debug_FILE_$(PRJ_DIR)/../../mp/mp_register.c_objects
-mp_register.o
-<END>
-
-<BEGIN> BUILD_PENTIUM2gnu.debug_FILE_$(PRJ_DIR)/../../mp/mp_register.c_toolMacro
-CC
-<END>
-
-<BEGIN> BUILD_PENTIUM2gnu.debug_FILE_$(PRJ_DIR)/../../mp/mp_stat.c_infoTags
-toolMacro objects
-<END>
-
-<BEGIN> BUILD_PENTIUM2gnu.debug_FILE_$(PRJ_DIR)/../../mp/mp_stat.c_objects
-mp_stat.o
-<END>
-
-<BEGIN> BUILD_PENTIUM2gnu.debug_FILE_$(PRJ_DIR)/../../mp/mp_stat.c_toolMacro
-CC
-<END>
-
-<BEGIN> BUILD_PENTIUM2gnu.debug_FILE_$(PRJ_DIR)/../../mp/mp_sync.c_infoTags
-toolMacro objects
-<END>
-
-<BEGIN> BUILD_PENTIUM2gnu.debug_FILE_$(PRJ_DIR)/../../mp/mp_sync.c_objects
-mp_sync.o
-<END>
-
-<BEGIN> BUILD_PENTIUM2gnu.debug_FILE_$(PRJ_DIR)/../../mp/mp_sync.c_toolMacro
-CC
-<END>
-
-<BEGIN> BUILD_PENTIUM2gnu.debug_FILE_$(PRJ_DIR)/../../mp/mp_trickle.c_infoTags
-toolMacro objects
-<END>
-
-<BEGIN> BUILD_PENTIUM2gnu.debug_FILE_$(PRJ_DIR)/../../mp/mp_trickle.c_objects
-mp_trickle.o
-<END>
-
-<BEGIN> BUILD_PENTIUM2gnu.debug_FILE_$(PRJ_DIR)/../../mp/mp_trickle.c_toolMacro
-CC
-<END>
-
-<BEGIN> BUILD_PENTIUM2gnu.debug_FILE_$(PRJ_DIR)/../../mutex/mut_tas.c_infoTags
-toolMacro objects
-<END>
-
-<BEGIN> BUILD_PENTIUM2gnu.debug_FILE_$(PRJ_DIR)/../../mutex/mut_tas.c_objects
-mut_tas.o
-<END>
-
-<BEGIN> BUILD_PENTIUM2gnu.debug_FILE_$(PRJ_DIR)/../../mutex/mut_tas.c_toolMacro
-CC
-<END>
-
-<BEGIN> BUILD_PENTIUM2gnu.debug_FILE_$(PRJ_DIR)/../../mutex/mutex.c_infoTags
-toolMacro objects
-<END>
-
-<BEGIN> BUILD_PENTIUM2gnu.debug_FILE_$(PRJ_DIR)/../../mutex/mutex.c_objects
-mutex.o
-<END>
-
-<BEGIN> BUILD_PENTIUM2gnu.debug_FILE_$(PRJ_DIR)/../../mutex/mutex.c_toolMacro
-CC
-<END>
-
-<BEGIN> BUILD_PENTIUM2gnu.debug_FILE_$(PRJ_DIR)/../../os/os_alloc.c_infoTags
-toolMacro objects
-<END>
-
-<BEGIN> BUILD_PENTIUM2gnu.debug_FILE_$(PRJ_DIR)/../../os/os_alloc.c_objects
-os_alloc.o
-<END>
-
-<BEGIN> BUILD_PENTIUM2gnu.debug_FILE_$(PRJ_DIR)/../../os/os_alloc.c_toolMacro
-CC
-<END>
-
-<BEGIN> BUILD_PENTIUM2gnu.debug_FILE_$(PRJ_DIR)/../../os/os_clock.c_infoTags
-toolMacro objects
-<END>
-
-<BEGIN> BUILD_PENTIUM2gnu.debug_FILE_$(PRJ_DIR)/../../os/os_clock.c_objects
-os_clock.o
-<END>
-
-<BEGIN> BUILD_PENTIUM2gnu.debug_FILE_$(PRJ_DIR)/../../os/os_clock.c_toolMacro
-CC
-<END>
-
-<BEGIN> BUILD_PENTIUM2gnu.debug_FILE_$(PRJ_DIR)/../../os/os_dir.c_infoTags
-toolMacro objects
-<END>
-
-<BEGIN> BUILD_PENTIUM2gnu.debug_FILE_$(PRJ_DIR)/../../os/os_dir.c_objects
-os_dir.o
-<END>
-
-<BEGIN> BUILD_PENTIUM2gnu.debug_FILE_$(PRJ_DIR)/../../os/os_dir.c_toolMacro
-CC
-<END>
-
-<BEGIN> BUILD_PENTIUM2gnu.debug_FILE_$(PRJ_DIR)/../../os/os_errno.c_infoTags
-toolMacro objects
-<END>
-
-<BEGIN> BUILD_PENTIUM2gnu.debug_FILE_$(PRJ_DIR)/../../os/os_errno.c_objects
-os_errno.o
-<END>
-
-<BEGIN> BUILD_PENTIUM2gnu.debug_FILE_$(PRJ_DIR)/../../os/os_errno.c_toolMacro
-CC
-<END>
-
-<BEGIN> BUILD_PENTIUM2gnu.debug_FILE_$(PRJ_DIR)/../../os/os_fid.c_infoTags
-toolMacro objects
-<END>
-
-<BEGIN> BUILD_PENTIUM2gnu.debug_FILE_$(PRJ_DIR)/../../os/os_fid.c_objects
-os_fid.o
-<END>
-
-<BEGIN> BUILD_PENTIUM2gnu.debug_FILE_$(PRJ_DIR)/../../os/os_fid.c_toolMacro
-CC
-<END>
-
-<BEGIN> BUILD_PENTIUM2gnu.debug_FILE_$(PRJ_DIR)/../../os/os_fsync.c_infoTags
-toolMacro objects
-<END>
-
-<BEGIN> BUILD_PENTIUM2gnu.debug_FILE_$(PRJ_DIR)/../../os/os_fsync.c_objects
-os_fsync.o
-<END>
-
-<BEGIN> BUILD_PENTIUM2gnu.debug_FILE_$(PRJ_DIR)/../../os/os_fsync.c_toolMacro
-CC
-<END>
-
-<BEGIN> BUILD_PENTIUM2gnu.debug_FILE_$(PRJ_DIR)/../../os/os_handle.c_infoTags
-toolMacro objects
-<END>
-
-<BEGIN> BUILD_PENTIUM2gnu.debug_FILE_$(PRJ_DIR)/../../os/os_handle.c_objects
-os_handle.o
-<END>
-
-<BEGIN> BUILD_PENTIUM2gnu.debug_FILE_$(PRJ_DIR)/../../os/os_handle.c_toolMacro
-CC
-<END>
-
-<BEGIN> BUILD_PENTIUM2gnu.debug_FILE_$(PRJ_DIR)/../../os/os_id.c_infoTags
-toolMacro objects
-<END>
-
-<BEGIN> BUILD_PENTIUM2gnu.debug_FILE_$(PRJ_DIR)/../../os/os_id.c_objects
-os_id.o
-<END>
-
-<BEGIN> BUILD_PENTIUM2gnu.debug_FILE_$(PRJ_DIR)/../../os/os_id.c_toolMacro
-CC
-<END>
-
-<BEGIN> BUILD_PENTIUM2gnu.debug_FILE_$(PRJ_DIR)/../../os/os_method.c_infoTags
-toolMacro objects
-<END>
-
-<BEGIN> BUILD_PENTIUM2gnu.debug_FILE_$(PRJ_DIR)/../../os/os_method.c_objects
-os_method.o
-<END>
-
-<BEGIN> BUILD_PENTIUM2gnu.debug_FILE_$(PRJ_DIR)/../../os/os_method.c_toolMacro
-CC
-<END>
-
-<BEGIN> BUILD_PENTIUM2gnu.debug_FILE_$(PRJ_DIR)/../../os/os_oflags.c_infoTags
-toolMacro objects
-<END>
-
-<BEGIN> BUILD_PENTIUM2gnu.debug_FILE_$(PRJ_DIR)/../../os/os_oflags.c_objects
-os_oflags.o
-<END>
-
-<BEGIN> BUILD_PENTIUM2gnu.debug_FILE_$(PRJ_DIR)/../../os/os_oflags.c_toolMacro
-CC
-<END>
-
-<BEGIN> BUILD_PENTIUM2gnu.debug_FILE_$(PRJ_DIR)/../../os/os_open.c_infoTags
-toolMacro objects
-<END>
-
-<BEGIN> BUILD_PENTIUM2gnu.debug_FILE_$(PRJ_DIR)/../../os/os_open.c_objects
-os_open.o
-<END>
-
-<BEGIN> BUILD_PENTIUM2gnu.debug_FILE_$(PRJ_DIR)/../../os/os_open.c_toolMacro
-CC
-<END>
-
-<BEGIN> BUILD_PENTIUM2gnu.debug_FILE_$(PRJ_DIR)/../../os/os_region.c_infoTags
-toolMacro objects
-<END>
-
-<BEGIN> BUILD_PENTIUM2gnu.debug_FILE_$(PRJ_DIR)/../../os/os_region.c_objects
-os_region.o
-<END>
-
-<BEGIN> BUILD_PENTIUM2gnu.debug_FILE_$(PRJ_DIR)/../../os/os_region.c_toolMacro
-CC
-<END>
-
-<BEGIN> BUILD_PENTIUM2gnu.debug_FILE_$(PRJ_DIR)/../../os/os_rename.c_infoTags
-toolMacro objects
-<END>
-
-<BEGIN> BUILD_PENTIUM2gnu.debug_FILE_$(PRJ_DIR)/../../os/os_rename.c_objects
-os_rename.o
-<END>
-
-<BEGIN> BUILD_PENTIUM2gnu.debug_FILE_$(PRJ_DIR)/../../os/os_rename.c_toolMacro
-CC
-<END>
-
-<BEGIN> BUILD_PENTIUM2gnu.debug_FILE_$(PRJ_DIR)/../../os/os_root.c_infoTags
-toolMacro objects
-<END>
-
-<BEGIN> BUILD_PENTIUM2gnu.debug_FILE_$(PRJ_DIR)/../../os/os_root.c_objects
-os_root.o
-<END>
-
-<BEGIN> BUILD_PENTIUM2gnu.debug_FILE_$(PRJ_DIR)/../../os/os_root.c_toolMacro
-CC
-<END>
-
-<BEGIN> BUILD_PENTIUM2gnu.debug_FILE_$(PRJ_DIR)/../../os/os_rpath.c_infoTags
-toolMacro objects
-<END>
-
-<BEGIN> BUILD_PENTIUM2gnu.debug_FILE_$(PRJ_DIR)/../../os/os_rpath.c_objects
-os_rpath.o
-<END>
-
-<BEGIN> BUILD_PENTIUM2gnu.debug_FILE_$(PRJ_DIR)/../../os/os_rpath.c_toolMacro
-CC
-<END>
-
-<BEGIN> BUILD_PENTIUM2gnu.debug_FILE_$(PRJ_DIR)/../../os/os_rw.c_infoTags
-toolMacro objects
-<END>
-
-<BEGIN> BUILD_PENTIUM2gnu.debug_FILE_$(PRJ_DIR)/../../os/os_rw.c_objects
-os_rw.o
-<END>
-
-<BEGIN> BUILD_PENTIUM2gnu.debug_FILE_$(PRJ_DIR)/../../os/os_rw.c_toolMacro
-CC
-<END>
-
-<BEGIN> BUILD_PENTIUM2gnu.debug_FILE_$(PRJ_DIR)/../../os/os_seek.c_infoTags
-toolMacro objects
-<END>
-
-<BEGIN> BUILD_PENTIUM2gnu.debug_FILE_$(PRJ_DIR)/../../os/os_seek.c_objects
-os_seek.o
-<END>
-
-<BEGIN> BUILD_PENTIUM2gnu.debug_FILE_$(PRJ_DIR)/../../os/os_seek.c_toolMacro
-CC
-<END>
-
-<BEGIN> BUILD_PENTIUM2gnu.debug_FILE_$(PRJ_DIR)/../../os/os_sleep.c_infoTags
-toolMacro objects
-<END>
-
-<BEGIN> BUILD_PENTIUM2gnu.debug_FILE_$(PRJ_DIR)/../../os/os_sleep.c_objects
-os_sleep.o
-<END>
-
-<BEGIN> BUILD_PENTIUM2gnu.debug_FILE_$(PRJ_DIR)/../../os/os_sleep.c_toolMacro
-CC
-<END>
-
-<BEGIN> BUILD_PENTIUM2gnu.debug_FILE_$(PRJ_DIR)/../../os/os_spin.c_infoTags
-toolMacro objects
-<END>
-
-<BEGIN> BUILD_PENTIUM2gnu.debug_FILE_$(PRJ_DIR)/../../os/os_spin.c_objects
-os_spin.o
-<END>
-
-<BEGIN> BUILD_PENTIUM2gnu.debug_FILE_$(PRJ_DIR)/../../os/os_spin.c_toolMacro
-CC
-<END>
-
-<BEGIN> BUILD_PENTIUM2gnu.debug_FILE_$(PRJ_DIR)/../../os/os_stat.c_infoTags
-toolMacro objects
-<END>
-
-<BEGIN> BUILD_PENTIUM2gnu.debug_FILE_$(PRJ_DIR)/../../os/os_stat.c_objects
-os_stat.o
-<END>
-
-<BEGIN> BUILD_PENTIUM2gnu.debug_FILE_$(PRJ_DIR)/../../os/os_stat.c_toolMacro
-CC
-<END>
-
-<BEGIN> BUILD_PENTIUM2gnu.debug_FILE_$(PRJ_DIR)/../../os/os_tmpdir.c_infoTags
-toolMacro objects
-<END>
-
-<BEGIN> BUILD_PENTIUM2gnu.debug_FILE_$(PRJ_DIR)/../../os/os_tmpdir.c_objects
-os_tmpdir.o
-<END>
-
-<BEGIN> BUILD_PENTIUM2gnu.debug_FILE_$(PRJ_DIR)/../../os/os_tmpdir.c_toolMacro
-CC
-<END>
-
-<BEGIN> BUILD_PENTIUM2gnu.debug_FILE_$(PRJ_DIR)/../../os/os_unlink.c_infoTags
-toolMacro objects
-<END>
-
-<BEGIN> BUILD_PENTIUM2gnu.debug_FILE_$(PRJ_DIR)/../../os/os_unlink.c_objects
-os_unlink.o
-<END>
-
-<BEGIN> BUILD_PENTIUM2gnu.debug_FILE_$(PRJ_DIR)/../../os/os_unlink.c_toolMacro
-CC
-<END>
-
-<BEGIN> BUILD_PENTIUM2gnu.debug_FILE_$(PRJ_DIR)/../../os_vxworks/os_vx_abs.c_infoTags
-toolMacro objects
-<END>
-
-<BEGIN> BUILD_PENTIUM2gnu.debug_FILE_$(PRJ_DIR)/../../os_vxworks/os_vx_abs.c_objects
-os_vx_abs.o
-<END>
-
-<BEGIN> BUILD_PENTIUM2gnu.debug_FILE_$(PRJ_DIR)/../../os_vxworks/os_vx_abs.c_toolMacro
-CC
-<END>
-
-<BEGIN> BUILD_PENTIUM2gnu.debug_FILE_$(PRJ_DIR)/../../os_vxworks/os_vx_config.c_infoTags
-toolMacro objects
-<END>
-
-<BEGIN> BUILD_PENTIUM2gnu.debug_FILE_$(PRJ_DIR)/../../os_vxworks/os_vx_config.c_objects
-os_vx_config.o
-<END>
-
-<BEGIN> BUILD_PENTIUM2gnu.debug_FILE_$(PRJ_DIR)/../../os_vxworks/os_vx_config.c_toolMacro
-CC
-<END>
-
-<BEGIN> BUILD_PENTIUM2gnu.debug_FILE_$(PRJ_DIR)/../../os_vxworks/os_vx_map.c_infoTags
-toolMacro objects
-<END>
-
-<BEGIN> BUILD_PENTIUM2gnu.debug_FILE_$(PRJ_DIR)/../../os_vxworks/os_vx_map.c_objects
-os_vx_map.o
-<END>
-
-<BEGIN> BUILD_PENTIUM2gnu.debug_FILE_$(PRJ_DIR)/../../os_vxworks/os_vx_map.c_toolMacro
-CC
-<END>
-
-<BEGIN> BUILD_PENTIUM2gnu.debug_FILE_$(PRJ_DIR)/../../qam/qam.c_infoTags
-toolMacro objects
-<END>
-
-<BEGIN> BUILD_PENTIUM2gnu.debug_FILE_$(PRJ_DIR)/../../qam/qam.c_objects
-qam.o
-<END>
-
-<BEGIN> BUILD_PENTIUM2gnu.debug_FILE_$(PRJ_DIR)/../../qam/qam.c_toolMacro
-CC
-<END>
-
-<BEGIN> BUILD_PENTIUM2gnu.debug_FILE_$(PRJ_DIR)/../../qam/qam_auto.c_infoTags
-toolMacro objects
-<END>
-
-<BEGIN> BUILD_PENTIUM2gnu.debug_FILE_$(PRJ_DIR)/../../qam/qam_auto.c_objects
-qam_auto.o
-<END>
-
-<BEGIN> BUILD_PENTIUM2gnu.debug_FILE_$(PRJ_DIR)/../../qam/qam_auto.c_toolMacro
-CC
-<END>
-
-<BEGIN> BUILD_PENTIUM2gnu.debug_FILE_$(PRJ_DIR)/../../qam/qam_conv.c_infoTags
-toolMacro objects
-<END>
-
-<BEGIN> BUILD_PENTIUM2gnu.debug_FILE_$(PRJ_DIR)/../../qam/qam_conv.c_objects
-qam_conv.o
-<END>
-
-<BEGIN> BUILD_PENTIUM2gnu.debug_FILE_$(PRJ_DIR)/../../qam/qam_conv.c_toolMacro
-CC
-<END>
-
-<BEGIN> BUILD_PENTIUM2gnu.debug_FILE_$(PRJ_DIR)/../../qam/qam_files.c_infoTags
-toolMacro objects
-<END>
-
-<BEGIN> BUILD_PENTIUM2gnu.debug_FILE_$(PRJ_DIR)/../../qam/qam_files.c_objects
-qam_files.o
-<END>
-
-<BEGIN> BUILD_PENTIUM2gnu.debug_FILE_$(PRJ_DIR)/../../qam/qam_files.c_toolMacro
-CC
-<END>
-
-<BEGIN> BUILD_PENTIUM2gnu.debug_FILE_$(PRJ_DIR)/../../qam/qam_method.c_infoTags
-toolMacro objects
-<END>
-
-<BEGIN> BUILD_PENTIUM2gnu.debug_FILE_$(PRJ_DIR)/../../qam/qam_method.c_objects
-qam_method.o
-<END>
-
-<BEGIN> BUILD_PENTIUM2gnu.debug_FILE_$(PRJ_DIR)/../../qam/qam_method.c_toolMacro
-CC
-<END>
-
-<BEGIN> BUILD_PENTIUM2gnu.debug_FILE_$(PRJ_DIR)/../../qam/qam_open.c_infoTags
-toolMacro objects
-<END>
-
-<BEGIN> BUILD_PENTIUM2gnu.debug_FILE_$(PRJ_DIR)/../../qam/qam_open.c_objects
-qam_open.o
-<END>
-
-<BEGIN> BUILD_PENTIUM2gnu.debug_FILE_$(PRJ_DIR)/../../qam/qam_open.c_toolMacro
-CC
-<END>
-
-<BEGIN> BUILD_PENTIUM2gnu.debug_FILE_$(PRJ_DIR)/../../qam/qam_rec.c_infoTags
-toolMacro objects
-<END>
-
-<BEGIN> BUILD_PENTIUM2gnu.debug_FILE_$(PRJ_DIR)/../../qam/qam_rec.c_objects
-qam_rec.o
-<END>
-
-<BEGIN> BUILD_PENTIUM2gnu.debug_FILE_$(PRJ_DIR)/../../qam/qam_rec.c_toolMacro
-CC
-<END>
-
-<BEGIN> BUILD_PENTIUM2gnu.debug_FILE_$(PRJ_DIR)/../../qam/qam_stat.c_infoTags
-toolMacro objects
-<END>
-
-<BEGIN> BUILD_PENTIUM2gnu.debug_FILE_$(PRJ_DIR)/../../qam/qam_stat.c_objects
-qam_stat.o
-<END>
-
-<BEGIN> BUILD_PENTIUM2gnu.debug_FILE_$(PRJ_DIR)/../../qam/qam_stat.c_toolMacro
-CC
-<END>
-
-<BEGIN> BUILD_PENTIUM2gnu.debug_FILE_$(PRJ_DIR)/../../qam/qam_upgrade.c_infoTags
-toolMacro objects
-<END>
-
-<BEGIN> BUILD_PENTIUM2gnu.debug_FILE_$(PRJ_DIR)/../../qam/qam_upgrade.c_objects
-qam_upgrade.o
-<END>
-
-<BEGIN> BUILD_PENTIUM2gnu.debug_FILE_$(PRJ_DIR)/../../qam/qam_upgrade.c_toolMacro
-CC
-<END>
-
-<BEGIN> BUILD_PENTIUM2gnu.debug_FILE_$(PRJ_DIR)/../../qam/qam_verify.c_infoTags
-toolMacro objects
-<END>
-
-<BEGIN> BUILD_PENTIUM2gnu.debug_FILE_$(PRJ_DIR)/../../qam/qam_verify.c_objects
-qam_verify.o
-<END>
-
-<BEGIN> BUILD_PENTIUM2gnu.debug_FILE_$(PRJ_DIR)/../../qam/qam_verify.c_toolMacro
-CC
-<END>
-
-<BEGIN> BUILD_PENTIUM2gnu.debug_FILE_$(PRJ_DIR)/../../rep/rep_method.c_infoTags
-toolMacro objects
-<END>
-
-<BEGIN> BUILD_PENTIUM2gnu.debug_FILE_$(PRJ_DIR)/../../rep/rep_method.c_objects
-rep_method.o
-<END>
-
-<BEGIN> BUILD_PENTIUM2gnu.debug_FILE_$(PRJ_DIR)/../../rep/rep_method.c_toolMacro
-CC
-<END>
-
-<BEGIN> BUILD_PENTIUM2gnu.debug_FILE_$(PRJ_DIR)/../../rep/rep_record.c_infoTags
-toolMacro objects
-<END>
-
-<BEGIN> BUILD_PENTIUM2gnu.debug_FILE_$(PRJ_DIR)/../../rep/rep_record.c_objects
-rep_record.o
-<END>
-
-<BEGIN> BUILD_PENTIUM2gnu.debug_FILE_$(PRJ_DIR)/../../rep/rep_record.c_toolMacro
-CC
-<END>
-
-<BEGIN> BUILD_PENTIUM2gnu.debug_FILE_$(PRJ_DIR)/../../rep/rep_region.c_infoTags
-toolMacro objects
-<END>
-
-<BEGIN> BUILD_PENTIUM2gnu.debug_FILE_$(PRJ_DIR)/../../rep/rep_region.c_objects
-rep_region.o
-<END>
-
-<BEGIN> BUILD_PENTIUM2gnu.debug_FILE_$(PRJ_DIR)/../../rep/rep_region.c_toolMacro
-CC
-<END>
-
-<BEGIN> BUILD_PENTIUM2gnu.debug_FILE_$(PRJ_DIR)/../../rep/rep_util.c_infoTags
-toolMacro objects
-<END>
-
-<BEGIN> BUILD_PENTIUM2gnu.debug_FILE_$(PRJ_DIR)/../../rep/rep_util.c_objects
-rep_util.o
-<END>
-
-<BEGIN> BUILD_PENTIUM2gnu.debug_FILE_$(PRJ_DIR)/../../rep/rep_util.c_toolMacro
-CC
-<END>
-
-<BEGIN> BUILD_PENTIUM2gnu.debug_FILE_$(PRJ_DIR)/../../rpc_client/client.c_infoTags
-toolMacro objects
-<END>
-
-<BEGIN> BUILD_PENTIUM2gnu.debug_FILE_$(PRJ_DIR)/../../rpc_client/client.c_objects
-client.o
-<END>
-
-<BEGIN> BUILD_PENTIUM2gnu.debug_FILE_$(PRJ_DIR)/../../rpc_client/client.c_toolMacro
-CC
-<END>
-
-<BEGIN> BUILD_PENTIUM2gnu.debug_FILE_$(PRJ_DIR)/../../rpc_client/db_server_clnt.c_infoTags
-toolMacro objects
-<END>
-
-<BEGIN> BUILD_PENTIUM2gnu.debug_FILE_$(PRJ_DIR)/../../rpc_client/db_server_clnt.c_objects
-db_server_clnt.o
-<END>
-
-<BEGIN> BUILD_PENTIUM2gnu.debug_FILE_$(PRJ_DIR)/../../rpc_client/db_server_clnt.c_toolMacro
-CC
-<END>
-
-<BEGIN> BUILD_PENTIUM2gnu.debug_FILE_$(PRJ_DIR)/../../rpc_client/gen_client.c_infoTags
-toolMacro objects
-<END>
-
-<BEGIN> BUILD_PENTIUM2gnu.debug_FILE_$(PRJ_DIR)/../../rpc_client/gen_client.c_objects
-gen_client.o
-<END>
-
-<BEGIN> BUILD_PENTIUM2gnu.debug_FILE_$(PRJ_DIR)/../../rpc_client/gen_client.c_toolMacro
-CC
-<END>
-
-<BEGIN> BUILD_PENTIUM2gnu.debug_FILE_$(PRJ_DIR)/../../rpc_client/gen_client_ret.c_infoTags
-toolMacro objects
-<END>
-
-<BEGIN> BUILD_PENTIUM2gnu.debug_FILE_$(PRJ_DIR)/../../rpc_client/gen_client_ret.c_objects
-gen_client_ret.o
-<END>
-
-<BEGIN> BUILD_PENTIUM2gnu.debug_FILE_$(PRJ_DIR)/../../rpc_client/gen_client_ret.c_toolMacro
-CC
-<END>
-
-<BEGIN> BUILD_PENTIUM2gnu.debug_FILE_$(PRJ_DIR)/../../rpc_server/c/db_server_xdr.c_infoTags
-toolMacro objects
-<END>
-
-<BEGIN> BUILD_PENTIUM2gnu.debug_FILE_$(PRJ_DIR)/../../rpc_server/c/db_server_xdr.c_objects
-db_server_xdr.o
-<END>
-
-<BEGIN> BUILD_PENTIUM2gnu.debug_FILE_$(PRJ_DIR)/../../rpc_server/c/db_server_xdr.c_toolMacro
-CC
-<END>
-
-<BEGIN> BUILD_PENTIUM2gnu.debug_FILE_$(PRJ_DIR)/../../txn/txn.c_infoTags
-toolMacro objects
-<END>
-
-<BEGIN> BUILD_PENTIUM2gnu.debug_FILE_$(PRJ_DIR)/../../txn/txn.c_objects
-txn.o
-<END>
-
-<BEGIN> BUILD_PENTIUM2gnu.debug_FILE_$(PRJ_DIR)/../../txn/txn.c_toolMacro
-CC
-<END>
-
-<BEGIN> BUILD_PENTIUM2gnu.debug_FILE_$(PRJ_DIR)/../../txn/txn_auto.c_infoTags
-toolMacro objects
-<END>
-
-<BEGIN> BUILD_PENTIUM2gnu.debug_FILE_$(PRJ_DIR)/../../txn/txn_auto.c_objects
-txn_auto.o
-<END>
-
-<BEGIN> BUILD_PENTIUM2gnu.debug_FILE_$(PRJ_DIR)/../../txn/txn_auto.c_toolMacro
-CC
-<END>
-
-<BEGIN> BUILD_PENTIUM2gnu.debug_FILE_$(PRJ_DIR)/../../txn/txn_method.c_infoTags
-toolMacro objects
-<END>
-
-<BEGIN> BUILD_PENTIUM2gnu.debug_FILE_$(PRJ_DIR)/../../txn/txn_method.c_objects
-txn_method.o
-<END>
-
-<BEGIN> BUILD_PENTIUM2gnu.debug_FILE_$(PRJ_DIR)/../../txn/txn_method.c_toolMacro
-CC
-<END>
-
-<BEGIN> BUILD_PENTIUM2gnu.debug_FILE_$(PRJ_DIR)/../../txn/txn_rec.c_infoTags
-toolMacro objects
-<END>
-
-<BEGIN> BUILD_PENTIUM2gnu.debug_FILE_$(PRJ_DIR)/../../txn/txn_rec.c_objects
-txn_rec.o
-<END>
-
-<BEGIN> BUILD_PENTIUM2gnu.debug_FILE_$(PRJ_DIR)/../../txn/txn_rec.c_toolMacro
-CC
-<END>
-
-<BEGIN> BUILD_PENTIUM2gnu.debug_FILE_$(PRJ_DIR)/../../txn/txn_recover.c_infoTags
-toolMacro objects
-<END>
-
-<BEGIN> BUILD_PENTIUM2gnu.debug_FILE_$(PRJ_DIR)/../../txn/txn_recover.c_objects
-txn_recover.o
-<END>
-
-<BEGIN> BUILD_PENTIUM2gnu.debug_FILE_$(PRJ_DIR)/../../txn/txn_recover.c_toolMacro
-CC
-<END>
-
-<BEGIN> BUILD_PENTIUM2gnu.debug_FILE_$(PRJ_DIR)/../../txn/txn_region.c_infoTags
-toolMacro objects
-<END>
-
-<BEGIN> BUILD_PENTIUM2gnu.debug_FILE_$(PRJ_DIR)/../../txn/txn_region.c_objects
-txn_region.o
-<END>
-
-<BEGIN> BUILD_PENTIUM2gnu.debug_FILE_$(PRJ_DIR)/../../txn/txn_region.c_toolMacro
-CC
-<END>
-
-<BEGIN> BUILD_PENTIUM2gnu.debug_FILE_$(PRJ_DIR)/../../txn/txn_stat.c_infoTags
-toolMacro objects
-<END>
-
-<BEGIN> BUILD_PENTIUM2gnu.debug_FILE_$(PRJ_DIR)/../../txn/txn_stat.c_objects
-txn_stat.o
-<END>
-
-<BEGIN> BUILD_PENTIUM2gnu.debug_FILE_$(PRJ_DIR)/../../txn/txn_stat.c_toolMacro
-CC
-<END>
-
-<BEGIN> BUILD_PENTIUM2gnu.debug_FILE_$(PRJ_DIR)/../../txn/txn_util.c_infoTags
-toolMacro objects
-<END>
-
-<BEGIN> BUILD_PENTIUM2gnu.debug_FILE_$(PRJ_DIR)/../../txn/txn_util.c_objects
-txn_util.o
-<END>
-
-<BEGIN> BUILD_PENTIUM2gnu.debug_FILE_$(PRJ_DIR)/../../txn/txn_util.c_toolMacro
-CC
-<END>
-
-<BEGIN> BUILD_PENTIUM2gnu.debug_FILE_$(PRJ_DIR)/../../xa/xa.c_infoTags
-toolMacro objects
-<END>
-
-<BEGIN> BUILD_PENTIUM2gnu.debug_FILE_$(PRJ_DIR)/../../xa/xa.c_objects
-xa.o
-<END>
-
-<BEGIN> BUILD_PENTIUM2gnu.debug_FILE_$(PRJ_DIR)/../../xa/xa.c_toolMacro
-CC
-<END>
-
-<BEGIN> BUILD_PENTIUM2gnu.debug_FILE_$(PRJ_DIR)/../../xa/xa_db.c_infoTags
-toolMacro objects
-<END>
-
-<BEGIN> BUILD_PENTIUM2gnu.debug_FILE_$(PRJ_DIR)/../../xa/xa_db.c_objects
-xa_db.o
-<END>
-
-<BEGIN> BUILD_PENTIUM2gnu.debug_FILE_$(PRJ_DIR)/../../xa/xa_db.c_toolMacro
-CC
-<END>
-
-<BEGIN> BUILD_PENTIUM2gnu.debug_FILE_$(PRJ_DIR)/../../xa/xa_map.c_infoTags
-toolMacro objects
-<END>
-
-<BEGIN> BUILD_PENTIUM2gnu.debug_FILE_$(PRJ_DIR)/../../xa/xa_map.c_objects
-xa_map.o
-<END>
-
-<BEGIN> BUILD_PENTIUM2gnu.debug_FILE_$(PRJ_DIR)/../../xa/xa_map.c_toolMacro
-CC
-<END>
-
-<BEGIN> BUILD_PENTIUM2gnu.debug_FILE_$(PRJ_DIR)/compConfig.c_infoTags
-toolMacro objects
-<END>
-
-<BEGIN> BUILD_PENTIUM2gnu.debug_FILE_$(PRJ_DIR)/compConfig.c_objects
-compConfig.o
-<END>
-
-<BEGIN> BUILD_PENTIUM2gnu.debug_FILE_$(PRJ_DIR)/compConfig.c_toolMacro
-CC
-<END>
-
-<BEGIN> BUILD_PENTIUM2gnu.debug_MACRO_AR
-arpentium
-<END>
-
-<BEGIN> BUILD_PENTIUM2gnu.debug_MACRO_AS
-ccpentium
-<END>
-
-<BEGIN> BUILD_PENTIUM2gnu.debug_MACRO_CC
-ccpentium
-<END>
-
-<BEGIN> BUILD_PENTIUM2gnu.debug_MACRO_CFLAGS
--mcpu=pentiumpro \
-	-march=pentiumpro \
-	-ansi \
-	-DRW_MULTI_THREAD \
-	-D_REENTRANT \
-	-g \
-	-nostdlib \
-	-fno-builtin \
-	-fno-defer-pop \
-	-MD \
-	-Wall \
-	-I. \
-	-I$(WIND_BASE)/target/h \
-	-DCPU=PENTIUM2 \
-	-I$(PRJ_DIR)/.. \
-	-I$(PRJ_DIR)/../.. \
-	-DDEBUG \
-	-DDIAGNOSTIC
-<END>
-
-<BEGIN> BUILD_PENTIUM2gnu.debug_MACRO_CFLAGS_AS
--mcpu=pentiumpro \
-	-march=pentiumpro \
-	-ansi \
-	-g \
-	-nostdlib \
-	-fno-builtin \
-	-fno-defer-pop \
-	-P \
-	-x \
-	assembler-with-cpp \
-	-Wall \
-	-I. \
-	-I$(WIND_BASE)/target/h \
-	-DCPU=PENTIUM2
-<END>
-
-<BEGIN> BUILD_PENTIUM2gnu.debug_MACRO_CPP
-ccpentium -E -P
-<END>
-
-<BEGIN> BUILD_PENTIUM2gnu.debug_MACRO_CPPFILT
-c++filtpentium --strip-underscores
-<END>
-
-<BEGIN> BUILD_PENTIUM2gnu.debug_MACRO_LD
-ldpentium
-<END>
-
-<BEGIN> BUILD_PENTIUM2gnu.debug_MACRO_LDFLAGS
--X
-<END>
-
-<BEGIN> BUILD_PENTIUM2gnu.debug_MACRO_LDPARTIAL
-ccpentium \
-	-B$(WIND_BASE)/host/$(WIND_HOST_TYPE)/lib/gcc-lib/ \
-	-nostdlib \
-	-r \
-	-Wl,-X
-<END>
-
-<BEGIN> BUILD_PENTIUM2gnu.debug_MACRO_LD_PARTIAL_FLAGS
--X -r
-<END>
-
-<BEGIN> BUILD_PENTIUM2gnu.debug_MACRO_NM
-nmpentium -g
-<END>
-
-<BEGIN> BUILD_PENTIUM2gnu.debug_MACRO_OPTION_DEFINE_MACRO
--D
-<END>
-
-<BEGIN> BUILD_PENTIUM2gnu.debug_MACRO_OPTION_GENERATE_DEPENDENCY_FILE
--MD
-<END>
-
-<BEGIN> BUILD_PENTIUM2gnu.debug_MACRO_OPTION_INCLUDE_DIR
--I
-<END>
-
-<BEGIN> BUILD_PENTIUM2gnu.debug_MACRO_RELEASE
-0
-<END>
-
-<BEGIN> BUILD_PENTIUM2gnu.debug_MACRO_SIZE
-sizepentium
-<END>
-
-<BEGIN> BUILD_PENTIUM2gnu.debug_RELEASE
-0
-<END>
-
-<BEGIN> BUILD_PENTIUM2gnu.debug_RO_DEPEND_PATH
-$(WIND_BASE)/target/h/
-<END>
-
-<BEGIN> BUILD_PENTIUM2gnu.debug_TC
-::tc_PENTIUM2gnu.debug
-<END>
-
-<BEGIN> BUILD_PENTIUM2gnu.release_DEFAULTFORCPU
-0
-<END>
-
-<BEGIN> BUILD_PENTIUM2gnu.release_FILE_$(PRJ_DIR)/../../btree/bt_compare.c_infoTags
-toolMacro objects
-<END>
-
-<BEGIN> BUILD_PENTIUM2gnu.release_FILE_$(PRJ_DIR)/../../btree/bt_compare.c_objects
-bt_compare.o
-<END>
-
-<BEGIN> BUILD_PENTIUM2gnu.release_FILE_$(PRJ_DIR)/../../btree/bt_compare.c_toolMacro
-CC
-<END>
-
-<BEGIN> BUILD_PENTIUM2gnu.release_FILE_$(PRJ_DIR)/../../btree/bt_conv.c_infoTags
-toolMacro objects
-<END>
-
-<BEGIN> BUILD_PENTIUM2gnu.release_FILE_$(PRJ_DIR)/../../btree/bt_conv.c_objects
-bt_conv.o
-<END>
-
-<BEGIN> BUILD_PENTIUM2gnu.release_FILE_$(PRJ_DIR)/../../btree/bt_conv.c_toolMacro
-CC
-<END>
-
-<BEGIN> BUILD_PENTIUM2gnu.release_FILE_$(PRJ_DIR)/../../btree/bt_curadj.c_infoTags
-toolMacro objects
-<END>
-
-<BEGIN> BUILD_PENTIUM2gnu.release_FILE_$(PRJ_DIR)/../../btree/bt_curadj.c_objects
-bt_curadj.o
-<END>
-
-<BEGIN> BUILD_PENTIUM2gnu.release_FILE_$(PRJ_DIR)/../../btree/bt_curadj.c_toolMacro
-CC
-<END>
-
-<BEGIN> BUILD_PENTIUM2gnu.release_FILE_$(PRJ_DIR)/../../btree/bt_cursor.c_infoTags
-toolMacro objects
-<END>
-
-<BEGIN> BUILD_PENTIUM2gnu.release_FILE_$(PRJ_DIR)/../../btree/bt_cursor.c_objects
-bt_cursor.o
-<END>
-
-<BEGIN> BUILD_PENTIUM2gnu.release_FILE_$(PRJ_DIR)/../../btree/bt_cursor.c_toolMacro
-CC
-<END>
-
-<BEGIN> BUILD_PENTIUM2gnu.release_FILE_$(PRJ_DIR)/../../btree/bt_delete.c_infoTags
-toolMacro objects
-<END>
-
-<BEGIN> BUILD_PENTIUM2gnu.release_FILE_$(PRJ_DIR)/../../btree/bt_delete.c_objects
-bt_delete.o
-<END>
-
-<BEGIN> BUILD_PENTIUM2gnu.release_FILE_$(PRJ_DIR)/../../btree/bt_delete.c_toolMacro
-CC
-<END>
-
-<BEGIN> BUILD_PENTIUM2gnu.release_FILE_$(PRJ_DIR)/../../btree/bt_method.c_infoTags
-toolMacro objects
-<END>
-
-<BEGIN> BUILD_PENTIUM2gnu.release_FILE_$(PRJ_DIR)/../../btree/bt_method.c_objects
-bt_method.o
-<END>
-
-<BEGIN> BUILD_PENTIUM2gnu.release_FILE_$(PRJ_DIR)/../../btree/bt_method.c_toolMacro
-CC
-<END>
-
-<BEGIN> BUILD_PENTIUM2gnu.release_FILE_$(PRJ_DIR)/../../btree/bt_open.c_infoTags
-toolMacro objects
-<END>
-
-<BEGIN> BUILD_PENTIUM2gnu.release_FILE_$(PRJ_DIR)/../../btree/bt_open.c_objects
-bt_open.o
-<END>
-
-<BEGIN> BUILD_PENTIUM2gnu.release_FILE_$(PRJ_DIR)/../../btree/bt_open.c_toolMacro
-CC
-<END>
-
-<BEGIN> BUILD_PENTIUM2gnu.release_FILE_$(PRJ_DIR)/../../btree/bt_put.c_infoTags
-toolMacro objects
-<END>
-
-<BEGIN> BUILD_PENTIUM2gnu.release_FILE_$(PRJ_DIR)/../../btree/bt_put.c_objects
-bt_put.o
-<END>
-
-<BEGIN> BUILD_PENTIUM2gnu.release_FILE_$(PRJ_DIR)/../../btree/bt_put.c_toolMacro
-CC
-<END>
-
-<BEGIN> BUILD_PENTIUM2gnu.release_FILE_$(PRJ_DIR)/../../btree/bt_rec.c_infoTags
-toolMacro objects
-<END>
-
-<BEGIN> BUILD_PENTIUM2gnu.release_FILE_$(PRJ_DIR)/../../btree/bt_rec.c_objects
-bt_rec.o
-<END>
-
-<BEGIN> BUILD_PENTIUM2gnu.release_FILE_$(PRJ_DIR)/../../btree/bt_rec.c_toolMacro
-CC
-<END>
-
-<BEGIN> BUILD_PENTIUM2gnu.release_FILE_$(PRJ_DIR)/../../btree/bt_reclaim.c_infoTags
-toolMacro objects
-<END>
-
-<BEGIN> BUILD_PENTIUM2gnu.release_FILE_$(PRJ_DIR)/../../btree/bt_reclaim.c_objects
-bt_reclaim.o
-<END>
-
-<BEGIN> BUILD_PENTIUM2gnu.release_FILE_$(PRJ_DIR)/../../btree/bt_reclaim.c_toolMacro
-CC
-<END>
-
-<BEGIN> BUILD_PENTIUM2gnu.release_FILE_$(PRJ_DIR)/../../btree/bt_recno.c_infoTags
-toolMacro objects
-<END>
-
-<BEGIN> BUILD_PENTIUM2gnu.release_FILE_$(PRJ_DIR)/../../btree/bt_recno.c_objects
-bt_recno.o
-<END>
-
-<BEGIN> BUILD_PENTIUM2gnu.release_FILE_$(PRJ_DIR)/../../btree/bt_recno.c_toolMacro
-CC
-<END>
-
-<BEGIN> BUILD_PENTIUM2gnu.release_FILE_$(PRJ_DIR)/../../btree/bt_rsearch.c_infoTags
-toolMacro objects
-<END>
-
-<BEGIN> BUILD_PENTIUM2gnu.release_FILE_$(PRJ_DIR)/../../btree/bt_rsearch.c_objects
-bt_rsearch.o
-<END>
-
-<BEGIN> BUILD_PENTIUM2gnu.release_FILE_$(PRJ_DIR)/../../btree/bt_rsearch.c_toolMacro
-CC
-<END>
-
-<BEGIN> BUILD_PENTIUM2gnu.release_FILE_$(PRJ_DIR)/../../btree/bt_search.c_infoTags
-toolMacro objects
-<END>
-
-<BEGIN> BUILD_PENTIUM2gnu.release_FILE_$(PRJ_DIR)/../../btree/bt_search.c_objects
-bt_search.o
-<END>
-
-<BEGIN> BUILD_PENTIUM2gnu.release_FILE_$(PRJ_DIR)/../../btree/bt_search.c_toolMacro
-CC
-<END>
-
-<BEGIN> BUILD_PENTIUM2gnu.release_FILE_$(PRJ_DIR)/../../btree/bt_split.c_infoTags
-toolMacro objects
-<END>
-
-<BEGIN> BUILD_PENTIUM2gnu.release_FILE_$(PRJ_DIR)/../../btree/bt_split.c_objects
-bt_split.o
-<END>
-
-<BEGIN> BUILD_PENTIUM2gnu.release_FILE_$(PRJ_DIR)/../../btree/bt_split.c_toolMacro
-CC
-<END>
-
-<BEGIN> BUILD_PENTIUM2gnu.release_FILE_$(PRJ_DIR)/../../btree/bt_stat.c_infoTags
-toolMacro objects
-<END>
-
-<BEGIN> BUILD_PENTIUM2gnu.release_FILE_$(PRJ_DIR)/../../btree/bt_stat.c_objects
-bt_stat.o
-<END>
-
-<BEGIN> BUILD_PENTIUM2gnu.release_FILE_$(PRJ_DIR)/../../btree/bt_stat.c_toolMacro
-CC
-<END>
-
-<BEGIN> BUILD_PENTIUM2gnu.release_FILE_$(PRJ_DIR)/../../btree/bt_upgrade.c_infoTags
-toolMacro objects
-<END>
-
-<BEGIN> BUILD_PENTIUM2gnu.release_FILE_$(PRJ_DIR)/../../btree/bt_upgrade.c_objects
-bt_upgrade.o
-<END>
-
-<BEGIN> BUILD_PENTIUM2gnu.release_FILE_$(PRJ_DIR)/../../btree/bt_upgrade.c_toolMacro
-CC
-<END>
-
-<BEGIN> BUILD_PENTIUM2gnu.release_FILE_$(PRJ_DIR)/../../btree/bt_verify.c_infoTags
-toolMacro objects
-<END>
-
-<BEGIN> BUILD_PENTIUM2gnu.release_FILE_$(PRJ_DIR)/../../btree/bt_verify.c_objects
-bt_verify.o
-<END>
-
-<BEGIN> BUILD_PENTIUM2gnu.release_FILE_$(PRJ_DIR)/../../btree/bt_verify.c_toolMacro
-CC
-<END>
-
-<BEGIN> BUILD_PENTIUM2gnu.release_FILE_$(PRJ_DIR)/../../btree/btree_auto.c_infoTags
-toolMacro objects
-<END>
-
-<BEGIN> BUILD_PENTIUM2gnu.release_FILE_$(PRJ_DIR)/../../btree/btree_auto.c_objects
-btree_auto.o
-<END>
-
-<BEGIN> BUILD_PENTIUM2gnu.release_FILE_$(PRJ_DIR)/../../btree/btree_auto.c_toolMacro
-CC
-<END>
-
-<BEGIN> BUILD_PENTIUM2gnu.release_FILE_$(PRJ_DIR)/../../clib/getopt.c_infoTags
-toolMacro objects
-<END>
-
-<BEGIN> BUILD_PENTIUM2gnu.release_FILE_$(PRJ_DIR)/../../clib/getopt.c_objects
-getopt.o
-<END>
-
-<BEGIN> BUILD_PENTIUM2gnu.release_FILE_$(PRJ_DIR)/../../clib/getopt.c_toolMacro
-CC
-<END>
-
-<BEGIN> BUILD_PENTIUM2gnu.release_FILE_$(PRJ_DIR)/../../clib/snprintf.c_infoTags
-toolMacro objects
-<END>
-
-<BEGIN> BUILD_PENTIUM2gnu.release_FILE_$(PRJ_DIR)/../../clib/snprintf.c_objects
-snprintf.o
-<END>
-
-<BEGIN> BUILD_PENTIUM2gnu.release_FILE_$(PRJ_DIR)/../../clib/snprintf.c_toolMacro
-CC
-<END>
-
-<BEGIN> BUILD_PENTIUM2gnu.release_FILE_$(PRJ_DIR)/../../clib/strcasecmp.c_infoTags
-toolMacro objects
-<END>
-
-<BEGIN> BUILD_PENTIUM2gnu.release_FILE_$(PRJ_DIR)/../../clib/strcasecmp.c_objects
-strcasecmp.o
-<END>
-
-<BEGIN> BUILD_PENTIUM2gnu.release_FILE_$(PRJ_DIR)/../../clib/strcasecmp.c_toolMacro
-CC
-<END>
-
-<BEGIN> BUILD_PENTIUM2gnu.release_FILE_$(PRJ_DIR)/../../clib/strdup.c_infoTags
-toolMacro objects
-<END>
-
-<BEGIN> BUILD_PENTIUM2gnu.release_FILE_$(PRJ_DIR)/../../clib/strdup.c_objects
-strdup.o
-<END>
-
-<BEGIN> BUILD_PENTIUM2gnu.release_FILE_$(PRJ_DIR)/../../clib/strdup.c_toolMacro
-CC
-<END>
-
-<BEGIN> BUILD_PENTIUM2gnu.release_FILE_$(PRJ_DIR)/../../clib/vsnprintf.c_infoTags
-toolMacro objects
-<END>
-
-<BEGIN> BUILD_PENTIUM2gnu.release_FILE_$(PRJ_DIR)/../../clib/vsnprintf.c_objects
-vsnprintf.o
-<END>
-
-<BEGIN> BUILD_PENTIUM2gnu.release_FILE_$(PRJ_DIR)/../../clib/vsnprintf.c_toolMacro
-CC
-<END>
-
-<BEGIN> BUILD_PENTIUM2gnu.release_FILE_$(PRJ_DIR)/../../common/db_byteorder.c_infoTags
-toolMacro objects
-<END>
-
-<BEGIN> BUILD_PENTIUM2gnu.release_FILE_$(PRJ_DIR)/../../common/db_byteorder.c_objects
-db_byteorder.o
-<END>
-
-<BEGIN> BUILD_PENTIUM2gnu.release_FILE_$(PRJ_DIR)/../../common/db_byteorder.c_toolMacro
-CC
-<END>
-
-<BEGIN> BUILD_PENTIUM2gnu.release_FILE_$(PRJ_DIR)/../../common/db_err.c_infoTags
-toolMacro objects
-<END>
-
-<BEGIN> BUILD_PENTIUM2gnu.release_FILE_$(PRJ_DIR)/../../common/db_err.c_objects
-db_err.o
-<END>
-
-<BEGIN> BUILD_PENTIUM2gnu.release_FILE_$(PRJ_DIR)/../../common/db_err.c_toolMacro
-CC
-<END>
-
-<BEGIN> BUILD_PENTIUM2gnu.release_FILE_$(PRJ_DIR)/../../common/db_getlong.c_infoTags
-toolMacro objects
-<END>
-
-<BEGIN> BUILD_PENTIUM2gnu.release_FILE_$(PRJ_DIR)/../../common/db_getlong.c_objects
-db_getlong.o
-<END>
-
-<BEGIN> BUILD_PENTIUM2gnu.release_FILE_$(PRJ_DIR)/../../common/db_getlong.c_toolMacro
-CC
-<END>
-
-<BEGIN> BUILD_PENTIUM2gnu.release_FILE_$(PRJ_DIR)/../../common/db_idspace.c_infoTags
-toolMacro objects
-<END>
-
-<BEGIN> BUILD_PENTIUM2gnu.release_FILE_$(PRJ_DIR)/../../common/db_idspace.c_objects
-db_idspace.o
-<END>
-
-<BEGIN> BUILD_PENTIUM2gnu.release_FILE_$(PRJ_DIR)/../../common/db_idspace.c_toolMacro
-CC
-<END>
-
-<BEGIN> BUILD_PENTIUM2gnu.release_FILE_$(PRJ_DIR)/../../common/db_log2.c_infoTags
-toolMacro objects
-<END>
-
-<BEGIN> BUILD_PENTIUM2gnu.release_FILE_$(PRJ_DIR)/../../common/db_log2.c_objects
-db_log2.o
-<END>
-
-<BEGIN> BUILD_PENTIUM2gnu.release_FILE_$(PRJ_DIR)/../../common/db_log2.c_toolMacro
-CC
-<END>
-
-<BEGIN> BUILD_PENTIUM2gnu.release_FILE_$(PRJ_DIR)/../../common/util_arg.c_infoTags
-toolMacro objects
-<END>
-
-<BEGIN> BUILD_PENTIUM2gnu.release_FILE_$(PRJ_DIR)/../../common/util_arg.c_objects
-util_arg.o
-<END>
-
-<BEGIN> BUILD_PENTIUM2gnu.release_FILE_$(PRJ_DIR)/../../common/util_arg.c_toolMacro
-CC
-<END>
-
-<BEGIN> BUILD_PENTIUM2gnu.release_FILE_$(PRJ_DIR)/../../common/util_cache.c_infoTags
-toolMacro objects
-<END>
-
-<BEGIN> BUILD_PENTIUM2gnu.release_FILE_$(PRJ_DIR)/../../common/util_cache.c_objects
-util_cache.o
-<END>
-
-<BEGIN> BUILD_PENTIUM2gnu.release_FILE_$(PRJ_DIR)/../../common/util_cache.c_toolMacro
-CC
-<END>
-
-<BEGIN> BUILD_PENTIUM2gnu.release_FILE_$(PRJ_DIR)/../../common/util_log.c_infoTags
-toolMacro objects
-<END>
-
-<BEGIN> BUILD_PENTIUM2gnu.release_FILE_$(PRJ_DIR)/../../common/util_log.c_objects
-util_log.o
-<END>
-
-<BEGIN> BUILD_PENTIUM2gnu.release_FILE_$(PRJ_DIR)/../../common/util_log.c_toolMacro
-CC
-<END>
-
-<BEGIN> BUILD_PENTIUM2gnu.release_FILE_$(PRJ_DIR)/../../common/util_sig.c_infoTags
-toolMacro objects
-<END>
-
-<BEGIN> BUILD_PENTIUM2gnu.release_FILE_$(PRJ_DIR)/../../common/util_sig.c_objects
-util_sig.o
-<END>
-
-<BEGIN> BUILD_PENTIUM2gnu.release_FILE_$(PRJ_DIR)/../../common/util_sig.c_toolMacro
-CC
-<END>
-
-<BEGIN> BUILD_PENTIUM2gnu.release_FILE_$(PRJ_DIR)/../../db/crdel_auto.c_infoTags
-toolMacro objects
-<END>
-
-<BEGIN> BUILD_PENTIUM2gnu.release_FILE_$(PRJ_DIR)/../../db/crdel_auto.c_objects
-crdel_auto.o
-<END>
-
-<BEGIN> BUILD_PENTIUM2gnu.release_FILE_$(PRJ_DIR)/../../db/crdel_auto.c_toolMacro
-CC
-<END>
-
-<BEGIN> BUILD_PENTIUM2gnu.release_FILE_$(PRJ_DIR)/../../db/crdel_rec.c_infoTags
-toolMacro objects
-<END>
-
-<BEGIN> BUILD_PENTIUM2gnu.release_FILE_$(PRJ_DIR)/../../db/crdel_rec.c_objects
-crdel_rec.o
-<END>
-
-<BEGIN> BUILD_PENTIUM2gnu.release_FILE_$(PRJ_DIR)/../../db/crdel_rec.c_toolMacro
-CC
-<END>
-
-<BEGIN> BUILD_PENTIUM2gnu.release_FILE_$(PRJ_DIR)/../../db/db.c_infoTags
-toolMacro objects
-<END>
-
-<BEGIN> BUILD_PENTIUM2gnu.release_FILE_$(PRJ_DIR)/../../db/db.c_objects
-db.o
-<END>
-
-<BEGIN> BUILD_PENTIUM2gnu.release_FILE_$(PRJ_DIR)/../../db/db.c_toolMacro
-CC
-<END>
-
-<BEGIN> BUILD_PENTIUM2gnu.release_FILE_$(PRJ_DIR)/../../db/db_am.c_infoTags
-toolMacro objects
-<END>
-
-<BEGIN> BUILD_PENTIUM2gnu.release_FILE_$(PRJ_DIR)/../../db/db_am.c_objects
-db_am.o
-<END>
-
-<BEGIN> BUILD_PENTIUM2gnu.release_FILE_$(PRJ_DIR)/../../db/db_am.c_toolMacro
-CC
-<END>
-
-<BEGIN> BUILD_PENTIUM2gnu.release_FILE_$(PRJ_DIR)/../../db/db_auto.c_infoTags
-toolMacro objects
-<END>
-
-<BEGIN> BUILD_PENTIUM2gnu.release_FILE_$(PRJ_DIR)/../../db/db_auto.c_objects
-db_auto.o
-<END>
-
-<BEGIN> BUILD_PENTIUM2gnu.release_FILE_$(PRJ_DIR)/../../db/db_auto.c_toolMacro
-CC
-<END>
-
-<BEGIN> BUILD_PENTIUM2gnu.release_FILE_$(PRJ_DIR)/../../db/db_cam.c_infoTags
-toolMacro objects
-<END>
-
-<BEGIN> BUILD_PENTIUM2gnu.release_FILE_$(PRJ_DIR)/../../db/db_cam.c_objects
-db_cam.o
-<END>
-
-<BEGIN> BUILD_PENTIUM2gnu.release_FILE_$(PRJ_DIR)/../../db/db_cam.c_toolMacro
-CC
-<END>
-
-<BEGIN> BUILD_PENTIUM2gnu.release_FILE_$(PRJ_DIR)/../../db/db_conv.c_infoTags
-toolMacro objects
-<END>
-
-<BEGIN> BUILD_PENTIUM2gnu.release_FILE_$(PRJ_DIR)/../../db/db_conv.c_objects
-db_conv.o
-<END>
-
-<BEGIN> BUILD_PENTIUM2gnu.release_FILE_$(PRJ_DIR)/../../db/db_conv.c_toolMacro
-CC
-<END>
-
-<BEGIN> BUILD_PENTIUM2gnu.release_FILE_$(PRJ_DIR)/../../db/db_dispatch.c_infoTags
-toolMacro objects
-<END>
-
-<BEGIN> BUILD_PENTIUM2gnu.release_FILE_$(PRJ_DIR)/../../db/db_dispatch.c_objects
-db_dispatch.o
-<END>
-
-<BEGIN> BUILD_PENTIUM2gnu.release_FILE_$(PRJ_DIR)/../../db/db_dispatch.c_toolMacro
-CC
-<END>
-
-<BEGIN> BUILD_PENTIUM2gnu.release_FILE_$(PRJ_DIR)/../../db/db_dup.c_infoTags
-toolMacro objects
-<END>
-
-<BEGIN> BUILD_PENTIUM2gnu.release_FILE_$(PRJ_DIR)/../../db/db_dup.c_objects
-db_dup.o
-<END>
-
-<BEGIN> BUILD_PENTIUM2gnu.release_FILE_$(PRJ_DIR)/../../db/db_dup.c_toolMacro
-CC
-<END>
-
-<BEGIN> BUILD_PENTIUM2gnu.release_FILE_$(PRJ_DIR)/../../db/db_iface.c_infoTags
-toolMacro objects
-<END>
-
-<BEGIN> BUILD_PENTIUM2gnu.release_FILE_$(PRJ_DIR)/../../db/db_iface.c_objects
-db_iface.o
-<END>
-
-<BEGIN> BUILD_PENTIUM2gnu.release_FILE_$(PRJ_DIR)/../../db/db_iface.c_toolMacro
-CC
-<END>
-
-<BEGIN> BUILD_PENTIUM2gnu.release_FILE_$(PRJ_DIR)/../../db/db_join.c_infoTags
-toolMacro objects
-<END>
-
-<BEGIN> BUILD_PENTIUM2gnu.release_FILE_$(PRJ_DIR)/../../db/db_join.c_objects
-db_join.o
-<END>
-
-<BEGIN> BUILD_PENTIUM2gnu.release_FILE_$(PRJ_DIR)/../../db/db_join.c_toolMacro
-CC
-<END>
-
-<BEGIN> BUILD_PENTIUM2gnu.release_FILE_$(PRJ_DIR)/../../db/db_meta.c_infoTags
-toolMacro objects
-<END>
-
-<BEGIN> BUILD_PENTIUM2gnu.release_FILE_$(PRJ_DIR)/../../db/db_meta.c_objects
-db_meta.o
-<END>
-
-<BEGIN> BUILD_PENTIUM2gnu.release_FILE_$(PRJ_DIR)/../../db/db_meta.c_toolMacro
-CC
-<END>
-
-<BEGIN> BUILD_PENTIUM2gnu.release_FILE_$(PRJ_DIR)/../../db/db_method.c_infoTags
-toolMacro objects
-<END>
-
-<BEGIN> BUILD_PENTIUM2gnu.release_FILE_$(PRJ_DIR)/../../db/db_method.c_objects
-db_method.o
-<END>
-
-<BEGIN> BUILD_PENTIUM2gnu.release_FILE_$(PRJ_DIR)/../../db/db_method.c_toolMacro
-CC
-<END>
-
-<BEGIN> BUILD_PENTIUM2gnu.release_FILE_$(PRJ_DIR)/../../db/db_open.c_infoTags
-toolMacro objects
-<END>
-
-<BEGIN> BUILD_PENTIUM2gnu.release_FILE_$(PRJ_DIR)/../../db/db_open.c_objects
-db_open.o
-<END>
-
-<BEGIN> BUILD_PENTIUM2gnu.release_FILE_$(PRJ_DIR)/../../db/db_open.c_toolMacro
-CC
-<END>
-
-<BEGIN> BUILD_PENTIUM2gnu.release_FILE_$(PRJ_DIR)/../../db/db_overflow.c_infoTags
-toolMacro objects
-<END>
-
-<BEGIN> BUILD_PENTIUM2gnu.release_FILE_$(PRJ_DIR)/../../db/db_overflow.c_objects
-db_overflow.o
-<END>
-
-<BEGIN> BUILD_PENTIUM2gnu.release_FILE_$(PRJ_DIR)/../../db/db_overflow.c_toolMacro
-CC
-<END>
-
-<BEGIN> BUILD_PENTIUM2gnu.release_FILE_$(PRJ_DIR)/../../db/db_pr.c_infoTags
-toolMacro objects
-<END>
-
-<BEGIN> BUILD_PENTIUM2gnu.release_FILE_$(PRJ_DIR)/../../db/db_pr.c_objects
-db_pr.o
-<END>
-
-<BEGIN> BUILD_PENTIUM2gnu.release_FILE_$(PRJ_DIR)/../../db/db_pr.c_toolMacro
-CC
-<END>
-
-<BEGIN> BUILD_PENTIUM2gnu.release_FILE_$(PRJ_DIR)/../../db/db_rec.c_infoTags
-toolMacro objects
-<END>
-
-<BEGIN> BUILD_PENTIUM2gnu.release_FILE_$(PRJ_DIR)/../../db/db_rec.c_objects
-db_rec.o
-<END>
-
-<BEGIN> BUILD_PENTIUM2gnu.release_FILE_$(PRJ_DIR)/../../db/db_rec.c_toolMacro
-CC
-<END>
-
-<BEGIN> BUILD_PENTIUM2gnu.release_FILE_$(PRJ_DIR)/../../db/db_reclaim.c_infoTags
-toolMacro objects
-<END>
-
-<BEGIN> BUILD_PENTIUM2gnu.release_FILE_$(PRJ_DIR)/../../db/db_reclaim.c_objects
-db_reclaim.o
-<END>
-
-<BEGIN> BUILD_PENTIUM2gnu.release_FILE_$(PRJ_DIR)/../../db/db_reclaim.c_toolMacro
-CC
-<END>
-
-<BEGIN> BUILD_PENTIUM2gnu.release_FILE_$(PRJ_DIR)/../../db/db_remove.c_infoTags
-toolMacro objects
-<END>
-
-<BEGIN> BUILD_PENTIUM2gnu.release_FILE_$(PRJ_DIR)/../../db/db_remove.c_objects
-db_remove.o
-<END>
-
-<BEGIN> BUILD_PENTIUM2gnu.release_FILE_$(PRJ_DIR)/../../db/db_remove.c_toolMacro
-CC
-<END>
-
-<BEGIN> BUILD_PENTIUM2gnu.release_FILE_$(PRJ_DIR)/../../db/db_rename.c_infoTags
-toolMacro objects
-<END>
-
-<BEGIN> BUILD_PENTIUM2gnu.release_FILE_$(PRJ_DIR)/../../db/db_rename.c_objects
-db_rename.o
-<END>
-
-<BEGIN> BUILD_PENTIUM2gnu.release_FILE_$(PRJ_DIR)/../../db/db_rename.c_toolMacro
-CC
-<END>
-
-<BEGIN> BUILD_PENTIUM2gnu.release_FILE_$(PRJ_DIR)/../../db/db_ret.c_infoTags
-toolMacro objects
-<END>
-
-<BEGIN> BUILD_PENTIUM2gnu.release_FILE_$(PRJ_DIR)/../../db/db_ret.c_objects
-db_ret.o
-<END>
-
-<BEGIN> BUILD_PENTIUM2gnu.release_FILE_$(PRJ_DIR)/../../db/db_ret.c_toolMacro
-CC
-<END>
-
-<BEGIN> BUILD_PENTIUM2gnu.release_FILE_$(PRJ_DIR)/../../db/db_truncate.c_infoTags
-toolMacro objects
-<END>
-
-<BEGIN> BUILD_PENTIUM2gnu.release_FILE_$(PRJ_DIR)/../../db/db_truncate.c_objects
-db_truncate.o
-<END>
-
-<BEGIN> BUILD_PENTIUM2gnu.release_FILE_$(PRJ_DIR)/../../db/db_truncate.c_toolMacro
-CC
-<END>
-
-<BEGIN> BUILD_PENTIUM2gnu.release_FILE_$(PRJ_DIR)/../../db/db_upg.c_infoTags
-toolMacro objects
-<END>
-
-<BEGIN> BUILD_PENTIUM2gnu.release_FILE_$(PRJ_DIR)/../../db/db_upg.c_objects
-db_upg.o
-<END>
-
-<BEGIN> BUILD_PENTIUM2gnu.release_FILE_$(PRJ_DIR)/../../db/db_upg.c_toolMacro
-CC
-<END>
-
-<BEGIN> BUILD_PENTIUM2gnu.release_FILE_$(PRJ_DIR)/../../db/db_upg_opd.c_infoTags
-toolMacro objects
-<END>
-
-<BEGIN> BUILD_PENTIUM2gnu.release_FILE_$(PRJ_DIR)/../../db/db_upg_opd.c_objects
-db_upg_opd.o
-<END>
-
-<BEGIN> BUILD_PENTIUM2gnu.release_FILE_$(PRJ_DIR)/../../db/db_upg_opd.c_toolMacro
-CC
-<END>
-
-<BEGIN> BUILD_PENTIUM2gnu.release_FILE_$(PRJ_DIR)/../../db/db_vrfy.c_infoTags
-toolMacro objects
-<END>
-
-<BEGIN> BUILD_PENTIUM2gnu.release_FILE_$(PRJ_DIR)/../../db/db_vrfy.c_objects
-db_vrfy.o
-<END>
-
-<BEGIN> BUILD_PENTIUM2gnu.release_FILE_$(PRJ_DIR)/../../db/db_vrfy.c_toolMacro
-CC
-<END>
-
-<BEGIN> BUILD_PENTIUM2gnu.release_FILE_$(PRJ_DIR)/../../db/db_vrfyutil.c_infoTags
-toolMacro objects
-<END>
-
-<BEGIN> BUILD_PENTIUM2gnu.release_FILE_$(PRJ_DIR)/../../db/db_vrfyutil.c_objects
-db_vrfyutil.o
-<END>
-
-<BEGIN> BUILD_PENTIUM2gnu.release_FILE_$(PRJ_DIR)/../../db/db_vrfyutil.c_toolMacro
-CC
-<END>
-
-<BEGIN> BUILD_PENTIUM2gnu.release_FILE_$(PRJ_DIR)/../../dbreg/dbreg.c_infoTags
-toolMacro objects
-<END>
-
-<BEGIN> BUILD_PENTIUM2gnu.release_FILE_$(PRJ_DIR)/../../dbreg/dbreg.c_objects
-dbreg.o
-<END>
-
-<BEGIN> BUILD_PENTIUM2gnu.release_FILE_$(PRJ_DIR)/../../dbreg/dbreg.c_toolMacro
-CC
-<END>
-
-<BEGIN> BUILD_PENTIUM2gnu.release_FILE_$(PRJ_DIR)/../../dbreg/dbreg_auto.c_infoTags
-toolMacro objects
-<END>
-
-<BEGIN> BUILD_PENTIUM2gnu.release_FILE_$(PRJ_DIR)/../../dbreg/dbreg_auto.c_objects
-dbreg_auto.o
-<END>
-
-<BEGIN> BUILD_PENTIUM2gnu.release_FILE_$(PRJ_DIR)/../../dbreg/dbreg_auto.c_toolMacro
-CC
-<END>
-
-<BEGIN> BUILD_PENTIUM2gnu.release_FILE_$(PRJ_DIR)/../../dbreg/dbreg_rec.c_infoTags
-toolMacro objects
-<END>
-
-<BEGIN> BUILD_PENTIUM2gnu.release_FILE_$(PRJ_DIR)/../../dbreg/dbreg_rec.c_objects
-dbreg_rec.o
-<END>
-
-<BEGIN> BUILD_PENTIUM2gnu.release_FILE_$(PRJ_DIR)/../../dbreg/dbreg_rec.c_toolMacro
-CC
-<END>
-
-<BEGIN> BUILD_PENTIUM2gnu.release_FILE_$(PRJ_DIR)/../../dbreg/dbreg_util.c_infoTags
-toolMacro objects
-<END>
-
-<BEGIN> BUILD_PENTIUM2gnu.release_FILE_$(PRJ_DIR)/../../dbreg/dbreg_util.c_objects
-dbreg_util.o
-<END>
-
-<BEGIN> BUILD_PENTIUM2gnu.release_FILE_$(PRJ_DIR)/../../dbreg/dbreg_util.c_toolMacro
-CC
-<END>
-
-<BEGIN> BUILD_PENTIUM2gnu.release_FILE_$(PRJ_DIR)/../../env/db_salloc.c_infoTags
-toolMacro objects
-<END>
-
-<BEGIN> BUILD_PENTIUM2gnu.release_FILE_$(PRJ_DIR)/../../env/db_salloc.c_objects
-db_salloc.o
-<END>
-
-<BEGIN> BUILD_PENTIUM2gnu.release_FILE_$(PRJ_DIR)/../../env/db_salloc.c_toolMacro
-CC
-<END>
-
-<BEGIN> BUILD_PENTIUM2gnu.release_FILE_$(PRJ_DIR)/../../env/db_shash.c_infoTags
-toolMacro objects
-<END>
-
-<BEGIN> BUILD_PENTIUM2gnu.release_FILE_$(PRJ_DIR)/../../env/db_shash.c_objects
-db_shash.o
-<END>
-
-<BEGIN> BUILD_PENTIUM2gnu.release_FILE_$(PRJ_DIR)/../../env/db_shash.c_toolMacro
-CC
-<END>
-
-<BEGIN> BUILD_PENTIUM2gnu.release_FILE_$(PRJ_DIR)/../../env/env_file.c_infoTags
-toolMacro objects
-<END>
-
-<BEGIN> BUILD_PENTIUM2gnu.release_FILE_$(PRJ_DIR)/../../env/env_file.c_objects
-env_file.o
-<END>
-
-<BEGIN> BUILD_PENTIUM2gnu.release_FILE_$(PRJ_DIR)/../../env/env_file.c_toolMacro
-CC
-<END>
-
-<BEGIN> BUILD_PENTIUM2gnu.release_FILE_$(PRJ_DIR)/../../env/env_method.c_infoTags
-toolMacro objects
-<END>
-
-<BEGIN> BUILD_PENTIUM2gnu.release_FILE_$(PRJ_DIR)/../../env/env_method.c_objects
-env_method.o
-<END>
-
-<BEGIN> BUILD_PENTIUM2gnu.release_FILE_$(PRJ_DIR)/../../env/env_method.c_toolMacro
-CC
-<END>
-
-<BEGIN> BUILD_PENTIUM2gnu.release_FILE_$(PRJ_DIR)/../../env/env_open.c_infoTags
-toolMacro objects
-<END>
-
-<BEGIN> BUILD_PENTIUM2gnu.release_FILE_$(PRJ_DIR)/../../env/env_open.c_objects
-env_open.o
-<END>
-
-<BEGIN> BUILD_PENTIUM2gnu.release_FILE_$(PRJ_DIR)/../../env/env_open.c_toolMacro
-CC
-<END>
-
-<BEGIN> BUILD_PENTIUM2gnu.release_FILE_$(PRJ_DIR)/../../env/env_recover.c_infoTags
-toolMacro objects
-<END>
-
-<BEGIN> BUILD_PENTIUM2gnu.release_FILE_$(PRJ_DIR)/../../env/env_recover.c_objects
-env_recover.o
-<END>
-
-<BEGIN> BUILD_PENTIUM2gnu.release_FILE_$(PRJ_DIR)/../../env/env_recover.c_toolMacro
-CC
-<END>
-
-<BEGIN> BUILD_PENTIUM2gnu.release_FILE_$(PRJ_DIR)/../../env/env_region.c_infoTags
-toolMacro objects
-<END>
-
-<BEGIN> BUILD_PENTIUM2gnu.release_FILE_$(PRJ_DIR)/../../env/env_region.c_objects
-env_region.o
-<END>
-
-<BEGIN> BUILD_PENTIUM2gnu.release_FILE_$(PRJ_DIR)/../../env/env_region.c_toolMacro
-CC
-<END>
-
-<BEGIN> BUILD_PENTIUM2gnu.release_FILE_$(PRJ_DIR)/../../fileops/fileops_auto.c_infoTags
-toolMacro objects
-<END>
-
-<BEGIN> BUILD_PENTIUM2gnu.release_FILE_$(PRJ_DIR)/../../fileops/fileops_auto.c_objects
-fileops_auto.o
-<END>
-
-<BEGIN> BUILD_PENTIUM2gnu.release_FILE_$(PRJ_DIR)/../../fileops/fileops_auto.c_toolMacro
-CC
-<END>
-
-<BEGIN> BUILD_PENTIUM2gnu.release_FILE_$(PRJ_DIR)/../../fileops/fop_basic.c_infoTags
-toolMacro objects
-<END>
-
-<BEGIN> BUILD_PENTIUM2gnu.release_FILE_$(PRJ_DIR)/../../fileops/fop_basic.c_objects
-fop_basic.o
-<END>
-
-<BEGIN> BUILD_PENTIUM2gnu.release_FILE_$(PRJ_DIR)/../../fileops/fop_basic.c_toolMacro
-CC
-<END>
-
-<BEGIN> BUILD_PENTIUM2gnu.release_FILE_$(PRJ_DIR)/../../fileops/fop_rec.c_infoTags
-toolMacro objects
-<END>
-
-<BEGIN> BUILD_PENTIUM2gnu.release_FILE_$(PRJ_DIR)/../../fileops/fop_rec.c_objects
-fop_rec.o
-<END>
-
-<BEGIN> BUILD_PENTIUM2gnu.release_FILE_$(PRJ_DIR)/../../fileops/fop_rec.c_toolMacro
-CC
-<END>
-
-<BEGIN> BUILD_PENTIUM2gnu.release_FILE_$(PRJ_DIR)/../../fileops/fop_util.c_infoTags
-toolMacro objects
-<END>
-
-<BEGIN> BUILD_PENTIUM2gnu.release_FILE_$(PRJ_DIR)/../../fileops/fop_util.c_objects
-fop_util.o
-<END>
-
-<BEGIN> BUILD_PENTIUM2gnu.release_FILE_$(PRJ_DIR)/../../fileops/fop_util.c_toolMacro
-CC
-<END>
-
-<BEGIN> BUILD_PENTIUM2gnu.release_FILE_$(PRJ_DIR)/../../hash/hash.c_infoTags
-toolMacro objects
-<END>
-
-<BEGIN> BUILD_PENTIUM2gnu.release_FILE_$(PRJ_DIR)/../../hash/hash.c_objects
-hash.o
-<END>
-
-<BEGIN> BUILD_PENTIUM2gnu.release_FILE_$(PRJ_DIR)/../../hash/hash.c_toolMacro
-CC
-<END>
-
-<BEGIN> BUILD_PENTIUM2gnu.release_FILE_$(PRJ_DIR)/../../hash/hash_auto.c_infoTags
-toolMacro objects
-<END>
-
-<BEGIN> BUILD_PENTIUM2gnu.release_FILE_$(PRJ_DIR)/../../hash/hash_auto.c_objects
-hash_auto.o
-<END>
-
-<BEGIN> BUILD_PENTIUM2gnu.release_FILE_$(PRJ_DIR)/../../hash/hash_auto.c_toolMacro
-CC
-<END>
-
-<BEGIN> BUILD_PENTIUM2gnu.release_FILE_$(PRJ_DIR)/../../hash/hash_conv.c_infoTags
-toolMacro objects
-<END>
-
-<BEGIN> BUILD_PENTIUM2gnu.release_FILE_$(PRJ_DIR)/../../hash/hash_conv.c_objects
-hash_conv.o
-<END>
-
-<BEGIN> BUILD_PENTIUM2gnu.release_FILE_$(PRJ_DIR)/../../hash/hash_conv.c_toolMacro
-CC
-<END>
-
-<BEGIN> BUILD_PENTIUM2gnu.release_FILE_$(PRJ_DIR)/../../hash/hash_dup.c_infoTags
-toolMacro objects
-<END>
-
-<BEGIN> BUILD_PENTIUM2gnu.release_FILE_$(PRJ_DIR)/../../hash/hash_dup.c_objects
-hash_dup.o
-<END>
-
-<BEGIN> BUILD_PENTIUM2gnu.release_FILE_$(PRJ_DIR)/../../hash/hash_dup.c_toolMacro
-CC
-<END>
-
-<BEGIN> BUILD_PENTIUM2gnu.release_FILE_$(PRJ_DIR)/../../hash/hash_func.c_infoTags
-toolMacro objects
-<END>
-
-<BEGIN> BUILD_PENTIUM2gnu.release_FILE_$(PRJ_DIR)/../../hash/hash_func.c_objects
-hash_func.o
-<END>
-
-<BEGIN> BUILD_PENTIUM2gnu.release_FILE_$(PRJ_DIR)/../../hash/hash_func.c_toolMacro
-CC
-<END>
-
-<BEGIN> BUILD_PENTIUM2gnu.release_FILE_$(PRJ_DIR)/../../hash/hash_meta.c_infoTags
-toolMacro objects
-<END>
-
-<BEGIN> BUILD_PENTIUM2gnu.release_FILE_$(PRJ_DIR)/../../hash/hash_meta.c_objects
-hash_meta.o
-<END>
-
-<BEGIN> BUILD_PENTIUM2gnu.release_FILE_$(PRJ_DIR)/../../hash/hash_meta.c_toolMacro
-CC
-<END>
-
-<BEGIN> BUILD_PENTIUM2gnu.release_FILE_$(PRJ_DIR)/../../hash/hash_method.c_infoTags
-toolMacro objects
-<END>
-
-<BEGIN> BUILD_PENTIUM2gnu.release_FILE_$(PRJ_DIR)/../../hash/hash_method.c_objects
-hash_method.o
-<END>
-
-<BEGIN> BUILD_PENTIUM2gnu.release_FILE_$(PRJ_DIR)/../../hash/hash_method.c_toolMacro
-CC
-<END>
-
-<BEGIN> BUILD_PENTIUM2gnu.release_FILE_$(PRJ_DIR)/../../hash/hash_open.c_infoTags
-toolMacro objects
-<END>
-
-<BEGIN> BUILD_PENTIUM2gnu.release_FILE_$(PRJ_DIR)/../../hash/hash_open.c_objects
-hash_open.o
-<END>
-
-<BEGIN> BUILD_PENTIUM2gnu.release_FILE_$(PRJ_DIR)/../../hash/hash_open.c_toolMacro
-CC
-<END>
-
-<BEGIN> BUILD_PENTIUM2gnu.release_FILE_$(PRJ_DIR)/../../hash/hash_page.c_infoTags
-toolMacro objects
-<END>
-
-<BEGIN> BUILD_PENTIUM2gnu.release_FILE_$(PRJ_DIR)/../../hash/hash_page.c_objects
-hash_page.o
-<END>
-
-<BEGIN> BUILD_PENTIUM2gnu.release_FILE_$(PRJ_DIR)/../../hash/hash_page.c_toolMacro
-CC
-<END>
-
-<BEGIN> BUILD_PENTIUM2gnu.release_FILE_$(PRJ_DIR)/../../hash/hash_rec.c_infoTags
-toolMacro objects
-<END>
-
-<BEGIN> BUILD_PENTIUM2gnu.release_FILE_$(PRJ_DIR)/../../hash/hash_rec.c_objects
-hash_rec.o
-<END>
-
-<BEGIN> BUILD_PENTIUM2gnu.release_FILE_$(PRJ_DIR)/../../hash/hash_rec.c_toolMacro
-CC
-<END>
-
-<BEGIN> BUILD_PENTIUM2gnu.release_FILE_$(PRJ_DIR)/../../hash/hash_reclaim.c_infoTags
-toolMacro objects
-<END>
-
-<BEGIN> BUILD_PENTIUM2gnu.release_FILE_$(PRJ_DIR)/../../hash/hash_reclaim.c_objects
-hash_reclaim.o
-<END>
-
-<BEGIN> BUILD_PENTIUM2gnu.release_FILE_$(PRJ_DIR)/../../hash/hash_reclaim.c_toolMacro
-CC
-<END>
-
-<BEGIN> BUILD_PENTIUM2gnu.release_FILE_$(PRJ_DIR)/../../hash/hash_stat.c_infoTags
-toolMacro objects
-<END>
-
-<BEGIN> BUILD_PENTIUM2gnu.release_FILE_$(PRJ_DIR)/../../hash/hash_stat.c_objects
-hash_stat.o
-<END>
-
-<BEGIN> BUILD_PENTIUM2gnu.release_FILE_$(PRJ_DIR)/../../hash/hash_stat.c_toolMacro
-CC
-<END>
-
-<BEGIN> BUILD_PENTIUM2gnu.release_FILE_$(PRJ_DIR)/../../hash/hash_upgrade.c_infoTags
-toolMacro objects
-<END>
-
-<BEGIN> BUILD_PENTIUM2gnu.release_FILE_$(PRJ_DIR)/../../hash/hash_upgrade.c_objects
-hash_upgrade.o
-<END>
-
-<BEGIN> BUILD_PENTIUM2gnu.release_FILE_$(PRJ_DIR)/../../hash/hash_upgrade.c_toolMacro
-CC
-<END>
-
-<BEGIN> BUILD_PENTIUM2gnu.release_FILE_$(PRJ_DIR)/../../hash/hash_verify.c_infoTags
-toolMacro objects
-<END>
-
-<BEGIN> BUILD_PENTIUM2gnu.release_FILE_$(PRJ_DIR)/../../hash/hash_verify.c_objects
-hash_verify.o
-<END>
-
-<BEGIN> BUILD_PENTIUM2gnu.release_FILE_$(PRJ_DIR)/../../hash/hash_verify.c_toolMacro
-CC
-<END>
-
-<BEGIN> BUILD_PENTIUM2gnu.release_FILE_$(PRJ_DIR)/../../hmac/hmac.c_infoTags
-toolMacro objects
-<END>
-
-<BEGIN> BUILD_PENTIUM2gnu.release_FILE_$(PRJ_DIR)/../../hmac/hmac.c_objects
-hmac.o
-<END>
-
-<BEGIN> BUILD_PENTIUM2gnu.release_FILE_$(PRJ_DIR)/../../hmac/hmac.c_toolMacro
-CC
-<END>
-
-<BEGIN> BUILD_PENTIUM2gnu.release_FILE_$(PRJ_DIR)/../../hmac/sha1.c_infoTags
-toolMacro objects
-<END>
-
-<BEGIN> BUILD_PENTIUM2gnu.release_FILE_$(PRJ_DIR)/../../hmac/sha1.c_objects
-sha1.o
-<END>
-
-<BEGIN> BUILD_PENTIUM2gnu.release_FILE_$(PRJ_DIR)/../../hmac/sha1.c_toolMacro
-CC
-<END>
-
-<BEGIN> BUILD_PENTIUM2gnu.release_FILE_$(PRJ_DIR)/../../hsearch/hsearch.c_infoTags
-toolMacro objects
-<END>
-
-<BEGIN> BUILD_PENTIUM2gnu.release_FILE_$(PRJ_DIR)/../../hsearch/hsearch.c_objects
-hsearch.o
-<END>
-
-<BEGIN> BUILD_PENTIUM2gnu.release_FILE_$(PRJ_DIR)/../../hsearch/hsearch.c_toolMacro
-CC
-<END>
-
-<BEGIN> BUILD_PENTIUM2gnu.release_FILE_$(PRJ_DIR)/../../lock/lock.c_infoTags
-toolMacro objects
-<END>
-
-<BEGIN> BUILD_PENTIUM2gnu.release_FILE_$(PRJ_DIR)/../../lock/lock.c_objects
-lock.o
-<END>
-
-<BEGIN> BUILD_PENTIUM2gnu.release_FILE_$(PRJ_DIR)/../../lock/lock.c_toolMacro
-CC
-<END>
-
-<BEGIN> BUILD_PENTIUM2gnu.release_FILE_$(PRJ_DIR)/../../lock/lock_deadlock.c_infoTags
-toolMacro objects
-<END>
-
-<BEGIN> BUILD_PENTIUM2gnu.release_FILE_$(PRJ_DIR)/../../lock/lock_deadlock.c_objects
-lock_deadlock.o
-<END>
-
-<BEGIN> BUILD_PENTIUM2gnu.release_FILE_$(PRJ_DIR)/../../lock/lock_deadlock.c_toolMacro
-CC
-<END>
-
-<BEGIN> BUILD_PENTIUM2gnu.release_FILE_$(PRJ_DIR)/../../lock/lock_method.c_infoTags
-toolMacro objects
-<END>
-
-<BEGIN> BUILD_PENTIUM2gnu.release_FILE_$(PRJ_DIR)/../../lock/lock_method.c_objects
-lock_method.o
-<END>
-
-<BEGIN> BUILD_PENTIUM2gnu.release_FILE_$(PRJ_DIR)/../../lock/lock_method.c_toolMacro
-CC
-<END>
-
-<BEGIN> BUILD_PENTIUM2gnu.release_FILE_$(PRJ_DIR)/../../lock/lock_region.c_infoTags
-toolMacro objects
-<END>
-
-<BEGIN> BUILD_PENTIUM2gnu.release_FILE_$(PRJ_DIR)/../../lock/lock_region.c_objects
-lock_region.o
-<END>
-
-<BEGIN> BUILD_PENTIUM2gnu.release_FILE_$(PRJ_DIR)/../../lock/lock_region.c_toolMacro
-CC
-<END>
-
-<BEGIN> BUILD_PENTIUM2gnu.release_FILE_$(PRJ_DIR)/../../lock/lock_stat.c_infoTags
-toolMacro objects
-<END>
-
-<BEGIN> BUILD_PENTIUM2gnu.release_FILE_$(PRJ_DIR)/../../lock/lock_stat.c_objects
-lock_stat.o
-<END>
-
-<BEGIN> BUILD_PENTIUM2gnu.release_FILE_$(PRJ_DIR)/../../lock/lock_stat.c_toolMacro
-CC
-<END>
-
-<BEGIN> BUILD_PENTIUM2gnu.release_FILE_$(PRJ_DIR)/../../lock/lock_util.c_infoTags
-toolMacro objects
-<END>
-
-<BEGIN> BUILD_PENTIUM2gnu.release_FILE_$(PRJ_DIR)/../../lock/lock_util.c_objects
-lock_util.o
-<END>
-
-<BEGIN> BUILD_PENTIUM2gnu.release_FILE_$(PRJ_DIR)/../../lock/lock_util.c_toolMacro
-CC
-<END>
-
-<BEGIN> BUILD_PENTIUM2gnu.release_FILE_$(PRJ_DIR)/../../log/log.c_infoTags
-toolMacro objects
-<END>
-
-<BEGIN> BUILD_PENTIUM2gnu.release_FILE_$(PRJ_DIR)/../../log/log.c_objects
-log.o
-<END>
-
-<BEGIN> BUILD_PENTIUM2gnu.release_FILE_$(PRJ_DIR)/../../log/log.c_toolMacro
-CC
-<END>
-
-<BEGIN> BUILD_PENTIUM2gnu.release_FILE_$(PRJ_DIR)/../../log/log_archive.c_infoTags
-toolMacro objects
-<END>
-
-<BEGIN> BUILD_PENTIUM2gnu.release_FILE_$(PRJ_DIR)/../../log/log_archive.c_objects
-log_archive.o
-<END>
-
-<BEGIN> BUILD_PENTIUM2gnu.release_FILE_$(PRJ_DIR)/../../log/log_archive.c_toolMacro
-CC
-<END>
-
-<BEGIN> BUILD_PENTIUM2gnu.release_FILE_$(PRJ_DIR)/../../log/log_compare.c_infoTags
-toolMacro objects
-<END>
-
-<BEGIN> BUILD_PENTIUM2gnu.release_FILE_$(PRJ_DIR)/../../log/log_compare.c_objects
-log_compare.o
-<END>
-
-<BEGIN> BUILD_PENTIUM2gnu.release_FILE_$(PRJ_DIR)/../../log/log_compare.c_toolMacro
-CC
-<END>
-
-<BEGIN> BUILD_PENTIUM2gnu.release_FILE_$(PRJ_DIR)/../../log/log_get.c_infoTags
-toolMacro objects
-<END>
-
-<BEGIN> BUILD_PENTIUM2gnu.release_FILE_$(PRJ_DIR)/../../log/log_get.c_objects
-log_get.o
-<END>
-
-<BEGIN> BUILD_PENTIUM2gnu.release_FILE_$(PRJ_DIR)/../../log/log_get.c_toolMacro
-CC
-<END>
-
-<BEGIN> BUILD_PENTIUM2gnu.release_FILE_$(PRJ_DIR)/../../log/log_method.c_infoTags
-toolMacro objects
-<END>
-
-<BEGIN> BUILD_PENTIUM2gnu.release_FILE_$(PRJ_DIR)/../../log/log_method.c_objects
-log_method.o
-<END>
-
-<BEGIN> BUILD_PENTIUM2gnu.release_FILE_$(PRJ_DIR)/../../log/log_method.c_toolMacro
-CC
-<END>
-
-<BEGIN> BUILD_PENTIUM2gnu.release_FILE_$(PRJ_DIR)/../../log/log_put.c_infoTags
-toolMacro objects
-<END>
-
-<BEGIN> BUILD_PENTIUM2gnu.release_FILE_$(PRJ_DIR)/../../log/log_put.c_objects
-log_put.o
-<END>
-
-<BEGIN> BUILD_PENTIUM2gnu.release_FILE_$(PRJ_DIR)/../../log/log_put.c_toolMacro
-CC
-<END>
-
-<BEGIN> BUILD_PENTIUM2gnu.release_FILE_$(PRJ_DIR)/../../mp/mp_alloc.c_infoTags
-toolMacro objects
-<END>
-
-<BEGIN> BUILD_PENTIUM2gnu.release_FILE_$(PRJ_DIR)/../../mp/mp_alloc.c_objects
-mp_alloc.o
-<END>
-
-<BEGIN> BUILD_PENTIUM2gnu.release_FILE_$(PRJ_DIR)/../../mp/mp_alloc.c_toolMacro
-CC
-<END>
-
-<BEGIN> BUILD_PENTIUM2gnu.release_FILE_$(PRJ_DIR)/../../mp/mp_bh.c_infoTags
-toolMacro objects
-<END>
-
-<BEGIN> BUILD_PENTIUM2gnu.release_FILE_$(PRJ_DIR)/../../mp/mp_bh.c_objects
-mp_bh.o
-<END>
-
-<BEGIN> BUILD_PENTIUM2gnu.release_FILE_$(PRJ_DIR)/../../mp/mp_bh.c_toolMacro
-CC
-<END>
-
-<BEGIN> BUILD_PENTIUM2gnu.release_FILE_$(PRJ_DIR)/../../mp/mp_fget.c_infoTags
-toolMacro objects
-<END>
-
-<BEGIN> BUILD_PENTIUM2gnu.release_FILE_$(PRJ_DIR)/../../mp/mp_fget.c_objects
-mp_fget.o
-<END>
-
-<BEGIN> BUILD_PENTIUM2gnu.release_FILE_$(PRJ_DIR)/../../mp/mp_fget.c_toolMacro
-CC
-<END>
-
-<BEGIN> BUILD_PENTIUM2gnu.release_FILE_$(PRJ_DIR)/../../mp/mp_fopen.c_infoTags
-toolMacro objects
-<END>
-
-<BEGIN> BUILD_PENTIUM2gnu.release_FILE_$(PRJ_DIR)/../../mp/mp_fopen.c_objects
-mp_fopen.o
-<END>
-
-<BEGIN> BUILD_PENTIUM2gnu.release_FILE_$(PRJ_DIR)/../../mp/mp_fopen.c_toolMacro
-CC
-<END>
-
-<BEGIN> BUILD_PENTIUM2gnu.release_FILE_$(PRJ_DIR)/../../mp/mp_fput.c_infoTags
-toolMacro objects
-<END>
-
-<BEGIN> BUILD_PENTIUM2gnu.release_FILE_$(PRJ_DIR)/../../mp/mp_fput.c_objects
-mp_fput.o
-<END>
-
-<BEGIN> BUILD_PENTIUM2gnu.release_FILE_$(PRJ_DIR)/../../mp/mp_fput.c_toolMacro
-CC
-<END>
-
-<BEGIN> BUILD_PENTIUM2gnu.release_FILE_$(PRJ_DIR)/../../mp/mp_fset.c_infoTags
-toolMacro objects
-<END>
-
-<BEGIN> BUILD_PENTIUM2gnu.release_FILE_$(PRJ_DIR)/../../mp/mp_fset.c_objects
-mp_fset.o
-<END>
-
-<BEGIN> BUILD_PENTIUM2gnu.release_FILE_$(PRJ_DIR)/../../mp/mp_fset.c_toolMacro
-CC
-<END>
-
-<BEGIN> BUILD_PENTIUM2gnu.release_FILE_$(PRJ_DIR)/../../mp/mp_method.c_infoTags
-toolMacro objects
-<END>
-
-<BEGIN> BUILD_PENTIUM2gnu.release_FILE_$(PRJ_DIR)/../../mp/mp_method.c_objects
-mp_method.o
-<END>
-
-<BEGIN> BUILD_PENTIUM2gnu.release_FILE_$(PRJ_DIR)/../../mp/mp_method.c_toolMacro
-CC
-<END>
-
-<BEGIN> BUILD_PENTIUM2gnu.release_FILE_$(PRJ_DIR)/../../mp/mp_region.c_infoTags
-toolMacro objects
-<END>
-
-<BEGIN> BUILD_PENTIUM2gnu.release_FILE_$(PRJ_DIR)/../../mp/mp_region.c_objects
-mp_region.o
-<END>
-
-<BEGIN> BUILD_PENTIUM2gnu.release_FILE_$(PRJ_DIR)/../../mp/mp_region.c_toolMacro
-CC
-<END>
-
-<BEGIN> BUILD_PENTIUM2gnu.release_FILE_$(PRJ_DIR)/../../mp/mp_register.c_infoTags
-toolMacro objects
-<END>
-
-<BEGIN> BUILD_PENTIUM2gnu.release_FILE_$(PRJ_DIR)/../../mp/mp_register.c_objects
-mp_register.o
-<END>
-
-<BEGIN> BUILD_PENTIUM2gnu.release_FILE_$(PRJ_DIR)/../../mp/mp_register.c_toolMacro
-CC
-<END>
-
-<BEGIN> BUILD_PENTIUM2gnu.release_FILE_$(PRJ_DIR)/../../mp/mp_stat.c_infoTags
-toolMacro objects
-<END>
-
-<BEGIN> BUILD_PENTIUM2gnu.release_FILE_$(PRJ_DIR)/../../mp/mp_stat.c_objects
-mp_stat.o
-<END>
-
-<BEGIN> BUILD_PENTIUM2gnu.release_FILE_$(PRJ_DIR)/../../mp/mp_stat.c_toolMacro
-CC
-<END>
-
-<BEGIN> BUILD_PENTIUM2gnu.release_FILE_$(PRJ_DIR)/../../mp/mp_sync.c_infoTags
-toolMacro objects
-<END>
-
-<BEGIN> BUILD_PENTIUM2gnu.release_FILE_$(PRJ_DIR)/../../mp/mp_sync.c_objects
-mp_sync.o
-<END>
-
-<BEGIN> BUILD_PENTIUM2gnu.release_FILE_$(PRJ_DIR)/../../mp/mp_sync.c_toolMacro
-CC
-<END>
-
-<BEGIN> BUILD_PENTIUM2gnu.release_FILE_$(PRJ_DIR)/../../mp/mp_trickle.c_infoTags
-toolMacro objects
-<END>
-
-<BEGIN> BUILD_PENTIUM2gnu.release_FILE_$(PRJ_DIR)/../../mp/mp_trickle.c_objects
-mp_trickle.o
-<END>
-
-<BEGIN> BUILD_PENTIUM2gnu.release_FILE_$(PRJ_DIR)/../../mp/mp_trickle.c_toolMacro
-CC
-<END>
-
-<BEGIN> BUILD_PENTIUM2gnu.release_FILE_$(PRJ_DIR)/../../mutex/mut_tas.c_infoTags
-toolMacro objects
-<END>
-
-<BEGIN> BUILD_PENTIUM2gnu.release_FILE_$(PRJ_DIR)/../../mutex/mut_tas.c_objects
-mut_tas.o
-<END>
-
-<BEGIN> BUILD_PENTIUM2gnu.release_FILE_$(PRJ_DIR)/../../mutex/mut_tas.c_toolMacro
-CC
-<END>
-
-<BEGIN> BUILD_PENTIUM2gnu.release_FILE_$(PRJ_DIR)/../../mutex/mutex.c_infoTags
-toolMacro objects
-<END>
-
-<BEGIN> BUILD_PENTIUM2gnu.release_FILE_$(PRJ_DIR)/../../mutex/mutex.c_objects
-mutex.o
-<END>
-
-<BEGIN> BUILD_PENTIUM2gnu.release_FILE_$(PRJ_DIR)/../../mutex/mutex.c_toolMacro
-CC
-<END>
-
-<BEGIN> BUILD_PENTIUM2gnu.release_FILE_$(PRJ_DIR)/../../os/os_alloc.c_infoTags
-toolMacro objects
-<END>
-
-<BEGIN> BUILD_PENTIUM2gnu.release_FILE_$(PRJ_DIR)/../../os/os_alloc.c_objects
-os_alloc.o
-<END>
-
-<BEGIN> BUILD_PENTIUM2gnu.release_FILE_$(PRJ_DIR)/../../os/os_alloc.c_toolMacro
-CC
-<END>
-
-<BEGIN> BUILD_PENTIUM2gnu.release_FILE_$(PRJ_DIR)/../../os/os_clock.c_infoTags
-toolMacro objects
-<END>
-
-<BEGIN> BUILD_PENTIUM2gnu.release_FILE_$(PRJ_DIR)/../../os/os_clock.c_objects
-os_clock.o
-<END>
-
-<BEGIN> BUILD_PENTIUM2gnu.release_FILE_$(PRJ_DIR)/../../os/os_clock.c_toolMacro
-CC
-<END>
-
-<BEGIN> BUILD_PENTIUM2gnu.release_FILE_$(PRJ_DIR)/../../os/os_dir.c_infoTags
-toolMacro objects
-<END>
-
-<BEGIN> BUILD_PENTIUM2gnu.release_FILE_$(PRJ_DIR)/../../os/os_dir.c_objects
-os_dir.o
-<END>
-
-<BEGIN> BUILD_PENTIUM2gnu.release_FILE_$(PRJ_DIR)/../../os/os_dir.c_toolMacro
-CC
-<END>
-
-<BEGIN> BUILD_PENTIUM2gnu.release_FILE_$(PRJ_DIR)/../../os/os_errno.c_infoTags
-toolMacro objects
-<END>
-
-<BEGIN> BUILD_PENTIUM2gnu.release_FILE_$(PRJ_DIR)/../../os/os_errno.c_objects
-os_errno.o
-<END>
-
-<BEGIN> BUILD_PENTIUM2gnu.release_FILE_$(PRJ_DIR)/../../os/os_errno.c_toolMacro
-CC
-<END>
-
-<BEGIN> BUILD_PENTIUM2gnu.release_FILE_$(PRJ_DIR)/../../os/os_fid.c_infoTags
-toolMacro objects
-<END>
-
-<BEGIN> BUILD_PENTIUM2gnu.release_FILE_$(PRJ_DIR)/../../os/os_fid.c_objects
-os_fid.o
-<END>
-
-<BEGIN> BUILD_PENTIUM2gnu.release_FILE_$(PRJ_DIR)/../../os/os_fid.c_toolMacro
-CC
-<END>
-
-<BEGIN> BUILD_PENTIUM2gnu.release_FILE_$(PRJ_DIR)/../../os/os_fsync.c_infoTags
-toolMacro objects
-<END>
-
-<BEGIN> BUILD_PENTIUM2gnu.release_FILE_$(PRJ_DIR)/../../os/os_fsync.c_objects
-os_fsync.o
-<END>
-
-<BEGIN> BUILD_PENTIUM2gnu.release_FILE_$(PRJ_DIR)/../../os/os_fsync.c_toolMacro
-CC
-<END>
-
-<BEGIN> BUILD_PENTIUM2gnu.release_FILE_$(PRJ_DIR)/../../os/os_handle.c_infoTags
-toolMacro objects
-<END>
-
-<BEGIN> BUILD_PENTIUM2gnu.release_FILE_$(PRJ_DIR)/../../os/os_handle.c_objects
-os_handle.o
-<END>
-
-<BEGIN> BUILD_PENTIUM2gnu.release_FILE_$(PRJ_DIR)/../../os/os_handle.c_toolMacro
-CC
-<END>
-
-<BEGIN> BUILD_PENTIUM2gnu.release_FILE_$(PRJ_DIR)/../../os/os_id.c_infoTags
-toolMacro objects
-<END>
-
-<BEGIN> BUILD_PENTIUM2gnu.release_FILE_$(PRJ_DIR)/../../os/os_id.c_objects
-os_id.o
-<END>
-
-<BEGIN> BUILD_PENTIUM2gnu.release_FILE_$(PRJ_DIR)/../../os/os_id.c_toolMacro
-CC
-<END>
-
-<BEGIN> BUILD_PENTIUM2gnu.release_FILE_$(PRJ_DIR)/../../os/os_method.c_infoTags
-toolMacro objects
-<END>
-
-<BEGIN> BUILD_PENTIUM2gnu.release_FILE_$(PRJ_DIR)/../../os/os_method.c_objects
-os_method.o
-<END>
-
-<BEGIN> BUILD_PENTIUM2gnu.release_FILE_$(PRJ_DIR)/../../os/os_method.c_toolMacro
-CC
-<END>
-
-<BEGIN> BUILD_PENTIUM2gnu.release_FILE_$(PRJ_DIR)/../../os/os_oflags.c_infoTags
-toolMacro objects
-<END>
-
-<BEGIN> BUILD_PENTIUM2gnu.release_FILE_$(PRJ_DIR)/../../os/os_oflags.c_objects
-os_oflags.o
-<END>
-
-<BEGIN> BUILD_PENTIUM2gnu.release_FILE_$(PRJ_DIR)/../../os/os_oflags.c_toolMacro
-CC
-<END>
-
-<BEGIN> BUILD_PENTIUM2gnu.release_FILE_$(PRJ_DIR)/../../os/os_open.c_infoTags
-toolMacro objects
-<END>
-
-<BEGIN> BUILD_PENTIUM2gnu.release_FILE_$(PRJ_DIR)/../../os/os_open.c_objects
-os_open.o
-<END>
-
-<BEGIN> BUILD_PENTIUM2gnu.release_FILE_$(PRJ_DIR)/../../os/os_open.c_toolMacro
-CC
-<END>
-
-<BEGIN> BUILD_PENTIUM2gnu.release_FILE_$(PRJ_DIR)/../../os/os_region.c_infoTags
-toolMacro objects
-<END>
-
-<BEGIN> BUILD_PENTIUM2gnu.release_FILE_$(PRJ_DIR)/../../os/os_region.c_objects
-os_region.o
-<END>
-
-<BEGIN> BUILD_PENTIUM2gnu.release_FILE_$(PRJ_DIR)/../../os/os_region.c_toolMacro
-CC
-<END>
-
-<BEGIN> BUILD_PENTIUM2gnu.release_FILE_$(PRJ_DIR)/../../os/os_rename.c_infoTags
-toolMacro objects
-<END>
-
-<BEGIN> BUILD_PENTIUM2gnu.release_FILE_$(PRJ_DIR)/../../os/os_rename.c_objects
-os_rename.o
-<END>
-
-<BEGIN> BUILD_PENTIUM2gnu.release_FILE_$(PRJ_DIR)/../../os/os_rename.c_toolMacro
-CC
-<END>
-
-<BEGIN> BUILD_PENTIUM2gnu.release_FILE_$(PRJ_DIR)/../../os/os_root.c_infoTags
-toolMacro objects
-<END>
-
-<BEGIN> BUILD_PENTIUM2gnu.release_FILE_$(PRJ_DIR)/../../os/os_root.c_objects
-os_root.o
-<END>
-
-<BEGIN> BUILD_PENTIUM2gnu.release_FILE_$(PRJ_DIR)/../../os/os_root.c_toolMacro
-CC
-<END>
-
-<BEGIN> BUILD_PENTIUM2gnu.release_FILE_$(PRJ_DIR)/../../os/os_rpath.c_infoTags
-toolMacro objects
-<END>
-
-<BEGIN> BUILD_PENTIUM2gnu.release_FILE_$(PRJ_DIR)/../../os/os_rpath.c_objects
-os_rpath.o
-<END>
-
-<BEGIN> BUILD_PENTIUM2gnu.release_FILE_$(PRJ_DIR)/../../os/os_rpath.c_toolMacro
-CC
-<END>
-
-<BEGIN> BUILD_PENTIUM2gnu.release_FILE_$(PRJ_DIR)/../../os/os_rw.c_infoTags
-toolMacro objects
-<END>
-
-<BEGIN> BUILD_PENTIUM2gnu.release_FILE_$(PRJ_DIR)/../../os/os_rw.c_objects
-os_rw.o
-<END>
-
-<BEGIN> BUILD_PENTIUM2gnu.release_FILE_$(PRJ_DIR)/../../os/os_rw.c_toolMacro
-CC
-<END>
-
-<BEGIN> BUILD_PENTIUM2gnu.release_FILE_$(PRJ_DIR)/../../os/os_seek.c_infoTags
-toolMacro objects
-<END>
-
-<BEGIN> BUILD_PENTIUM2gnu.release_FILE_$(PRJ_DIR)/../../os/os_seek.c_objects
-os_seek.o
-<END>
-
-<BEGIN> BUILD_PENTIUM2gnu.release_FILE_$(PRJ_DIR)/../../os/os_seek.c_toolMacro
-CC
-<END>
-
-<BEGIN> BUILD_PENTIUM2gnu.release_FILE_$(PRJ_DIR)/../../os/os_sleep.c_infoTags
-toolMacro objects
-<END>
-
-<BEGIN> BUILD_PENTIUM2gnu.release_FILE_$(PRJ_DIR)/../../os/os_sleep.c_objects
-os_sleep.o
-<END>
-
-<BEGIN> BUILD_PENTIUM2gnu.release_FILE_$(PRJ_DIR)/../../os/os_sleep.c_toolMacro
-CC
-<END>
-
-<BEGIN> BUILD_PENTIUM2gnu.release_FILE_$(PRJ_DIR)/../../os/os_spin.c_infoTags
-toolMacro objects
-<END>
-
-<BEGIN> BUILD_PENTIUM2gnu.release_FILE_$(PRJ_DIR)/../../os/os_spin.c_objects
-os_spin.o
-<END>
-
-<BEGIN> BUILD_PENTIUM2gnu.release_FILE_$(PRJ_DIR)/../../os/os_spin.c_toolMacro
-CC
-<END>
-
-<BEGIN> BUILD_PENTIUM2gnu.release_FILE_$(PRJ_DIR)/../../os/os_stat.c_infoTags
-toolMacro objects
-<END>
-
-<BEGIN> BUILD_PENTIUM2gnu.release_FILE_$(PRJ_DIR)/../../os/os_stat.c_objects
-os_stat.o
-<END>
-
-<BEGIN> BUILD_PENTIUM2gnu.release_FILE_$(PRJ_DIR)/../../os/os_stat.c_toolMacro
-CC
-<END>
-
-<BEGIN> BUILD_PENTIUM2gnu.release_FILE_$(PRJ_DIR)/../../os/os_tmpdir.c_infoTags
-toolMacro objects
-<END>
-
-<BEGIN> BUILD_PENTIUM2gnu.release_FILE_$(PRJ_DIR)/../../os/os_tmpdir.c_objects
-os_tmpdir.o
-<END>
-
-<BEGIN> BUILD_PENTIUM2gnu.release_FILE_$(PRJ_DIR)/../../os/os_tmpdir.c_toolMacro
-CC
-<END>
-
-<BEGIN> BUILD_PENTIUM2gnu.release_FILE_$(PRJ_DIR)/../../os/os_unlink.c_infoTags
-toolMacro objects
-<END>
-
-<BEGIN> BUILD_PENTIUM2gnu.release_FILE_$(PRJ_DIR)/../../os/os_unlink.c_objects
-os_unlink.o
-<END>
-
-<BEGIN> BUILD_PENTIUM2gnu.release_FILE_$(PRJ_DIR)/../../os/os_unlink.c_toolMacro
-CC
-<END>
-
-<BEGIN> BUILD_PENTIUM2gnu.release_FILE_$(PRJ_DIR)/../../os_vxworks/os_vx_abs.c_infoTags
-toolMacro objects
-<END>
-
-<BEGIN> BUILD_PENTIUM2gnu.release_FILE_$(PRJ_DIR)/../../os_vxworks/os_vx_abs.c_objects
-os_vx_abs.o
-<END>
-
-<BEGIN> BUILD_PENTIUM2gnu.release_FILE_$(PRJ_DIR)/../../os_vxworks/os_vx_abs.c_toolMacro
-CC
-<END>
-
-<BEGIN> BUILD_PENTIUM2gnu.release_FILE_$(PRJ_DIR)/../../os_vxworks/os_vx_config.c_infoTags
-toolMacro objects
-<END>
-
-<BEGIN> BUILD_PENTIUM2gnu.release_FILE_$(PRJ_DIR)/../../os_vxworks/os_vx_config.c_objects
-os_vx_config.o
-<END>
-
-<BEGIN> BUILD_PENTIUM2gnu.release_FILE_$(PRJ_DIR)/../../os_vxworks/os_vx_config.c_toolMacro
-CC
-<END>
-
-<BEGIN> BUILD_PENTIUM2gnu.release_FILE_$(PRJ_DIR)/../../os_vxworks/os_vx_map.c_infoTags
-toolMacro objects
-<END>
-
-<BEGIN> BUILD_PENTIUM2gnu.release_FILE_$(PRJ_DIR)/../../os_vxworks/os_vx_map.c_objects
-os_vx_map.o
-<END>
-
-<BEGIN> BUILD_PENTIUM2gnu.release_FILE_$(PRJ_DIR)/../../os_vxworks/os_vx_map.c_toolMacro
-CC
-<END>
-
-<BEGIN> BUILD_PENTIUM2gnu.release_FILE_$(PRJ_DIR)/../../qam/qam.c_infoTags
-toolMacro objects
-<END>
-
-<BEGIN> BUILD_PENTIUM2gnu.release_FILE_$(PRJ_DIR)/../../qam/qam.c_objects
-qam.o
-<END>
-
-<BEGIN> BUILD_PENTIUM2gnu.release_FILE_$(PRJ_DIR)/../../qam/qam.c_toolMacro
-CC
-<END>
-
-<BEGIN> BUILD_PENTIUM2gnu.release_FILE_$(PRJ_DIR)/../../qam/qam_auto.c_infoTags
-toolMacro objects
-<END>
-
-<BEGIN> BUILD_PENTIUM2gnu.release_FILE_$(PRJ_DIR)/../../qam/qam_auto.c_objects
-qam_auto.o
-<END>
-
-<BEGIN> BUILD_PENTIUM2gnu.release_FILE_$(PRJ_DIR)/../../qam/qam_auto.c_toolMacro
-CC
-<END>
-
-<BEGIN> BUILD_PENTIUM2gnu.release_FILE_$(PRJ_DIR)/../../qam/qam_conv.c_infoTags
-toolMacro objects
-<END>
-
-<BEGIN> BUILD_PENTIUM2gnu.release_FILE_$(PRJ_DIR)/../../qam/qam_conv.c_objects
-qam_conv.o
-<END>
-
-<BEGIN> BUILD_PENTIUM2gnu.release_FILE_$(PRJ_DIR)/../../qam/qam_conv.c_toolMacro
-CC
-<END>
-
-<BEGIN> BUILD_PENTIUM2gnu.release_FILE_$(PRJ_DIR)/../../qam/qam_files.c_infoTags
-toolMacro objects
-<END>
-
-<BEGIN> BUILD_PENTIUM2gnu.release_FILE_$(PRJ_DIR)/../../qam/qam_files.c_objects
-qam_files.o
-<END>
-
-<BEGIN> BUILD_PENTIUM2gnu.release_FILE_$(PRJ_DIR)/../../qam/qam_files.c_toolMacro
-CC
-<END>
-
-<BEGIN> BUILD_PENTIUM2gnu.release_FILE_$(PRJ_DIR)/../../qam/qam_method.c_infoTags
-toolMacro objects
-<END>
-
-<BEGIN> BUILD_PENTIUM2gnu.release_FILE_$(PRJ_DIR)/../../qam/qam_method.c_objects
-qam_method.o
-<END>
-
-<BEGIN> BUILD_PENTIUM2gnu.release_FILE_$(PRJ_DIR)/../../qam/qam_method.c_toolMacro
-CC
-<END>
-
-<BEGIN> BUILD_PENTIUM2gnu.release_FILE_$(PRJ_DIR)/../../qam/qam_open.c_infoTags
-toolMacro objects
-<END>
-
-<BEGIN> BUILD_PENTIUM2gnu.release_FILE_$(PRJ_DIR)/../../qam/qam_open.c_objects
-qam_open.o
-<END>
-
-<BEGIN> BUILD_PENTIUM2gnu.release_FILE_$(PRJ_DIR)/../../qam/qam_open.c_toolMacro
-CC
-<END>
-
-<BEGIN> BUILD_PENTIUM2gnu.release_FILE_$(PRJ_DIR)/../../qam/qam_rec.c_infoTags
-toolMacro objects
-<END>
-
-<BEGIN> BUILD_PENTIUM2gnu.release_FILE_$(PRJ_DIR)/../../qam/qam_rec.c_objects
-qam_rec.o
-<END>
-
-<BEGIN> BUILD_PENTIUM2gnu.release_FILE_$(PRJ_DIR)/../../qam/qam_rec.c_toolMacro
-CC
-<END>
-
-<BEGIN> BUILD_PENTIUM2gnu.release_FILE_$(PRJ_DIR)/../../qam/qam_stat.c_infoTags
-toolMacro objects
-<END>
-
-<BEGIN> BUILD_PENTIUM2gnu.release_FILE_$(PRJ_DIR)/../../qam/qam_stat.c_objects
-qam_stat.o
-<END>
-
-<BEGIN> BUILD_PENTIUM2gnu.release_FILE_$(PRJ_DIR)/../../qam/qam_stat.c_toolMacro
-CC
-<END>
-
-<BEGIN> BUILD_PENTIUM2gnu.release_FILE_$(PRJ_DIR)/../../qam/qam_upgrade.c_infoTags
-toolMacro objects
-<END>
-
-<BEGIN> BUILD_PENTIUM2gnu.release_FILE_$(PRJ_DIR)/../../qam/qam_upgrade.c_objects
-qam_upgrade.o
-<END>
-
-<BEGIN> BUILD_PENTIUM2gnu.release_FILE_$(PRJ_DIR)/../../qam/qam_upgrade.c_toolMacro
-CC
-<END>
-
-<BEGIN> BUILD_PENTIUM2gnu.release_FILE_$(PRJ_DIR)/../../qam/qam_verify.c_infoTags
-toolMacro objects
-<END>
-
-<BEGIN> BUILD_PENTIUM2gnu.release_FILE_$(PRJ_DIR)/../../qam/qam_verify.c_objects
-qam_verify.o
-<END>
-
-<BEGIN> BUILD_PENTIUM2gnu.release_FILE_$(PRJ_DIR)/../../qam/qam_verify.c_toolMacro
-CC
-<END>
-
-<BEGIN> BUILD_PENTIUM2gnu.release_FILE_$(PRJ_DIR)/../../rep/rep_method.c_infoTags
-toolMacro objects
-<END>
-
-<BEGIN> BUILD_PENTIUM2gnu.release_FILE_$(PRJ_DIR)/../../rep/rep_method.c_objects
-rep_method.o
-<END>
-
-<BEGIN> BUILD_PENTIUM2gnu.release_FILE_$(PRJ_DIR)/../../rep/rep_method.c_toolMacro
-CC
-<END>
-
-<BEGIN> BUILD_PENTIUM2gnu.release_FILE_$(PRJ_DIR)/../../rep/rep_record.c_infoTags
-toolMacro objects
-<END>
-
-<BEGIN> BUILD_PENTIUM2gnu.release_FILE_$(PRJ_DIR)/../../rep/rep_record.c_objects
-rep_record.o
-<END>
-
-<BEGIN> BUILD_PENTIUM2gnu.release_FILE_$(PRJ_DIR)/../../rep/rep_record.c_toolMacro
-CC
-<END>
-
-<BEGIN> BUILD_PENTIUM2gnu.release_FILE_$(PRJ_DIR)/../../rep/rep_region.c_infoTags
-toolMacro objects
-<END>
-
-<BEGIN> BUILD_PENTIUM2gnu.release_FILE_$(PRJ_DIR)/../../rep/rep_region.c_objects
-rep_region.o
-<END>
-
-<BEGIN> BUILD_PENTIUM2gnu.release_FILE_$(PRJ_DIR)/../../rep/rep_region.c_toolMacro
-CC
-<END>
-
-<BEGIN> BUILD_PENTIUM2gnu.release_FILE_$(PRJ_DIR)/../../rep/rep_util.c_infoTags
-toolMacro objects
-<END>
-
-<BEGIN> BUILD_PENTIUM2gnu.release_FILE_$(PRJ_DIR)/../../rep/rep_util.c_objects
-rep_util.o
-<END>
-
-<BEGIN> BUILD_PENTIUM2gnu.release_FILE_$(PRJ_DIR)/../../rep/rep_util.c_toolMacro
-CC
-<END>
-
-<BEGIN> BUILD_PENTIUM2gnu.release_FILE_$(PRJ_DIR)/../../rpc_client/client.c_infoTags
-toolMacro objects
-<END>
-
-<BEGIN> BUILD_PENTIUM2gnu.release_FILE_$(PRJ_DIR)/../../rpc_client/client.c_objects
-client.o
-<END>
-
-<BEGIN> BUILD_PENTIUM2gnu.release_FILE_$(PRJ_DIR)/../../rpc_client/client.c_toolMacro
-CC
-<END>
-
-<BEGIN> BUILD_PENTIUM2gnu.release_FILE_$(PRJ_DIR)/../../rpc_client/db_server_clnt.c_infoTags
-toolMacro objects
-<END>
-
-<BEGIN> BUILD_PENTIUM2gnu.release_FILE_$(PRJ_DIR)/../../rpc_client/db_server_clnt.c_objects
-db_server_clnt.o
-<END>
-
-<BEGIN> BUILD_PENTIUM2gnu.release_FILE_$(PRJ_DIR)/../../rpc_client/db_server_clnt.c_toolMacro
-CC
-<END>
-
-<BEGIN> BUILD_PENTIUM2gnu.release_FILE_$(PRJ_DIR)/../../rpc_client/gen_client.c_infoTags
-toolMacro objects
-<END>
-
-<BEGIN> BUILD_PENTIUM2gnu.release_FILE_$(PRJ_DIR)/../../rpc_client/gen_client.c_objects
-gen_client.o
-<END>
-
-<BEGIN> BUILD_PENTIUM2gnu.release_FILE_$(PRJ_DIR)/../../rpc_client/gen_client.c_toolMacro
-CC
-<END>
-
-<BEGIN> BUILD_PENTIUM2gnu.release_FILE_$(PRJ_DIR)/../../rpc_client/gen_client_ret.c_infoTags
-toolMacro objects
-<END>
-
-<BEGIN> BUILD_PENTIUM2gnu.release_FILE_$(PRJ_DIR)/../../rpc_client/gen_client_ret.c_objects
-gen_client_ret.o
-<END>
-
-<BEGIN> BUILD_PENTIUM2gnu.release_FILE_$(PRJ_DIR)/../../rpc_client/gen_client_ret.c_toolMacro
-CC
-<END>
-
-<BEGIN> BUILD_PENTIUM2gnu.release_FILE_$(PRJ_DIR)/../../rpc_server/c/db_server_xdr.c_infoTags
-toolMacro objects
-<END>
-
-<BEGIN> BUILD_PENTIUM2gnu.release_FILE_$(PRJ_DIR)/../../rpc_server/c/db_server_xdr.c_objects
-db_server_xdr.o
-<END>
-
-<BEGIN> BUILD_PENTIUM2gnu.release_FILE_$(PRJ_DIR)/../../rpc_server/c/db_server_xdr.c_toolMacro
-CC
-<END>
-
-<BEGIN> BUILD_PENTIUM2gnu.release_FILE_$(PRJ_DIR)/../../txn/txn.c_infoTags
-toolMacro objects
-<END>
-
-<BEGIN> BUILD_PENTIUM2gnu.release_FILE_$(PRJ_DIR)/../../txn/txn.c_objects
-txn.o
-<END>
-
-<BEGIN> BUILD_PENTIUM2gnu.release_FILE_$(PRJ_DIR)/../../txn/txn.c_toolMacro
-CC
-<END>
-
-<BEGIN> BUILD_PENTIUM2gnu.release_FILE_$(PRJ_DIR)/../../txn/txn_auto.c_infoTags
-toolMacro objects
-<END>
-
-<BEGIN> BUILD_PENTIUM2gnu.release_FILE_$(PRJ_DIR)/../../txn/txn_auto.c_objects
-txn_auto.o
-<END>
-
-<BEGIN> BUILD_PENTIUM2gnu.release_FILE_$(PRJ_DIR)/../../txn/txn_auto.c_toolMacro
-CC
-<END>
-
-<BEGIN> BUILD_PENTIUM2gnu.release_FILE_$(PRJ_DIR)/../../txn/txn_method.c_infoTags
-toolMacro objects
-<END>
-
-<BEGIN> BUILD_PENTIUM2gnu.release_FILE_$(PRJ_DIR)/../../txn/txn_method.c_objects
-txn_method.o
-<END>
-
-<BEGIN> BUILD_PENTIUM2gnu.release_FILE_$(PRJ_DIR)/../../txn/txn_method.c_toolMacro
-CC
-<END>
-
-<BEGIN> BUILD_PENTIUM2gnu.release_FILE_$(PRJ_DIR)/../../txn/txn_rec.c_infoTags
-toolMacro objects
-<END>
-
-<BEGIN> BUILD_PENTIUM2gnu.release_FILE_$(PRJ_DIR)/../../txn/txn_rec.c_objects
-txn_rec.o
-<END>
-
-<BEGIN> BUILD_PENTIUM2gnu.release_FILE_$(PRJ_DIR)/../../txn/txn_rec.c_toolMacro
-CC
-<END>
-
-<BEGIN> BUILD_PENTIUM2gnu.release_FILE_$(PRJ_DIR)/../../txn/txn_recover.c_infoTags
-toolMacro objects
-<END>
-
-<BEGIN> BUILD_PENTIUM2gnu.release_FILE_$(PRJ_DIR)/../../txn/txn_recover.c_objects
-txn_recover.o
-<END>
-
-<BEGIN> BUILD_PENTIUM2gnu.release_FILE_$(PRJ_DIR)/../../txn/txn_recover.c_toolMacro
-CC
-<END>
-
-<BEGIN> BUILD_PENTIUM2gnu.release_FILE_$(PRJ_DIR)/../../txn/txn_region.c_infoTags
-toolMacro objects
-<END>
-
-<BEGIN> BUILD_PENTIUM2gnu.release_FILE_$(PRJ_DIR)/../../txn/txn_region.c_objects
-txn_region.o
-<END>
-
-<BEGIN> BUILD_PENTIUM2gnu.release_FILE_$(PRJ_DIR)/../../txn/txn_region.c_toolMacro
-CC
-<END>
-
-<BEGIN> BUILD_PENTIUM2gnu.release_FILE_$(PRJ_DIR)/../../txn/txn_stat.c_infoTags
-toolMacro objects
-<END>
-
-<BEGIN> BUILD_PENTIUM2gnu.release_FILE_$(PRJ_DIR)/../../txn/txn_stat.c_objects
-txn_stat.o
-<END>
-
-<BEGIN> BUILD_PENTIUM2gnu.release_FILE_$(PRJ_DIR)/../../txn/txn_stat.c_toolMacro
-CC
-<END>
-
-<BEGIN> BUILD_PENTIUM2gnu.release_FILE_$(PRJ_DIR)/../../txn/txn_util.c_infoTags
-toolMacro objects
-<END>
-
-<BEGIN> BUILD_PENTIUM2gnu.release_FILE_$(PRJ_DIR)/../../txn/txn_util.c_objects
-txn_util.o
-<END>
-
-<BEGIN> BUILD_PENTIUM2gnu.release_FILE_$(PRJ_DIR)/../../txn/txn_util.c_toolMacro
-CC
-<END>
-
-<BEGIN> BUILD_PENTIUM2gnu.release_FILE_$(PRJ_DIR)/../../xa/xa.c_infoTags
-toolMacro objects
-<END>
-
-<BEGIN> BUILD_PENTIUM2gnu.release_FILE_$(PRJ_DIR)/../../xa/xa.c_objects
-xa.o
-<END>
-
-<BEGIN> BUILD_PENTIUM2gnu.release_FILE_$(PRJ_DIR)/../../xa/xa.c_toolMacro
-CC
-<END>
-
-<BEGIN> BUILD_PENTIUM2gnu.release_FILE_$(PRJ_DIR)/../../xa/xa_db.c_infoTags
-toolMacro objects
-<END>
-
-<BEGIN> BUILD_PENTIUM2gnu.release_FILE_$(PRJ_DIR)/../../xa/xa_db.c_objects
-xa_db.o
-<END>
-
-<BEGIN> BUILD_PENTIUM2gnu.release_FILE_$(PRJ_DIR)/../../xa/xa_db.c_toolMacro
-CC
-<END>
-
-<BEGIN> BUILD_PENTIUM2gnu.release_FILE_$(PRJ_DIR)/../../xa/xa_map.c_infoTags
-toolMacro objects
-<END>
-
-<BEGIN> BUILD_PENTIUM2gnu.release_FILE_$(PRJ_DIR)/../../xa/xa_map.c_objects
-xa_map.o
-<END>
-
-<BEGIN> BUILD_PENTIUM2gnu.release_FILE_$(PRJ_DIR)/../../xa/xa_map.c_toolMacro
-CC
-<END>
-
-<BEGIN> BUILD_PENTIUM2gnu.release_FILE_$(PRJ_DIR)/compConfig.c_infoTags
-toolMacro objects
-<END>
-
-<BEGIN> BUILD_PENTIUM2gnu.release_FILE_$(PRJ_DIR)/compConfig.c_objects
-compConfig.o
-<END>
-
-<BEGIN> BUILD_PENTIUM2gnu.release_FILE_$(PRJ_DIR)/compConfig.c_toolMacro
-CC
-<END>
-
-<BEGIN> BUILD_PENTIUM2gnu.release_MACRO_AR
-arpentium
-<END>
-
-<BEGIN> BUILD_PENTIUM2gnu.release_MACRO_AS
-ccpentium
-<END>
-
-<BEGIN> BUILD_PENTIUM2gnu.release_MACRO_CC
-ccpentium
-<END>
-
-<BEGIN> BUILD_PENTIUM2gnu.release_MACRO_CFLAGS
--mcpu=pentiumpro \
-	-march=pentiumpro \
-	-ansi \
-	-DRW_MULTI_THREAD \
-	-D_REENTRANT \
-	-O2 \
-	-nostdlib \
-	-fno-builtin \
-	-fno-defer-pop \
-	-MD \
-	-Wall \
-	-I. \
-	-I$(WIND_BASE)/target/h \
-	-DCPU=PENTIUM2 \
-	-I$(PRJ_DIR)/.. \
-	-I$(PRJ_DIR)/../..
-<END>
-
-<BEGIN> BUILD_PENTIUM2gnu.release_MACRO_CFLAGS_AS
--mcpu=pentiumpro \
-	-march=pentiumpro \
-	-ansi \
-	-O2 \
-	-nostdlib \
-	-fno-builtin \
-	-fno-defer-pop \
-	-P \
-	-x \
-	assembler-with-cpp \
-	-Wall \
-	-I. \
-	-I$(WIND_BASE)/target/h \
-	-DCPU=PENTIUM2
-<END>
-
-<BEGIN> BUILD_PENTIUM2gnu.release_MACRO_CPP
-ccpentium -E -P
-<END>
-
-<BEGIN> BUILD_PENTIUM2gnu.release_MACRO_CPPFILT
-c++filtpentium --strip-underscores
-<END>
-
-<BEGIN> BUILD_PENTIUM2gnu.release_MACRO_LD
-ldpentium
-<END>
-
-<BEGIN> BUILD_PENTIUM2gnu.release_MACRO_LDFLAGS
--X
-<END>
-
-<BEGIN> BUILD_PENTIUM2gnu.release_MACRO_LDPARTIAL
-ccpentium \
-	-B$(WIND_BASE)/host/$(WIND_HOST_TYPE)/lib/gcc-lib/ \
-	-nostdlib \
-	-r \
-	-Wl,-X
-<END>
-
-<BEGIN> BUILD_PENTIUM2gnu.release_MACRO_LD_PARTIAL_FLAGS
--X -r
-<END>
-
-<BEGIN> BUILD_PENTIUM2gnu.release_MACRO_NM
-nmpentium -g
-<END>
-
-<BEGIN> BUILD_PENTIUM2gnu.release_MACRO_OPTION_DEFINE_MACRO
--D
-<END>
-
-<BEGIN> BUILD_PENTIUM2gnu.release_MACRO_OPTION_GENERATE_DEPENDENCY_FILE
--MD
-<END>
-
-<BEGIN> BUILD_PENTIUM2gnu.release_MACRO_OPTION_INCLUDE_DIR
--I
-<END>
-
-<BEGIN> BUILD_PENTIUM2gnu.release_MACRO_RELEASE
-1
-<END>
-
-<BEGIN> BUILD_PENTIUM2gnu.release_MACRO_SIZE
-sizepentium
-<END>
-
-<BEGIN> BUILD_PENTIUM2gnu.release_RELEASE
-1
-<END>
-
-<BEGIN> BUILD_PENTIUM2gnu.release_RO_DEPEND_PATH
-$(WIND_BASE)/target/h/
-<END>
-
-<BEGIN> BUILD_PENTIUM2gnu.release_TC
-::tc_PENTIUM2gnu.release
-<END>
-
-<BEGIN> BUILD_PENTIUMgnu.debug_DEFAULTFORCPU
-1
-<END>
-
-<BEGIN> BUILD_PENTIUMgnu.debug_FILE_$(PRJ_DIR)/../../btree/bt_compare.c_infoTags
-toolMacro objects
-<END>
-
-<BEGIN> BUILD_PENTIUMgnu.debug_FILE_$(PRJ_DIR)/../../btree/bt_compare.c_objects
-bt_compare.o
-<END>
-
-<BEGIN> BUILD_PENTIUMgnu.debug_FILE_$(PRJ_DIR)/../../btree/bt_compare.c_toolMacro
-CC
-<END>
-
-<BEGIN> BUILD_PENTIUMgnu.debug_FILE_$(PRJ_DIR)/../../btree/bt_conv.c_infoTags
-toolMacro objects
-<END>
-
-<BEGIN> BUILD_PENTIUMgnu.debug_FILE_$(PRJ_DIR)/../../btree/bt_conv.c_objects
-bt_conv.o
-<END>
-
-<BEGIN> BUILD_PENTIUMgnu.debug_FILE_$(PRJ_DIR)/../../btree/bt_conv.c_toolMacro
-CC
-<END>
-
-<BEGIN> BUILD_PENTIUMgnu.debug_FILE_$(PRJ_DIR)/../../btree/bt_curadj.c_infoTags
-toolMacro objects
-<END>
-
-<BEGIN> BUILD_PENTIUMgnu.debug_FILE_$(PRJ_DIR)/../../btree/bt_curadj.c_objects
-bt_curadj.o
-<END>
-
-<BEGIN> BUILD_PENTIUMgnu.debug_FILE_$(PRJ_DIR)/../../btree/bt_curadj.c_toolMacro
-CC
-<END>
-
-<BEGIN> BUILD_PENTIUMgnu.debug_FILE_$(PRJ_DIR)/../../btree/bt_cursor.c_infoTags
-toolMacro objects
-<END>
-
-<BEGIN> BUILD_PENTIUMgnu.debug_FILE_$(PRJ_DIR)/../../btree/bt_cursor.c_objects
-bt_cursor.o
-<END>
-
-<BEGIN> BUILD_PENTIUMgnu.debug_FILE_$(PRJ_DIR)/../../btree/bt_cursor.c_toolMacro
-CC
-<END>
-
-<BEGIN> BUILD_PENTIUMgnu.debug_FILE_$(PRJ_DIR)/../../btree/bt_delete.c_infoTags
-toolMacro objects
-<END>
-
-<BEGIN> BUILD_PENTIUMgnu.debug_FILE_$(PRJ_DIR)/../../btree/bt_delete.c_objects
-bt_delete.o
-<END>
-
-<BEGIN> BUILD_PENTIUMgnu.debug_FILE_$(PRJ_DIR)/../../btree/bt_delete.c_toolMacro
-CC
-<END>
-
-<BEGIN> BUILD_PENTIUMgnu.debug_FILE_$(PRJ_DIR)/../../btree/bt_method.c_infoTags
-toolMacro objects
-<END>
-
-<BEGIN> BUILD_PENTIUMgnu.debug_FILE_$(PRJ_DIR)/../../btree/bt_method.c_objects
-bt_method.o
-<END>
-
-<BEGIN> BUILD_PENTIUMgnu.debug_FILE_$(PRJ_DIR)/../../btree/bt_method.c_toolMacro
-CC
-<END>
-
-<BEGIN> BUILD_PENTIUMgnu.debug_FILE_$(PRJ_DIR)/../../btree/bt_open.c_infoTags
-toolMacro objects
-<END>
-
-<BEGIN> BUILD_PENTIUMgnu.debug_FILE_$(PRJ_DIR)/../../btree/bt_open.c_objects
-bt_open.o
-<END>
-
-<BEGIN> BUILD_PENTIUMgnu.debug_FILE_$(PRJ_DIR)/../../btree/bt_open.c_toolMacro
-CC
-<END>
-
-<BEGIN> BUILD_PENTIUMgnu.debug_FILE_$(PRJ_DIR)/../../btree/bt_put.c_infoTags
-toolMacro objects
-<END>
-
-<BEGIN> BUILD_PENTIUMgnu.debug_FILE_$(PRJ_DIR)/../../btree/bt_put.c_objects
-bt_put.o
-<END>
-
-<BEGIN> BUILD_PENTIUMgnu.debug_FILE_$(PRJ_DIR)/../../btree/bt_put.c_toolMacro
-CC
-<END>
-
-<BEGIN> BUILD_PENTIUMgnu.debug_FILE_$(PRJ_DIR)/../../btree/bt_rec.c_infoTags
-toolMacro objects
-<END>
-
-<BEGIN> BUILD_PENTIUMgnu.debug_FILE_$(PRJ_DIR)/../../btree/bt_rec.c_objects
-bt_rec.o
-<END>
-
-<BEGIN> BUILD_PENTIUMgnu.debug_FILE_$(PRJ_DIR)/../../btree/bt_rec.c_toolMacro
-CC
-<END>
-
-<BEGIN> BUILD_PENTIUMgnu.debug_FILE_$(PRJ_DIR)/../../btree/bt_reclaim.c_infoTags
-toolMacro objects
-<END>
-
-<BEGIN> BUILD_PENTIUMgnu.debug_FILE_$(PRJ_DIR)/../../btree/bt_reclaim.c_objects
-bt_reclaim.o
-<END>
-
-<BEGIN> BUILD_PENTIUMgnu.debug_FILE_$(PRJ_DIR)/../../btree/bt_reclaim.c_toolMacro
-CC
-<END>
-
-<BEGIN> BUILD_PENTIUMgnu.debug_FILE_$(PRJ_DIR)/../../btree/bt_recno.c_infoTags
-toolMacro objects
-<END>
-
-<BEGIN> BUILD_PENTIUMgnu.debug_FILE_$(PRJ_DIR)/../../btree/bt_recno.c_objects
-bt_recno.o
-<END>
-
-<BEGIN> BUILD_PENTIUMgnu.debug_FILE_$(PRJ_DIR)/../../btree/bt_recno.c_toolMacro
-CC
-<END>
-
-<BEGIN> BUILD_PENTIUMgnu.debug_FILE_$(PRJ_DIR)/../../btree/bt_rsearch.c_infoTags
-toolMacro objects
-<END>
-
-<BEGIN> BUILD_PENTIUMgnu.debug_FILE_$(PRJ_DIR)/../../btree/bt_rsearch.c_objects
-bt_rsearch.o
-<END>
-
-<BEGIN> BUILD_PENTIUMgnu.debug_FILE_$(PRJ_DIR)/../../btree/bt_rsearch.c_toolMacro
-CC
-<END>
-
-<BEGIN> BUILD_PENTIUMgnu.debug_FILE_$(PRJ_DIR)/../../btree/bt_search.c_infoTags
-toolMacro objects
-<END>
-
-<BEGIN> BUILD_PENTIUMgnu.debug_FILE_$(PRJ_DIR)/../../btree/bt_search.c_objects
-bt_search.o
-<END>
-
-<BEGIN> BUILD_PENTIUMgnu.debug_FILE_$(PRJ_DIR)/../../btree/bt_search.c_toolMacro
-CC
-<END>
-
-<BEGIN> BUILD_PENTIUMgnu.debug_FILE_$(PRJ_DIR)/../../btree/bt_split.c_infoTags
-toolMacro objects
-<END>
-
-<BEGIN> BUILD_PENTIUMgnu.debug_FILE_$(PRJ_DIR)/../../btree/bt_split.c_objects
-bt_split.o
-<END>
-
-<BEGIN> BUILD_PENTIUMgnu.debug_FILE_$(PRJ_DIR)/../../btree/bt_split.c_toolMacro
-CC
-<END>
-
-<BEGIN> BUILD_PENTIUMgnu.debug_FILE_$(PRJ_DIR)/../../btree/bt_stat.c_infoTags
-toolMacro objects
-<END>
-
-<BEGIN> BUILD_PENTIUMgnu.debug_FILE_$(PRJ_DIR)/../../btree/bt_stat.c_objects
-bt_stat.o
-<END>
-
-<BEGIN> BUILD_PENTIUMgnu.debug_FILE_$(PRJ_DIR)/../../btree/bt_stat.c_toolMacro
-CC
-<END>
-
-<BEGIN> BUILD_PENTIUMgnu.debug_FILE_$(PRJ_DIR)/../../btree/bt_upgrade.c_infoTags
-toolMacro objects
-<END>
-
-<BEGIN> BUILD_PENTIUMgnu.debug_FILE_$(PRJ_DIR)/../../btree/bt_upgrade.c_objects
-bt_upgrade.o
-<END>
-
-<BEGIN> BUILD_PENTIUMgnu.debug_FILE_$(PRJ_DIR)/../../btree/bt_upgrade.c_toolMacro
-CC
-<END>
-
-<BEGIN> BUILD_PENTIUMgnu.debug_FILE_$(PRJ_DIR)/../../btree/bt_verify.c_infoTags
-toolMacro objects
-<END>
-
-<BEGIN> BUILD_PENTIUMgnu.debug_FILE_$(PRJ_DIR)/../../btree/bt_verify.c_objects
-bt_verify.o
-<END>
-
-<BEGIN> BUILD_PENTIUMgnu.debug_FILE_$(PRJ_DIR)/../../btree/bt_verify.c_toolMacro
-CC
-<END>
-
-<BEGIN> BUILD_PENTIUMgnu.debug_FILE_$(PRJ_DIR)/../../btree/btree_auto.c_infoTags
-toolMacro objects
-<END>
-
-<BEGIN> BUILD_PENTIUMgnu.debug_FILE_$(PRJ_DIR)/../../btree/btree_auto.c_objects
-btree_auto.o
-<END>
-
-<BEGIN> BUILD_PENTIUMgnu.debug_FILE_$(PRJ_DIR)/../../btree/btree_auto.c_toolMacro
-CC
-<END>
-
-<BEGIN> BUILD_PENTIUMgnu.debug_FILE_$(PRJ_DIR)/../../clib/getopt.c_infoTags
-toolMacro objects
-<END>
-
-<BEGIN> BUILD_PENTIUMgnu.debug_FILE_$(PRJ_DIR)/../../clib/getopt.c_objects
-getopt.o
-<END>
-
-<BEGIN> BUILD_PENTIUMgnu.debug_FILE_$(PRJ_DIR)/../../clib/getopt.c_toolMacro
-CC
-<END>
-
-<BEGIN> BUILD_PENTIUMgnu.debug_FILE_$(PRJ_DIR)/../../clib/snprintf.c_infoTags
-toolMacro objects
-<END>
-
-<BEGIN> BUILD_PENTIUMgnu.debug_FILE_$(PRJ_DIR)/../../clib/snprintf.c_objects
-snprintf.o
-<END>
-
-<BEGIN> BUILD_PENTIUMgnu.debug_FILE_$(PRJ_DIR)/../../clib/snprintf.c_toolMacro
-CC
-<END>
-
-<BEGIN> BUILD_PENTIUMgnu.debug_FILE_$(PRJ_DIR)/../../clib/strcasecmp.c_infoTags
-toolMacro objects
-<END>
-
-<BEGIN> BUILD_PENTIUMgnu.debug_FILE_$(PRJ_DIR)/../../clib/strcasecmp.c_objects
-strcasecmp.o
-<END>
-
-<BEGIN> BUILD_PENTIUMgnu.debug_FILE_$(PRJ_DIR)/../../clib/strcasecmp.c_toolMacro
-CC
-<END>
-
-<BEGIN> BUILD_PENTIUMgnu.debug_FILE_$(PRJ_DIR)/../../clib/strdup.c_infoTags
-toolMacro objects
-<END>
-
-<BEGIN> BUILD_PENTIUMgnu.debug_FILE_$(PRJ_DIR)/../../clib/strdup.c_objects
-strdup.o
-<END>
-
-<BEGIN> BUILD_PENTIUMgnu.debug_FILE_$(PRJ_DIR)/../../clib/strdup.c_toolMacro
-CC
-<END>
-
-<BEGIN> BUILD_PENTIUMgnu.debug_FILE_$(PRJ_DIR)/../../clib/vsnprintf.c_infoTags
-toolMacro objects
-<END>
-
-<BEGIN> BUILD_PENTIUMgnu.debug_FILE_$(PRJ_DIR)/../../clib/vsnprintf.c_objects
-vsnprintf.o
-<END>
-
-<BEGIN> BUILD_PENTIUMgnu.debug_FILE_$(PRJ_DIR)/../../clib/vsnprintf.c_toolMacro
-CC
-<END>
-
-<BEGIN> BUILD_PENTIUMgnu.debug_FILE_$(PRJ_DIR)/../../common/db_byteorder.c_infoTags
-toolMacro objects
-<END>
-
-<BEGIN> BUILD_PENTIUMgnu.debug_FILE_$(PRJ_DIR)/../../common/db_byteorder.c_objects
-db_byteorder.o
-<END>
-
-<BEGIN> BUILD_PENTIUMgnu.debug_FILE_$(PRJ_DIR)/../../common/db_byteorder.c_toolMacro
-CC
-<END>
-
-<BEGIN> BUILD_PENTIUMgnu.debug_FILE_$(PRJ_DIR)/../../common/db_err.c_infoTags
-toolMacro objects
-<END>
-
-<BEGIN> BUILD_PENTIUMgnu.debug_FILE_$(PRJ_DIR)/../../common/db_err.c_objects
-db_err.o
-<END>
-
-<BEGIN> BUILD_PENTIUMgnu.debug_FILE_$(PRJ_DIR)/../../common/db_err.c_toolMacro
-CC
-<END>
-
-<BEGIN> BUILD_PENTIUMgnu.debug_FILE_$(PRJ_DIR)/../../common/db_getlong.c_infoTags
-toolMacro objects
-<END>
-
-<BEGIN> BUILD_PENTIUMgnu.debug_FILE_$(PRJ_DIR)/../../common/db_getlong.c_objects
-db_getlong.o
-<END>
-
-<BEGIN> BUILD_PENTIUMgnu.debug_FILE_$(PRJ_DIR)/../../common/db_getlong.c_toolMacro
-CC
-<END>
-
-<BEGIN> BUILD_PENTIUMgnu.debug_FILE_$(PRJ_DIR)/../../common/db_idspace.c_infoTags
-toolMacro objects
-<END>
-
-<BEGIN> BUILD_PENTIUMgnu.debug_FILE_$(PRJ_DIR)/../../common/db_idspace.c_objects
-db_idspace.o
-<END>
-
-<BEGIN> BUILD_PENTIUMgnu.debug_FILE_$(PRJ_DIR)/../../common/db_idspace.c_toolMacro
-CC
-<END>
-
-<BEGIN> BUILD_PENTIUMgnu.debug_FILE_$(PRJ_DIR)/../../common/db_log2.c_infoTags
-toolMacro objects
-<END>
-
-<BEGIN> BUILD_PENTIUMgnu.debug_FILE_$(PRJ_DIR)/../../common/db_log2.c_objects
-db_log2.o
-<END>
-
-<BEGIN> BUILD_PENTIUMgnu.debug_FILE_$(PRJ_DIR)/../../common/db_log2.c_toolMacro
-CC
-<END>
-
-<BEGIN> BUILD_PENTIUMgnu.debug_FILE_$(PRJ_DIR)/../../common/util_arg.c_infoTags
-toolMacro objects
-<END>
-
-<BEGIN> BUILD_PENTIUMgnu.debug_FILE_$(PRJ_DIR)/../../common/util_arg.c_objects
-util_arg.o
-<END>
-
-<BEGIN> BUILD_PENTIUMgnu.debug_FILE_$(PRJ_DIR)/../../common/util_arg.c_toolMacro
-CC
-<END>
-
-<BEGIN> BUILD_PENTIUMgnu.debug_FILE_$(PRJ_DIR)/../../common/util_cache.c_infoTags
-toolMacro objects
-<END>
-
-<BEGIN> BUILD_PENTIUMgnu.debug_FILE_$(PRJ_DIR)/../../common/util_cache.c_objects
-util_cache.o
-<END>
-
-<BEGIN> BUILD_PENTIUMgnu.debug_FILE_$(PRJ_DIR)/../../common/util_cache.c_toolMacro
-CC
-<END>
-
-<BEGIN> BUILD_PENTIUMgnu.debug_FILE_$(PRJ_DIR)/../../common/util_log.c_infoTags
-toolMacro objects
-<END>
-
-<BEGIN> BUILD_PENTIUMgnu.debug_FILE_$(PRJ_DIR)/../../common/util_log.c_objects
-util_log.o
-<END>
-
-<BEGIN> BUILD_PENTIUMgnu.debug_FILE_$(PRJ_DIR)/../../common/util_log.c_toolMacro
-CC
-<END>
-
-<BEGIN> BUILD_PENTIUMgnu.debug_FILE_$(PRJ_DIR)/../../common/util_sig.c_infoTags
-toolMacro objects
-<END>
-
-<BEGIN> BUILD_PENTIUMgnu.debug_FILE_$(PRJ_DIR)/../../common/util_sig.c_objects
-util_sig.o
-<END>
-
-<BEGIN> BUILD_PENTIUMgnu.debug_FILE_$(PRJ_DIR)/../../common/util_sig.c_toolMacro
-CC
-<END>
-
-<BEGIN> BUILD_PENTIUMgnu.debug_FILE_$(PRJ_DIR)/../../db/crdel_auto.c_infoTags
-toolMacro objects
-<END>
-
-<BEGIN> BUILD_PENTIUMgnu.debug_FILE_$(PRJ_DIR)/../../db/crdel_auto.c_objects
-crdel_auto.o
-<END>
-
-<BEGIN> BUILD_PENTIUMgnu.debug_FILE_$(PRJ_DIR)/../../db/crdel_auto.c_toolMacro
-CC
-<END>
-
-<BEGIN> BUILD_PENTIUMgnu.debug_FILE_$(PRJ_DIR)/../../db/crdel_rec.c_infoTags
-toolMacro objects
-<END>
-
-<BEGIN> BUILD_PENTIUMgnu.debug_FILE_$(PRJ_DIR)/../../db/crdel_rec.c_objects
-crdel_rec.o
-<END>
-
-<BEGIN> BUILD_PENTIUMgnu.debug_FILE_$(PRJ_DIR)/../../db/crdel_rec.c_toolMacro
-CC
-<END>
-
-<BEGIN> BUILD_PENTIUMgnu.debug_FILE_$(PRJ_DIR)/../../db/db.c_infoTags
-toolMacro objects
-<END>
-
-<BEGIN> BUILD_PENTIUMgnu.debug_FILE_$(PRJ_DIR)/../../db/db.c_objects
-db.o
-<END>
-
-<BEGIN> BUILD_PENTIUMgnu.debug_FILE_$(PRJ_DIR)/../../db/db.c_toolMacro
-CC
-<END>
-
-<BEGIN> BUILD_PENTIUMgnu.debug_FILE_$(PRJ_DIR)/../../db/db_am.c_infoTags
-toolMacro objects
-<END>
-
-<BEGIN> BUILD_PENTIUMgnu.debug_FILE_$(PRJ_DIR)/../../db/db_am.c_objects
-db_am.o
-<END>
-
-<BEGIN> BUILD_PENTIUMgnu.debug_FILE_$(PRJ_DIR)/../../db/db_am.c_toolMacro
-CC
-<END>
-
-<BEGIN> BUILD_PENTIUMgnu.debug_FILE_$(PRJ_DIR)/../../db/db_auto.c_infoTags
-toolMacro objects
-<END>
-
-<BEGIN> BUILD_PENTIUMgnu.debug_FILE_$(PRJ_DIR)/../../db/db_auto.c_objects
-db_auto.o
-<END>
-
-<BEGIN> BUILD_PENTIUMgnu.debug_FILE_$(PRJ_DIR)/../../db/db_auto.c_toolMacro
-CC
-<END>
-
-<BEGIN> BUILD_PENTIUMgnu.debug_FILE_$(PRJ_DIR)/../../db/db_cam.c_infoTags
-toolMacro objects
-<END>
-
-<BEGIN> BUILD_PENTIUMgnu.debug_FILE_$(PRJ_DIR)/../../db/db_cam.c_objects
-db_cam.o
-<END>
-
-<BEGIN> BUILD_PENTIUMgnu.debug_FILE_$(PRJ_DIR)/../../db/db_cam.c_toolMacro
-CC
-<END>
-
-<BEGIN> BUILD_PENTIUMgnu.debug_FILE_$(PRJ_DIR)/../../db/db_conv.c_infoTags
-toolMacro objects
-<END>
-
-<BEGIN> BUILD_PENTIUMgnu.debug_FILE_$(PRJ_DIR)/../../db/db_conv.c_objects
-db_conv.o
-<END>
-
-<BEGIN> BUILD_PENTIUMgnu.debug_FILE_$(PRJ_DIR)/../../db/db_conv.c_toolMacro
-CC
-<END>
-
-<BEGIN> BUILD_PENTIUMgnu.debug_FILE_$(PRJ_DIR)/../../db/db_dispatch.c_infoTags
-toolMacro objects
-<END>
-
-<BEGIN> BUILD_PENTIUMgnu.debug_FILE_$(PRJ_DIR)/../../db/db_dispatch.c_objects
-db_dispatch.o
-<END>
-
-<BEGIN> BUILD_PENTIUMgnu.debug_FILE_$(PRJ_DIR)/../../db/db_dispatch.c_toolMacro
-CC
-<END>
-
-<BEGIN> BUILD_PENTIUMgnu.debug_FILE_$(PRJ_DIR)/../../db/db_dup.c_infoTags
-toolMacro objects
-<END>
-
-<BEGIN> BUILD_PENTIUMgnu.debug_FILE_$(PRJ_DIR)/../../db/db_dup.c_objects
-db_dup.o
-<END>
-
-<BEGIN> BUILD_PENTIUMgnu.debug_FILE_$(PRJ_DIR)/../../db/db_dup.c_toolMacro
-CC
-<END>
-
-<BEGIN> BUILD_PENTIUMgnu.debug_FILE_$(PRJ_DIR)/../../db/db_iface.c_infoTags
-toolMacro objects
-<END>
-
-<BEGIN> BUILD_PENTIUMgnu.debug_FILE_$(PRJ_DIR)/../../db/db_iface.c_objects
-db_iface.o
-<END>
-
-<BEGIN> BUILD_PENTIUMgnu.debug_FILE_$(PRJ_DIR)/../../db/db_iface.c_toolMacro
-CC
-<END>
-
-<BEGIN> BUILD_PENTIUMgnu.debug_FILE_$(PRJ_DIR)/../../db/db_join.c_infoTags
-toolMacro objects
-<END>
-
-<BEGIN> BUILD_PENTIUMgnu.debug_FILE_$(PRJ_DIR)/../../db/db_join.c_objects
-db_join.o
-<END>
-
-<BEGIN> BUILD_PENTIUMgnu.debug_FILE_$(PRJ_DIR)/../../db/db_join.c_toolMacro
-CC
-<END>
-
-<BEGIN> BUILD_PENTIUMgnu.debug_FILE_$(PRJ_DIR)/../../db/db_meta.c_infoTags
-toolMacro objects
-<END>
-
-<BEGIN> BUILD_PENTIUMgnu.debug_FILE_$(PRJ_DIR)/../../db/db_meta.c_objects
-db_meta.o
-<END>
-
-<BEGIN> BUILD_PENTIUMgnu.debug_FILE_$(PRJ_DIR)/../../db/db_meta.c_toolMacro
-CC
-<END>
-
-<BEGIN> BUILD_PENTIUMgnu.debug_FILE_$(PRJ_DIR)/../../db/db_method.c_infoTags
-toolMacro objects
-<END>
-
-<BEGIN> BUILD_PENTIUMgnu.debug_FILE_$(PRJ_DIR)/../../db/db_method.c_objects
-db_method.o
-<END>
-
-<BEGIN> BUILD_PENTIUMgnu.debug_FILE_$(PRJ_DIR)/../../db/db_method.c_toolMacro
-CC
-<END>
-
-<BEGIN> BUILD_PENTIUMgnu.debug_FILE_$(PRJ_DIR)/../../db/db_open.c_infoTags
-toolMacro objects
-<END>
-
-<BEGIN> BUILD_PENTIUMgnu.debug_FILE_$(PRJ_DIR)/../../db/db_open.c_objects
-db_open.o
-<END>
-
-<BEGIN> BUILD_PENTIUMgnu.debug_FILE_$(PRJ_DIR)/../../db/db_open.c_toolMacro
-CC
-<END>
-
-<BEGIN> BUILD_PENTIUMgnu.debug_FILE_$(PRJ_DIR)/../../db/db_overflow.c_infoTags
-toolMacro objects
-<END>
-
-<BEGIN> BUILD_PENTIUMgnu.debug_FILE_$(PRJ_DIR)/../../db/db_overflow.c_objects
-db_overflow.o
-<END>
-
-<BEGIN> BUILD_PENTIUMgnu.debug_FILE_$(PRJ_DIR)/../../db/db_overflow.c_toolMacro
-CC
-<END>
-
-<BEGIN> BUILD_PENTIUMgnu.debug_FILE_$(PRJ_DIR)/../../db/db_pr.c_infoTags
-toolMacro objects
-<END>
-
-<BEGIN> BUILD_PENTIUMgnu.debug_FILE_$(PRJ_DIR)/../../db/db_pr.c_objects
-db_pr.o
-<END>
-
-<BEGIN> BUILD_PENTIUMgnu.debug_FILE_$(PRJ_DIR)/../../db/db_pr.c_toolMacro
-CC
-<END>
-
-<BEGIN> BUILD_PENTIUMgnu.debug_FILE_$(PRJ_DIR)/../../db/db_rec.c_infoTags
-toolMacro objects
-<END>
-
-<BEGIN> BUILD_PENTIUMgnu.debug_FILE_$(PRJ_DIR)/../../db/db_rec.c_objects
-db_rec.o
-<END>
-
-<BEGIN> BUILD_PENTIUMgnu.debug_FILE_$(PRJ_DIR)/../../db/db_rec.c_toolMacro
-CC
-<END>
-
-<BEGIN> BUILD_PENTIUMgnu.debug_FILE_$(PRJ_DIR)/../../db/db_reclaim.c_infoTags
-toolMacro objects
-<END>
-
-<BEGIN> BUILD_PENTIUMgnu.debug_FILE_$(PRJ_DIR)/../../db/db_reclaim.c_objects
-db_reclaim.o
-<END>
-
-<BEGIN> BUILD_PENTIUMgnu.debug_FILE_$(PRJ_DIR)/../../db/db_reclaim.c_toolMacro
-CC
-<END>
-
-<BEGIN> BUILD_PENTIUMgnu.debug_FILE_$(PRJ_DIR)/../../db/db_remove.c_infoTags
-toolMacro objects
-<END>
-
-<BEGIN> BUILD_PENTIUMgnu.debug_FILE_$(PRJ_DIR)/../../db/db_remove.c_objects
-db_remove.o
-<END>
-
-<BEGIN> BUILD_PENTIUMgnu.debug_FILE_$(PRJ_DIR)/../../db/db_remove.c_toolMacro
-CC
-<END>
-
-<BEGIN> BUILD_PENTIUMgnu.debug_FILE_$(PRJ_DIR)/../../db/db_rename.c_infoTags
-toolMacro objects
-<END>
-
-<BEGIN> BUILD_PENTIUMgnu.debug_FILE_$(PRJ_DIR)/../../db/db_rename.c_objects
-db_rename.o
-<END>
-
-<BEGIN> BUILD_PENTIUMgnu.debug_FILE_$(PRJ_DIR)/../../db/db_rename.c_toolMacro
-CC
-<END>
-
-<BEGIN> BUILD_PENTIUMgnu.debug_FILE_$(PRJ_DIR)/../../db/db_ret.c_infoTags
-toolMacro objects
-<END>
-
-<BEGIN> BUILD_PENTIUMgnu.debug_FILE_$(PRJ_DIR)/../../db/db_ret.c_objects
-db_ret.o
-<END>
-
-<BEGIN> BUILD_PENTIUMgnu.debug_FILE_$(PRJ_DIR)/../../db/db_ret.c_toolMacro
-CC
-<END>
-
-<BEGIN> BUILD_PENTIUMgnu.debug_FILE_$(PRJ_DIR)/../../db/db_truncate.c_infoTags
-toolMacro objects
-<END>
-
-<BEGIN> BUILD_PENTIUMgnu.debug_FILE_$(PRJ_DIR)/../../db/db_truncate.c_objects
-db_truncate.o
-<END>
-
-<BEGIN> BUILD_PENTIUMgnu.debug_FILE_$(PRJ_DIR)/../../db/db_truncate.c_toolMacro
-CC
-<END>
-
-<BEGIN> BUILD_PENTIUMgnu.debug_FILE_$(PRJ_DIR)/../../db/db_upg.c_infoTags
-toolMacro objects
-<END>
-
-<BEGIN> BUILD_PENTIUMgnu.debug_FILE_$(PRJ_DIR)/../../db/db_upg.c_objects
-db_upg.o
-<END>
-
-<BEGIN> BUILD_PENTIUMgnu.debug_FILE_$(PRJ_DIR)/../../db/db_upg.c_toolMacro
-CC
-<END>
-
-<BEGIN> BUILD_PENTIUMgnu.debug_FILE_$(PRJ_DIR)/../../db/db_upg_opd.c_infoTags
-toolMacro objects
-<END>
-
-<BEGIN> BUILD_PENTIUMgnu.debug_FILE_$(PRJ_DIR)/../../db/db_upg_opd.c_objects
-db_upg_opd.o
-<END>
-
-<BEGIN> BUILD_PENTIUMgnu.debug_FILE_$(PRJ_DIR)/../../db/db_upg_opd.c_toolMacro
-CC
-<END>
-
-<BEGIN> BUILD_PENTIUMgnu.debug_FILE_$(PRJ_DIR)/../../db/db_vrfy.c_infoTags
-toolMacro objects
-<END>
-
-<BEGIN> BUILD_PENTIUMgnu.debug_FILE_$(PRJ_DIR)/../../db/db_vrfy.c_objects
-db_vrfy.o
-<END>
-
-<BEGIN> BUILD_PENTIUMgnu.debug_FILE_$(PRJ_DIR)/../../db/db_vrfy.c_toolMacro
-CC
-<END>
-
-<BEGIN> BUILD_PENTIUMgnu.debug_FILE_$(PRJ_DIR)/../../db/db_vrfyutil.c_infoTags
-toolMacro objects
-<END>
-
-<BEGIN> BUILD_PENTIUMgnu.debug_FILE_$(PRJ_DIR)/../../db/db_vrfyutil.c_objects
-db_vrfyutil.o
-<END>
-
-<BEGIN> BUILD_PENTIUMgnu.debug_FILE_$(PRJ_DIR)/../../db/db_vrfyutil.c_toolMacro
-CC
-<END>
-
-<BEGIN> BUILD_PENTIUMgnu.debug_FILE_$(PRJ_DIR)/../../dbreg/dbreg.c_infoTags
-toolMacro objects
-<END>
-
-<BEGIN> BUILD_PENTIUMgnu.debug_FILE_$(PRJ_DIR)/../../dbreg/dbreg.c_objects
-dbreg.o
-<END>
-
-<BEGIN> BUILD_PENTIUMgnu.debug_FILE_$(PRJ_DIR)/../../dbreg/dbreg.c_toolMacro
-CC
-<END>
-
-<BEGIN> BUILD_PENTIUMgnu.debug_FILE_$(PRJ_DIR)/../../dbreg/dbreg_auto.c_infoTags
-toolMacro objects
-<END>
-
-<BEGIN> BUILD_PENTIUMgnu.debug_FILE_$(PRJ_DIR)/../../dbreg/dbreg_auto.c_objects
-dbreg_auto.o
-<END>
-
-<BEGIN> BUILD_PENTIUMgnu.debug_FILE_$(PRJ_DIR)/../../dbreg/dbreg_auto.c_toolMacro
-CC
-<END>
-
-<BEGIN> BUILD_PENTIUMgnu.debug_FILE_$(PRJ_DIR)/../../dbreg/dbreg_rec.c_infoTags
-toolMacro objects
-<END>
-
-<BEGIN> BUILD_PENTIUMgnu.debug_FILE_$(PRJ_DIR)/../../dbreg/dbreg_rec.c_objects
-dbreg_rec.o
-<END>
-
-<BEGIN> BUILD_PENTIUMgnu.debug_FILE_$(PRJ_DIR)/../../dbreg/dbreg_rec.c_toolMacro
-CC
-<END>
-
-<BEGIN> BUILD_PENTIUMgnu.debug_FILE_$(PRJ_DIR)/../../dbreg/dbreg_util.c_infoTags
-toolMacro objects
-<END>
-
-<BEGIN> BUILD_PENTIUMgnu.debug_FILE_$(PRJ_DIR)/../../dbreg/dbreg_util.c_objects
-dbreg_util.o
-<END>
-
-<BEGIN> BUILD_PENTIUMgnu.debug_FILE_$(PRJ_DIR)/../../dbreg/dbreg_util.c_toolMacro
-CC
-<END>
-
-<BEGIN> BUILD_PENTIUMgnu.debug_FILE_$(PRJ_DIR)/../../env/db_salloc.c_infoTags
-toolMacro objects
-<END>
-
-<BEGIN> BUILD_PENTIUMgnu.debug_FILE_$(PRJ_DIR)/../../env/db_salloc.c_objects
-db_salloc.o
-<END>
-
-<BEGIN> BUILD_PENTIUMgnu.debug_FILE_$(PRJ_DIR)/../../env/db_salloc.c_toolMacro
-CC
-<END>
-
-<BEGIN> BUILD_PENTIUMgnu.debug_FILE_$(PRJ_DIR)/../../env/db_shash.c_infoTags
-toolMacro objects
-<END>
-
-<BEGIN> BUILD_PENTIUMgnu.debug_FILE_$(PRJ_DIR)/../../env/db_shash.c_objects
-db_shash.o
-<END>
-
-<BEGIN> BUILD_PENTIUMgnu.debug_FILE_$(PRJ_DIR)/../../env/db_shash.c_toolMacro
-CC
-<END>
-
-<BEGIN> BUILD_PENTIUMgnu.debug_FILE_$(PRJ_DIR)/../../env/env_file.c_infoTags
-toolMacro objects
-<END>
-
-<BEGIN> BUILD_PENTIUMgnu.debug_FILE_$(PRJ_DIR)/../../env/env_file.c_objects
-env_file.o
-<END>
-
-<BEGIN> BUILD_PENTIUMgnu.debug_FILE_$(PRJ_DIR)/../../env/env_file.c_toolMacro
-CC
-<END>
-
-<BEGIN> BUILD_PENTIUMgnu.debug_FILE_$(PRJ_DIR)/../../env/env_method.c_infoTags
-toolMacro objects
-<END>
-
-<BEGIN> BUILD_PENTIUMgnu.debug_FILE_$(PRJ_DIR)/../../env/env_method.c_objects
-env_method.o
-<END>
-
-<BEGIN> BUILD_PENTIUMgnu.debug_FILE_$(PRJ_DIR)/../../env/env_method.c_toolMacro
-CC
-<END>
-
-<BEGIN> BUILD_PENTIUMgnu.debug_FILE_$(PRJ_DIR)/../../env/env_open.c_infoTags
-toolMacro objects
-<END>
-
-<BEGIN> BUILD_PENTIUMgnu.debug_FILE_$(PRJ_DIR)/../../env/env_open.c_objects
-env_open.o
-<END>
-
-<BEGIN> BUILD_PENTIUMgnu.debug_FILE_$(PRJ_DIR)/../../env/env_open.c_toolMacro
-CC
-<END>
-
-<BEGIN> BUILD_PENTIUMgnu.debug_FILE_$(PRJ_DIR)/../../env/env_recover.c_infoTags
-toolMacro objects
-<END>
-
-<BEGIN> BUILD_PENTIUMgnu.debug_FILE_$(PRJ_DIR)/../../env/env_recover.c_objects
-env_recover.o
-<END>
-
-<BEGIN> BUILD_PENTIUMgnu.debug_FILE_$(PRJ_DIR)/../../env/env_recover.c_toolMacro
-CC
-<END>
-
-<BEGIN> BUILD_PENTIUMgnu.debug_FILE_$(PRJ_DIR)/../../env/env_region.c_infoTags
-toolMacro objects
-<END>
-
-<BEGIN> BUILD_PENTIUMgnu.debug_FILE_$(PRJ_DIR)/../../env/env_region.c_objects
-env_region.o
-<END>
-
-<BEGIN> BUILD_PENTIUMgnu.debug_FILE_$(PRJ_DIR)/../../env/env_region.c_toolMacro
-CC
-<END>
-
-<BEGIN> BUILD_PENTIUMgnu.debug_FILE_$(PRJ_DIR)/../../fileops/fileops_auto.c_infoTags
-toolMacro objects
-<END>
-
-<BEGIN> BUILD_PENTIUMgnu.debug_FILE_$(PRJ_DIR)/../../fileops/fileops_auto.c_objects
-fileops_auto.o
-<END>
-
-<BEGIN> BUILD_PENTIUMgnu.debug_FILE_$(PRJ_DIR)/../../fileops/fileops_auto.c_toolMacro
-CC
-<END>
-
-<BEGIN> BUILD_PENTIUMgnu.debug_FILE_$(PRJ_DIR)/../../fileops/fop_basic.c_infoTags
-toolMacro objects
-<END>
-
-<BEGIN> BUILD_PENTIUMgnu.debug_FILE_$(PRJ_DIR)/../../fileops/fop_basic.c_objects
-fop_basic.o
-<END>
-
-<BEGIN> BUILD_PENTIUMgnu.debug_FILE_$(PRJ_DIR)/../../fileops/fop_basic.c_toolMacro
-CC
-<END>
-
-<BEGIN> BUILD_PENTIUMgnu.debug_FILE_$(PRJ_DIR)/../../fileops/fop_rec.c_infoTags
-toolMacro objects
-<END>
-
-<BEGIN> BUILD_PENTIUMgnu.debug_FILE_$(PRJ_DIR)/../../fileops/fop_rec.c_objects
-fop_rec.o
-<END>
-
-<BEGIN> BUILD_PENTIUMgnu.debug_FILE_$(PRJ_DIR)/../../fileops/fop_rec.c_toolMacro
-CC
-<END>
-
-<BEGIN> BUILD_PENTIUMgnu.debug_FILE_$(PRJ_DIR)/../../fileops/fop_util.c_infoTags
-toolMacro objects
-<END>
-
-<BEGIN> BUILD_PENTIUMgnu.debug_FILE_$(PRJ_DIR)/../../fileops/fop_util.c_objects
-fop_util.o
-<END>
-
-<BEGIN> BUILD_PENTIUMgnu.debug_FILE_$(PRJ_DIR)/../../fileops/fop_util.c_toolMacro
-CC
-<END>
-
-<BEGIN> BUILD_PENTIUMgnu.debug_FILE_$(PRJ_DIR)/../../hash/hash.c_infoTags
-toolMacro objects
-<END>
-
-<BEGIN> BUILD_PENTIUMgnu.debug_FILE_$(PRJ_DIR)/../../hash/hash.c_objects
-hash.o
-<END>
-
-<BEGIN> BUILD_PENTIUMgnu.debug_FILE_$(PRJ_DIR)/../../hash/hash.c_toolMacro
-CC
-<END>
-
-<BEGIN> BUILD_PENTIUMgnu.debug_FILE_$(PRJ_DIR)/../../hash/hash_auto.c_infoTags
-toolMacro objects
-<END>
-
-<BEGIN> BUILD_PENTIUMgnu.debug_FILE_$(PRJ_DIR)/../../hash/hash_auto.c_objects
-hash_auto.o
-<END>
-
-<BEGIN> BUILD_PENTIUMgnu.debug_FILE_$(PRJ_DIR)/../../hash/hash_auto.c_toolMacro
-CC
-<END>
-
-<BEGIN> BUILD_PENTIUMgnu.debug_FILE_$(PRJ_DIR)/../../hash/hash_conv.c_infoTags
-toolMacro objects
-<END>
-
-<BEGIN> BUILD_PENTIUMgnu.debug_FILE_$(PRJ_DIR)/../../hash/hash_conv.c_objects
-hash_conv.o
-<END>
-
-<BEGIN> BUILD_PENTIUMgnu.debug_FILE_$(PRJ_DIR)/../../hash/hash_conv.c_toolMacro
-CC
-<END>
-
-<BEGIN> BUILD_PENTIUMgnu.debug_FILE_$(PRJ_DIR)/../../hash/hash_dup.c_infoTags
-toolMacro objects
-<END>
-
-<BEGIN> BUILD_PENTIUMgnu.debug_FILE_$(PRJ_DIR)/../../hash/hash_dup.c_objects
-hash_dup.o
-<END>
-
-<BEGIN> BUILD_PENTIUMgnu.debug_FILE_$(PRJ_DIR)/../../hash/hash_dup.c_toolMacro
-CC
-<END>
-
-<BEGIN> BUILD_PENTIUMgnu.debug_FILE_$(PRJ_DIR)/../../hash/hash_func.c_infoTags
-toolMacro objects
-<END>
-
-<BEGIN> BUILD_PENTIUMgnu.debug_FILE_$(PRJ_DIR)/../../hash/hash_func.c_objects
-hash_func.o
-<END>
-
-<BEGIN> BUILD_PENTIUMgnu.debug_FILE_$(PRJ_DIR)/../../hash/hash_func.c_toolMacro
-CC
-<END>
-
-<BEGIN> BUILD_PENTIUMgnu.debug_FILE_$(PRJ_DIR)/../../hash/hash_meta.c_infoTags
-toolMacro objects
-<END>
-
-<BEGIN> BUILD_PENTIUMgnu.debug_FILE_$(PRJ_DIR)/../../hash/hash_meta.c_objects
-hash_meta.o
-<END>
-
-<BEGIN> BUILD_PENTIUMgnu.debug_FILE_$(PRJ_DIR)/../../hash/hash_meta.c_toolMacro
-CC
-<END>
-
-<BEGIN> BUILD_PENTIUMgnu.debug_FILE_$(PRJ_DIR)/../../hash/hash_method.c_infoTags
-toolMacro objects
-<END>
-
-<BEGIN> BUILD_PENTIUMgnu.debug_FILE_$(PRJ_DIR)/../../hash/hash_method.c_objects
-hash_method.o
-<END>
-
-<BEGIN> BUILD_PENTIUMgnu.debug_FILE_$(PRJ_DIR)/../../hash/hash_method.c_toolMacro
-CC
-<END>
-
-<BEGIN> BUILD_PENTIUMgnu.debug_FILE_$(PRJ_DIR)/../../hash/hash_open.c_infoTags
-toolMacro objects
-<END>
-
-<BEGIN> BUILD_PENTIUMgnu.debug_FILE_$(PRJ_DIR)/../../hash/hash_open.c_objects
-hash_open.o
-<END>
-
-<BEGIN> BUILD_PENTIUMgnu.debug_FILE_$(PRJ_DIR)/../../hash/hash_open.c_toolMacro
-CC
-<END>
-
-<BEGIN> BUILD_PENTIUMgnu.debug_FILE_$(PRJ_DIR)/../../hash/hash_page.c_infoTags
-toolMacro objects
-<END>
-
-<BEGIN> BUILD_PENTIUMgnu.debug_FILE_$(PRJ_DIR)/../../hash/hash_page.c_objects
-hash_page.o
-<END>
-
-<BEGIN> BUILD_PENTIUMgnu.debug_FILE_$(PRJ_DIR)/../../hash/hash_page.c_toolMacro
-CC
-<END>
-
-<BEGIN> BUILD_PENTIUMgnu.debug_FILE_$(PRJ_DIR)/../../hash/hash_rec.c_infoTags
-toolMacro objects
-<END>
-
-<BEGIN> BUILD_PENTIUMgnu.debug_FILE_$(PRJ_DIR)/../../hash/hash_rec.c_objects
-hash_rec.o
-<END>
-
-<BEGIN> BUILD_PENTIUMgnu.debug_FILE_$(PRJ_DIR)/../../hash/hash_rec.c_toolMacro
-CC
-<END>
-
-<BEGIN> BUILD_PENTIUMgnu.debug_FILE_$(PRJ_DIR)/../../hash/hash_reclaim.c_infoTags
-toolMacro objects
-<END>
-
-<BEGIN> BUILD_PENTIUMgnu.debug_FILE_$(PRJ_DIR)/../../hash/hash_reclaim.c_objects
-hash_reclaim.o
-<END>
-
-<BEGIN> BUILD_PENTIUMgnu.debug_FILE_$(PRJ_DIR)/../../hash/hash_reclaim.c_toolMacro
-CC
-<END>
-
-<BEGIN> BUILD_PENTIUMgnu.debug_FILE_$(PRJ_DIR)/../../hash/hash_stat.c_infoTags
-toolMacro objects
-<END>
-
-<BEGIN> BUILD_PENTIUMgnu.debug_FILE_$(PRJ_DIR)/../../hash/hash_stat.c_objects
-hash_stat.o
-<END>
-
-<BEGIN> BUILD_PENTIUMgnu.debug_FILE_$(PRJ_DIR)/../../hash/hash_stat.c_toolMacro
-CC
-<END>
-
-<BEGIN> BUILD_PENTIUMgnu.debug_FILE_$(PRJ_DIR)/../../hash/hash_upgrade.c_infoTags
-toolMacro objects
-<END>
-
-<BEGIN> BUILD_PENTIUMgnu.debug_FILE_$(PRJ_DIR)/../../hash/hash_upgrade.c_objects
-hash_upgrade.o
-<END>
-
-<BEGIN> BUILD_PENTIUMgnu.debug_FILE_$(PRJ_DIR)/../../hash/hash_upgrade.c_toolMacro
-CC
-<END>
-
-<BEGIN> BUILD_PENTIUMgnu.debug_FILE_$(PRJ_DIR)/../../hash/hash_verify.c_infoTags
-toolMacro objects
-<END>
-
-<BEGIN> BUILD_PENTIUMgnu.debug_FILE_$(PRJ_DIR)/../../hash/hash_verify.c_objects
-hash_verify.o
-<END>
-
-<BEGIN> BUILD_PENTIUMgnu.debug_FILE_$(PRJ_DIR)/../../hash/hash_verify.c_toolMacro
-CC
-<END>
-
-<BEGIN> BUILD_PENTIUMgnu.debug_FILE_$(PRJ_DIR)/../../hmac/hmac.c_infoTags
-toolMacro objects
-<END>
-
-<BEGIN> BUILD_PENTIUMgnu.debug_FILE_$(PRJ_DIR)/../../hmac/hmac.c_objects
-hmac.o
-<END>
-
-<BEGIN> BUILD_PENTIUMgnu.debug_FILE_$(PRJ_DIR)/../../hmac/hmac.c_toolMacro
-CC
-<END>
-
-<BEGIN> BUILD_PENTIUMgnu.debug_FILE_$(PRJ_DIR)/../../hmac/sha1.c_infoTags
-toolMacro objects
-<END>
-
-<BEGIN> BUILD_PENTIUMgnu.debug_FILE_$(PRJ_DIR)/../../hmac/sha1.c_objects
-sha1.o
-<END>
-
-<BEGIN> BUILD_PENTIUMgnu.debug_FILE_$(PRJ_DIR)/../../hmac/sha1.c_toolMacro
-CC
-<END>
-
-<BEGIN> BUILD_PENTIUMgnu.debug_FILE_$(PRJ_DIR)/../../hsearch/hsearch.c_infoTags
-toolMacro objects
-<END>
-
-<BEGIN> BUILD_PENTIUMgnu.debug_FILE_$(PRJ_DIR)/../../hsearch/hsearch.c_objects
-hsearch.o
-<END>
-
-<BEGIN> BUILD_PENTIUMgnu.debug_FILE_$(PRJ_DIR)/../../hsearch/hsearch.c_toolMacro
-CC
-<END>
-
-<BEGIN> BUILD_PENTIUMgnu.debug_FILE_$(PRJ_DIR)/../../lock/lock.c_infoTags
-toolMacro objects
-<END>
-
-<BEGIN> BUILD_PENTIUMgnu.debug_FILE_$(PRJ_DIR)/../../lock/lock.c_objects
-lock.o
-<END>
-
-<BEGIN> BUILD_PENTIUMgnu.debug_FILE_$(PRJ_DIR)/../../lock/lock.c_toolMacro
-CC
-<END>
-
-<BEGIN> BUILD_PENTIUMgnu.debug_FILE_$(PRJ_DIR)/../../lock/lock_deadlock.c_infoTags
-toolMacro objects
-<END>
-
-<BEGIN> BUILD_PENTIUMgnu.debug_FILE_$(PRJ_DIR)/../../lock/lock_deadlock.c_objects
-lock_deadlock.o
-<END>
-
-<BEGIN> BUILD_PENTIUMgnu.debug_FILE_$(PRJ_DIR)/../../lock/lock_deadlock.c_toolMacro
-CC
-<END>
-
-<BEGIN> BUILD_PENTIUMgnu.debug_FILE_$(PRJ_DIR)/../../lock/lock_method.c_infoTags
-toolMacro objects
-<END>
-
-<BEGIN> BUILD_PENTIUMgnu.debug_FILE_$(PRJ_DIR)/../../lock/lock_method.c_objects
-lock_method.o
-<END>
-
-<BEGIN> BUILD_PENTIUMgnu.debug_FILE_$(PRJ_DIR)/../../lock/lock_method.c_toolMacro
-CC
-<END>
-
-<BEGIN> BUILD_PENTIUMgnu.debug_FILE_$(PRJ_DIR)/../../lock/lock_region.c_infoTags
-toolMacro objects
-<END>
-
-<BEGIN> BUILD_PENTIUMgnu.debug_FILE_$(PRJ_DIR)/../../lock/lock_region.c_objects
-lock_region.o
-<END>
-
-<BEGIN> BUILD_PENTIUMgnu.debug_FILE_$(PRJ_DIR)/../../lock/lock_region.c_toolMacro
-CC
-<END>
-
-<BEGIN> BUILD_PENTIUMgnu.debug_FILE_$(PRJ_DIR)/../../lock/lock_stat.c_infoTags
-toolMacro objects
-<END>
-
-<BEGIN> BUILD_PENTIUMgnu.debug_FILE_$(PRJ_DIR)/../../lock/lock_stat.c_objects
-lock_stat.o
-<END>
-
-<BEGIN> BUILD_PENTIUMgnu.debug_FILE_$(PRJ_DIR)/../../lock/lock_stat.c_toolMacro
-CC
-<END>
-
-<BEGIN> BUILD_PENTIUMgnu.debug_FILE_$(PRJ_DIR)/../../lock/lock_util.c_infoTags
-toolMacro objects
-<END>
-
-<BEGIN> BUILD_PENTIUMgnu.debug_FILE_$(PRJ_DIR)/../../lock/lock_util.c_objects
-lock_util.o
-<END>
-
-<BEGIN> BUILD_PENTIUMgnu.debug_FILE_$(PRJ_DIR)/../../lock/lock_util.c_toolMacro
-CC
-<END>
-
-<BEGIN> BUILD_PENTIUMgnu.debug_FILE_$(PRJ_DIR)/../../log/log.c_infoTags
-toolMacro objects
-<END>
-
-<BEGIN> BUILD_PENTIUMgnu.debug_FILE_$(PRJ_DIR)/../../log/log.c_objects
-log.o
-<END>
-
-<BEGIN> BUILD_PENTIUMgnu.debug_FILE_$(PRJ_DIR)/../../log/log.c_toolMacro
-CC
-<END>
-
-<BEGIN> BUILD_PENTIUMgnu.debug_FILE_$(PRJ_DIR)/../../log/log_archive.c_infoTags
-toolMacro objects
-<END>
-
-<BEGIN> BUILD_PENTIUMgnu.debug_FILE_$(PRJ_DIR)/../../log/log_archive.c_objects
-log_archive.o
-<END>
-
-<BEGIN> BUILD_PENTIUMgnu.debug_FILE_$(PRJ_DIR)/../../log/log_archive.c_toolMacro
-CC
-<END>
-
-<BEGIN> BUILD_PENTIUMgnu.debug_FILE_$(PRJ_DIR)/../../log/log_compare.c_infoTags
-toolMacro objects
-<END>
-
-<BEGIN> BUILD_PENTIUMgnu.debug_FILE_$(PRJ_DIR)/../../log/log_compare.c_objects
-log_compare.o
-<END>
-
-<BEGIN> BUILD_PENTIUMgnu.debug_FILE_$(PRJ_DIR)/../../log/log_compare.c_toolMacro
-CC
-<END>
-
-<BEGIN> BUILD_PENTIUMgnu.debug_FILE_$(PRJ_DIR)/../../log/log_get.c_infoTags
-toolMacro objects
-<END>
-
-<BEGIN> BUILD_PENTIUMgnu.debug_FILE_$(PRJ_DIR)/../../log/log_get.c_objects
-log_get.o
-<END>
-
-<BEGIN> BUILD_PENTIUMgnu.debug_FILE_$(PRJ_DIR)/../../log/log_get.c_toolMacro
-CC
-<END>
-
-<BEGIN> BUILD_PENTIUMgnu.debug_FILE_$(PRJ_DIR)/../../log/log_method.c_infoTags
-toolMacro objects
-<END>
-
-<BEGIN> BUILD_PENTIUMgnu.debug_FILE_$(PRJ_DIR)/../../log/log_method.c_objects
-log_method.o
-<END>
-
-<BEGIN> BUILD_PENTIUMgnu.debug_FILE_$(PRJ_DIR)/../../log/log_method.c_toolMacro
-CC
-<END>
-
-<BEGIN> BUILD_PENTIUMgnu.debug_FILE_$(PRJ_DIR)/../../log/log_put.c_infoTags
-toolMacro objects
-<END>
-
-<BEGIN> BUILD_PENTIUMgnu.debug_FILE_$(PRJ_DIR)/../../log/log_put.c_objects
-log_put.o
-<END>
-
-<BEGIN> BUILD_PENTIUMgnu.debug_FILE_$(PRJ_DIR)/../../log/log_put.c_toolMacro
-CC
-<END>
-
-<BEGIN> BUILD_PENTIUMgnu.debug_FILE_$(PRJ_DIR)/../../mp/mp_alloc.c_infoTags
-toolMacro objects
-<END>
-
-<BEGIN> BUILD_PENTIUMgnu.debug_FILE_$(PRJ_DIR)/../../mp/mp_alloc.c_objects
-mp_alloc.o
-<END>
-
-<BEGIN> BUILD_PENTIUMgnu.debug_FILE_$(PRJ_DIR)/../../mp/mp_alloc.c_toolMacro
-CC
-<END>
-
-<BEGIN> BUILD_PENTIUMgnu.debug_FILE_$(PRJ_DIR)/../../mp/mp_bh.c_infoTags
-toolMacro objects
-<END>
-
-<BEGIN> BUILD_PENTIUMgnu.debug_FILE_$(PRJ_DIR)/../../mp/mp_bh.c_objects
-mp_bh.o
-<END>
-
-<BEGIN> BUILD_PENTIUMgnu.debug_FILE_$(PRJ_DIR)/../../mp/mp_bh.c_toolMacro
-CC
-<END>
-
-<BEGIN> BUILD_PENTIUMgnu.debug_FILE_$(PRJ_DIR)/../../mp/mp_fget.c_infoTags
-toolMacro objects
-<END>
-
-<BEGIN> BUILD_PENTIUMgnu.debug_FILE_$(PRJ_DIR)/../../mp/mp_fget.c_objects
-mp_fget.o
-<END>
-
-<BEGIN> BUILD_PENTIUMgnu.debug_FILE_$(PRJ_DIR)/../../mp/mp_fget.c_toolMacro
-CC
-<END>
-
-<BEGIN> BUILD_PENTIUMgnu.debug_FILE_$(PRJ_DIR)/../../mp/mp_fopen.c_infoTags
-toolMacro objects
-<END>
-
-<BEGIN> BUILD_PENTIUMgnu.debug_FILE_$(PRJ_DIR)/../../mp/mp_fopen.c_objects
-mp_fopen.o
-<END>
-
-<BEGIN> BUILD_PENTIUMgnu.debug_FILE_$(PRJ_DIR)/../../mp/mp_fopen.c_toolMacro
-CC
-<END>
-
-<BEGIN> BUILD_PENTIUMgnu.debug_FILE_$(PRJ_DIR)/../../mp/mp_fput.c_infoTags
-toolMacro objects
-<END>
-
-<BEGIN> BUILD_PENTIUMgnu.debug_FILE_$(PRJ_DIR)/../../mp/mp_fput.c_objects
-mp_fput.o
-<END>
-
-<BEGIN> BUILD_PENTIUMgnu.debug_FILE_$(PRJ_DIR)/../../mp/mp_fput.c_toolMacro
-CC
-<END>
-
-<BEGIN> BUILD_PENTIUMgnu.debug_FILE_$(PRJ_DIR)/../../mp/mp_fset.c_infoTags
-toolMacro objects
-<END>
-
-<BEGIN> BUILD_PENTIUMgnu.debug_FILE_$(PRJ_DIR)/../../mp/mp_fset.c_objects
-mp_fset.o
-<END>
-
-<BEGIN> BUILD_PENTIUMgnu.debug_FILE_$(PRJ_DIR)/../../mp/mp_fset.c_toolMacro
-CC
-<END>
-
-<BEGIN> BUILD_PENTIUMgnu.debug_FILE_$(PRJ_DIR)/../../mp/mp_method.c_infoTags
-toolMacro objects
-<END>
-
-<BEGIN> BUILD_PENTIUMgnu.debug_FILE_$(PRJ_DIR)/../../mp/mp_method.c_objects
-mp_method.o
-<END>
-
-<BEGIN> BUILD_PENTIUMgnu.debug_FILE_$(PRJ_DIR)/../../mp/mp_method.c_toolMacro
-CC
-<END>
-
-<BEGIN> BUILD_PENTIUMgnu.debug_FILE_$(PRJ_DIR)/../../mp/mp_region.c_infoTags
-toolMacro objects
-<END>
-
-<BEGIN> BUILD_PENTIUMgnu.debug_FILE_$(PRJ_DIR)/../../mp/mp_region.c_objects
-mp_region.o
-<END>
-
-<BEGIN> BUILD_PENTIUMgnu.debug_FILE_$(PRJ_DIR)/../../mp/mp_region.c_toolMacro
-CC
-<END>
-
-<BEGIN> BUILD_PENTIUMgnu.debug_FILE_$(PRJ_DIR)/../../mp/mp_register.c_infoTags
-toolMacro objects
-<END>
-
-<BEGIN> BUILD_PENTIUMgnu.debug_FILE_$(PRJ_DIR)/../../mp/mp_register.c_objects
-mp_register.o
-<END>
-
-<BEGIN> BUILD_PENTIUMgnu.debug_FILE_$(PRJ_DIR)/../../mp/mp_register.c_toolMacro
-CC
-<END>
-
-<BEGIN> BUILD_PENTIUMgnu.debug_FILE_$(PRJ_DIR)/../../mp/mp_stat.c_infoTags
-toolMacro objects
-<END>
-
-<BEGIN> BUILD_PENTIUMgnu.debug_FILE_$(PRJ_DIR)/../../mp/mp_stat.c_objects
-mp_stat.o
-<END>
-
-<BEGIN> BUILD_PENTIUMgnu.debug_FILE_$(PRJ_DIR)/../../mp/mp_stat.c_toolMacro
-CC
-<END>
-
-<BEGIN> BUILD_PENTIUMgnu.debug_FILE_$(PRJ_DIR)/../../mp/mp_sync.c_infoTags
-toolMacro objects
-<END>
-
-<BEGIN> BUILD_PENTIUMgnu.debug_FILE_$(PRJ_DIR)/../../mp/mp_sync.c_objects
-mp_sync.o
-<END>
-
-<BEGIN> BUILD_PENTIUMgnu.debug_FILE_$(PRJ_DIR)/../../mp/mp_sync.c_toolMacro
-CC
-<END>
-
-<BEGIN> BUILD_PENTIUMgnu.debug_FILE_$(PRJ_DIR)/../../mp/mp_trickle.c_infoTags
-toolMacro objects
-<END>
-
-<BEGIN> BUILD_PENTIUMgnu.debug_FILE_$(PRJ_DIR)/../../mp/mp_trickle.c_objects
-mp_trickle.o
-<END>
-
-<BEGIN> BUILD_PENTIUMgnu.debug_FILE_$(PRJ_DIR)/../../mp/mp_trickle.c_toolMacro
-CC
-<END>
-
-<BEGIN> BUILD_PENTIUMgnu.debug_FILE_$(PRJ_DIR)/../../mutex/mut_tas.c_infoTags
-toolMacro objects
-<END>
-
-<BEGIN> BUILD_PENTIUMgnu.debug_FILE_$(PRJ_DIR)/../../mutex/mut_tas.c_objects
-mut_tas.o
-<END>
-
-<BEGIN> BUILD_PENTIUMgnu.debug_FILE_$(PRJ_DIR)/../../mutex/mut_tas.c_toolMacro
-CC
-<END>
-
-<BEGIN> BUILD_PENTIUMgnu.debug_FILE_$(PRJ_DIR)/../../mutex/mutex.c_infoTags
-toolMacro objects
-<END>
-
-<BEGIN> BUILD_PENTIUMgnu.debug_FILE_$(PRJ_DIR)/../../mutex/mutex.c_objects
-mutex.o
-<END>
-
-<BEGIN> BUILD_PENTIUMgnu.debug_FILE_$(PRJ_DIR)/../../mutex/mutex.c_toolMacro
-CC
-<END>
-
-<BEGIN> BUILD_PENTIUMgnu.debug_FILE_$(PRJ_DIR)/../../os/os_alloc.c_infoTags
-toolMacro objects
-<END>
-
-<BEGIN> BUILD_PENTIUMgnu.debug_FILE_$(PRJ_DIR)/../../os/os_alloc.c_objects
-os_alloc.o
-<END>
-
-<BEGIN> BUILD_PENTIUMgnu.debug_FILE_$(PRJ_DIR)/../../os/os_alloc.c_toolMacro
-CC
-<END>
-
-<BEGIN> BUILD_PENTIUMgnu.debug_FILE_$(PRJ_DIR)/../../os/os_clock.c_infoTags
-toolMacro objects
-<END>
-
-<BEGIN> BUILD_PENTIUMgnu.debug_FILE_$(PRJ_DIR)/../../os/os_clock.c_objects
-os_clock.o
-<END>
-
-<BEGIN> BUILD_PENTIUMgnu.debug_FILE_$(PRJ_DIR)/../../os/os_clock.c_toolMacro
-CC
-<END>
-
-<BEGIN> BUILD_PENTIUMgnu.debug_FILE_$(PRJ_DIR)/../../os/os_dir.c_infoTags
-toolMacro objects
-<END>
-
-<BEGIN> BUILD_PENTIUMgnu.debug_FILE_$(PRJ_DIR)/../../os/os_dir.c_objects
-os_dir.o
-<END>
-
-<BEGIN> BUILD_PENTIUMgnu.debug_FILE_$(PRJ_DIR)/../../os/os_dir.c_toolMacro
-CC
-<END>
-
-<BEGIN> BUILD_PENTIUMgnu.debug_FILE_$(PRJ_DIR)/../../os/os_errno.c_infoTags
-toolMacro objects
-<END>
-
-<BEGIN> BUILD_PENTIUMgnu.debug_FILE_$(PRJ_DIR)/../../os/os_errno.c_objects
-os_errno.o
-<END>
-
-<BEGIN> BUILD_PENTIUMgnu.debug_FILE_$(PRJ_DIR)/../../os/os_errno.c_toolMacro
-CC
-<END>
-
-<BEGIN> BUILD_PENTIUMgnu.debug_FILE_$(PRJ_DIR)/../../os/os_fid.c_infoTags
-toolMacro objects
-<END>
-
-<BEGIN> BUILD_PENTIUMgnu.debug_FILE_$(PRJ_DIR)/../../os/os_fid.c_objects
-os_fid.o
-<END>
-
-<BEGIN> BUILD_PENTIUMgnu.debug_FILE_$(PRJ_DIR)/../../os/os_fid.c_toolMacro
-CC
-<END>
-
-<BEGIN> BUILD_PENTIUMgnu.debug_FILE_$(PRJ_DIR)/../../os/os_fsync.c_infoTags
-toolMacro objects
-<END>
-
-<BEGIN> BUILD_PENTIUMgnu.debug_FILE_$(PRJ_DIR)/../../os/os_fsync.c_objects
-os_fsync.o
-<END>
-
-<BEGIN> BUILD_PENTIUMgnu.debug_FILE_$(PRJ_DIR)/../../os/os_fsync.c_toolMacro
-CC
-<END>
-
-<BEGIN> BUILD_PENTIUMgnu.debug_FILE_$(PRJ_DIR)/../../os/os_handle.c_infoTags
-toolMacro objects
-<END>
-
-<BEGIN> BUILD_PENTIUMgnu.debug_FILE_$(PRJ_DIR)/../../os/os_handle.c_objects
-os_handle.o
-<END>
-
-<BEGIN> BUILD_PENTIUMgnu.debug_FILE_$(PRJ_DIR)/../../os/os_handle.c_toolMacro
-CC
-<END>
-
-<BEGIN> BUILD_PENTIUMgnu.debug_FILE_$(PRJ_DIR)/../../os/os_id.c_infoTags
-toolMacro objects
-<END>
-
-<BEGIN> BUILD_PENTIUMgnu.debug_FILE_$(PRJ_DIR)/../../os/os_id.c_objects
-os_id.o
-<END>
-
-<BEGIN> BUILD_PENTIUMgnu.debug_FILE_$(PRJ_DIR)/../../os/os_id.c_toolMacro
-CC
-<END>
-
-<BEGIN> BUILD_PENTIUMgnu.debug_FILE_$(PRJ_DIR)/../../os/os_method.c_infoTags
-toolMacro objects
-<END>
-
-<BEGIN> BUILD_PENTIUMgnu.debug_FILE_$(PRJ_DIR)/../../os/os_method.c_objects
-os_method.o
-<END>
-
-<BEGIN> BUILD_PENTIUMgnu.debug_FILE_$(PRJ_DIR)/../../os/os_method.c_toolMacro
-CC
-<END>
-
-<BEGIN> BUILD_PENTIUMgnu.debug_FILE_$(PRJ_DIR)/../../os/os_oflags.c_infoTags
-toolMacro objects
-<END>
-
-<BEGIN> BUILD_PENTIUMgnu.debug_FILE_$(PRJ_DIR)/../../os/os_oflags.c_objects
-os_oflags.o
-<END>
-
-<BEGIN> BUILD_PENTIUMgnu.debug_FILE_$(PRJ_DIR)/../../os/os_oflags.c_toolMacro
-CC
-<END>
-
-<BEGIN> BUILD_PENTIUMgnu.debug_FILE_$(PRJ_DIR)/../../os/os_open.c_infoTags
-toolMacro objects
-<END>
-
-<BEGIN> BUILD_PENTIUMgnu.debug_FILE_$(PRJ_DIR)/../../os/os_open.c_objects
-os_open.o
-<END>
-
-<BEGIN> BUILD_PENTIUMgnu.debug_FILE_$(PRJ_DIR)/../../os/os_open.c_toolMacro
-CC
-<END>
-
-<BEGIN> BUILD_PENTIUMgnu.debug_FILE_$(PRJ_DIR)/../../os/os_region.c_infoTags
-toolMacro objects
-<END>
-
-<BEGIN> BUILD_PENTIUMgnu.debug_FILE_$(PRJ_DIR)/../../os/os_region.c_objects
-os_region.o
-<END>
-
-<BEGIN> BUILD_PENTIUMgnu.debug_FILE_$(PRJ_DIR)/../../os/os_region.c_toolMacro
-CC
-<END>
-
-<BEGIN> BUILD_PENTIUMgnu.debug_FILE_$(PRJ_DIR)/../../os/os_rename.c_infoTags
-toolMacro objects
-<END>
-
-<BEGIN> BUILD_PENTIUMgnu.debug_FILE_$(PRJ_DIR)/../../os/os_rename.c_objects
-os_rename.o
-<END>
-
-<BEGIN> BUILD_PENTIUMgnu.debug_FILE_$(PRJ_DIR)/../../os/os_rename.c_toolMacro
-CC
-<END>
-
-<BEGIN> BUILD_PENTIUMgnu.debug_FILE_$(PRJ_DIR)/../../os/os_root.c_infoTags
-toolMacro objects
-<END>
-
-<BEGIN> BUILD_PENTIUMgnu.debug_FILE_$(PRJ_DIR)/../../os/os_root.c_objects
-os_root.o
-<END>
-
-<BEGIN> BUILD_PENTIUMgnu.debug_FILE_$(PRJ_DIR)/../../os/os_root.c_toolMacro
-CC
-<END>
-
-<BEGIN> BUILD_PENTIUMgnu.debug_FILE_$(PRJ_DIR)/../../os/os_rpath.c_infoTags
-toolMacro objects
-<END>
-
-<BEGIN> BUILD_PENTIUMgnu.debug_FILE_$(PRJ_DIR)/../../os/os_rpath.c_objects
-os_rpath.o
-<END>
-
-<BEGIN> BUILD_PENTIUMgnu.debug_FILE_$(PRJ_DIR)/../../os/os_rpath.c_toolMacro
-CC
-<END>
-
-<BEGIN> BUILD_PENTIUMgnu.debug_FILE_$(PRJ_DIR)/../../os/os_rw.c_infoTags
-toolMacro objects
-<END>
-
-<BEGIN> BUILD_PENTIUMgnu.debug_FILE_$(PRJ_DIR)/../../os/os_rw.c_objects
-os_rw.o
-<END>
-
-<BEGIN> BUILD_PENTIUMgnu.debug_FILE_$(PRJ_DIR)/../../os/os_rw.c_toolMacro
-CC
-<END>
-
-<BEGIN> BUILD_PENTIUMgnu.debug_FILE_$(PRJ_DIR)/../../os/os_seek.c_infoTags
-toolMacro objects
-<END>
-
-<BEGIN> BUILD_PENTIUMgnu.debug_FILE_$(PRJ_DIR)/../../os/os_seek.c_objects
-os_seek.o
-<END>
-
-<BEGIN> BUILD_PENTIUMgnu.debug_FILE_$(PRJ_DIR)/../../os/os_seek.c_toolMacro
-CC
-<END>
-
-<BEGIN> BUILD_PENTIUMgnu.debug_FILE_$(PRJ_DIR)/../../os/os_sleep.c_infoTags
-toolMacro objects
-<END>
-
-<BEGIN> BUILD_PENTIUMgnu.debug_FILE_$(PRJ_DIR)/../../os/os_sleep.c_objects
-os_sleep.o
-<END>
-
-<BEGIN> BUILD_PENTIUMgnu.debug_FILE_$(PRJ_DIR)/../../os/os_sleep.c_toolMacro
-CC
-<END>
-
-<BEGIN> BUILD_PENTIUMgnu.debug_FILE_$(PRJ_DIR)/../../os/os_spin.c_infoTags
-toolMacro objects
-<END>
-
-<BEGIN> BUILD_PENTIUMgnu.debug_FILE_$(PRJ_DIR)/../../os/os_spin.c_objects
-os_spin.o
-<END>
-
-<BEGIN> BUILD_PENTIUMgnu.debug_FILE_$(PRJ_DIR)/../../os/os_spin.c_toolMacro
-CC
-<END>
-
-<BEGIN> BUILD_PENTIUMgnu.debug_FILE_$(PRJ_DIR)/../../os/os_stat.c_infoTags
-toolMacro objects
-<END>
-
-<BEGIN> BUILD_PENTIUMgnu.debug_FILE_$(PRJ_DIR)/../../os/os_stat.c_objects
-os_stat.o
-<END>
-
-<BEGIN> BUILD_PENTIUMgnu.debug_FILE_$(PRJ_DIR)/../../os/os_stat.c_toolMacro
-CC
-<END>
-
-<BEGIN> BUILD_PENTIUMgnu.debug_FILE_$(PRJ_DIR)/../../os/os_tmpdir.c_infoTags
-toolMacro objects
-<END>
-
-<BEGIN> BUILD_PENTIUMgnu.debug_FILE_$(PRJ_DIR)/../../os/os_tmpdir.c_objects
-os_tmpdir.o
-<END>
-
-<BEGIN> BUILD_PENTIUMgnu.debug_FILE_$(PRJ_DIR)/../../os/os_tmpdir.c_toolMacro
-CC
-<END>
-
-<BEGIN> BUILD_PENTIUMgnu.debug_FILE_$(PRJ_DIR)/../../os/os_unlink.c_infoTags
-toolMacro objects
-<END>
-
-<BEGIN> BUILD_PENTIUMgnu.debug_FILE_$(PRJ_DIR)/../../os/os_unlink.c_objects
-os_unlink.o
-<END>
-
-<BEGIN> BUILD_PENTIUMgnu.debug_FILE_$(PRJ_DIR)/../../os/os_unlink.c_toolMacro
-CC
-<END>
-
-<BEGIN> BUILD_PENTIUMgnu.debug_FILE_$(PRJ_DIR)/../../os_vxworks/os_vx_abs.c_infoTags
-toolMacro objects
-<END>
-
-<BEGIN> BUILD_PENTIUMgnu.debug_FILE_$(PRJ_DIR)/../../os_vxworks/os_vx_abs.c_objects
-os_vx_abs.o
-<END>
-
-<BEGIN> BUILD_PENTIUMgnu.debug_FILE_$(PRJ_DIR)/../../os_vxworks/os_vx_abs.c_toolMacro
-CC
-<END>
-
-<BEGIN> BUILD_PENTIUMgnu.debug_FILE_$(PRJ_DIR)/../../os_vxworks/os_vx_config.c_infoTags
-toolMacro objects
-<END>
-
-<BEGIN> BUILD_PENTIUMgnu.debug_FILE_$(PRJ_DIR)/../../os_vxworks/os_vx_config.c_objects
-os_vx_config.o
-<END>
-
-<BEGIN> BUILD_PENTIUMgnu.debug_FILE_$(PRJ_DIR)/../../os_vxworks/os_vx_config.c_toolMacro
-CC
-<END>
-
-<BEGIN> BUILD_PENTIUMgnu.debug_FILE_$(PRJ_DIR)/../../os_vxworks/os_vx_map.c_infoTags
-toolMacro objects
-<END>
-
-<BEGIN> BUILD_PENTIUMgnu.debug_FILE_$(PRJ_DIR)/../../os_vxworks/os_vx_map.c_objects
-os_vx_map.o
-<END>
-
-<BEGIN> BUILD_PENTIUMgnu.debug_FILE_$(PRJ_DIR)/../../os_vxworks/os_vx_map.c_toolMacro
-CC
-<END>
-
-<BEGIN> BUILD_PENTIUMgnu.debug_FILE_$(PRJ_DIR)/../../qam/qam.c_infoTags
-toolMacro objects
-<END>
-
-<BEGIN> BUILD_PENTIUMgnu.debug_FILE_$(PRJ_DIR)/../../qam/qam.c_objects
-qam.o
-<END>
-
-<BEGIN> BUILD_PENTIUMgnu.debug_FILE_$(PRJ_DIR)/../../qam/qam.c_toolMacro
-CC
-<END>
-
-<BEGIN> BUILD_PENTIUMgnu.debug_FILE_$(PRJ_DIR)/../../qam/qam_auto.c_infoTags
-toolMacro objects
-<END>
-
-<BEGIN> BUILD_PENTIUMgnu.debug_FILE_$(PRJ_DIR)/../../qam/qam_auto.c_objects
-qam_auto.o
-<END>
-
-<BEGIN> BUILD_PENTIUMgnu.debug_FILE_$(PRJ_DIR)/../../qam/qam_auto.c_toolMacro
-CC
-<END>
-
-<BEGIN> BUILD_PENTIUMgnu.debug_FILE_$(PRJ_DIR)/../../qam/qam_conv.c_infoTags
-toolMacro objects
-<END>
-
-<BEGIN> BUILD_PENTIUMgnu.debug_FILE_$(PRJ_DIR)/../../qam/qam_conv.c_objects
-qam_conv.o
-<END>
-
-<BEGIN> BUILD_PENTIUMgnu.debug_FILE_$(PRJ_DIR)/../../qam/qam_conv.c_toolMacro
-CC
-<END>
-
-<BEGIN> BUILD_PENTIUMgnu.debug_FILE_$(PRJ_DIR)/../../qam/qam_files.c_infoTags
-toolMacro objects
-<END>
-
-<BEGIN> BUILD_PENTIUMgnu.debug_FILE_$(PRJ_DIR)/../../qam/qam_files.c_objects
-qam_files.o
-<END>
-
-<BEGIN> BUILD_PENTIUMgnu.debug_FILE_$(PRJ_DIR)/../../qam/qam_files.c_toolMacro
-CC
-<END>
-
-<BEGIN> BUILD_PENTIUMgnu.debug_FILE_$(PRJ_DIR)/../../qam/qam_method.c_infoTags
-toolMacro objects
-<END>
-
-<BEGIN> BUILD_PENTIUMgnu.debug_FILE_$(PRJ_DIR)/../../qam/qam_method.c_objects
-qam_method.o
-<END>
-
-<BEGIN> BUILD_PENTIUMgnu.debug_FILE_$(PRJ_DIR)/../../qam/qam_method.c_toolMacro
-CC
-<END>
-
-<BEGIN> BUILD_PENTIUMgnu.debug_FILE_$(PRJ_DIR)/../../qam/qam_open.c_infoTags
-toolMacro objects
-<END>
-
-<BEGIN> BUILD_PENTIUMgnu.debug_FILE_$(PRJ_DIR)/../../qam/qam_open.c_objects
-qam_open.o
-<END>
-
-<BEGIN> BUILD_PENTIUMgnu.debug_FILE_$(PRJ_DIR)/../../qam/qam_open.c_toolMacro
-CC
-<END>
-
-<BEGIN> BUILD_PENTIUMgnu.debug_FILE_$(PRJ_DIR)/../../qam/qam_rec.c_infoTags
-toolMacro objects
-<END>
-
-<BEGIN> BUILD_PENTIUMgnu.debug_FILE_$(PRJ_DIR)/../../qam/qam_rec.c_objects
-qam_rec.o
-<END>
-
-<BEGIN> BUILD_PENTIUMgnu.debug_FILE_$(PRJ_DIR)/../../qam/qam_rec.c_toolMacro
-CC
-<END>
-
-<BEGIN> BUILD_PENTIUMgnu.debug_FILE_$(PRJ_DIR)/../../qam/qam_stat.c_infoTags
-toolMacro objects
-<END>
-
-<BEGIN> BUILD_PENTIUMgnu.debug_FILE_$(PRJ_DIR)/../../qam/qam_stat.c_objects
-qam_stat.o
-<END>
-
-<BEGIN> BUILD_PENTIUMgnu.debug_FILE_$(PRJ_DIR)/../../qam/qam_stat.c_toolMacro
-CC
-<END>
-
-<BEGIN> BUILD_PENTIUMgnu.debug_FILE_$(PRJ_DIR)/../../qam/qam_upgrade.c_infoTags
-toolMacro objects
-<END>
-
-<BEGIN> BUILD_PENTIUMgnu.debug_FILE_$(PRJ_DIR)/../../qam/qam_upgrade.c_objects
-qam_upgrade.o
-<END>
-
-<BEGIN> BUILD_PENTIUMgnu.debug_FILE_$(PRJ_DIR)/../../qam/qam_upgrade.c_toolMacro
-CC
-<END>
-
-<BEGIN> BUILD_PENTIUMgnu.debug_FILE_$(PRJ_DIR)/../../qam/qam_verify.c_infoTags
-toolMacro objects
-<END>
-
-<BEGIN> BUILD_PENTIUMgnu.debug_FILE_$(PRJ_DIR)/../../qam/qam_verify.c_objects
-qam_verify.o
-<END>
-
-<BEGIN> BUILD_PENTIUMgnu.debug_FILE_$(PRJ_DIR)/../../qam/qam_verify.c_toolMacro
-CC
-<END>
-
-<BEGIN> BUILD_PENTIUMgnu.debug_FILE_$(PRJ_DIR)/../../rep/rep_method.c_infoTags
-toolMacro objects
-<END>
-
-<BEGIN> BUILD_PENTIUMgnu.debug_FILE_$(PRJ_DIR)/../../rep/rep_method.c_objects
-rep_method.o
-<END>
-
-<BEGIN> BUILD_PENTIUMgnu.debug_FILE_$(PRJ_DIR)/../../rep/rep_method.c_toolMacro
-CC
-<END>
-
-<BEGIN> BUILD_PENTIUMgnu.debug_FILE_$(PRJ_DIR)/../../rep/rep_record.c_infoTags
-toolMacro objects
-<END>
-
-<BEGIN> BUILD_PENTIUMgnu.debug_FILE_$(PRJ_DIR)/../../rep/rep_record.c_objects
-rep_record.o
-<END>
-
-<BEGIN> BUILD_PENTIUMgnu.debug_FILE_$(PRJ_DIR)/../../rep/rep_record.c_toolMacro
-CC
-<END>
-
-<BEGIN> BUILD_PENTIUMgnu.debug_FILE_$(PRJ_DIR)/../../rep/rep_region.c_infoTags
-toolMacro objects
-<END>
-
-<BEGIN> BUILD_PENTIUMgnu.debug_FILE_$(PRJ_DIR)/../../rep/rep_region.c_objects
-rep_region.o
-<END>
-
-<BEGIN> BUILD_PENTIUMgnu.debug_FILE_$(PRJ_DIR)/../../rep/rep_region.c_toolMacro
-CC
-<END>
-
-<BEGIN> BUILD_PENTIUMgnu.debug_FILE_$(PRJ_DIR)/../../rep/rep_util.c_infoTags
-toolMacro objects
-<END>
-
-<BEGIN> BUILD_PENTIUMgnu.debug_FILE_$(PRJ_DIR)/../../rep/rep_util.c_objects
-rep_util.o
-<END>
-
-<BEGIN> BUILD_PENTIUMgnu.debug_FILE_$(PRJ_DIR)/../../rep/rep_util.c_toolMacro
-CC
-<END>
-
-<BEGIN> BUILD_PENTIUMgnu.debug_FILE_$(PRJ_DIR)/../../rpc_client/client.c_infoTags
-toolMacro objects
-<END>
-
-<BEGIN> BUILD_PENTIUMgnu.debug_FILE_$(PRJ_DIR)/../../rpc_client/client.c_objects
-client.o
-<END>
-
-<BEGIN> BUILD_PENTIUMgnu.debug_FILE_$(PRJ_DIR)/../../rpc_client/client.c_toolMacro
-CC
-<END>
-
-<BEGIN> BUILD_PENTIUMgnu.debug_FILE_$(PRJ_DIR)/../../rpc_client/db_server_clnt.c_infoTags
-toolMacro objects
-<END>
-
-<BEGIN> BUILD_PENTIUMgnu.debug_FILE_$(PRJ_DIR)/../../rpc_client/db_server_clnt.c_objects
-db_server_clnt.o
-<END>
-
-<BEGIN> BUILD_PENTIUMgnu.debug_FILE_$(PRJ_DIR)/../../rpc_client/db_server_clnt.c_toolMacro
-CC
-<END>
-
-<BEGIN> BUILD_PENTIUMgnu.debug_FILE_$(PRJ_DIR)/../../rpc_client/gen_client.c_infoTags
-toolMacro objects
-<END>
-
-<BEGIN> BUILD_PENTIUMgnu.debug_FILE_$(PRJ_DIR)/../../rpc_client/gen_client.c_objects
-gen_client.o
-<END>
-
-<BEGIN> BUILD_PENTIUMgnu.debug_FILE_$(PRJ_DIR)/../../rpc_client/gen_client.c_toolMacro
-CC
-<END>
-
-<BEGIN> BUILD_PENTIUMgnu.debug_FILE_$(PRJ_DIR)/../../rpc_client/gen_client_ret.c_infoTags
-toolMacro objects
-<END>
-
-<BEGIN> BUILD_PENTIUMgnu.debug_FILE_$(PRJ_DIR)/../../rpc_client/gen_client_ret.c_objects
-gen_client_ret.o
-<END>
-
-<BEGIN> BUILD_PENTIUMgnu.debug_FILE_$(PRJ_DIR)/../../rpc_client/gen_client_ret.c_toolMacro
-CC
-<END>
-
-<BEGIN> BUILD_PENTIUMgnu.debug_FILE_$(PRJ_DIR)/../../rpc_server/c/db_server_xdr.c_infoTags
-toolMacro objects
-<END>
-
-<BEGIN> BUILD_PENTIUMgnu.debug_FILE_$(PRJ_DIR)/../../rpc_server/c/db_server_xdr.c_objects
-db_server_xdr.o
-<END>
-
-<BEGIN> BUILD_PENTIUMgnu.debug_FILE_$(PRJ_DIR)/../../rpc_server/c/db_server_xdr.c_toolMacro
-CC
-<END>
-
-<BEGIN> BUILD_PENTIUMgnu.debug_FILE_$(PRJ_DIR)/../../txn/txn.c_infoTags
-toolMacro objects
-<END>
-
-<BEGIN> BUILD_PENTIUMgnu.debug_FILE_$(PRJ_DIR)/../../txn/txn.c_objects
-txn.o
-<END>
-
-<BEGIN> BUILD_PENTIUMgnu.debug_FILE_$(PRJ_DIR)/../../txn/txn.c_toolMacro
-CC
-<END>
-
-<BEGIN> BUILD_PENTIUMgnu.debug_FILE_$(PRJ_DIR)/../../txn/txn_auto.c_infoTags
-toolMacro objects
-<END>
-
-<BEGIN> BUILD_PENTIUMgnu.debug_FILE_$(PRJ_DIR)/../../txn/txn_auto.c_objects
-txn_auto.o
-<END>
-
-<BEGIN> BUILD_PENTIUMgnu.debug_FILE_$(PRJ_DIR)/../../txn/txn_auto.c_toolMacro
-CC
-<END>
-
-<BEGIN> BUILD_PENTIUMgnu.debug_FILE_$(PRJ_DIR)/../../txn/txn_method.c_infoTags
-toolMacro objects
-<END>
-
-<BEGIN> BUILD_PENTIUMgnu.debug_FILE_$(PRJ_DIR)/../../txn/txn_method.c_objects
-txn_method.o
-<END>
-
-<BEGIN> BUILD_PENTIUMgnu.debug_FILE_$(PRJ_DIR)/../../txn/txn_method.c_toolMacro
-CC
-<END>
-
-<BEGIN> BUILD_PENTIUMgnu.debug_FILE_$(PRJ_DIR)/../../txn/txn_rec.c_infoTags
-toolMacro objects
-<END>
-
-<BEGIN> BUILD_PENTIUMgnu.debug_FILE_$(PRJ_DIR)/../../txn/txn_rec.c_objects
-txn_rec.o
-<END>
-
-<BEGIN> BUILD_PENTIUMgnu.debug_FILE_$(PRJ_DIR)/../../txn/txn_rec.c_toolMacro
-CC
-<END>
-
-<BEGIN> BUILD_PENTIUMgnu.debug_FILE_$(PRJ_DIR)/../../txn/txn_recover.c_infoTags
-toolMacro objects
-<END>
-
-<BEGIN> BUILD_PENTIUMgnu.debug_FILE_$(PRJ_DIR)/../../txn/txn_recover.c_objects
-txn_recover.o
-<END>
-
-<BEGIN> BUILD_PENTIUMgnu.debug_FILE_$(PRJ_DIR)/../../txn/txn_recover.c_toolMacro
-CC
-<END>
-
-<BEGIN> BUILD_PENTIUMgnu.debug_FILE_$(PRJ_DIR)/../../txn/txn_region.c_infoTags
-toolMacro objects
-<END>
-
-<BEGIN> BUILD_PENTIUMgnu.debug_FILE_$(PRJ_DIR)/../../txn/txn_region.c_objects
-txn_region.o
-<END>
-
-<BEGIN> BUILD_PENTIUMgnu.debug_FILE_$(PRJ_DIR)/../../txn/txn_region.c_toolMacro
-CC
-<END>
-
-<BEGIN> BUILD_PENTIUMgnu.debug_FILE_$(PRJ_DIR)/../../txn/txn_stat.c_infoTags
-toolMacro objects
-<END>
-
-<BEGIN> BUILD_PENTIUMgnu.debug_FILE_$(PRJ_DIR)/../../txn/txn_stat.c_objects
-txn_stat.o
-<END>
-
-<BEGIN> BUILD_PENTIUMgnu.debug_FILE_$(PRJ_DIR)/../../txn/txn_stat.c_toolMacro
-CC
-<END>
-
-<BEGIN> BUILD_PENTIUMgnu.debug_FILE_$(PRJ_DIR)/../../txn/txn_util.c_infoTags
-toolMacro objects
-<END>
-
-<BEGIN> BUILD_PENTIUMgnu.debug_FILE_$(PRJ_DIR)/../../txn/txn_util.c_objects
-txn_util.o
-<END>
-
-<BEGIN> BUILD_PENTIUMgnu.debug_FILE_$(PRJ_DIR)/../../txn/txn_util.c_toolMacro
-CC
-<END>
-
-<BEGIN> BUILD_PENTIUMgnu.debug_FILE_$(PRJ_DIR)/../../xa/xa.c_infoTags
-toolMacro objects
-<END>
-
-<BEGIN> BUILD_PENTIUMgnu.debug_FILE_$(PRJ_DIR)/../../xa/xa.c_objects
-xa.o
-<END>
-
-<BEGIN> BUILD_PENTIUMgnu.debug_FILE_$(PRJ_DIR)/../../xa/xa.c_toolMacro
-CC
-<END>
-
-<BEGIN> BUILD_PENTIUMgnu.debug_FILE_$(PRJ_DIR)/../../xa/xa_db.c_infoTags
-toolMacro objects
-<END>
-
-<BEGIN> BUILD_PENTIUMgnu.debug_FILE_$(PRJ_DIR)/../../xa/xa_db.c_objects
-xa_db.o
-<END>
-
-<BEGIN> BUILD_PENTIUMgnu.debug_FILE_$(PRJ_DIR)/../../xa/xa_db.c_toolMacro
-CC
-<END>
-
-<BEGIN> BUILD_PENTIUMgnu.debug_FILE_$(PRJ_DIR)/../../xa/xa_map.c_infoTags
-toolMacro objects
-<END>
-
-<BEGIN> BUILD_PENTIUMgnu.debug_FILE_$(PRJ_DIR)/../../xa/xa_map.c_objects
-xa_map.o
-<END>
-
-<BEGIN> BUILD_PENTIUMgnu.debug_FILE_$(PRJ_DIR)/../../xa/xa_map.c_toolMacro
-CC
-<END>
-
-<BEGIN> BUILD_PENTIUMgnu.debug_FILE_$(PRJ_DIR)/compConfig.c_infoTags
-toolMacro objects
-<END>   
-
-<BEGIN> BUILD_PENTIUMgnu.debug_FILE_$(PRJ_DIR)/compConfig.c_objects
-compConfig.o
-<END>   
-
-<BEGIN> BUILD_PENTIUMgnu.debug_FILE_$(PRJ_DIR)/compConfig.c_toolMacro
-CC   
-<END>
-
-<BEGIN> BUILD_PENTIUMgnu.debug_MACRO_AR
-arpentium
-<END>
-
-<BEGIN> BUILD_PENTIUMgnu.debug_MACRO_AS
-ccpentium
-<END>
-
-<BEGIN> BUILD_PENTIUMgnu.debug_MACRO_CC
-ccpentium
-<END>
-
-<BEGIN> BUILD_PENTIUMgnu.debug_MACRO_CFLAGS
--mcpu=pentium \
-	-march=pentium \
-	-ansi \
-	-DRW_MULTI_THREAD \
-	-D_REENTRANT \
-	-g \
-	-nostdlib \
-	-fno-builtin \
-	-fno-defer-pop \
-	-MD \
-	-Wall \
-	-I. \
-	-I$(WIND_BASE)/target/h \
-	-DCPU=PENTIUM \
-	-I$(PRJ_DIR)/.. \
-	-I$(PRJ_DIR)/../.. \
-	-DDEBUG \
-	-DDIAGNOSTIC
-<END>
-
-<BEGIN> BUILD_PENTIUMgnu.debug_MACRO_CFLAGS_AS
--mcpu=pentium \
-	-march=pentium \
-	-ansi \
-	-g \
-	-nostdlib \
-	-fno-builtin \
-	-fno-defer-pop \
-	-P \
-	-x \
-	assembler-with-cpp \
-	-Wall \
-	-I. \
-	-I$(WIND_BASE)/target/h \
-	-DCPU=PENTIUM
-<END>
-
-<BEGIN> BUILD_PENTIUMgnu.debug_MACRO_CPP
-ccpentium -E -P
-<END>
-
-<BEGIN> BUILD_PENTIUMgnu.debug_MACRO_CPPFILT
-c++filtpentium --strip-underscores
-<END>
-
-<BEGIN> BUILD_PENTIUMgnu.debug_MACRO_LD
-ldpentium
-<END>
-
-<BEGIN> BUILD_PENTIUMgnu.debug_MACRO_LDFLAGS
--X
-<END>
-
-<BEGIN> BUILD_PENTIUMgnu.debug_MACRO_LDPARTIAL
-ccpentium \
-	-B$(WIND_BASE)/host/$(WIND_HOST_TYPE)/lib/gcc-lib/ \
-	-nostdlib \
-	-r \
-	-Wl,-X
-<END>
-
-<BEGIN> BUILD_PENTIUMgnu.debug_MACRO_LD_PARTIAL_FLAGS
--X -r
-<END>
-
-<BEGIN> BUILD_PENTIUMgnu.debug_MACRO_NM
-nmpentium -g
-<END>
-
-<BEGIN> BUILD_PENTIUMgnu.debug_MACRO_OPTION_DEFINE_MACRO
--D
-<END>
-
-<BEGIN> BUILD_PENTIUMgnu.debug_MACRO_OPTION_GENERATE_DEPENDENCY_FILE
--MD
-<END>
-
-<BEGIN> BUILD_PENTIUMgnu.debug_MACRO_OPTION_INCLUDE_DIR
--I
-<END>
-
-<BEGIN> BUILD_PENTIUMgnu.debug_MACRO_RELEASE
-0
-<END>
-
-<BEGIN> BUILD_PENTIUMgnu.debug_MACRO_SIZE
-sizepentium
-<END>
-
-<BEGIN> BUILD_PENTIUMgnu.debug_RELEASE
-0
-<END>
-
-<BEGIN> BUILD_PENTIUMgnu.debug_RO_DEPEND_PATH
-$(WIND_BASE)/target/h/
-<END>
-
-<BEGIN> BUILD_PENTIUMgnu.debug_TC
-::tc_PENTIUMgnu.debug
-<END>
-
-<BEGIN> BUILD__LIST
-PENTIUMgnu.debug PENTIUM2gnu.debug PENTIUM2gnu.release
-<END>
-
-<BEGIN> COMPONENT_COM_TYPE
-
-<END>
-
-<BEGIN> PROJECT_FILES
-$(PRJ_DIR)/../../btree/bt_compare.c \
-	$(PRJ_DIR)/../../btree/bt_conv.c \
-	$(PRJ_DIR)/../../btree/bt_curadj.c \
-	$(PRJ_DIR)/../../btree/bt_cursor.c \
-	$(PRJ_DIR)/../../btree/bt_delete.c \
-	$(PRJ_DIR)/../../btree/bt_method.c \
-	$(PRJ_DIR)/../../btree/bt_open.c \
-	$(PRJ_DIR)/../../btree/bt_put.c \
-	$(PRJ_DIR)/../../btree/bt_rec.c \
-	$(PRJ_DIR)/../../btree/bt_reclaim.c \
-	$(PRJ_DIR)/../../btree/bt_recno.c \
-	$(PRJ_DIR)/../../btree/bt_rsearch.c \
-	$(PRJ_DIR)/../../btree/bt_search.c \
-	$(PRJ_DIR)/../../btree/bt_split.c \
-	$(PRJ_DIR)/../../btree/bt_stat.c \
-	$(PRJ_DIR)/../../btree/bt_upgrade.c \
-	$(PRJ_DIR)/../../btree/bt_verify.c \
-	$(PRJ_DIR)/../../btree/btree_auto.c \
-	$(PRJ_DIR)/../../clib/getopt.c \
-	$(PRJ_DIR)/../../clib/snprintf.c \
-	$(PRJ_DIR)/../../clib/strcasecmp.c \
-	$(PRJ_DIR)/../../clib/strdup.c \
-	$(PRJ_DIR)/../../clib/vsnprintf.c \
-	$(PRJ_DIR)/../../common/db_byteorder.c \
-	$(PRJ_DIR)/../../common/db_err.c \
-	$(PRJ_DIR)/../../common/db_getlong.c \
-	$(PRJ_DIR)/../../common/db_idspace.c \
-	$(PRJ_DIR)/../../common/db_log2.c \
-	$(PRJ_DIR)/../../common/util_arg.c \
-	$(PRJ_DIR)/../../common/util_cache.c \
-	$(PRJ_DIR)/../../common/util_log.c \
-	$(PRJ_DIR)/../../common/util_sig.c \
-	$(PRJ_DIR)/../../db/crdel_auto.c \
-	$(PRJ_DIR)/../../db/crdel_rec.c \
-	$(PRJ_DIR)/../../db/db.c \
-	$(PRJ_DIR)/../../db/db_am.c \
-	$(PRJ_DIR)/../../db/db_auto.c \
-	$(PRJ_DIR)/../../db/db_cam.c \
-	$(PRJ_DIR)/../../db/db_conv.c \
-	$(PRJ_DIR)/../../db/db_dispatch.c \
-	$(PRJ_DIR)/../../db/db_dup.c \
-	$(PRJ_DIR)/../../db/db_iface.c \
-	$(PRJ_DIR)/../../db/db_join.c \
-	$(PRJ_DIR)/../../db/db_meta.c \
-	$(PRJ_DIR)/../../db/db_method.c \
-	$(PRJ_DIR)/../../db/db_open.c \
-	$(PRJ_DIR)/../../db/db_overflow.c \
-	$(PRJ_DIR)/../../db/db_pr.c \
-	$(PRJ_DIR)/../../db/db_rec.c \
-	$(PRJ_DIR)/../../db/db_reclaim.c \
-	$(PRJ_DIR)/../../db/db_remove.c \
-	$(PRJ_DIR)/../../db/db_rename.c \
-	$(PRJ_DIR)/../../db/db_ret.c \
-	$(PRJ_DIR)/../../db/db_truncate.c \
-	$(PRJ_DIR)/../../db/db_upg.c \
-	$(PRJ_DIR)/../../db/db_upg_opd.c \
-	$(PRJ_DIR)/../../db/db_vrfy.c \
-	$(PRJ_DIR)/../../db/db_vrfyutil.c \
-	$(PRJ_DIR)/../../dbreg/dbreg.c \
-	$(PRJ_DIR)/../../dbreg/dbreg_auto.c \
-	$(PRJ_DIR)/../../dbreg/dbreg_rec.c \
-	$(PRJ_DIR)/../../dbreg/dbreg_util.c \
-	$(PRJ_DIR)/../../env/db_salloc.c \
-	$(PRJ_DIR)/../../env/db_shash.c \
-	$(PRJ_DIR)/../../env/env_file.c \
-	$(PRJ_DIR)/../../env/env_method.c \
-	$(PRJ_DIR)/../../env/env_open.c \
-	$(PRJ_DIR)/../../env/env_recover.c \
-	$(PRJ_DIR)/../../env/env_region.c \
-	$(PRJ_DIR)/../../fileops/fileops_auto.c \
-	$(PRJ_DIR)/../../fileops/fop_basic.c \
-	$(PRJ_DIR)/../../fileops/fop_rec.c \
-	$(PRJ_DIR)/../../fileops/fop_util.c \
-	$(PRJ_DIR)/../../hash/hash.c \
-	$(PRJ_DIR)/../../hash/hash_auto.c \
-	$(PRJ_DIR)/../../hash/hash_conv.c \
-	$(PRJ_DIR)/../../hash/hash_dup.c \
-	$(PRJ_DIR)/../../hash/hash_func.c \
-	$(PRJ_DIR)/../../hash/hash_meta.c \
-	$(PRJ_DIR)/../../hash/hash_method.c \
-	$(PRJ_DIR)/../../hash/hash_open.c \
-	$(PRJ_DIR)/../../hash/hash_page.c \
-	$(PRJ_DIR)/../../hash/hash_rec.c \
-	$(PRJ_DIR)/../../hash/hash_reclaim.c \
-	$(PRJ_DIR)/../../hash/hash_stat.c \
-	$(PRJ_DIR)/../../hash/hash_upgrade.c \
-	$(PRJ_DIR)/../../hash/hash_verify.c \
-	$(PRJ_DIR)/../../hmac/hmac.c \
-	$(PRJ_DIR)/../../hmac/sha1.c \
-	$(PRJ_DIR)/../../hsearch/hsearch.c \
-	$(PRJ_DIR)/../../lock/lock.c \
-	$(PRJ_DIR)/../../lock/lock_deadlock.c \
-	$(PRJ_DIR)/../../lock/lock_method.c \
-	$(PRJ_DIR)/../../lock/lock_region.c \
-	$(PRJ_DIR)/../../lock/lock_stat.c \
-	$(PRJ_DIR)/../../lock/lock_util.c \
-	$(PRJ_DIR)/../../log/log.c \
-	$(PRJ_DIR)/../../log/log_archive.c \
-	$(PRJ_DIR)/../../log/log_compare.c \
-	$(PRJ_DIR)/../../log/log_get.c \
-	$(PRJ_DIR)/../../log/log_method.c \
-	$(PRJ_DIR)/../../log/log_put.c \
-	$(PRJ_DIR)/../../mp/mp_alloc.c \
-	$(PRJ_DIR)/../../mp/mp_bh.c \
-	$(PRJ_DIR)/../../mp/mp_fget.c \
-	$(PRJ_DIR)/../../mp/mp_fopen.c \
-	$(PRJ_DIR)/../../mp/mp_fput.c \
-	$(PRJ_DIR)/../../mp/mp_fset.c \
-	$(PRJ_DIR)/../../mp/mp_method.c \
-	$(PRJ_DIR)/../../mp/mp_region.c \
-	$(PRJ_DIR)/../../mp/mp_register.c \
-	$(PRJ_DIR)/../../mp/mp_stat.c \
-	$(PRJ_DIR)/../../mp/mp_sync.c \
-	$(PRJ_DIR)/../../mp/mp_trickle.c \
-	$(PRJ_DIR)/../../mutex/mut_tas.c \
-	$(PRJ_DIR)/../../mutex/mutex.c \
-	$(PRJ_DIR)/../../os/os_alloc.c \
-	$(PRJ_DIR)/../../os/os_clock.c \
-	$(PRJ_DIR)/../../os/os_dir.c \
-	$(PRJ_DIR)/../../os/os_errno.c \
-	$(PRJ_DIR)/../../os/os_fid.c \
-	$(PRJ_DIR)/../../os/os_fsync.c \
-	$(PRJ_DIR)/../../os/os_handle.c \
-	$(PRJ_DIR)/../../os/os_id.c \
-	$(PRJ_DIR)/../../os/os_method.c \
-	$(PRJ_DIR)/../../os/os_oflags.c \
-	$(PRJ_DIR)/../../os/os_open.c \
-	$(PRJ_DIR)/../../os/os_region.c \
-	$(PRJ_DIR)/../../os/os_rename.c \
-	$(PRJ_DIR)/../../os/os_root.c \
-	$(PRJ_DIR)/../../os/os_rpath.c \
-	$(PRJ_DIR)/../../os/os_rw.c \
-	$(PRJ_DIR)/../../os/os_seek.c \
-	$(PRJ_DIR)/../../os/os_sleep.c \
-	$(PRJ_DIR)/../../os/os_spin.c \
-	$(PRJ_DIR)/../../os/os_stat.c \
-	$(PRJ_DIR)/../../os/os_tmpdir.c \
-	$(PRJ_DIR)/../../os/os_unlink.c \
-	$(PRJ_DIR)/../../os_vxworks/os_vx_abs.c \
-	$(PRJ_DIR)/../../os_vxworks/os_vx_config.c \
-	$(PRJ_DIR)/../../os_vxworks/os_vx_map.c \
-	$(PRJ_DIR)/../../qam/qam.c \
-	$(PRJ_DIR)/../../qam/qam_auto.c \
-	$(PRJ_DIR)/../../qam/qam_conv.c \
-	$(PRJ_DIR)/../../qam/qam_files.c \
-	$(PRJ_DIR)/../../qam/qam_method.c \
-	$(PRJ_DIR)/../../qam/qam_open.c \
-	$(PRJ_DIR)/../../qam/qam_rec.c \
-	$(PRJ_DIR)/../../qam/qam_stat.c \
-	$(PRJ_DIR)/../../qam/qam_upgrade.c \
-	$(PRJ_DIR)/../../qam/qam_verify.c \
-	$(PRJ_DIR)/../../rep/rep_method.c \
-	$(PRJ_DIR)/../../rep/rep_record.c \
-	$(PRJ_DIR)/../../rep/rep_region.c \
-	$(PRJ_DIR)/../../rep/rep_util.c \
-	$(PRJ_DIR)/../../rpc_client/client.c \
-	$(PRJ_DIR)/../../rpc_client/db_server_clnt.c \
-	$(PRJ_DIR)/../../rpc_client/gen_client.c \
-	$(PRJ_DIR)/../../rpc_client/gen_client_ret.c \
-	$(PRJ_DIR)/../../rpc_server/c/db_server_xdr.c \
-	$(PRJ_DIR)/../../txn/txn.c \
-	$(PRJ_DIR)/../../txn/txn_auto.c \
-	$(PRJ_DIR)/../../txn/txn_method.c \
-	$(PRJ_DIR)/../../txn/txn_rec.c \
-	$(PRJ_DIR)/../../txn/txn_recover.c \
-	$(PRJ_DIR)/../../txn/txn_region.c \
-	$(PRJ_DIR)/../../txn/txn_stat.c \
-	$(PRJ_DIR)/../../txn/txn_util.c \
-	$(PRJ_DIR)/../../xa/xa.c \
-	$(PRJ_DIR)/../../xa/xa_db.c \
-	$(PRJ_DIR)/../../xa/xa_map.c
-<END>
-
-<BEGIN> WCC__CDF_PATH
-$(PRJ_DIR)
-<END>
-
-<BEGIN> WCC__CURRENT
-PENTIUMgnu.debug
-<END>
-
-<BEGIN> WCC__LIST
-PENTIUMgnu.debug
-<END>
-
-<BEGIN> WCC__MXR_LIBS
-lib$(CPU)$(TOOL)vx.a
-<END>
-
-<BEGIN> WCC__OBJS_PATH
-$(WIND_BASE)/target/lib/obj$CPU$TOOLvx
-<END>
-
diff --git a/bdb/build_vxworks/db_archive/db_archive.c b/bdb/build_vxworks/db_archive/db_archive.c
deleted file mode 100644
index 5e43f32cd8e0fc4476855a3c5392846658c4446e..0000000000000000000000000000000000000000
--- a/bdb/build_vxworks/db_archive/db_archive.c
+++ /dev/null
@@ -1,195 +0,0 @@
-/*-
- * See the file LICENSE for redistribution information.
- *
- * Copyright (c) 1996-2002
- *	Sleepycat Software.  All rights reserved.
- */
-
-#include "db_config.h"
-
-#ifndef lint
-static const char copyright[] =
-    "Copyright (c) 1996-2002\nSleepycat Software Inc.  All rights reserved.\n";
-static const char revid[] =
-    "$Id: db_archive.c,v 11.36 2002/03/28 20:13:34 bostic Exp $";
-#endif
-
-#ifndef NO_SYSTEM_INCLUDES
-#include <sys/types.h>
-
-#include <stdio.h>
-#include <stdlib.h>
-#include <string.h>
-#include <unistd.h>
-#endif
-
-#include "db_int.h"
-
-int db_archive_main __P((int, char *[]));
-int db_archive_usage __P((void));
-int db_archive_version_check __P((const char *));
-
-int
-db_archive(args)
-	char *args;
-{
-	int argc;
-	char **argv;
-
-	__db_util_arg("db_archive", args, &argc, &argv);
-	return (db_archive_main(argc, argv) ? EXIT_FAILURE : EXIT_SUCCESS);
-}
-
-#include <stdio.h>
-#define	ERROR_RETURN	ERROR
-
-int
-db_archive_main(argc, argv)
-	int argc;
-	char *argv[];
-{
-	extern char *optarg;
-	extern int optind, __db_getopt_reset;
-	const char *progname = "db_archive";
-	DB_ENV	*dbenv;
-	u_int32_t flags;
-	int ch, e_close, exitval, ret, verbose;
-	char **file, *home, **list, *passwd;
-
-	if ((ret = db_archive_version_check(progname)) != 0)
-		return (ret);
-
-	flags = 0;
-	e_close = exitval = verbose = 0;
-	home = passwd = NULL;
-	__db_getopt_reset = 1;
-	while ((ch = getopt(argc, argv, "ah:lP:sVv")) != EOF)
-		switch (ch) {
-		case 'a':
-			LF_SET(DB_ARCH_ABS);
-			break;
-		case 'h':
-			home = optarg;
-			break;
-		case 'l':
-			LF_SET(DB_ARCH_LOG);
-			break;
-		case 'P':
-			passwd = strdup(optarg);
-			memset(optarg, 0, strlen(optarg));
-			if (passwd == NULL) {
-				fprintf(stderr, "%s: strdup: %s\n",
-				    progname, strerror(errno));
-				return (EXIT_FAILURE);
-			}
-			break;
-		case 's':
-			LF_SET(DB_ARCH_DATA);
-			break;
-		case 'V':
-			printf("%s\n", db_version(NULL, NULL, NULL));
-			return (EXIT_SUCCESS);
-		case 'v':
-			verbose = 1;
-			break;
-		case '?':
-		default:
-			return (db_archive_usage());
-		}
-	argc -= optind;
-	argv += optind;
-
-	if (argc != 0)
-		return (db_archive_usage());
-
-	/* Handle possible interruptions. */
-	__db_util_siginit();
-
-	/*
-	 * Create an environment object and initialize it for error
-	 * reporting.
-	 */
-	if ((ret = db_env_create(&dbenv, 0)) != 0) {
-		fprintf(stderr,
-		    "%s: db_env_create: %s\n", progname, db_strerror(ret));
-		goto shutdown;
-	}
-	e_close = 1;
-
-	dbenv->set_errfile(dbenv, stderr);
-	dbenv->set_errpfx(dbenv, progname);
-
-	if (verbose)
-		(void)dbenv->set_verbose(dbenv, DB_VERB_CHKPOINT, 1);
-
-	if (passwd != NULL && (ret = dbenv->set_encrypt(dbenv,
-	    passwd, DB_ENCRYPT_AES)) != 0) {
-		dbenv->err(dbenv, ret, "set_passwd");
-		goto shutdown;
-	}
-	/*
-	 * If attaching to a pre-existing environment fails, create a
-	 * private one and try again.
-	 */
-	if ((ret = dbenv->open(dbenv,
-	    home, DB_JOINENV | DB_USE_ENVIRON, 0)) != 0 &&
-	    (ret = dbenv->open(dbenv, home, DB_CREATE |
-	    DB_INIT_LOG | DB_INIT_TXN | DB_PRIVATE | DB_USE_ENVIRON, 0)) != 0) {
-		dbenv->err(dbenv, ret, "open");
-		goto shutdown;
-	}
-
-	/* Get the list of names. */
-	if ((ret = dbenv->log_archive(dbenv, &list, flags)) != 0) {
-		dbenv->err(dbenv, ret, "DB_ENV->log_archive");
-		goto shutdown;
-	}
-
-	/* Print the list of names. */
-	if (list != NULL) {
-		for (file = list; *file != NULL; ++file)
-			printf("%s\n", *file);
-		free(list);
-	}
-
-	if (0) {
-shutdown:	exitval = 1;
-	}
-	if (e_close && (ret = dbenv->close(dbenv, 0)) != 0) {
-		exitval = 1;
-		fprintf(stderr,
-		    "%s: dbenv->close: %s\n", progname, db_strerror(ret));
-	}
-
-	/* Resend any caught signal. */
-	__db_util_sigresend();
-
-	return (exitval == 0 ? EXIT_SUCCESS : EXIT_FAILURE);
-}
-
-int
-db_archive_usage()
-{
-	(void)fprintf(stderr,
-	    "usage: db_archive [-alsVv] [-h home] [-P password]\n");
-	return (EXIT_FAILURE);
-}
-
-int
-db_archive_version_check(progname)
-	const char *progname;
-{
-	int v_major, v_minor, v_patch;
-
-	/* Make sure we're loaded with the right version of the DB library. */
-	(void)db_version(&v_major, &v_minor, &v_patch);
-	if (v_major != DB_VERSION_MAJOR ||
-	    v_minor != DB_VERSION_MINOR || v_patch != DB_VERSION_PATCH) {
-		fprintf(stderr,
-	"%s: version %d.%d.%d doesn't match library version %d.%d.%d\n",
-		    progname, DB_VERSION_MAJOR, DB_VERSION_MINOR,
-		    DB_VERSION_PATCH, v_major, v_minor, v_patch);
-		return (EXIT_FAILURE);
-	}
-	return (0);
-}
diff --git a/bdb/build_vxworks/db_archive/db_archive.wpj b/bdb/build_vxworks/db_archive/db_archive.wpj
deleted file mode 100755
index 06091bb6b5f79a6c0757ec4f2c3eefe3dbe5af29..0000000000000000000000000000000000000000
--- a/bdb/build_vxworks/db_archive/db_archive.wpj
+++ /dev/null
@@ -1,160 +0,0 @@
-Document file - DO NOT EDIT
-
-<BEGIN> BUILD_PENTIUMgnu_BUILDRULE
-db_archive.out
-<END>
-
-<BEGIN> BUILD_PENTIUMgnu_MACRO_AR
-ar386
-<END>
-
-<BEGIN> BUILD_PENTIUMgnu_MACRO_ARCHIVE
-$(PRJ_DIR)/PENTIUMgnu/db_archive.a
-<END>
-
-<BEGIN> BUILD_PENTIUMgnu_MACRO_AS
-cc386
-<END>
-
-<BEGIN> BUILD_PENTIUMgnu_MACRO_CC
-cc386
-<END>
-
-<BEGIN> BUILD_PENTIUMgnu_MACRO_CFLAGS
--g \
-	-mpentium \
-	-ansi \
-	-nostdinc \
-	-DRW_MULTI_THREAD \
-	-D_REENTRANT \
-	-fvolatile \
-	-nostdlib \
-	-fno-builtin \
-	-fno-defer-pop \
-	-I$(PRJ_DIR)/.. \
-	-I$(PRJ_DIR)/../.. \
-	-I$(WIND_BASE)/target/h \
-	-DCPU=PENTIUM
-<END>
-
-<BEGIN> BUILD_PENTIUMgnu_MACRO_CFLAGS_AS
--g \
-	-mpentium \
-	-ansi \
-	-nostdinc \
-	-fvolatile \
-	-nostdlib \
-	-fno-builtin \
-	-fno-defer-pop \
-	-P \
-	-x \
-	assembler-with-cpp \
-	-I$(WIND_BASE)/target/h \
-	-DCPU=PENTIUM
-<END>
-
-<BEGIN> BUILD_PENTIUMgnu_MACRO_CPP
-cc386 -E -P -xc
-<END>
-
-<BEGIN> BUILD_PENTIUMgnu_MACRO_LD
-ld386
-<END>
-
-<BEGIN> BUILD_PENTIUMgnu_MACRO_LDDEPS
-
-<END>
-
-<BEGIN> BUILD_PENTIUMgnu_MACRO_LDFLAGS
--X -N
-<END>
-
-<BEGIN> BUILD_PENTIUMgnu_MACRO_LD_PARTIAL_FLAGS
--X -r
-<END>
-
-<BEGIN> BUILD_PENTIUMgnu_MACRO_NM
-nm386 -g
-<END>
-
-<BEGIN> BUILD_PENTIUMgnu_MACRO_OPTION_DEFINE_MACRO
--D
-<END>
-
-<BEGIN> BUILD_PENTIUMgnu_MACRO_OPTION_INCLUDE_DIR
--I
-<END>
-
-<BEGIN> BUILD_PENTIUMgnu_MACRO_POST_BUILD_RULE
-
-<END>
-
-<BEGIN> BUILD_PENTIUMgnu_MACRO_PRJ_LIBS
-
-<END>
-
-<BEGIN> BUILD_PENTIUMgnu_MACRO_SIZE
-size386
-<END>
-
-<BEGIN> BUILD_PENTIUMgnu_RO_DEPEND_PATH
-{$(WIND_BASE)/target/h/} \
-	{$(WIND_BASE)/target/src/} \
-	{$(WIND_BASE)/target/config/}
-<END>
-
-<BEGIN> BUILD_PENTIUMgnu_TC
-::tc_PENTIUMgnu
-<END>
-
-<BEGIN> BUILD_RULE_archive
-
-<END>
-
-<BEGIN> BUILD_RULE_db_archive.out
-
-<END>
-
-<BEGIN> BUILD_RULE_objects
-
-<END>
-
-<BEGIN> BUILD__CURRENT
-PENTIUMgnu
-<END>
-
-<BEGIN> BUILD__LIST
-PENTIUMgnu
-<END>
-
-<BEGIN> CORE_INFO_TYPE
-::prj_vxApp
-<END>
-
-<BEGIN> CORE_INFO_VERSION
-2.0
-<END>
-
-<BEGIN> FILE_db_archive.c_dependDone
-FALSE
-<END>
-
-<BEGIN> FILE_db_archive.c_dependencies
-
-<END>
-
-<BEGIN> FILE_db_archive.c_objects
-db_archive.o
-<END>
-
-<BEGIN> FILE_db_archive.c_tool
-C/C++ compiler
-<END>
-
-<BEGIN> PROJECT_FILES
-$(PRJ_DIR)/db_archive.c
-<END>
-
-<BEGIN> userComments
-db_archive
-<END>
diff --git a/bdb/build_vxworks/db_archive/db_archive/Makefile.custom b/bdb/build_vxworks/db_archive/db_archive/Makefile.custom
deleted file mode 100644
index ca781f7b251ef99e49e5fc1859ee6cf3d67c60b0..0000000000000000000000000000000000000000
--- a/bdb/build_vxworks/db_archive/db_archive/Makefile.custom
+++ /dev/null
@@ -1,51 +0,0 @@
-#
-# Custom Makefile shell
-#
-# This file may be edited freely, since it will not be regenerated
-# by the project manager.
-#
-# Use this makefile to define rules to make external binaries
-# and deposit them in the $(EXTERNAL_BINARIES_DIR) directory.
-#
-# If you have specified external modules during your component
-# creation, you will find make rules already in place below.
-# You will likely have to edit these to suit your individual
-# build setup.
-#
-# You may wish to use the CPU, BUILD_SPEC or TOOL make variables in
-# your Makefile to support builds for different architectures.  Use
-# the FORCE_EXTERNAL_MAKE phony target to ensure that your external
-# make always runs.
-#
-# The example below assumes that your custom makefile is in the
-# mySourceTree directory, and that the binary file it produces
-# is placed into the $(BUILD_SPEC) sub-directory.
-#
-# EXTERNAL_SOURCE_BASE = /folk/me/mySourceTree
-# EXTERNAL_MODULE = myLibrary.o
-# EXTERNAL_MAKE = make
-#
-# $(EXTERNAL_BINARIES_DIR)/$(EXTERNAL_MODULE) : FORCE_EXTERNAL_MAKE
-#	$(EXTERNAL_MAKE) -C $(EXTERNAL_SOURCE_BASE) \
-#	-f $(EXTERNAL_SOURCE_BASE)/Makefile \
-#	CPU=$(CPU) BUILD_SPEC=$(BUILD_SPEC) $(@F)
-#	$(CP) $(subst /,$(DIRCHAR),$(EXTERNAL_SOURCE_BASE)/$(BUILD_SPEC)/$(@F) $@)
-#
-# If you are not adding your external modules from the component wizard,
-# you will have to include them in your component yourself:
-#
-# From the GUI, you can do this with the Component's 'Add external module'
-# dialog.
-#
-# If you are using the command line, add the module(s) by editing the
-# MODULES line in component.cdf file, e.g.
-#
-# Component INCLUDE_MYCOMPONENT {
-#
-#   MODULES         foo.o goo.o \
-#         myLibrary.o
-#
-
-
-# rules to build custom libraries
-
diff --git a/bdb/build_vxworks/db_archive/db_archive/component.cdf b/bdb/build_vxworks/db_archive/db_archive/component.cdf
deleted file mode 100755
index cf88762cbc5052c3d02903bdd41c7e7a3afc7e0f..0000000000000000000000000000000000000000
--- a/bdb/build_vxworks/db_archive/db_archive/component.cdf
+++ /dev/null
@@ -1,30 +0,0 @@
-/* component.cdf - dynamically updated configuration */
-
-/*
- * NOTE: you may edit this file to alter the configuration
- * But all non-configuration information, including comments,
- * will be lost upon rebuilding this project.
- */
-
-/* Component information */
-
-Component INCLUDE_DB_ARCHIVE {
-	ENTRY_POINTS	ALL_GLOBAL_SYMBOLS 
-	MODULES		db_archive.o 
-	NAME		db_archive
-	PREF_DOMAIN	ANY
-	_INIT_ORDER	usrComponentsInit
-}
-
-/* EntryPoint information */
-
-/* Module information */
-
-Module db_archive.o {
-
-	NAME		db_archive.o
-	SRC_PATH_NAME	$PRJ_DIR/../db_archive.c
-}
-
-/* Parameter information */
-
diff --git a/bdb/build_vxworks/db_archive/db_archive/component.wpj b/bdb/build_vxworks/db_archive/db_archive/component.wpj
deleted file mode 100755
index e50d91592e62210f67e479882e0573dcf19dc284..0000000000000000000000000000000000000000
--- a/bdb/build_vxworks/db_archive/db_archive/component.wpj
+++ /dev/null
@@ -1,475 +0,0 @@
-Document file - DO NOT EDIT
-
-<BEGIN> CORE_INFO_TYPE
-::prj_component
-<END>
-
-<BEGIN> CORE_INFO_VERSION
-AE1.1
-<END>
-
-<BEGIN> BUILD__CURRENT
-PENTIUM2gnu.debug
-<END>
-
-<BEGIN> BUILD_PENTIUM2gnu.debug_CURRENT_TARGET
-default
-<END>
-
-<BEGIN> BUILD_PENTIUM2gnu.debug_DEFAULTFORCPU
-1
-<END>
-
-<BEGIN> BUILD_PENTIUM2gnu.debug_FILE_$(PRJ_DIR)/../db_archive.c_infoTags
-toolMacro objects
-<END>
-
-<BEGIN> BUILD_PENTIUM2gnu.debug_FILE_$(PRJ_DIR)/../db_archive.c_objects
-db_archive.o
-<END>
-
-<BEGIN> BUILD_PENTIUM2gnu.debug_FILE_$(PRJ_DIR)/../db_archive.c_toolMacro
-CC
-<END>
-
-<BEGIN> BUILD_PENTIUM2gnu.debug_FILE_$(PRJ_DIR)/../db_archive.c_objects
-db_archive.o
-<END>
-
-<BEGIN> BUILD_PENTIUM2gnu.debug_FILE_$(PRJ_DIR)/../db_archive.c_toolMacro
-CC
-<END>
-
-<BEGIN> BUILD_PENTIUM2gnu.debug_FILE_$(PRJ_DIR)/compConfig.c_infoTags
-toolMacro objects
-<END>
-
-<BEGIN> BUILD_PENTIUM2gnu.debug_FILE_$(PRJ_DIR)/compConfig.c_objects
-compConfig.o
-<END>
-
-<BEGIN> BUILD_PENTIUM2gnu.debug_FILE_$(PRJ_DIR)/compConfig.c_toolMacro
-CC
-<END>
-
-<BEGIN> BUILD_PENTIUM2gnu.debug_MACRO_AR
-arpentium
-<END>
-
-<BEGIN> BUILD_PENTIUM2gnu.debug_MACRO_AS
-ccpentium
-<END>
-
-<BEGIN> BUILD_PENTIUM2gnu.debug_MACRO_CC
-ccpentium
-<END>
-
-<BEGIN> BUILD_PENTIUM2gnu.debug_MACRO_CFLAGS
--mcpu=pentiumpro \
-	-march=pentiumpro \
-	-ansi \
-	-DRW_MULTI_THREAD \
-	-D_REENTRANT \
-	-g \
-	-nostdlib \
-	-fno-builtin \
-	-fno-defer-pop \
-	-MD \
-	-Wall \
-	-I. \
-	-I$(WIND_BASE)/target/h \
-	-I$(PRJ_DIR)/../.. \
-	-I$(PRJ_DIR)/../../.. \
-	-DCPU=PENTIUM2
-<END>
-
-<BEGIN> BUILD_PENTIUM2gnu.debug_MACRO_CFLAGS_AS
--mcpu=pentiumpro \
-	-march=pentiumpro \
-	-ansi \
-	-g \
-	-nostdlib \
-	-fno-builtin \
-	-fno-defer-pop \
-	-P \
-	-x \
-	assembler-with-cpp \
-	-Wall \
-	-I. \
-	-I$(WIND_BASE)/target/h \
-	-DCPU=PENTIUM2
-<END>
-
-<BEGIN> BUILD_PENTIUM2gnu.debug_MACRO_CPP
-ccpentium -E -P
-<END>
-
-<BEGIN> BUILD_PENTIUM2gnu.debug_MACRO_CPPFILT
-c++filtpentium --strip-underscores
-<END>
-
-<BEGIN> BUILD_PENTIUM2gnu.debug_MACRO_LD
-ldpentium
-<END>
-
-<BEGIN> BUILD_PENTIUM2gnu.debug_MACRO_LDFLAGS
--X
-<END>
-
-<BEGIN> BUILD_PENTIUM2gnu.debug_MACRO_LDPARTIAL
-ccpentium \
-	-B$(WIND_BASE)/host/$(WIND_HOST_TYPE)/lib/gcc-lib/ \
-	-nostdlib \
-	-r \
-	-Wl,-X
-<END>
-
-<BEGIN> BUILD_PENTIUM2gnu.debug_MACRO_LD_PARTIAL_FLAGS
--X -r
-<END>
-
-<BEGIN> BUILD_PENTIUM2gnu.debug_MACRO_NM
-nmpentium -g
-<END>
-
-<BEGIN> BUILD_PENTIUM2gnu.debug_MACRO_OPTION_DEFINE_MACRO
--D
-<END>
-
-<BEGIN> BUILD_PENTIUM2gnu.debug_MACRO_OPTION_GENERATE_DEPENDENCY_FILE
--MD
-<END>
-
-<BEGIN> BUILD_PENTIUM2gnu.debug_MACRO_OPTION_INCLUDE_DIR
--I
-<END>
-
-<BEGIN> BUILD_PENTIUM2gnu.debug_MACRO_RELEASE
-0
-<END>
-
-<BEGIN> BUILD_PENTIUM2gnu.debug_MACRO_SIZE
-sizepentium
-<END>
-
-<BEGIN> BUILD_PENTIUM2gnu.debug_RELEASE
-0
-<END>
-
-<BEGIN> BUILD_PENTIUM2gnu.debug_RO_DEPEND_PATH
-$(WIND_BASE)/target/h/
-<END>
-
-<BEGIN> BUILD_PENTIUM2gnu.debug_TC
-::tc_PENTIUM2gnu.debug
-<END>
-
-<BEGIN> BUILD_PENTIUM2gnu.release_DEFAULTFORCPU
-0
-<END>
-
-<BEGIN> BUILD_PENTIUM2gnu.release_FILE_$(PRJ_DIR)/../db_archive.c_infoTags
-toolMacro objects
-<END>
-
-<BEGIN> BUILD_PENTIUM2gnu.release_FILE_$(PRJ_DIR)/../db_archive.c_objects
-db_archive.o
-<END>
-
-<BEGIN> BUILD_PENTIUM2gnu.release_FILE_$(PRJ_DIR)/../db_archive.c_toolMacro
-CC
-<END>
-
-<BEGIN> BUILD_PENTIUM2gnu.release_FILE_$(PRJ_DIR)/compConfig.c_infoTags
-toolMacro objects
-<END>
-
-<BEGIN> BUILD_PENTIUM2gnu.release_FILE_$(PRJ_DIR)/compConfig.c_objects
-compConfig.o
-<END>
-
-<BEGIN> BUILD_PENTIUM2gnu.release_FILE_$(PRJ_DIR)/compConfig.c_toolMacro
-CC
-<END>
-
-<BEGIN> BUILD_PENTIUM2gnu.release_MACRO_AR
-arpentium
-<END>
-
-<BEGIN> BUILD_PENTIUM2gnu.release_MACRO_AS
-ccpentium
-<END>
-
-<BEGIN> BUILD_PENTIUM2gnu.release_MACRO_CC
-ccpentium
-<END>
-
-<BEGIN> BUILD_PENTIUM2gnu.release_MACRO_CFLAGS
--mcpu=pentiumpro \
-	-march=pentiumpro \
-	-ansi \
-	-DRW_MULTI_THREAD \
-	-D_REENTRANT \
-	-O2 \
-	-nostdlib \
-	-fno-builtin \
-	-fno-defer-pop \
-	-MD \
-	-Wall \
-	-I. \
-	-I$(WIND_BASE)/target/h \
-	-I$(PRJ_DIR)/../.. \
-	-I$(PRJ_DIR)/../../.. \
-	-DCPU=PENTIUM2
-<END>
-
-<BEGIN> BUILD_PENTIUM2gnu.release_MACRO_CFLAGS_AS
--mcpu=pentiumpro \
-	-march=pentiumpro \
-	-ansi \
-	-O2 \
-	-nostdlib \
-	-fno-builtin \
-	-fno-defer-pop \
-	-P \
-	-x \
-	assembler-with-cpp \
-	-Wall \
-	-I. \
-	-I$(WIND_BASE)/target/h \
-	-DCPU=PENTIUM2
-<END>
-
-<BEGIN> BUILD_PENTIUM2gnu.release_MACRO_CPP
-ccpentium -E -P
-<END>
-
-<BEGIN> BUILD_PENTIUM2gnu.release_MACRO_CPPFILT
-c++filtpentium --strip-underscores
-<END>
-
-<BEGIN> BUILD_PENTIUM2gnu.release_MACRO_LD
-ldpentium
-<END>
-
-<BEGIN> BUILD_PENTIUM2gnu.release_MACRO_LDFLAGS
--X
-<END>
-
-<BEGIN> BUILD_PENTIUM2gnu.release_MACRO_LDPARTIAL
-ccpentium \
-	-B$(WIND_BASE)/host/$(WIND_HOST_TYPE)/lib/gcc-lib/ \
-	-nostdlib \
-	-r \
-	-Wl,-X
-<END>
-
-<BEGIN> BUILD_PENTIUM2gnu.release_MACRO_LD_PARTIAL_FLAGS
--X -r
-<END>
-
-<BEGIN> BUILD_PENTIUM2gnu.release_MACRO_NM
-nmpentium -g
-<END>
-
-<BEGIN> BUILD_PENTIUM2gnu.release_MACRO_OPTION_DEFINE_MACRO
--D
-<END>
-
-<BEGIN> BUILD_PENTIUM2gnu.release_MACRO_OPTION_GENERATE_DEPENDENCY_FILE
--MD
-<END>
-
-<BEGIN> BUILD_PENTIUM2gnu.release_MACRO_OPTION_INCLUDE_DIR
--I
-<END>
-
-<BEGIN> BUILD_PENTIUM2gnu.release_MACRO_RELEASE
-1
-<END>
-
-<BEGIN> BUILD_PENTIUM2gnu.release_MACRO_SIZE
-sizepentium
-<END>
-
-<BEGIN> BUILD_PENTIUM2gnu.release_RELEASE
-1
-<END>
-
-<BEGIN> BUILD_PENTIUM2gnu.release_RO_DEPEND_PATH
-$(WIND_BASE)/target/h/
-<END>
-
-<BEGIN> BUILD_PENTIUM2gnu.release_TC
-::tc_PENTIUM2gnu.release
-<END>
-
-<BEGIN> BUILD_PENTIUMgnu.debug_DEFAULTFORCPU
-1
-<END>
-
-<BEGIN> BUILD_PENTIUMgnu.debug_FILE_$(PRJ_DIR)/../db_archive.c_infoTags
-toolMacro objects
-<END>
-
-<BEGIN> BUILD_PENTIUMgnu.debug_FILE_$(PRJ_DIR)/../db_archive.c_objects
-db_archive.o
-<END>
-
-<BEGIN> BUILD_PENTIUMgnu.debug_FILE_$(PRJ_DIR)/../db_archive.c_toolMacro
-CC
-<END>
-
-<BEGIN> BUILD_PENTIUMgnu.debug_FILE_$(PRJ_DIR)/compConfig.c_infoTags
-toolMacro objects
-<END>
-
-<BEGIN> BUILD_PENTIUMgnu.debug_FILE_$(PRJ_DIR)/compConfig.c_objects
-compConfig.o
-<END>
-
-<BEGIN> BUILD_PENTIUMgnu.debug_FILE_$(PRJ_DIR)/compConfig.c_toolMacro
-CC
-<END>
-
-<BEGIN> BUILD_PENTIUMgnu.debug_MACRO_AR
-arpentium
-<END>
-
-<BEGIN> BUILD_PENTIUMgnu.debug_MACRO_AS
-ccpentium
-<END>
-
-<BEGIN> BUILD_PENTIUMgnu.debug_MACRO_CC
-ccpentium
-<END>
-
-<BEGIN> BUILD_PENTIUMgnu.debug_MACRO_CFLAGS
--mcpu=pentium \
-	-march=pentium \
-	-ansi \
-	-DRW_MULTI_THREAD \
-	-D_REENTRANT \
-	-g \
-	-nostdlib \
-	-fno-builtin \
-	-fno-defer-pop \
-	-MD \
-	-Wall \
-	-I. \
-	-I$(WIND_BASE)/target/h \
-	-I$(PRJ_DIR)/../.. \
-	-I$(PRJ_DIR)/../../.. \
-	-DCPU=PENTIUM
-<END>
-
-<BEGIN> BUILD_PENTIUMgnu.debug_MACRO_CFLAGS_AS
--mcpu=pentium \
-	-march=pentium \
-	-ansi \
-	-g \
-	-nostdlib \
-	-fno-builtin \
-	-fno-defer-pop \
-	-P \
-	-x \
-	assembler-with-cpp \
-	-Wall \
-	-I. \
-	-I$(WIND_BASE)/target/h \
-	-DCPU=PENTIUM
-<END>
-
-<BEGIN> BUILD_PENTIUMgnu.debug_MACRO_CPP
-ccpentium -E -P
-<END>
-
-<BEGIN> BUILD_PENTIUMgnu.debug_MACRO_CPPFILT
-c++filtpentium --strip-underscores
-<END>
-
-<BEGIN> BUILD_PENTIUMgnu.debug_MACRO_LD
-ldpentium
-<END>
-
-<BEGIN> BUILD_PENTIUMgnu.debug_MACRO_LDFLAGS
--X
-<END>
-
-<BEGIN> BUILD_PENTIUMgnu.debug_MACRO_LDPARTIAL
-ccpentium \
-	-B$(WIND_BASE)/host/$(WIND_HOST_TYPE)/lib/gcc-lib/ \
-	-nostdlib \
-	-r \
-	-Wl,-X
-<END>
-
-<BEGIN> BUILD_PENTIUMgnu.debug_MACRO_LD_PARTIAL_FLAGS
--X -r
-<END>
-
-<BEGIN> BUILD_PENTIUMgnu.debug_MACRO_NM
-nmpentium -g
-<END>
-
-<BEGIN> BUILD_PENTIUMgnu.debug_MACRO_OPTION_DEFINE_MACRO
--D
-<END>
-
-<BEGIN> BUILD_PENTIUMgnu.debug_MACRO_OPTION_GENERATE_DEPENDENCY_FILE
--MD
-<END>
-
-<BEGIN> BUILD_PENTIUMgnu.debug_MACRO_OPTION_INCLUDE_DIR
--I
-<END>
-
-<BEGIN> BUILD_PENTIUMgnu.debug_MACRO_RELEASE
-0
-<END>
-
-<BEGIN> BUILD_PENTIUMgnu.debug_MACRO_SIZE
-sizepentium
-<END>
-
-<BEGIN> BUILD_PENTIUMgnu.debug_RELEASE
-0
-<END>
-
-<BEGIN> BUILD_PENTIUMgnu.debug_RO_DEPEND_PATH
-$(WIND_BASE)/target/h/
-<END>
-
-<BEGIN> BUILD_PENTIUMgnu.debug_TC
-::tc_PENTIUMgnu.debug
-<END>
-
-<BEGIN> BUILD__LIST
-PENTIUM2gnu.debug PENTIUM2gnu.release PENTIUMgnu.debug
-<END>
-
-<BEGIN> PROJECT_FILES
-$(PRJ_DIR)/../db_archive.c \
-	$(PRJ_DIR)/compConfig.c
-<END>
-
-<BEGIN> WCC__CDF_PATH
-$(PRJ_DIR)
-<END>
-
-<BEGIN> WCC__CURRENT
-PENTIUM2gnu.debug
-<END>
-
-<BEGIN> WCC__LIST
-PENTIUM2gnu.debug
-<END>
-
-<BEGIN> WCC__MXR_LIBS
-lib$(CPU)$(TOOL)vx.a
-<END>
-
-<BEGIN> WCC__OBJS_PATH
-$(WIND_BASE)/target/lib/obj$CPU$TOOLvx
-<END>
-
diff --git a/bdb/build_vxworks/db_checkpoint/db_checkpoint.c b/bdb/build_vxworks/db_checkpoint/db_checkpoint.c
deleted file mode 100644
index 1e5a45a6fe5dca1b122eb42cf860c020ce6c3f70..0000000000000000000000000000000000000000
--- a/bdb/build_vxworks/db_checkpoint/db_checkpoint.c
+++ /dev/null
@@ -1,258 +0,0 @@
-/*-
- * See the file LICENSE for redistribution information.
- *
- * Copyright (c) 1996-2002
- *	Sleepycat Software.  All rights reserved.
- */
-
-#include "db_config.h"
-
-#ifndef lint
-static const char copyright[] =
-    "Copyright (c) 1996-2002\nSleepycat Software Inc.  All rights reserved.\n";
-static const char revid[] =
-    "$Id: db_checkpoint.c,v 11.46 2002/08/08 03:50:31 bostic Exp $";
-#endif
-
-#ifndef NO_SYSTEM_INCLUDES
-#include <sys/types.h>
-
-#if TIME_WITH_SYS_TIME
-#include <sys/time.h>
-#include <time.h>
-#else
-#if HAVE_SYS_TIME_H
-#include <sys/time.h>
-#else
-#include <time.h>
-#endif
-#endif
-
-#include <limits.h>
-#include <stdio.h>
-#include <stdlib.h>
-#include <string.h>
-#include <unistd.h>
-#endif
-
-#include "db_int.h"
-#include "dbinc/db_page.h"
-#include "dbinc/db_am.h"
-
-int	 db_checkpoint_main __P((int, char *[]));
-int	 db_checkpoint_usage __P((void));
-int	 db_checkpoint_version_check __P((const char *));
-
-int
-db_checkpoint(args)
-	char *args;
-{
-	int argc;
-	char **argv;
-
-	__db_util_arg("db_checkpoint", args, &argc, &argv);
-	return (db_checkpoint_main(argc, argv) ? EXIT_FAILURE : EXIT_SUCCESS);
-}
-
-#include <stdio.h>
-#define	ERROR_RETURN	ERROR
-
-int
-db_checkpoint_main(argc, argv)
-	int argc;
-	char *argv[];
-{
-	extern char *optarg;
-	extern int optind, __db_getopt_reset;
-	DB_ENV	*dbenv;
-	const char *progname = "db_checkpoint";
-	time_t now;
-	long argval;
-	u_int32_t flags, kbytes, minutes, seconds;
-	int ch, e_close, exitval, once, ret, verbose;
-	char *home, *logfile, *passwd;
-
-	if ((ret = db_checkpoint_version_check(progname)) != 0)
-		return (ret);
-
-	/*
-	 * !!!
-	 * Don't allow a fully unsigned 32-bit number, some compilers get
-	 * upset and require it to be specified in hexadecimal and so on.
-	 */
-#define	MAX_UINT32_T	2147483647
-
-	kbytes = minutes = 0;
-	e_close = exitval = once = verbose = 0;
-	flags = 0;
-	home = logfile = passwd = NULL;
-	__db_getopt_reset = 1;
-	while ((ch = getopt(argc, argv, "1h:k:L:P:p:Vv")) != EOF)
-		switch (ch) {
-		case '1':
-			once = 1;
-			flags = DB_FORCE;
-			break;
-		case 'h':
-			home = optarg;
-			break;
-		case 'k':
-			if (__db_getlong(NULL, progname,
-			    optarg, 1, (long)MAX_UINT32_T, &argval))
-				return (EXIT_FAILURE);
-			kbytes = argval;
-			break;
-		case 'L':
-			logfile = optarg;
-			break;
-		case 'P':
-			passwd = strdup(optarg);
-			memset(optarg, 0, strlen(optarg));
-			if (passwd == NULL) {
-				fprintf(stderr, "%s: strdup: %s\n",
-				    progname, strerror(errno));
-				return (EXIT_FAILURE);
-			}
-			break;
-		case 'p':
-			if (__db_getlong(NULL, progname,
-			    optarg, 1, (long)MAX_UINT32_T, &argval))
-				return (EXIT_FAILURE);
-			minutes = argval;
-			break;
-		case 'V':
-			printf("%s\n", db_version(NULL, NULL, NULL));
-			return (EXIT_SUCCESS);
-		case 'v':
-			verbose = 1;
-			break;
-		case '?':
-		default:
-			return (db_checkpoint_usage());
-		}
-	argc -= optind;
-	argv += optind;
-
-	if (argc != 0)
-		return (db_checkpoint_usage());
-
-	if (once == 0 && kbytes == 0 && minutes == 0) {
-		(void)fprintf(stderr,
-		    "%s: at least one of -1, -k and -p must be specified\n",
-		    progname);
-		return (EXIT_FAILURE);
-	}
-
-	/* Handle possible interruptions. */
-	__db_util_siginit();
-
-	/* Log our process ID. */
-	if (logfile != NULL && __db_util_logset(progname, logfile))
-		goto shutdown;
-
-	/*
-	 * Create an environment object and initialize it for error
-	 * reporting.
-	 */
-	if ((ret = db_env_create(&dbenv, 0)) != 0) {
-		fprintf(stderr,
-		    "%s: db_env_create: %s\n", progname, db_strerror(ret));
-		goto shutdown;
-	}
-	e_close = 1;
-
-	dbenv->set_errfile(dbenv, stderr);
-	dbenv->set_errpfx(dbenv, progname);
-
-	if (passwd != NULL && (ret = dbenv->set_encrypt(dbenv,
-	    passwd, DB_ENCRYPT_AES)) != 0) {
-		dbenv->err(dbenv, ret, "set_passwd");
-		goto shutdown;
-	}
-	/* Initialize the environment. */
-	if ((ret = dbenv->open(dbenv,
-	    home, DB_JOINENV | DB_USE_ENVIRON, 0)) != 0) {
-		dbenv->err(dbenv, ret, "open");
-		goto shutdown;
-	}
-
-	/* Register the standard pgin/pgout functions, in case we do I/O. */
-	if ((ret = dbenv->memp_register(
-	    dbenv, DB_FTYPE_SET, __db_pgin, __db_pgout)) != 0) {
-		dbenv->err(dbenv, ret,
-    "DB_ENV->memp_register: failed to register access method functions");
-		goto shutdown;
-	}
-
-	/*
-	 * If we have only a time delay, then we'll sleep the right amount
-	 * to wake up when a checkpoint is necessary.  If we have a "kbytes"
-	 * field set, then we'll check every 30 seconds.
-	 */
-	seconds = kbytes != 0 ? 30 : minutes * 60;
-	while (!__db_util_interrupted()) {
-		if (verbose) {
-			(void)time(&now);
-			dbenv->errx(dbenv, "checkpoint: %s", ctime(&now));
-		}
-
-		if ((ret = dbenv->txn_checkpoint(dbenv,
-		    kbytes, minutes, flags)) != 0) {
-			dbenv->err(dbenv, ret, "txn_checkpoint");
-			goto shutdown;
-		}
-
-		if (once)
-			break;
-
-		(void)__os_sleep(dbenv, seconds, 0);
-	}
-
-	if (0) {
-shutdown:	exitval = 1;
-	}
-
-	/* Clean up the logfile. */
-	if (logfile != NULL)
-		remove(logfile);
-
-	/* Clean up the environment. */
-	if (e_close && (ret = dbenv->close(dbenv, 0)) != 0) {
-		exitval = 1;
-		fprintf(stderr,
-		    "%s: dbenv->close: %s\n", progname, db_strerror(ret));
-	}
-
-	/* Resend any caught signal. */
-	__db_util_sigresend();
-
-	return (exitval == 0 ? EXIT_SUCCESS : EXIT_FAILURE);
-}
-
-int
-db_checkpoint_usage()
-{
-	(void)fprintf(stderr, "%s\n\t%s\n",
-	    "usage: db_checkpoint [-1Vv]",
-	    "[-h home] [-k kbytes] [-L file] [-P password] [-p min]");
-	return (EXIT_FAILURE);
-}
-
-int
-db_checkpoint_version_check(progname)
-	const char *progname;
-{
-	int v_major, v_minor, v_patch;
-
-	/* Make sure we're loaded with the right version of the DB library. */
-	(void)db_version(&v_major, &v_minor, &v_patch);
-	if (v_major != DB_VERSION_MAJOR ||
-	    v_minor != DB_VERSION_MINOR || v_patch != DB_VERSION_PATCH) {
-		fprintf(stderr,
-	"%s: version %d.%d.%d doesn't match library version %d.%d.%d\n",
-		    progname, DB_VERSION_MAJOR, DB_VERSION_MINOR,
-		    DB_VERSION_PATCH, v_major, v_minor, v_patch);
-		return (EXIT_FAILURE);
-	}
-	return (0);
-}
diff --git a/bdb/build_vxworks/db_checkpoint/db_checkpoint.wpj b/bdb/build_vxworks/db_checkpoint/db_checkpoint.wpj
deleted file mode 100755
index cae4317821bf9f18cecb7bdac6b3ab32a4840701..0000000000000000000000000000000000000000
--- a/bdb/build_vxworks/db_checkpoint/db_checkpoint.wpj
+++ /dev/null
@@ -1,160 +0,0 @@
-Document file - DO NOT EDIT
-
-<BEGIN> BUILD_PENTIUMgnu_BUILDRULE
-db_checkpoint.out
-<END>
-
-<BEGIN> BUILD_PENTIUMgnu_MACRO_AR
-ar386
-<END>
-
-<BEGIN> BUILD_PENTIUMgnu_MACRO_ARCHIVE
-$(PRJ_DIR)/PENTIUMgnu/db_checkpoint.a
-<END>
-
-<BEGIN> BUILD_PENTIUMgnu_MACRO_AS
-cc386
-<END>
-
-<BEGIN> BUILD_PENTIUMgnu_MACRO_CC
-cc386
-<END>
-
-<BEGIN> BUILD_PENTIUMgnu_MACRO_CFLAGS
--g \
-	-mpentium \
-	-ansi \
-	-nostdinc \
-	-DRW_MULTI_THREAD \
-	-D_REENTRANT \
-	-fvolatile \
-	-nostdlib \
-	-fno-builtin \
-	-fno-defer-pop \
-	-I$(PRJ_DIR)/.. \
-	-I$(PRJ_DIR)/../.. \
-	-I$(WIND_BASE)/target/h \
-	-DCPU=PENTIUM
-<END>
-
-<BEGIN> BUILD_PENTIUMgnu_MACRO_CFLAGS_AS
--g \
-	-mpentium \
-	-ansi \
-	-nostdinc \
-	-fvolatile \
-	-nostdlib \
-	-fno-builtin \
-	-fno-defer-pop \
-	-P \
-	-x \
-	assembler-with-cpp \
-	-I$(WIND_BASE)/target/h \
-	-DCPU=PENTIUM
-<END>
-
-<BEGIN> BUILD_PENTIUMgnu_MACRO_CPP
-cc386 -E -P -xc
-<END>
-
-<BEGIN> BUILD_PENTIUMgnu_MACRO_LD
-ld386
-<END>
-
-<BEGIN> BUILD_PENTIUMgnu_MACRO_LDDEPS
-
-<END>
-
-<BEGIN> BUILD_PENTIUMgnu_MACRO_LDFLAGS
--X -N
-<END>
-
-<BEGIN> BUILD_PENTIUMgnu_MACRO_LD_PARTIAL_FLAGS
--X -r
-<END>
-
-<BEGIN> BUILD_PENTIUMgnu_MACRO_NM
-nm386 -g
-<END>
-
-<BEGIN> BUILD_PENTIUMgnu_MACRO_OPTION_DEFINE_MACRO
--D
-<END>
-
-<BEGIN> BUILD_PENTIUMgnu_MACRO_OPTION_INCLUDE_DIR
--I
-<END>
-
-<BEGIN> BUILD_PENTIUMgnu_MACRO_POST_BUILD_RULE
-
-<END>
-
-<BEGIN> BUILD_PENTIUMgnu_MACRO_PRJ_LIBS
-
-<END>
-
-<BEGIN> BUILD_PENTIUMgnu_MACRO_SIZE
-size386
-<END>
-
-<BEGIN> BUILD_PENTIUMgnu_RO_DEPEND_PATH
-{$(WIND_BASE)/target/h/} \
-	{$(WIND_BASE)/target/src/} \
-	{$(WIND_BASE)/target/config/}
-<END>
-
-<BEGIN> BUILD_PENTIUMgnu_TC
-::tc_PENTIUMgnu
-<END>
-
-<BEGIN> BUILD_RULE_archive
-
-<END>
-
-<BEGIN> BUILD_RULE_db_checkpoint.out
-
-<END>
-
-<BEGIN> BUILD_RULE_objects
-
-<END>
-
-<BEGIN> BUILD__CURRENT
-PENTIUMgnu
-<END>
-
-<BEGIN> BUILD__LIST
-PENTIUMgnu
-<END>
-
-<BEGIN> CORE_INFO_TYPE
-::prj_vxApp
-<END>
-
-<BEGIN> CORE_INFO_VERSION
-2.0
-<END>
-
-<BEGIN> FILE_db_checkpoint.c_dependDone
-FALSE
-<END>
-
-<BEGIN> FILE_db_checkpoint.c_dependencies
-
-<END>
-
-<BEGIN> FILE_db_checkpoint.c_objects
-db_checkpoint.o
-<END>
-
-<BEGIN> FILE_db_checkpoint.c_tool
-C/C++ compiler
-<END>
-
-<BEGIN> PROJECT_FILES
-$(PRJ_DIR)/db_checkpoint.c
-<END>
-
-<BEGIN> userComments
-db_checkpoint
-<END>
diff --git a/bdb/build_vxworks/db_checkpoint/db_checkpoint/Makefile.custom b/bdb/build_vxworks/db_checkpoint/db_checkpoint/Makefile.custom
deleted file mode 100644
index ca781f7b251ef99e49e5fc1859ee6cf3d67c60b0..0000000000000000000000000000000000000000
--- a/bdb/build_vxworks/db_checkpoint/db_checkpoint/Makefile.custom
+++ /dev/null
@@ -1,51 +0,0 @@
-#
-# Custom Makefile shell
-#
-# This file may be edited freely, since it will not be regenerated
-# by the project manager.
-#
-# Use this makefile to define rules to make external binaries
-# and deposit them in the $(EXTERNAL_BINARIES_DIR) directory.
-#
-# If you have specified external modules during your component
-# creation, you will find make rules already in place below.
-# You will likely have to edit these to suit your individual
-# build setup.
-#
-# You may wish to use the CPU, BUILD_SPEC or TOOL make variables in
-# your Makefile to support builds for different architectures.  Use
-# the FORCE_EXTERNAL_MAKE phony target to ensure that your external
-# make always runs.
-#
-# The example below assumes that your custom makefile is in the
-# mySourceTree directory, and that the binary file it produces
-# is placed into the $(BUILD_SPEC) sub-directory.
-#
-# EXTERNAL_SOURCE_BASE = /folk/me/mySourceTree
-# EXTERNAL_MODULE = myLibrary.o
-# EXTERNAL_MAKE = make
-#
-# $(EXTERNAL_BINARIES_DIR)/$(EXTERNAL_MODULE) : FORCE_EXTERNAL_MAKE
-#	$(EXTERNAL_MAKE) -C $(EXTERNAL_SOURCE_BASE) \
-#	-f $(EXTERNAL_SOURCE_BASE)/Makefile \
-#	CPU=$(CPU) BUILD_SPEC=$(BUILD_SPEC) $(@F)
-#	$(CP) $(subst /,$(DIRCHAR),$(EXTERNAL_SOURCE_BASE)/$(BUILD_SPEC)/$(@F) $@)
-#
-# If you are not adding your external modules from the component wizard,
-# you will have to include them in your component yourself:
-#
-# From the GUI, you can do this with the Component's 'Add external module'
-# dialog.
-#
-# If you are using the command line, add the module(s) by editing the
-# MODULES line in component.cdf file, e.g.
-#
-# Component INCLUDE_MYCOMPONENT {
-#
-#   MODULES         foo.o goo.o \
-#         myLibrary.o
-#
-
-
-# rules to build custom libraries
-
diff --git a/bdb/build_vxworks/db_checkpoint/db_checkpoint/component.cdf b/bdb/build_vxworks/db_checkpoint/db_checkpoint/component.cdf
deleted file mode 100755
index ea05c3a61829b4e9ada7a80ee3deb8e2ff3ded58..0000000000000000000000000000000000000000
--- a/bdb/build_vxworks/db_checkpoint/db_checkpoint/component.cdf
+++ /dev/null
@@ -1,30 +0,0 @@
-/* component.cdf - dynamically updated configuration */
-
-/*
- * NOTE: you may edit this file to alter the configuration
- * But all non-configuration information, including comments,
- * will be lost upon rebuilding this project.
- */
-
-/* Component information */
-
-Component INCLUDE_DB_CHECKPOINT {
-	ENTRY_POINTS	ALL_GLOBAL_SYMBOLS 
-	MODULES		db_checkpoint.o 
-	NAME		db_checkpoint
-	PREF_DOMAIN	ANY
-	_INIT_ORDER	usrComponentsInit
-}
-
-/* EntryPoint information */
-
-/* Module information */
-
-Module db_checkpoint.o {
-
-	NAME		db_checkpoint.o
-	SRC_PATH_NAME	$PRJ_DIR/../db_checkpoint.c
-}
-
-/* Parameter information */
-
diff --git a/bdb/build_vxworks/db_checkpoint/db_checkpoint/component.wpj b/bdb/build_vxworks/db_checkpoint/db_checkpoint/component.wpj
deleted file mode 100755
index 3b5daa113e13c0fde695da642117336905d8797e..0000000000000000000000000000000000000000
--- a/bdb/build_vxworks/db_checkpoint/db_checkpoint/component.wpj
+++ /dev/null
@@ -1,475 +0,0 @@
-Document file - DO NOT EDIT
-
-<BEGIN> CORE_INFO_TYPE
-::prj_component
-<END>
-
-<BEGIN> CORE_INFO_VERSION
-AE1.1
-<END>
-
-<BEGIN> BUILD__CURRENT
-PENTIUM2gnu.debug
-<END>
-
-<BEGIN> BUILD_PENTIUM2gnu.debug_CURRENT_TARGET
-default
-<END>
-
-<BEGIN> BUILD_PENTIUM2gnu.debug_DEFAULTFORCPU
-1
-<END>
-
-<BEGIN> BUILD_PENTIUM2gnu.debug_FILE_$(PRJ_DIR)/../db_checkpoint.c_infoTags
-toolMacro objects
-<END>
-
-<BEGIN> BUILD_PENTIUM2gnu.debug_FILE_$(PRJ_DIR)/../db_checkpoint.c_objects
-db_checkpoint.o
-<END>
-
-<BEGIN> BUILD_PENTIUM2gnu.debug_FILE_$(PRJ_DIR)/../db_checkpoint.c_toolMacro
-CC
-<END>
-
-<BEGIN> BUILD_PENTIUM2gnu.debug_FILE_$(PRJ_DIR)/../db_checkpoint.c_objects
-db_checkpoint.o
-<END>
-
-<BEGIN> BUILD_PENTIUM2gnu.debug_FILE_$(PRJ_DIR)/../db_checkpoint.c_toolMacro
-CC
-<END>
-
-<BEGIN> BUILD_PENTIUM2gnu.debug_FILE_$(PRJ_DIR)/compConfig.c_infoTags
-toolMacro objects
-<END>
-
-<BEGIN> BUILD_PENTIUM2gnu.debug_FILE_$(PRJ_DIR)/compConfig.c_objects
-compConfig.o
-<END>
-
-<BEGIN> BUILD_PENTIUM2gnu.debug_FILE_$(PRJ_DIR)/compConfig.c_toolMacro
-CC
-<END>
-
-<BEGIN> BUILD_PENTIUM2gnu.debug_MACRO_AR
-arpentium
-<END>
-
-<BEGIN> BUILD_PENTIUM2gnu.debug_MACRO_AS
-ccpentium
-<END>
-
-<BEGIN> BUILD_PENTIUM2gnu.debug_MACRO_CC
-ccpentium
-<END>
-
-<BEGIN> BUILD_PENTIUM2gnu.debug_MACRO_CFLAGS
--mcpu=pentiumpro \
-	-march=pentiumpro \
-	-ansi \
-	-DRW_MULTI_THREAD \
-	-D_REENTRANT \
-	-g \
-	-nostdlib \
-	-fno-builtin \
-	-fno-defer-pop \
-	-MD \
-	-Wall \
-	-I. \
-	-I$(WIND_BASE)/target/h \
-	-I$(PRJ_DIR)/../.. \
-	-I$(PRJ_DIR)/../../.. \
-	-DCPU=PENTIUM2
-<END>
-
-<BEGIN> BUILD_PENTIUM2gnu.debug_MACRO_CFLAGS_AS
--mcpu=pentiumpro \
-	-march=pentiumpro \
-	-ansi \
-	-g \
-	-nostdlib \
-	-fno-builtin \
-	-fno-defer-pop \
-	-P \
-	-x \
-	assembler-with-cpp \
-	-Wall \
-	-I. \
-	-I$(WIND_BASE)/target/h \
-	-DCPU=PENTIUM2
-<END>
-
-<BEGIN> BUILD_PENTIUM2gnu.debug_MACRO_CPP
-ccpentium -E -P
-<END>
-
-<BEGIN> BUILD_PENTIUM2gnu.debug_MACRO_CPPFILT
-c++filtpentium --strip-underscores
-<END>
-
-<BEGIN> BUILD_PENTIUM2gnu.debug_MACRO_LD
-ldpentium
-<END>
-
-<BEGIN> BUILD_PENTIUM2gnu.debug_MACRO_LDFLAGS
--X
-<END>
-
-<BEGIN> BUILD_PENTIUM2gnu.debug_MACRO_LDPARTIAL
-ccpentium \
-	-B$(WIND_BASE)/host/$(WIND_HOST_TYPE)/lib/gcc-lib/ \
-	-nostdlib \
-	-r \
-	-Wl,-X
-<END>
-
-<BEGIN> BUILD_PENTIUM2gnu.debug_MACRO_LD_PARTIAL_FLAGS
--X -r
-<END>
-
-<BEGIN> BUILD_PENTIUM2gnu.debug_MACRO_NM
-nmpentium -g
-<END>
-
-<BEGIN> BUILD_PENTIUM2gnu.debug_MACRO_OPTION_DEFINE_MACRO
--D
-<END>
-
-<BEGIN> BUILD_PENTIUM2gnu.debug_MACRO_OPTION_GENERATE_DEPENDENCY_FILE
--MD
-<END>
-
-<BEGIN> BUILD_PENTIUM2gnu.debug_MACRO_OPTION_INCLUDE_DIR
--I
-<END>
-
-<BEGIN> BUILD_PENTIUM2gnu.debug_MACRO_RELEASE
-0
-<END>
-
-<BEGIN> BUILD_PENTIUM2gnu.debug_MACRO_SIZE
-sizepentium
-<END>
-
-<BEGIN> BUILD_PENTIUM2gnu.debug_RELEASE
-0
-<END>
-
-<BEGIN> BUILD_PENTIUM2gnu.debug_RO_DEPEND_PATH
-$(WIND_BASE)/target/h/
-<END>
-
-<BEGIN> BUILD_PENTIUM2gnu.debug_TC
-::tc_PENTIUM2gnu.debug
-<END>
-
-<BEGIN> BUILD_PENTIUM2gnu.release_DEFAULTFORCPU
-0
-<END>
-
-<BEGIN> BUILD_PENTIUM2gnu.release_FILE_$(PRJ_DIR)/../db_checkpoint.c_infoTags
-toolMacro objects
-<END>
-
-<BEGIN> BUILD_PENTIUM2gnu.release_FILE_$(PRJ_DIR)/../db_checkpoint.c_objects
-db_checkpoint.o
-<END>
-
-<BEGIN> BUILD_PENTIUM2gnu.release_FILE_$(PRJ_DIR)/../db_checkpoint.c_toolMacro
-CC
-<END>
-
-<BEGIN> BUILD_PENTIUM2gnu.release_FILE_$(PRJ_DIR)/compConfig.c_infoTags
-toolMacro objects
-<END>
-
-<BEGIN> BUILD_PENTIUM2gnu.release_FILE_$(PRJ_DIR)/compConfig.c_objects
-compConfig.o
-<END>
-
-<BEGIN> BUILD_PENTIUM2gnu.release_FILE_$(PRJ_DIR)/compConfig.c_toolMacro
-CC
-<END>
-
-<BEGIN> BUILD_PENTIUM2gnu.release_MACRO_AR
-arpentium
-<END>
-
-<BEGIN> BUILD_PENTIUM2gnu.release_MACRO_AS
-ccpentium
-<END>
-
-<BEGIN> BUILD_PENTIUM2gnu.release_MACRO_CC
-ccpentium
-<END>
-
-<BEGIN> BUILD_PENTIUM2gnu.release_MACRO_CFLAGS
--mcpu=pentiumpro \
-	-march=pentiumpro \
-	-ansi \
-	-DRW_MULTI_THREAD \
-	-D_REENTRANT \
-	-O2 \
-	-nostdlib \
-	-fno-builtin \
-	-fno-defer-pop \
-	-MD \
-	-Wall \
-	-I. \
-	-I$(WIND_BASE)/target/h \
-	-I$(PRJ_DIR)/../.. \
-	-I$(PRJ_DIR)/../../.. \
-	-DCPU=PENTIUM2
-<END>
-
-<BEGIN> BUILD_PENTIUM2gnu.release_MACRO_CFLAGS_AS
--mcpu=pentiumpro \
-	-march=pentiumpro \
-	-ansi \
-	-O2 \
-	-nostdlib \
-	-fno-builtin \
-	-fno-defer-pop \
-	-P \
-	-x \
-	assembler-with-cpp \
-	-Wall \
-	-I. \
-	-I$(WIND_BASE)/target/h \
-	-DCPU=PENTIUM2
-<END>
-
-<BEGIN> BUILD_PENTIUM2gnu.release_MACRO_CPP
-ccpentium -E -P
-<END>
-
-<BEGIN> BUILD_PENTIUM2gnu.release_MACRO_CPPFILT
-c++filtpentium --strip-underscores
-<END>
-
-<BEGIN> BUILD_PENTIUM2gnu.release_MACRO_LD
-ldpentium
-<END>
-
-<BEGIN> BUILD_PENTIUM2gnu.release_MACRO_LDFLAGS
--X
-<END>
-
-<BEGIN> BUILD_PENTIUM2gnu.release_MACRO_LDPARTIAL
-ccpentium \
-	-B$(WIND_BASE)/host/$(WIND_HOST_TYPE)/lib/gcc-lib/ \
-	-nostdlib \
-	-r \
-	-Wl,-X
-<END>
-
-<BEGIN> BUILD_PENTIUM2gnu.release_MACRO_LD_PARTIAL_FLAGS
--X -r
-<END>
-
-<BEGIN> BUILD_PENTIUM2gnu.release_MACRO_NM
-nmpentium -g
-<END>
-
-<BEGIN> BUILD_PENTIUM2gnu.release_MACRO_OPTION_DEFINE_MACRO
--D
-<END>
-
-<BEGIN> BUILD_PENTIUM2gnu.release_MACRO_OPTION_GENERATE_DEPENDENCY_FILE
--MD
-<END>
-
-<BEGIN> BUILD_PENTIUM2gnu.release_MACRO_OPTION_INCLUDE_DIR
--I
-<END>
-
-<BEGIN> BUILD_PENTIUM2gnu.release_MACRO_RELEASE
-1
-<END>
-
-<BEGIN> BUILD_PENTIUM2gnu.release_MACRO_SIZE
-sizepentium
-<END>
-
-<BEGIN> BUILD_PENTIUM2gnu.release_RELEASE
-1
-<END>
-
-<BEGIN> BUILD_PENTIUM2gnu.release_RO_DEPEND_PATH
-$(WIND_BASE)/target/h/
-<END>
-
-<BEGIN> BUILD_PENTIUM2gnu.release_TC
-::tc_PENTIUM2gnu.release
-<END>
-
-<BEGIN> BUILD_PENTIUMgnu.debug_DEFAULTFORCPU
-1
-<END>
-
-<BEGIN> BUILD_PENTIUMgnu.debug_FILE_$(PRJ_DIR)/../db_checkpoint.c_infoTags
-toolMacro objects
-<END>
-
-<BEGIN> BUILD_PENTIUMgnu.debug_FILE_$(PRJ_DIR)/../db_checkpoint.c_objects
-db_checkpoint.o
-<END>
-
-<BEGIN> BUILD_PENTIUMgnu.debug_FILE_$(PRJ_DIR)/../db_checkpoint.c_toolMacro
-CC
-<END>
-
-<BEGIN> BUILD_PENTIUMgnu.debug_FILE_$(PRJ_DIR)/compConfig.c_infoTags
-toolMacro objects
-<END>
-
-<BEGIN> BUILD_PENTIUMgnu.debug_FILE_$(PRJ_DIR)/compConfig.c_objects
-compConfig.o
-<END>
-
-<BEGIN> BUILD_PENTIUMgnu.debug_FILE_$(PRJ_DIR)/compConfig.c_toolMacro
-CC
-<END>
-
-<BEGIN> BUILD_PENTIUMgnu.debug_MACRO_AR
-arpentium
-<END>
-
-<BEGIN> BUILD_PENTIUMgnu.debug_MACRO_AS
-ccpentium
-<END>
-
-<BEGIN> BUILD_PENTIUMgnu.debug_MACRO_CC
-ccpentium
-<END>
-
-<BEGIN> BUILD_PENTIUMgnu.debug_MACRO_CFLAGS
--mcpu=pentium \
-	-march=pentium \
-	-ansi \
-	-DRW_MULTI_THREAD \
-	-D_REENTRANT \
-	-g \
-	-nostdlib \
-	-fno-builtin \
-	-fno-defer-pop \
-	-MD \
-	-Wall \
-	-I. \
-	-I$(WIND_BASE)/target/h \
-	-I$(PRJ_DIR)/../.. \
-	-I$(PRJ_DIR)/../../.. \
-	-DCPU=PENTIUM
-<END>
-
-<BEGIN> BUILD_PENTIUMgnu.debug_MACRO_CFLAGS_AS
--mcpu=pentium \
-	-march=pentium \
-	-ansi \
-	-g \
-	-nostdlib \
-	-fno-builtin \
-	-fno-defer-pop \
-	-P \
-	-x \
-	assembler-with-cpp \
-	-Wall \
-	-I. \
-	-I$(WIND_BASE)/target/h \
-	-DCPU=PENTIUM
-<END>
-
-<BEGIN> BUILD_PENTIUMgnu.debug_MACRO_CPP
-ccpentium -E -P
-<END>
-
-<BEGIN> BUILD_PENTIUMgnu.debug_MACRO_CPPFILT
-c++filtpentium --strip-underscores
-<END>
-
-<BEGIN> BUILD_PENTIUMgnu.debug_MACRO_LD
-ldpentium
-<END>
-
-<BEGIN> BUILD_PENTIUMgnu.debug_MACRO_LDFLAGS
--X
-<END>
-
-<BEGIN> BUILD_PENTIUMgnu.debug_MACRO_LDPARTIAL
-ccpentium \
-	-B$(WIND_BASE)/host/$(WIND_HOST_TYPE)/lib/gcc-lib/ \
-	-nostdlib \
-	-r \
-	-Wl,-X
-<END>
-
-<BEGIN> BUILD_PENTIUMgnu.debug_MACRO_LD_PARTIAL_FLAGS
--X -r
-<END>
-
-<BEGIN> BUILD_PENTIUMgnu.debug_MACRO_NM
-nmpentium -g
-<END>
-
-<BEGIN> BUILD_PENTIUMgnu.debug_MACRO_OPTION_DEFINE_MACRO
--D
-<END>
-
-<BEGIN> BUILD_PENTIUMgnu.debug_MACRO_OPTION_GENERATE_DEPENDENCY_FILE
--MD
-<END>
-
-<BEGIN> BUILD_PENTIUMgnu.debug_MACRO_OPTION_INCLUDE_DIR
--I
-<END>
-
-<BEGIN> BUILD_PENTIUMgnu.debug_MACRO_RELEASE
-0
-<END>
-
-<BEGIN> BUILD_PENTIUMgnu.debug_MACRO_SIZE
-sizepentium
-<END>
-
-<BEGIN> BUILD_PENTIUMgnu.debug_RELEASE
-0
-<END>
-
-<BEGIN> BUILD_PENTIUMgnu.debug_RO_DEPEND_PATH
-$(WIND_BASE)/target/h/
-<END>
-
-<BEGIN> BUILD_PENTIUMgnu.debug_TC
-::tc_PENTIUMgnu.debug
-<END>
-
-<BEGIN> BUILD__LIST
-PENTIUM2gnu.debug PENTIUM2gnu.release PENTIUMgnu.debug
-<END>
-
-<BEGIN> PROJECT_FILES
-$(PRJ_DIR)/../db_checkpoint.c \
-	$(PRJ_DIR)/compConfig.c
-<END>
-
-<BEGIN> WCC__CDF_PATH
-$(PRJ_DIR)
-<END>
-
-<BEGIN> WCC__CURRENT
-PENTIUM2gnu.debug
-<END>
-
-<BEGIN> WCC__LIST
-PENTIUM2gnu.debug
-<END>
-
-<BEGIN> WCC__MXR_LIBS
-lib$(CPU)$(TOOL)vx.a
-<END>
-
-<BEGIN> WCC__OBJS_PATH
-$(WIND_BASE)/target/lib/obj$CPU$TOOLvx
-<END>
-
diff --git a/bdb/build_vxworks/db_config.h b/bdb/build_vxworks/db_config.h
deleted file mode 100644
index 642d9927f67ecc8f6f9f741083f7f31cb258d777..0000000000000000000000000000000000000000
--- a/bdb/build_vxworks/db_config.h
+++ /dev/null
@@ -1,382 +0,0 @@
-/* DO NOT EDIT: automatically built by dist/s_vxworks. */
-/* !!!
- * The CONFIG_TEST option may be added using the Tornado project build.
- * DO NOT modify it here.
- */
-/* Define to 1 if you want to build a version for running the test suite. */
-/* #undef CONFIG_TEST */
-
-/* !!!
- * The DEBUG option may be added using the Tornado project build.
- * DO NOT modify it here.
- */
-/* Define to 1 if you want a debugging version. */
-/* #undef DEBUG */
-
-/* Define to 1 if you want a version that logs read operations. */
-/* #undef DEBUG_ROP */
-
-/* Define to 1 if you want a version that logs write operations. */
-/* #undef DEBUG_WOP */
-
-/* !!!
- * The DIAGNOSTIC option may be added using the Tornado project build.
- * DO NOT modify it here.
- */
-/* Define to 1 if you want a version with run-time diagnostic checking. */
-/* #undef DIAGNOSTIC */
-
-/* Define to 1 if you have the `clock_gettime' function. */
-#define HAVE_CLOCK_GETTIME 1
-
-/* Define to 1 if Berkeley DB release includes strong cryptography. */
-/* #undef HAVE_CRYPTO */
-
-/* Define to 1 if you have the `directio' function. */
-/* #undef HAVE_DIRECTIO */
-
-/* Define to 1 if you have the <dirent.h> header file, and it defines `DIR'.
-   */
-#define HAVE_DIRENT_H 1
-
-/* Define to 1 if you have the <dlfcn.h> header file. */
-/* #undef HAVE_DLFCN_H */
-
-/* Define to 1 if you have EXIT_SUCCESS/EXIT_FAILURE #defines. */
-#define HAVE_EXIT_SUCCESS 1
-
-/* Define to 1 if fcntl/F_SETFD denies child access to file descriptors. */
-/* #undef HAVE_FCNTL_F_SETFD */
-
-/* Define to 1 if allocated filesystem blocks are not zeroed. */
-#define HAVE_FILESYSTEM_NOTZERO 1
-
-/* Define to 1 if you have the `getcwd' function. */
-#define HAVE_GETCWD 1
-
-/* Define to 1 if you have the `getopt' function. */
-/* #undef HAVE_GETOPT */
-
-/* Define to 1 if you have the `gettimeofday' function. */
-/* #undef HAVE_GETTIMEOFDAY */
-
-/* Define to 1 if you have the `getuid' function. */
-/* #undef HAVE_GETUID */
-
-/* Define to 1 if you have the <inttypes.h> header file. */
-/* #undef HAVE_INTTYPES_H */
-
-/* Define to 1 if you have the `nsl' library (-lnsl). */
-/* #undef HAVE_LIBNSL */
-
-/* Define to 1 if you have the `memcmp' function. */
-#define HAVE_MEMCMP 1
-
-/* Define to 1 if you have the `memcpy' function. */
-#define HAVE_MEMCPY 1
-
-/* Define to 1 if you have the `memmove' function. */
-#define HAVE_MEMMOVE 1
-
-/* Define to 1 if you have the <memory.h> header file. */
-#define HAVE_MEMORY_H 1
-
-/* Define to 1 if you have the `mlock' function. */
-/* #undef HAVE_MLOCK */
-
-/* Define to 1 if you have the `mmap' function. */
-/* #undef HAVE_MMAP */
-
-/* Define to 1 if you have the `munlock' function. */
-/* #undef HAVE_MUNLOCK */
-
-/* Define to 1 if you have the `munmap' function. */
-/* #undef HAVE_MUNMAP */
-
-/* Define to 1 to use the GCC compiler and 68K assembly language mutexes. */
-/* #undef HAVE_MUTEX_68K_GCC_ASSEMBLY */
-
-/* Define to 1 to use the AIX _check_lock mutexes. */
-/* #undef HAVE_MUTEX_AIX_CHECK_LOCK */
-
-/* Define to 1 to use the GCC compiler and Alpha assembly language mutexes. */
-/* #undef HAVE_MUTEX_ALPHA_GCC_ASSEMBLY */
-
-/* Define to 1 to use the GCC compiler and ARM assembly language mutexes. */
-/* #undef HAVE_MUTEX_ARM_GCC_ASSEMBLY */
-
-/* Define to 1 to use the UNIX fcntl system call mutexes. */
-/* #undef HAVE_MUTEX_FCNTL */
-
-/* Define to 1 to use the GCC compiler and PaRisc assembly language mutexes.
-   */
-/* #undef HAVE_MUTEX_HPPA_GCC_ASSEMBLY */
-
-/* Define to 1 to use the msem_XXX mutexes on HP-UX. */
-/* #undef HAVE_MUTEX_HPPA_MSEM_INIT */
-
-/* Define to 1 to use the GCC compiler and IA64 assembly language mutexes. */
-/* #undef HAVE_MUTEX_IA64_GCC_ASSEMBLY */
-
-/* Define to 1 to use the msem_XXX mutexes on systems other than HP-UX. */
-/* #undef HAVE_MUTEX_MSEM_INIT */
-
-/* Define to 1 to use the GCC compiler and Apple PowerPC assembly language. */
-/* #undef HAVE_MUTEX_PPC_APPLE_GCC_ASSEMBLY */
-
-/* Define to 1 to use the GCC compiler and generic PowerPC assembly language.
-   */
-/* #undef HAVE_MUTEX_PPC_GENERIC_GCC_ASSEMBLY */
-
-/* Define to 1 to use POSIX 1003.1 pthread_XXX mutexes. */
-/* #undef HAVE_MUTEX_PTHREADS */
-
-/* Define to 1 to use Reliant UNIX initspin mutexes. */
-/* #undef HAVE_MUTEX_RELIANTUNIX_INITSPIN */
-
-/* Define to 1 to use the GCC compiler and S/390 assembly language mutexes. */
-/* #undef HAVE_MUTEX_S390_GCC_ASSEMBLY */
-
-/* Define to 1 to use the SCO compiler and x86 assembly language mutexes. */
-/* #undef HAVE_MUTEX_SCO_X86_CC_ASSEMBLY */
-
-/* Define to 1 to use the obsolete POSIX 1003.1 sema_XXX mutexes. */
-/* #undef HAVE_MUTEX_SEMA_INIT */
-
-/* Define to 1 to use the SGI XXX_lock mutexes. */
-/* #undef HAVE_MUTEX_SGI_INIT_LOCK */
-
-/* Define to 1 to use the Solaris _lock_XXX mutexes. */
-/* #undef HAVE_MUTEX_SOLARIS_LOCK_TRY */
-
-/* Define to 1 to use the Solaris lwp threads mutexes. */
-/* #undef HAVE_MUTEX_SOLARIS_LWP */
-
-/* Define to 1 to use the GCC compiler and Sparc assembly language mutexes. */
-/* #undef HAVE_MUTEX_SPARC_GCC_ASSEMBLY */
-
-/* Define to 1 if mutexes hold system resources. */
-#define HAVE_MUTEX_SYSTEM_RESOURCES 1
-
-/* Define to 1 if fast mutexes are available. */
-#define HAVE_MUTEX_THREADS 1
-
-/* Define to 1 to configure mutexes intra-process only. */
-/* #undef HAVE_MUTEX_THREAD_ONLY */
-
-/* Define to 1 to use the UNIX International mutexes. */
-/* #undef HAVE_MUTEX_UI_THREADS */
-
-/* Define to 1 to use the UTS compiler and assembly language mutexes. */
-/* #undef HAVE_MUTEX_UTS_CC_ASSEMBLY */
-
-/* Define to 1 to use VMS mutexes. */
-/* #undef HAVE_MUTEX_VMS */
-
-/* Define to 1 to use VxWorks mutexes. */
-#define HAVE_MUTEX_VXWORKS 1
-
-/* Define to 1 to use Windows mutexes. */
-/* #undef HAVE_MUTEX_WIN32 */
-
-/* Define to 1 to use the GCC compiler and x86 assembly language mutexes. */
-/* #undef HAVE_MUTEX_X86_GCC_ASSEMBLY */
-
-/* Define to 1 if you have the <ndir.h> header file, and it defines `DIR'. */
-/* #undef HAVE_NDIR_H */
-
-/* Define to 1 if you have the O_DIRECT flag. */
-/* #undef HAVE_O_DIRECT */
-
-/* Define to 1 if you have the `pread' function. */
-/* #undef HAVE_PREAD */
-
-/* Define to 1 if you have the `pstat_getdynamic' function. */
-/* #undef HAVE_PSTAT_GETDYNAMIC */
-
-/* Define to 1 if you have the `pwrite' function. */
-/* #undef HAVE_PWRITE */
-
-/* Define to 1 if building on QNX. */
-/* #undef HAVE_QNX */
-
-/* Define to 1 if you have the `qsort' function. */
-#define HAVE_QSORT 1
-
-/* Define to 1 if you have the `raise' function. */
-#define HAVE_RAISE 1
-
-/* Define to 1 if building RPC client/server. */
-/* #undef HAVE_RPC */
-
-/* Define to 1 if you have the `sched_yield' function. */
-#define HAVE_SCHED_YIELD 1
-
-/* Define to 1 if you have the `select' function. */
-#define HAVE_SELECT 1
-
-/* Define to 1 if you have the `shmget' function. */
-/* #undef HAVE_SHMGET */
-
-/* Define to 1 if you have the `snprintf' function. */
-/* #undef HAVE_SNPRINTF */
-
-/* Define to 1 if you have the <stdint.h> header file. */
-/* #undef HAVE_STDINT_H */
-
-/* Define to 1 if you have the <stdlib.h> header file. */
-#define HAVE_STDLIB_H 1
-
-/* Define to 1 if you have the `strcasecmp' function. */
-/* #undef HAVE_STRCASECMP */
-
-/* Define to 1 if you have the `strdup' function. */
-/* #undef HAVE_STRDUP */
-
-/* Define to 1 if you have the `strerror' function. */
-#define HAVE_STRERROR 1
-
-/* Define to 1 if you have the <strings.h> header file. */
-#define HAVE_STRINGS_H 1
-
-/* Define to 1 if you have the <string.h> header file. */
-#define HAVE_STRING_H 1
-
-/* Define to 1 if you have the `strtoul' function. */
-#define HAVE_STRTOUL 1
-
-/* Define to 1 if `st_blksize' is member of `struct stat'. */
-#define HAVE_STRUCT_STAT_ST_BLKSIZE 1
-
-/* Define to 1 if you have the `sysconf' function. */
-/* #undef HAVE_SYSCONF */
-
-/* Define to 1 if you have the <sys/dir.h> header file, and it defines `DIR'.
-   */
-/* #undef HAVE_SYS_DIR_H */
-
-/* Define to 1 if you have the <sys/ndir.h> header file, and it defines `DIR'.
-   */
-/* #undef HAVE_SYS_NDIR_H */
-
-/* Define to 1 if you have the <sys/select.h> header file. */
-/* #undef HAVE_SYS_SELECT_H */
-
-/* Define to 1 if you have the <sys/stat.h> header file. */
-/* #undef HAVE_SYS_STAT_H */
-
-/* Define to 1 if you have the <sys/time.h> header file. */
-/* #undef HAVE_SYS_TIME_H */
-
-/* Define to 1 if you have the <sys/types.h> header file. */
-/* #undef HAVE_SYS_TYPES_H */
-
-/* Define to 1 if you have the <unistd.h> header file. */
-#define HAVE_UNISTD_H 1
-
-/* Define to 1 if unlink of file with open file descriptors will fail. */
-#define HAVE_UNLINK_WITH_OPEN_FAILURE 1
-
-/* Define to 1 if you have the `vsnprintf' function. */
-/* #undef HAVE_VSNPRINTF */
-
-/* Define to 1 if building VxWorks. */
-#define HAVE_VXWORKS 1
-
-/* Define to 1 if you have the `yield' function. */
-/* #undef HAVE_YIELD */
-
-/* Define to 1 if you have the `_fstati64' function. */
-/* #undef HAVE__FSTATI64 */
-
-/* Define to the address where bug reports for this package should be sent. */
-#define PACKAGE_BUGREPORT "support@sleepycat.com"
-
-/* Define to the full name of this package. */
-#define PACKAGE_NAME "Berkeley DB"
-
-/* Define to the full name and version of this package. */
-#define PACKAGE_STRING "Berkeley DB 4.1.24"
-
-/* Define to the one symbol short name of this package. */
-#define PACKAGE_TARNAME "db-4.1.24"
-
-/* Define to the version of this package. */
-#define PACKAGE_VERSION "4.1.24"
-
-/* Define to 1 if the `S_IS*' macros in <sys/stat.h> do not work properly. */
-/* #undef STAT_MACROS_BROKEN */
-
-/* Define to 1 if you have the ANSI C header files. */
-#define STDC_HEADERS 1
-
-/* Define to 1 if you can safely include both <sys/time.h> and <time.h>. */
-/* #undef TIME_WITH_SYS_TIME */
-
-/* Define to 1 to mask harmless unitialized memory read/writes. */
-/* #undef UMRW */
-
-/* Number of bits in a file offset, on hosts where this is settable. */
-/* #undef _FILE_OFFSET_BITS */
-
-/* Define for large files, on AIX-style hosts. */
-/* #undef _LARGE_FILES */
-
-/* Define to empty if `const' does not conform to ANSI C. */
-/* #undef const */
-
-/*
- * Exit success/failure macros.
- */
-#ifndef	HAVE_EXIT_SUCCESS
-#define	EXIT_FAILURE	1
-#define	EXIT_SUCCESS	0
-#endif
-
-/*
- * Don't step on the namespace.  Other libraries may have their own
- * implementations of these functions, we don't want to use their
- * implementations or force them to use ours based on the load order.
- */
-#ifndef	HAVE_GETCWD
-#define	getcwd		__db_Cgetcwd
-#endif
-#ifndef	HAVE_GETOPT
-#define	getopt		__db_Cgetopt
-#define	optarg		__db_Coptarg
-#define	opterr		__db_Copterr
-#define	optind		__db_Coptind
-#define	optopt		__db_Coptopt
-#endif
-#ifndef	HAVE_MEMCMP
-#define	memcmp		__db_Cmemcmp
-#endif
-#ifndef	HAVE_MEMCPY
-#define	memcpy		__db_Cmemcpy
-#endif
-#ifndef	HAVE_MEMMOVE
-#define	memmove		__db_Cmemmove
-#endif
-#ifndef	HAVE_RAISE
-#define	raise		__db_Craise
-#endif
-#ifndef	HAVE_SNPRINTF
-#define	snprintf	__db_Csnprintf
-#endif
-#ifndef	HAVE_STRCASECMP
-#define	strcasecmp	__db_Cstrcasecmp
-#define	strncasecmp	__db_Cstrncasecmp
-#endif
-#ifndef	HAVE_STRERROR
-#define	strerror	__db_Cstrerror
-#endif
-#ifndef	HAVE_VSNPRINTF
-#define	vsnprintf	__db_Cvsnprintf
-#endif
-
-/*
- * !!!
- * The following is not part of the automatic configuration setup, but
- * provides the information necessary to build Berkeley DB on VxWorks.
- */
-#include "vxWorks.h"
diff --git a/bdb/build_vxworks/db_deadlock/db_deadlock.c b/bdb/build_vxworks/db_deadlock/db_deadlock.c
deleted file mode 100644
index 3e9f4ba7b028787f7c93f648f9bf4af071195024..0000000000000000000000000000000000000000
--- a/bdb/build_vxworks/db_deadlock/db_deadlock.c
+++ /dev/null
@@ -1,249 +0,0 @@
-/*-
- * See the file LICENSE for redistribution information.
- *
- * Copyright (c) 1996-2002
- *	Sleepycat Software.  All rights reserved.
- */
-
-#include "db_config.h"
-
-#ifndef lint
-static const char copyright[] =
-    "Copyright (c) 1996-2002\nSleepycat Software Inc.  All rights reserved.\n";
-static const char revid[] =
-    "$Id: db_deadlock.c,v 11.38 2002/08/08 03:50:32 bostic Exp $";
-#endif
-
-#ifndef NO_SYSTEM_INCLUDES
-#include <sys/types.h>
-
-#if TIME_WITH_SYS_TIME
-#include <sys/time.h>
-#include <time.h>
-#else
-#if HAVE_SYS_TIME_H
-#include <sys/time.h>
-#else
-#include <time.h>
-#endif
-#endif
-
-#include <limits.h>
-#include <stdio.h>
-#include <stdlib.h>
-#include <string.h>
-#include <unistd.h>
-#endif
-
-#include "db_int.h"
-
-int db_deadlock_main __P((int, char *[]));
-int db_deadlock_usage __P((void));
-int db_deadlock_version_check __P((const char *));
-
-int
-db_deadlock(args)
-	char *args;
-{
-	int argc;
-	char **argv;
-
-	__db_util_arg("db_deadlock", args, &argc, &argv);
-	return (db_deadlock_main(argc, argv) ? EXIT_FAILURE : EXIT_SUCCESS);
-}
-
-#include <stdio.h>
-#define	ERROR_RETURN	ERROR
-
-int
-db_deadlock_main(argc, argv)
-	int argc;
-	char *argv[];
-{
-	extern char *optarg;
-	extern int optind, __db_getopt_reset;
-	const char *progname = "db_deadlock";
-	DB_ENV  *dbenv;
-	u_int32_t atype;
-	time_t now;
-	long secs, usecs;
-	int ch, e_close, exitval, ret, verbose;
-	char *home, *logfile, *str;
-
-	if ((ret = db_deadlock_version_check(progname)) != 0)
-		return (ret);
-
-	atype = DB_LOCK_DEFAULT;
-	home = logfile = NULL;
-	secs = usecs = 0;
-	e_close = exitval = verbose = 0;
-	__db_getopt_reset = 1;
-	while ((ch = getopt(argc, argv, "a:h:L:t:Vvw")) != EOF)
-		switch (ch) {
-		case 'a':
-			switch (optarg[0]) {
-			case 'e':
-				atype = DB_LOCK_EXPIRE;
-				break;
-			case 'm':
-				atype = DB_LOCK_MAXLOCKS;
-				break;
-			case 'n':
-				atype = DB_LOCK_MINLOCKS;
-				break;
-			case 'o':
-				atype = DB_LOCK_OLDEST;
-				break;
-			case 'w':
-				atype = DB_LOCK_MINWRITE;
-				break;
-			case 'y':
-				atype = DB_LOCK_YOUNGEST;
-				break;
-			default:
-				return (db_deadlock_usage());
-				/* NOTREACHED */
-			}
-			if (optarg[1] != '\0')
-				return (db_deadlock_usage());
-			break;
-		case 'h':
-			home = optarg;
-			break;
-		case 'L':
-			logfile = optarg;
-			break;
-		case 't':
-			if ((str = strchr(optarg, '.')) != NULL) {
-				*str++ = '\0';
-				if (*str != '\0' && __db_getlong(
-				    NULL, progname, str, 0, LONG_MAX, &usecs))
-					return (EXIT_FAILURE);
-			}
-			if (*optarg != '\0' && __db_getlong(
-			    NULL, progname, optarg, 0, LONG_MAX, &secs))
-				return (EXIT_FAILURE);
-			if (secs == 0 && usecs == 0)
-				return (db_deadlock_usage());
-
-			break;
-
-		case 'V':
-			printf("%s\n", db_version(NULL, NULL, NULL));
-			return (EXIT_SUCCESS);
-		case 'v':
-			verbose = 1;
-			break;
-		case 'w':			/* Undocumented. */
-			/* Detect every 100ms (100000 us) when polling. */
-			secs = 0;
-			usecs = 100000;
-			break;
-		case '?':
-		default:
-			return (db_deadlock_usage());
-		}
-	argc -= optind;
-	argv += optind;
-
-	if (argc != 0)
-		return (db_deadlock_usage());
-
-	/* Handle possible interruptions. */
-	__db_util_siginit();
-
-	/* Log our process ID. */
-	if (logfile != NULL && __db_util_logset(progname, logfile))
-		goto shutdown;
-
-	/*
-	 * Create an environment object and initialize it for error
-	 * reporting.
-	 */
-	if ((ret = db_env_create(&dbenv, 0)) != 0) {
-		fprintf(stderr,
-		    "%s: db_env_create: %s\n", progname, db_strerror(ret));
-		goto shutdown;
-	}
-	e_close = 1;
-
-	dbenv->set_errfile(dbenv, stderr);
-	dbenv->set_errpfx(dbenv, progname);
-
-	if (verbose) {
-		(void)dbenv->set_verbose(dbenv, DB_VERB_DEADLOCK, 1);
-		(void)dbenv->set_verbose(dbenv, DB_VERB_WAITSFOR, 1);
-	}
-
-	/* An environment is required. */
-	if ((ret = dbenv->open(dbenv, home,
-	    DB_JOINENV | DB_USE_ENVIRON, 0)) != 0) {
-		dbenv->err(dbenv, ret, "open");
-		goto shutdown;
-	}
-
-	while (!__db_util_interrupted()) {
-		if (verbose) {
-			(void)time(&now);
-			dbenv->errx(dbenv, "running at %.24s", ctime(&now));
-		}
-
-		if ((ret = dbenv->lock_detect(dbenv, 0, atype, NULL)) != 0) {
-			dbenv->err(dbenv, ret, "DB_ENV->lock_detect");
-			goto shutdown;
-		}
-
-		/* Make a pass every "secs" secs and "usecs" usecs. */
-		if (secs == 0 && usecs == 0)
-			break;
-		(void)__os_sleep(dbenv, secs, usecs);
-	}
-
-	if (0) {
-shutdown:	exitval = 1;
-	}
-
-	/* Clean up the logfile. */
-	if (logfile != NULL)
-		remove(logfile);
-
-	/* Clean up the environment. */
-	if (e_close && (ret = dbenv->close(dbenv, 0)) != 0) {
-		exitval = 1;
-		fprintf(stderr,
-		    "%s: dbenv->close: %s\n", progname, db_strerror(ret));
-	}
-
-	/* Resend any caught signal. */
-	__db_util_sigresend();
-
-	return (exitval == 0 ? EXIT_SUCCESS : EXIT_FAILURE);
-}
-
-int
-db_deadlock_usage()
-{
-	(void)fprintf(stderr, "%s\n\t%s\n",
-	    "usage: db_deadlock [-Vv]",
-	    "[-a e | m | n | o | w | y] [-h home] [-L file] [-t sec.usec]");
-	return (EXIT_FAILURE);
-}
-
-int
-db_deadlock_version_check(progname)
-	const char *progname;
-{
-	int v_major, v_minor, v_patch;
-
-	/* Make sure we're loaded with the right version of the DB library. */
-	(void)db_version(&v_major, &v_minor, &v_patch);
-	if (v_major != DB_VERSION_MAJOR ||
-	    v_minor != DB_VERSION_MINOR || v_patch != DB_VERSION_PATCH) {
-		fprintf(stderr,
-	"%s: version %d.%d.%d doesn't match library version %d.%d.%d\n",
-		    progname, DB_VERSION_MAJOR, DB_VERSION_MINOR,
-		    DB_VERSION_PATCH, v_major, v_minor, v_patch);
-		return (EXIT_FAILURE);
-	}
-	return (0);
-}
diff --git a/bdb/build_vxworks/db_deadlock/db_deadlock.wpj b/bdb/build_vxworks/db_deadlock/db_deadlock.wpj
deleted file mode 100755
index 10cc2dc6cb65e7d874f22e35bb3697db63cb682e..0000000000000000000000000000000000000000
--- a/bdb/build_vxworks/db_deadlock/db_deadlock.wpj
+++ /dev/null
@@ -1,160 +0,0 @@
-Document file - DO NOT EDIT
-
-<BEGIN> BUILD_PENTIUMgnu_BUILDRULE
-db_deadlock.out
-<END>
-
-<BEGIN> BUILD_PENTIUMgnu_MACRO_AR
-ar386
-<END>
-
-<BEGIN> BUILD_PENTIUMgnu_MACRO_ARCHIVE
-$(PRJ_DIR)/PENTIUMgnu/db_deadlock.a
-<END>
-
-<BEGIN> BUILD_PENTIUMgnu_MACRO_AS
-cc386
-<END>
-
-<BEGIN> BUILD_PENTIUMgnu_MACRO_CC
-cc386
-<END>
-
-<BEGIN> BUILD_PENTIUMgnu_MACRO_CFLAGS
--g \
-	-mpentium \
-	-ansi \
-	-nostdinc \
-	-DRW_MULTI_THREAD \
-	-D_REENTRANT \
-	-fvolatile \
-	-nostdlib \
-	-fno-builtin \
-	-fno-defer-pop \
-	-I$(PRJ_DIR)/.. \
-	-I$(PRJ_DIR)/../.. \
-	-I$(WIND_BASE)/target/h \
-	-DCPU=PENTIUM
-<END>
-
-<BEGIN> BUILD_PENTIUMgnu_MACRO_CFLAGS_AS
--g \
-	-mpentium \
-	-ansi \
-	-nostdinc \
-	-fvolatile \
-	-nostdlib \
-	-fno-builtin \
-	-fno-defer-pop \
-	-P \
-	-x \
-	assembler-with-cpp \
-	-I$(WIND_BASE)/target/h \
-	-DCPU=PENTIUM
-<END>
-
-<BEGIN> BUILD_PENTIUMgnu_MACRO_CPP
-cc386 -E -P -xc
-<END>
-
-<BEGIN> BUILD_PENTIUMgnu_MACRO_LD
-ld386
-<END>
-
-<BEGIN> BUILD_PENTIUMgnu_MACRO_LDDEPS
-
-<END>
-
-<BEGIN> BUILD_PENTIUMgnu_MACRO_LDFLAGS
--X -N
-<END>
-
-<BEGIN> BUILD_PENTIUMgnu_MACRO_LD_PARTIAL_FLAGS
--X -r
-<END>
-
-<BEGIN> BUILD_PENTIUMgnu_MACRO_NM
-nm386 -g
-<END>
-
-<BEGIN> BUILD_PENTIUMgnu_MACRO_OPTION_DEFINE_MACRO
--D
-<END>
-
-<BEGIN> BUILD_PENTIUMgnu_MACRO_OPTION_INCLUDE_DIR
--I
-<END>
-
-<BEGIN> BUILD_PENTIUMgnu_MACRO_POST_BUILD_RULE
-
-<END>
-
-<BEGIN> BUILD_PENTIUMgnu_MACRO_PRJ_LIBS
-
-<END>
-
-<BEGIN> BUILD_PENTIUMgnu_MACRO_SIZE
-size386
-<END>
-
-<BEGIN> BUILD_PENTIUMgnu_RO_DEPEND_PATH
-{$(WIND_BASE)/target/h/} \
-	{$(WIND_BASE)/target/src/} \
-	{$(WIND_BASE)/target/config/}
-<END>
-
-<BEGIN> BUILD_PENTIUMgnu_TC
-::tc_PENTIUMgnu
-<END>
-
-<BEGIN> BUILD_RULE_archive
-
-<END>
-
-<BEGIN> BUILD_RULE_db_deadlock.out
-
-<END>
-
-<BEGIN> BUILD_RULE_objects
-
-<END>
-
-<BEGIN> BUILD__CURRENT
-PENTIUMgnu
-<END>
-
-<BEGIN> BUILD__LIST
-PENTIUMgnu
-<END>
-
-<BEGIN> CORE_INFO_TYPE
-::prj_vxApp
-<END>
-
-<BEGIN> CORE_INFO_VERSION
-2.0
-<END>
-
-<BEGIN> FILE_db_deadlock.c_dependDone
-FALSE
-<END>
-
-<BEGIN> FILE_db_deadlock.c_dependencies
-
-<END>
-
-<BEGIN> FILE_db_deadlock.c_objects
-db_deadlock.o
-<END>
-
-<BEGIN> FILE_db_deadlock.c_tool
-C/C++ compiler
-<END>
-
-<BEGIN> PROJECT_FILES
-$(PRJ_DIR)/db_deadlock.c
-<END>
-
-<BEGIN> userComments
-db_deadlock
-<END>
diff --git a/bdb/build_vxworks/db_deadlock/db_deadlock/Makefile.custom b/bdb/build_vxworks/db_deadlock/db_deadlock/Makefile.custom
deleted file mode 100644
index ca781f7b251ef99e49e5fc1859ee6cf3d67c60b0..0000000000000000000000000000000000000000
--- a/bdb/build_vxworks/db_deadlock/db_deadlock/Makefile.custom
+++ /dev/null
@@ -1,51 +0,0 @@
-#
-# Custom Makefile shell
-#
-# This file may be edited freely, since it will not be regenerated
-# by the project manager.
-#
-# Use this makefile to define rules to make external binaries
-# and deposit them in the $(EXTERNAL_BINARIES_DIR) directory.
-#
-# If you have specified external modules during your component
-# creation, you will find make rules already in place below.
-# You will likely have to edit these to suit your individual
-# build setup.
-#
-# You may wish to use the CPU, BUILD_SPEC or TOOL make variables in
-# your Makefile to support builds for different architectures.  Use
-# the FORCE_EXTERNAL_MAKE phony target to ensure that your external
-# make always runs.
-#
-# The example below assumes that your custom makefile is in the
-# mySourceTree directory, and that the binary file it produces
-# is placed into the $(BUILD_SPEC) sub-directory.
-#
-# EXTERNAL_SOURCE_BASE = /folk/me/mySourceTree
-# EXTERNAL_MODULE = myLibrary.o
-# EXTERNAL_MAKE = make
-#
-# $(EXTERNAL_BINARIES_DIR)/$(EXTERNAL_MODULE) : FORCE_EXTERNAL_MAKE
-#	$(EXTERNAL_MAKE) -C $(EXTERNAL_SOURCE_BASE) \
-#	-f $(EXTERNAL_SOURCE_BASE)/Makefile \
-#	CPU=$(CPU) BUILD_SPEC=$(BUILD_SPEC) $(@F)
-#	$(CP) $(subst /,$(DIRCHAR),$(EXTERNAL_SOURCE_BASE)/$(BUILD_SPEC)/$(@F) $@)
-#
-# If you are not adding your external modules from the component wizard,
-# you will have to include them in your component yourself:
-#
-# From the GUI, you can do this with the Component's 'Add external module'
-# dialog.
-#
-# If you are using the command line, add the module(s) by editing the
-# MODULES line in component.cdf file, e.g.
-#
-# Component INCLUDE_MYCOMPONENT {
-#
-#   MODULES         foo.o goo.o \
-#         myLibrary.o
-#
-
-
-# rules to build custom libraries
-
diff --git a/bdb/build_vxworks/db_deadlock/db_deadlock/component.cdf b/bdb/build_vxworks/db_deadlock/db_deadlock/component.cdf
deleted file mode 100755
index efc498475bf821cc63a0f28d5c557693118b311d..0000000000000000000000000000000000000000
--- a/bdb/build_vxworks/db_deadlock/db_deadlock/component.cdf
+++ /dev/null
@@ -1,30 +0,0 @@
-/* component.cdf - dynamically updated configuration */
-
-/*
- * NOTE: you may edit this file to alter the configuration
- * But all non-configuration information, including comments,
- * will be lost upon rebuilding this project.
- */
-
-/* Component information */
-
-Component INCLUDE_DB_DEADLOCK {
-	ENTRY_POINTS	ALL_GLOBAL_SYMBOLS 
-	MODULES		db_deadlock.o 
-	NAME		db_deadlock
-	PREF_DOMAIN	ANY
-	_INIT_ORDER	usrComponentsInit
-}
-
-/* EntryPoint information */
-
-/* Module information */
-
-Module db_deadlock.o {
-
-	NAME		db_deadlock.o
-	SRC_PATH_NAME	$PRJ_DIR/../db_deadlock.c
-}
-
-/* Parameter information */
-
diff --git a/bdb/build_vxworks/db_deadlock/db_deadlock/component.wpj b/bdb/build_vxworks/db_deadlock/db_deadlock/component.wpj
deleted file mode 100755
index f9a1b82cd9c74824e2a8ba70ece61d05a82a7eac..0000000000000000000000000000000000000000
--- a/bdb/build_vxworks/db_deadlock/db_deadlock/component.wpj
+++ /dev/null
@@ -1,475 +0,0 @@
-Document file - DO NOT EDIT
-
-<BEGIN> CORE_INFO_TYPE
-::prj_component
-<END>
-
-<BEGIN> CORE_INFO_VERSION
-AE1.1
-<END>
-
-<BEGIN> BUILD__CURRENT
-PENTIUM2gnu.debug
-<END>
-
-<BEGIN> BUILD_PENTIUM2gnu.debug_CURRENT_TARGET
-default
-<END>
-
-<BEGIN> BUILD_PENTIUM2gnu.debug_DEFAULTFORCPU
-1
-<END>
-
-<BEGIN> BUILD_PENTIUM2gnu.debug_FILE_$(PRJ_DIR)/../db_deadlock.c_infoTags
-toolMacro objects
-<END>
-
-<BEGIN> BUILD_PENTIUM2gnu.debug_FILE_$(PRJ_DIR)/../db_deadlock.c_objects
-db_deadlock.o
-<END>
-
-<BEGIN> BUILD_PENTIUM2gnu.debug_FILE_$(PRJ_DIR)/../db_deadlock.c_toolMacro
-CC
-<END>
-
-<BEGIN> BUILD_PENTIUM2gnu.debug_FILE_$(PRJ_DIR)/../db_deadlock.c_objects
-db_deadlock.o
-<END>
-
-<BEGIN> BUILD_PENTIUM2gnu.debug_FILE_$(PRJ_DIR)/../db_deadlock.c_toolMacro
-CC
-<END>
-
-<BEGIN> BUILD_PENTIUM2gnu.debug_FILE_$(PRJ_DIR)/compConfig.c_infoTags
-toolMacro objects
-<END>
-
-<BEGIN> BUILD_PENTIUM2gnu.debug_FILE_$(PRJ_DIR)/compConfig.c_objects
-compConfig.o
-<END>
-
-<BEGIN> BUILD_PENTIUM2gnu.debug_FILE_$(PRJ_DIR)/compConfig.c_toolMacro
-CC
-<END>
-
-<BEGIN> BUILD_PENTIUM2gnu.debug_MACRO_AR
-arpentium
-<END>
-
-<BEGIN> BUILD_PENTIUM2gnu.debug_MACRO_AS
-ccpentium
-<END>
-
-<BEGIN> BUILD_PENTIUM2gnu.debug_MACRO_CC
-ccpentium
-<END>
-
-<BEGIN> BUILD_PENTIUM2gnu.debug_MACRO_CFLAGS
--mcpu=pentiumpro \
-	-march=pentiumpro \
-	-ansi \
-	-DRW_MULTI_THREAD \
-	-D_REENTRANT \
-	-g \
-	-nostdlib \
-	-fno-builtin \
-	-fno-defer-pop \
-	-MD \
-	-Wall \
-	-I. \
-	-I$(WIND_BASE)/target/h \
-	-I$(PRJ_DIR)/../.. \
-	-I$(PRJ_DIR)/../../.. \
-	-DCPU=PENTIUM2
-<END>
-
-<BEGIN> BUILD_PENTIUM2gnu.debug_MACRO_CFLAGS_AS
--mcpu=pentiumpro \
-	-march=pentiumpro \
-	-ansi \
-	-g \
-	-nostdlib \
-	-fno-builtin \
-	-fno-defer-pop \
-	-P \
-	-x \
-	assembler-with-cpp \
-	-Wall \
-	-I. \
-	-I$(WIND_BASE)/target/h \
-	-DCPU=PENTIUM2
-<END>
-
-<BEGIN> BUILD_PENTIUM2gnu.debug_MACRO_CPP
-ccpentium -E -P
-<END>
-
-<BEGIN> BUILD_PENTIUM2gnu.debug_MACRO_CPPFILT
-c++filtpentium --strip-underscores
-<END>
-
-<BEGIN> BUILD_PENTIUM2gnu.debug_MACRO_LD
-ldpentium
-<END>
-
-<BEGIN> BUILD_PENTIUM2gnu.debug_MACRO_LDFLAGS
--X
-<END>
-
-<BEGIN> BUILD_PENTIUM2gnu.debug_MACRO_LDPARTIAL
-ccpentium \
-	-B$(WIND_BASE)/host/$(WIND_HOST_TYPE)/lib/gcc-lib/ \
-	-nostdlib \
-	-r \
-	-Wl,-X
-<END>
-
-<BEGIN> BUILD_PENTIUM2gnu.debug_MACRO_LD_PARTIAL_FLAGS
--X -r
-<END>
-
-<BEGIN> BUILD_PENTIUM2gnu.debug_MACRO_NM
-nmpentium -g
-<END>
-
-<BEGIN> BUILD_PENTIUM2gnu.debug_MACRO_OPTION_DEFINE_MACRO
--D
-<END>
-
-<BEGIN> BUILD_PENTIUM2gnu.debug_MACRO_OPTION_GENERATE_DEPENDENCY_FILE
--MD
-<END>
-
-<BEGIN> BUILD_PENTIUM2gnu.debug_MACRO_OPTION_INCLUDE_DIR
--I
-<END>
-
-<BEGIN> BUILD_PENTIUM2gnu.debug_MACRO_RELEASE
-0
-<END>
-
-<BEGIN> BUILD_PENTIUM2gnu.debug_MACRO_SIZE
-sizepentium
-<END>
-
-<BEGIN> BUILD_PENTIUM2gnu.debug_RELEASE
-0
-<END>
-
-<BEGIN> BUILD_PENTIUM2gnu.debug_RO_DEPEND_PATH
-$(WIND_BASE)/target/h/
-<END>
-
-<BEGIN> BUILD_PENTIUM2gnu.debug_TC
-::tc_PENTIUM2gnu.debug
-<END>
-
-<BEGIN> BUILD_PENTIUM2gnu.release_DEFAULTFORCPU
-0
-<END>
-
-<BEGIN> BUILD_PENTIUM2gnu.release_FILE_$(PRJ_DIR)/../db_deadlock.c_infoTags
-toolMacro objects
-<END>
-
-<BEGIN> BUILD_PENTIUM2gnu.release_FILE_$(PRJ_DIR)/../db_deadlock.c_objects
-db_deadlock.o
-<END>
-
-<BEGIN> BUILD_PENTIUM2gnu.release_FILE_$(PRJ_DIR)/../db_deadlock.c_toolMacro
-CC
-<END>
-
-<BEGIN> BUILD_PENTIUM2gnu.release_FILE_$(PRJ_DIR)/compConfig.c_infoTags
-toolMacro objects
-<END>
-
-<BEGIN> BUILD_PENTIUM2gnu.release_FILE_$(PRJ_DIR)/compConfig.c_objects
-compConfig.o
-<END>
-
-<BEGIN> BUILD_PENTIUM2gnu.release_FILE_$(PRJ_DIR)/compConfig.c_toolMacro
-CC
-<END>
-
-<BEGIN> BUILD_PENTIUM2gnu.release_MACRO_AR
-arpentium
-<END>
-
-<BEGIN> BUILD_PENTIUM2gnu.release_MACRO_AS
-ccpentium
-<END>
-
-<BEGIN> BUILD_PENTIUM2gnu.release_MACRO_CC
-ccpentium
-<END>
-
-<BEGIN> BUILD_PENTIUM2gnu.release_MACRO_CFLAGS
--mcpu=pentiumpro \
-	-march=pentiumpro \
-	-ansi \
-	-DRW_MULTI_THREAD \
-	-D_REENTRANT \
-	-O2 \
-	-nostdlib \
-	-fno-builtin \
-	-fno-defer-pop \
-	-MD \
-	-Wall \
-	-I. \
-	-I$(WIND_BASE)/target/h \
-	-I$(PRJ_DIR)/../.. \
-	-I$(PRJ_DIR)/../../.. \
-	-DCPU=PENTIUM2
-<END>
-
-<BEGIN> BUILD_PENTIUM2gnu.release_MACRO_CFLAGS_AS
--mcpu=pentiumpro \
-	-march=pentiumpro \
-	-ansi \
-	-O2 \
-	-nostdlib \
-	-fno-builtin \
-	-fno-defer-pop \
-	-P \
-	-x \
-	assembler-with-cpp \
-	-Wall \
-	-I. \
-	-I$(WIND_BASE)/target/h \
-	-DCPU=PENTIUM2
-<END>
-
-<BEGIN> BUILD_PENTIUM2gnu.release_MACRO_CPP
-ccpentium -E -P
-<END>
-
-<BEGIN> BUILD_PENTIUM2gnu.release_MACRO_CPPFILT
-c++filtpentium --strip-underscores
-<END>
-
-<BEGIN> BUILD_PENTIUM2gnu.release_MACRO_LD
-ldpentium
-<END>
-
-<BEGIN> BUILD_PENTIUM2gnu.release_MACRO_LDFLAGS
--X
-<END>
-
-<BEGIN> BUILD_PENTIUM2gnu.release_MACRO_LDPARTIAL
-ccpentium \
-	-B$(WIND_BASE)/host/$(WIND_HOST_TYPE)/lib/gcc-lib/ \
-	-nostdlib \
-	-r \
-	-Wl,-X
-<END>
-
-<BEGIN> BUILD_PENTIUM2gnu.release_MACRO_LD_PARTIAL_FLAGS
--X -r
-<END>
-
-<BEGIN> BUILD_PENTIUM2gnu.release_MACRO_NM
-nmpentium -g
-<END>
-
-<BEGIN> BUILD_PENTIUM2gnu.release_MACRO_OPTION_DEFINE_MACRO
--D
-<END>
-
-<BEGIN> BUILD_PENTIUM2gnu.release_MACRO_OPTION_GENERATE_DEPENDENCY_FILE
--MD
-<END>
-
-<BEGIN> BUILD_PENTIUM2gnu.release_MACRO_OPTION_INCLUDE_DIR
--I
-<END>
-
-<BEGIN> BUILD_PENTIUM2gnu.release_MACRO_RELEASE
-1
-<END>
-
-<BEGIN> BUILD_PENTIUM2gnu.release_MACRO_SIZE
-sizepentium
-<END>
-
-<BEGIN> BUILD_PENTIUM2gnu.release_RELEASE
-1
-<END>
-
-<BEGIN> BUILD_PENTIUM2gnu.release_RO_DEPEND_PATH
-$(WIND_BASE)/target/h/
-<END>
-
-<BEGIN> BUILD_PENTIUM2gnu.release_TC
-::tc_PENTIUM2gnu.release
-<END>
-
-<BEGIN> BUILD_PENTIUMgnu.debug_DEFAULTFORCPU
-1
-<END>
-
-<BEGIN> BUILD_PENTIUMgnu.debug_FILE_$(PRJ_DIR)/../db_deadlock.c_infoTags
-toolMacro objects
-<END>
-
-<BEGIN> BUILD_PENTIUMgnu.debug_FILE_$(PRJ_DIR)/../db_deadlock.c_objects
-db_deadlock.o
-<END>
-
-<BEGIN> BUILD_PENTIUMgnu.debug_FILE_$(PRJ_DIR)/../db_deadlock.c_toolMacro
-CC
-<END>
-
-<BEGIN> BUILD_PENTIUMgnu.debug_FILE_$(PRJ_DIR)/compConfig.c_infoTags
-toolMacro objects
-<END>
-
-<BEGIN> BUILD_PENTIUMgnu.debug_FILE_$(PRJ_DIR)/compConfig.c_objects
-compConfig.o
-<END>
-
-<BEGIN> BUILD_PENTIUMgnu.debug_FILE_$(PRJ_DIR)/compConfig.c_toolMacro
-CC
-<END>
-
-<BEGIN> BUILD_PENTIUMgnu.debug_MACRO_AR
-arpentium
-<END>
-
-<BEGIN> BUILD_PENTIUMgnu.debug_MACRO_AS
-ccpentium
-<END>
-
-<BEGIN> BUILD_PENTIUMgnu.debug_MACRO_CC
-ccpentium
-<END>
-
-<BEGIN> BUILD_PENTIUMgnu.debug_MACRO_CFLAGS
--mcpu=pentium \
-	-march=pentium \
-	-ansi \
-	-DRW_MULTI_THREAD \
-	-D_REENTRANT \
-	-g \
-	-nostdlib \
-	-fno-builtin \
-	-fno-defer-pop \
-	-MD \
-	-Wall \
-	-I. \
-	-I$(WIND_BASE)/target/h \
-	-I$(PRJ_DIR)/../.. \
-	-I$(PRJ_DIR)/../../.. \
-	-DCPU=PENTIUM
-<END>
-
-<BEGIN> BUILD_PENTIUMgnu.debug_MACRO_CFLAGS_AS
--mcpu=pentium \
-	-march=pentium \
-	-ansi \
-	-g \
-	-nostdlib \
-	-fno-builtin \
-	-fno-defer-pop \
-	-P \
-	-x \
-	assembler-with-cpp \
-	-Wall \
-	-I. \
-	-I$(WIND_BASE)/target/h \
-	-DCPU=PENTIUM
-<END>
-
-<BEGIN> BUILD_PENTIUMgnu.debug_MACRO_CPP
-ccpentium -E -P
-<END>
-
-<BEGIN> BUILD_PENTIUMgnu.debug_MACRO_CPPFILT
-c++filtpentium --strip-underscores
-<END>
-
-<BEGIN> BUILD_PENTIUMgnu.debug_MACRO_LD
-ldpentium
-<END>
-
-<BEGIN> BUILD_PENTIUMgnu.debug_MACRO_LDFLAGS
--X
-<END>
-
-<BEGIN> BUILD_PENTIUMgnu.debug_MACRO_LDPARTIAL
-ccpentium \
-	-B$(WIND_BASE)/host/$(WIND_HOST_TYPE)/lib/gcc-lib/ \
-	-nostdlib \
-	-r \
-	-Wl,-X
-<END>
-
-<BEGIN> BUILD_PENTIUMgnu.debug_MACRO_LD_PARTIAL_FLAGS
--X -r
-<END>
-
-<BEGIN> BUILD_PENTIUMgnu.debug_MACRO_NM
-nmpentium -g
-<END>
-
-<BEGIN> BUILD_PENTIUMgnu.debug_MACRO_OPTION_DEFINE_MACRO
--D
-<END>
-
-<BEGIN> BUILD_PENTIUMgnu.debug_MACRO_OPTION_GENERATE_DEPENDENCY_FILE
--MD
-<END>
-
-<BEGIN> BUILD_PENTIUMgnu.debug_MACRO_OPTION_INCLUDE_DIR
--I
-<END>
-
-<BEGIN> BUILD_PENTIUMgnu.debug_MACRO_RELEASE
-0
-<END>
-
-<BEGIN> BUILD_PENTIUMgnu.debug_MACRO_SIZE
-sizepentium
-<END>
-
-<BEGIN> BUILD_PENTIUMgnu.debug_RELEASE
-0
-<END>
-
-<BEGIN> BUILD_PENTIUMgnu.debug_RO_DEPEND_PATH
-$(WIND_BASE)/target/h/
-<END>
-
-<BEGIN> BUILD_PENTIUMgnu.debug_TC
-::tc_PENTIUMgnu.debug
-<END>
-
-<BEGIN> BUILD__LIST
-PENTIUM2gnu.debug PENTIUM2gnu.release PENTIUMgnu.debug
-<END>
-
-<BEGIN> PROJECT_FILES
-$(PRJ_DIR)/../db_deadlock.c \
-	$(PRJ_DIR)/compConfig.c
-<END>
-
-<BEGIN> WCC__CDF_PATH
-$(PRJ_DIR)
-<END>
-
-<BEGIN> WCC__CURRENT
-PENTIUM2gnu.debug
-<END>
-
-<BEGIN> WCC__LIST
-PENTIUM2gnu.debug
-<END>
-
-<BEGIN> WCC__MXR_LIBS
-lib$(CPU)$(TOOL)vx.a
-<END>
-
-<BEGIN> WCC__OBJS_PATH
-$(WIND_BASE)/target/lib/obj$CPU$TOOLvx
-<END>
-
diff --git a/bdb/build_vxworks/db_dump/db_dump.c b/bdb/build_vxworks/db_dump/db_dump.c
deleted file mode 100644
index 60e987c48b92dcb857752f48d480a157a81292dd..0000000000000000000000000000000000000000
--- a/bdb/build_vxworks/db_dump/db_dump.c
+++ /dev/null
@@ -1,626 +0,0 @@
-/*-
- * See the file LICENSE for redistribution information.
- *
- * Copyright (c) 1996-2002
- *	Sleepycat Software.  All rights reserved.
- */
-
-#include "db_config.h"
-
-#ifndef lint
-static const char copyright[] =
-    "Copyright (c) 1996-2002\nSleepycat Software Inc.  All rights reserved.\n";
-static const char revid[] =
-    "$Id: db_dump.c,v 11.80 2002/08/08 03:50:34 bostic Exp $";
-#endif
-
-#ifndef NO_SYSTEM_INCLUDES
-#include <sys/types.h>
-
-#include <stdio.h>
-#include <stdlib.h>
-#include <string.h>
-#include <unistd.h>
-#endif
-
-#include "db_int.h"
-#include "dbinc/db_page.h"
-#include "dbinc/db_am.h"
-
-int	 db_dump_db_init __P((DB_ENV *, char *, int, u_int32_t, int *));
-int	 db_dump_dump __P((DB *, int, int));
-int	 db_dump_dump_sub __P((DB_ENV *, DB *, char *, int, int));
-int	 db_dump_is_sub __P((DB *, int *));
-int	 db_dump_main __P((int, char *[]));
-int	 db_dump_show_subs __P((DB *));
-int	 db_dump_usage __P((void));
-int	 db_dump_version_check __P((const char *));
-
-int
-db_dump(args)
-	char *args;
-{
-	int argc;
-	char **argv;
-
-	__db_util_arg("db_dump", args, &argc, &argv);
-	return (db_dump_main(argc, argv) ? EXIT_FAILURE : EXIT_SUCCESS);
-}
-
-#include <stdio.h>
-#define	ERROR_RETURN	ERROR
-
-int
-db_dump_main(argc, argv)
-	int argc;
-	char *argv[];
-{
-	extern char *optarg;
-	extern int optind, __db_getopt_reset;
-	const char *progname = "db_dump";
-	DB_ENV	*dbenv;
-	DB *dbp;
-	u_int32_t cache;
-	int ch, d_close;
-	int e_close, exitval, keyflag, lflag, nflag, pflag, private;
-	int ret, Rflag, rflag, resize, subs;
-	char *dopt, *home, *passwd, *subname;
-
-	if ((ret = db_dump_version_check(progname)) != 0)
-		return (ret);
-
-	dbp = NULL;
-	d_close = e_close = exitval = lflag = nflag = pflag = rflag = Rflag = 0;
-	keyflag = 0;
-	cache = MEGABYTE;
-	private = 0;
-	dopt = home = passwd = subname = NULL;
-	__db_getopt_reset = 1;
-	while ((ch = getopt(argc, argv, "d:f:h:klNpP:rRs:V")) != EOF)
-		switch (ch) {
-		case 'd':
-			dopt = optarg;
-			break;
-		case 'f':
-			if (freopen(optarg, "w", stdout) == NULL) {
-				fprintf(stderr, "%s: %s: reopen: %s\n",
-				    progname, optarg, strerror(errno));
-				return (EXIT_FAILURE);
-			}
-			break;
-		case 'h':
-			home = optarg;
-			break;
-		case 'k':
-			keyflag = 1;
-			break;
-		case 'l':
-			lflag = 1;
-			break;
-		case 'N':
-			nflag = 1;
-			break;
-		case 'P':
-			passwd = strdup(optarg);
-			memset(optarg, 0, strlen(optarg));
-			if (passwd == NULL) {
-				fprintf(stderr, "%s: strdup: %s\n",
-				    progname, strerror(errno));
-				return (EXIT_FAILURE);
-			}
-			break;
-		case 'p':
-			pflag = 1;
-			break;
-		case 's':
-			subname = optarg;
-			break;
-		case 'R':
-			Rflag = 1;
-			/* DB_AGGRESSIVE requires DB_SALVAGE */
-			/* FALLTHROUGH */
-		case 'r':
-			rflag = 1;
-			break;
-		case 'V':
-			printf("%s\n", db_version(NULL, NULL, NULL));
-			return (EXIT_SUCCESS);
-		case '?':
-		default:
-			return (db_dump_usage());
-		}
-	argc -= optind;
-	argv += optind;
-
-	if (argc != 1)
-		return (db_dump_usage());
-
-	if (dopt != NULL && pflag) {
-		fprintf(stderr,
-		    "%s: the -d and -p options may not both be specified\n",
-		    progname);
-		return (EXIT_FAILURE);
-	}
-	if (lflag && subname != NULL) {
-		fprintf(stderr,
-		    "%s: the -l and -s options may not both be specified\n",
-		    progname);
-		return (EXIT_FAILURE);
-	}
-
-	if (keyflag && rflag) {
-		fprintf(stderr, "%s: %s",
-		    "the -k and -r or -R options may not both be specified\n",
-		    progname);
-		return (EXIT_FAILURE);
-	}
-
-	if (subname != NULL && rflag) {
-		fprintf(stderr, "%s: %s",
-		    "the -s and -r or R options may not both be specified\n",
-		    progname);
-		return (EXIT_FAILURE);
-	}
-
-	/* Handle possible interruptions. */
-	__db_util_siginit();
-
-	/*
-	 * Create an environment object and initialize it for error
-	 * reporting.
-	 */
-retry:	if ((ret = db_env_create(&dbenv, 0)) != 0) {
-		fprintf(stderr,
-		    "%s: db_env_create: %s\n", progname, db_strerror(ret));
-		goto err;
-	}
-	e_close = 1;
-
-	dbenv->set_errfile(dbenv, stderr);
-	dbenv->set_errpfx(dbenv, progname);
-	if (nflag) {
-		if ((ret = dbenv->set_flags(dbenv, DB_NOLOCKING, 1)) != 0) {
-			dbenv->err(dbenv, ret, "set_flags: DB_NOLOCKING");
-			goto err;
-		}
-		if ((ret = dbenv->set_flags(dbenv, DB_NOPANIC, 1)) != 0) {
-			dbenv->err(dbenv, ret, "set_flags: DB_NOPANIC");
-			goto err;
-		}
-	}
-	if (passwd != NULL && (ret = dbenv->set_encrypt(dbenv,
-	    passwd, DB_ENCRYPT_AES)) != 0) {
-		dbenv->err(dbenv, ret, "set_passwd");
-		goto err;
-	}
-
-	/* Initialize the environment. */
-	if (db_dump_db_init(dbenv, home, rflag, cache, &private) != 0)
-		goto err;
-
-	/* Create the DB object and open the file. */
-	if ((ret = db_create(&dbp, dbenv, 0)) != 0) {
-		dbenv->err(dbenv, ret, "db_create");
-		goto err;
-	}
-	d_close = 1;
-
-	/*
-	 * If we're salvaging, don't do an open;  it might not be safe.
-	 * Dispatch now into the salvager.
-	 */
-	if (rflag) {
-		if ((ret = dbp->verify(dbp, argv[0], NULL, stdout,
-		    DB_SALVAGE |
-		    (Rflag ? DB_AGGRESSIVE : 0) |
-		    (pflag ? DB_PRINTABLE : 0))) != 0)
-			goto err;
-		exitval = 0;
-		goto done;
-	}
-
-	if ((ret = dbp->open(dbp, NULL,
-	    argv[0], subname, DB_UNKNOWN, DB_RDONLY, 0)) != 0) {
-		dbp->err(dbp, ret, "open: %s", argv[0]);
-		goto err;
-	}
-	if (private != 0) {
-		if ((ret = __db_util_cache(dbenv, dbp, &cache, &resize)) != 0)
-			goto err;
-		if (resize) {
-			(void)dbp->close(dbp, 0);
-			d_close = 0;
-
-			(void)dbenv->close(dbenv, 0);
-			e_close = 0;
-			goto retry;
-		}
-	}
-
-	if (dopt != NULL) {
-		if (__db_dump(dbp, dopt, NULL)) {
-			dbp->err(dbp, ret, "__db_dump: %s", argv[0]);
-			goto err;
-		}
-	} else if (lflag) {
-		if (db_dump_is_sub(dbp, &subs))
-			goto err;
-		if (subs == 0) {
-			dbp->errx(dbp,
-			    "%s: does not contain multiple databases", argv[0]);
-			goto err;
-		}
-		if (db_dump_show_subs(dbp))
-			goto err;
-	} else {
-		subs = 0;
-		if (subname == NULL && db_dump_is_sub(dbp, &subs))
-			goto err;
-		if (subs) {
-			if (db_dump_dump_sub(dbenv, dbp, argv[0], pflag, keyflag))
-				goto err;
-		} else
-			if (__db_prheader(dbp, NULL, pflag, keyflag, stdout,
-			    __db_verify_callback, NULL, 0) ||
-			    db_dump_dump(dbp, pflag, keyflag))
-				goto err;
-	}
-
-	if (0) {
-err:		exitval = 1;
-	}
-done:	if (d_close && (ret = dbp->close(dbp, 0)) != 0) {
-		exitval = 1;
-		dbenv->err(dbenv, ret, "close");
-	}
-	if (e_close && (ret = dbenv->close(dbenv, 0)) != 0) {
-		exitval = 1;
-		fprintf(stderr,
-		    "%s: dbenv->close: %s\n", progname, db_strerror(ret));
-	}
-
-	/* Resend any caught signal. */
-	__db_util_sigresend();
-
-	return (exitval == 0 ? EXIT_SUCCESS : EXIT_FAILURE);
-}
-
-/*
- * db_init --
- *	Initialize the environment.
- */
-int
-db_dump_db_init(dbenv, home, is_salvage, cache, is_privatep)
-	DB_ENV *dbenv;
-	char *home;
-	int is_salvage;
-	u_int32_t cache;
-	int *is_privatep;
-{
-	int ret;
-
-	/*
-	 * Try and use the underlying environment when opening a database.
-	 * We wish to use the buffer pool so our information is as up-to-date
-	 * as possible, even if the mpool cache hasn't been flushed.
-	 *
-	 * If we are not doing a salvage, we wish to use the DB_JOINENV flag;
-	 * if a locking system is present, this will let us use it and be
-	 * safe to run concurrently with other threads of control.  (We never
-	 * need to use transactions explicitly, as we're read-only.)  Note
-	 * that in CDB, too, this will configure our environment
-	 * appropriately, and our cursors will (correctly) do locking as CDB
-	 * read cursors.
-	 *
-	 * If we are doing a salvage, the verification code will protest
-	 * if we initialize transactions, logging, or locking;  do an
-	 * explicit DB_INIT_MPOOL to try to join any existing environment
-	 * before we create our own.
-	 */
-	*is_privatep = 0;
-	if (dbenv->open(dbenv, home,
-	    DB_USE_ENVIRON | (is_salvage ? DB_INIT_MPOOL : DB_JOINENV), 0) == 0)
-		return (0);
-
-	/*
-	 * An environment is required because we may be trying to look at
-	 * databases in directories other than the current one.  We could
-	 * avoid using an environment iff the -h option wasn't specified,
-	 * but that seems like more work than it's worth.
-	 *
-	 * No environment exists (or, at least no environment that includes
-	 * an mpool region exists).  Create one, but make it private so that
-	 * no files are actually created.
-	 */
-	*is_privatep = 1;
-	if ((ret = dbenv->set_cachesize(dbenv, 0, cache, 1)) == 0 &&
-	    (ret = dbenv->open(dbenv, home,
-	    DB_CREATE | DB_INIT_MPOOL | DB_PRIVATE | DB_USE_ENVIRON, 0)) == 0)
-		return (0);
-
-	/* An environment is required. */
-	dbenv->err(dbenv, ret, "open");
-	return (1);
-}
-
-/*
- * is_sub --
- *	Return if the database contains subdatabases.
- */
-int
-db_dump_is_sub(dbp, yesno)
-	DB *dbp;
-	int *yesno;
-{
-	DB_BTREE_STAT *btsp;
-	DB_HASH_STAT *hsp;
-	int ret;
-
-	switch (dbp->type) {
-	case DB_BTREE:
-	case DB_RECNO:
-		if ((ret = dbp->stat(dbp, &btsp, DB_FAST_STAT)) != 0) {
-			dbp->err(dbp, ret, "DB->stat");
-			return (ret);
-		}
-		*yesno = btsp->bt_metaflags & BTM_SUBDB ? 1 : 0;
-		free(btsp);
-		break;
-	case DB_HASH:
-		if ((ret = dbp->stat(dbp, &hsp, DB_FAST_STAT)) != 0) {
-			dbp->err(dbp, ret, "DB->stat");
-			return (ret);
-		}
-		*yesno = hsp->hash_metaflags & DB_HASH_SUBDB ? 1 : 0;
-		free(hsp);
-		break;
-	case DB_QUEUE:
-		break;
-	default:
-		dbp->errx(dbp, "unknown database type");
-		return (1);
-	}
-	return (0);
-}
-
-/*
- * dump_sub --
- *	Dump out the records for a DB containing subdatabases.
- */
-int
-db_dump_dump_sub(dbenv, parent_dbp, parent_name, pflag, keyflag)
-	DB_ENV *dbenv;
-	DB *parent_dbp;
-	char *parent_name;
-	int pflag, keyflag;
-{
-	DB *dbp;
-	DBC *dbcp;
-	DBT key, data;
-	int ret;
-	char *subdb;
-
-	/*
-	 * Get a cursor and step through the database, dumping out each
-	 * subdatabase.
-	 */
-	if ((ret = parent_dbp->cursor(parent_dbp, NULL, &dbcp, 0)) != 0) {
-		dbenv->err(dbenv, ret, "DB->cursor");
-		return (1);
-	}
-
-	memset(&key, 0, sizeof(key));
-	memset(&data, 0, sizeof(data));
-	while ((ret = dbcp->c_get(dbcp, &key, &data, DB_NEXT)) == 0) {
-		/* Nul terminate the subdatabase name. */
-		if ((subdb = malloc(key.size + 1)) == NULL) {
-			dbenv->err(dbenv, ENOMEM, NULL);
-			return (1);
-		}
-		memcpy(subdb, key.data, key.size);
-		subdb[key.size] = '\0';
-
-		/* Create the DB object and open the file. */
-		if ((ret = db_create(&dbp, dbenv, 0)) != 0) {
-			dbenv->err(dbenv, ret, "db_create");
-			free(subdb);
-			return (1);
-		}
-		if ((ret = dbp->open(dbp, NULL,
-		    parent_name, subdb, DB_UNKNOWN, DB_RDONLY, 0)) != 0)
-			dbp->err(dbp, ret,
-			    "DB->open: %s:%s", parent_name, subdb);
-		if (ret == 0 &&
-		    (__db_prheader(dbp, subdb, pflag, keyflag, stdout,
-		    __db_verify_callback, NULL, 0) ||
-		    db_dump_dump(dbp, pflag, keyflag)))
-			ret = 1;
-		(void)dbp->close(dbp, 0);
-		free(subdb);
-		if (ret != 0)
-			return (1);
-	}
-	if (ret != DB_NOTFOUND) {
-		dbp->err(dbp, ret, "DBcursor->get");
-		return (1);
-	}
-
-	if ((ret = dbcp->c_close(dbcp)) != 0) {
-		dbp->err(dbp, ret, "DBcursor->close");
-		return (1);
-	}
-
-	return (0);
-}
-
-/*
- * show_subs --
- *	Display the subdatabases for a database.
- */
-int
-db_dump_show_subs(dbp)
-	DB *dbp;
-{
-	DBC *dbcp;
-	DBT key, data;
-	int ret;
-
-	/*
-	 * Get a cursor and step through the database, printing out the key
-	 * of each key/data pair.
-	 */
-	if ((ret = dbp->cursor(dbp, NULL, &dbcp, 0)) != 0) {
-		dbp->err(dbp, ret, "DB->cursor");
-		return (1);
-	}
-
-	memset(&key, 0, sizeof(key));
-	memset(&data, 0, sizeof(data));
-	while ((ret = dbcp->c_get(dbcp, &key, &data, DB_NEXT)) == 0) {
-		if ((ret = __db_prdbt(&key, 1, NULL, stdout,
-		    __db_verify_callback, 0, NULL)) != 0) {
-			dbp->errx(dbp, NULL);
-			return (1);
-		}
-	}
-	if (ret != DB_NOTFOUND) {
-		dbp->err(dbp, ret, "DBcursor->get");
-		return (1);
-	}
-
-	if ((ret = dbcp->c_close(dbcp)) != 0) {
-		dbp->err(dbp, ret, "DBcursor->close");
-		return (1);
-	}
-	return (0);
-}
-
-/*
- * dump --
- *	Dump out the records for a DB.
- */
-int
-db_dump_dump(dbp, pflag, keyflag)
-	DB *dbp;
-	int pflag, keyflag;
-{
-	DBC *dbcp;
-	DBT key, data;
-	DBT keyret, dataret;
-	db_recno_t recno;
-	int is_recno, failed, ret;
-	void *pointer;
-
-	/*
-	 * Get a cursor and step through the database, printing out each
-	 * key/data pair.
-	 */
-	if ((ret = dbp->cursor(dbp, NULL, &dbcp, 0)) != 0) {
-		dbp->err(dbp, ret, "DB->cursor");
-		return (1);
-	}
-
-	failed = 0;
-	memset(&key, 0, sizeof(key));
-	memset(&data, 0, sizeof(data));
-	data.data = malloc(1024 * 1024);
-	if (data.data == NULL) {
-		dbp->err(dbp, ENOMEM, "bulk get buffer");
-		failed = 1;
-		goto err;
-	}
-	data.ulen = 1024 * 1024;
-	data.flags = DB_DBT_USERMEM;
-	is_recno = (dbp->type == DB_RECNO || dbp->type == DB_QUEUE);
-	keyflag = is_recno ? keyflag : 1;
-	if (is_recno) {
-		keyret.data = &recno;
-		keyret.size = sizeof(recno);
-	}
-
-retry:
-	while ((ret =
-	    dbcp->c_get(dbcp, &key, &data, DB_NEXT | DB_MULTIPLE_KEY)) == 0) {
-		DB_MULTIPLE_INIT(pointer, &data);
-		for (;;) {
-			if (is_recno)
-				DB_MULTIPLE_RECNO_NEXT(pointer, &data,
-				    recno, dataret.data, dataret.size);
-			else
-				DB_MULTIPLE_KEY_NEXT(pointer,
-				    &data, keyret.data,
-				    keyret.size, dataret.data, dataret.size);
-
-			if (dataret.data == NULL)
-				break;
-
-			if ((keyflag && (ret = __db_prdbt(&keyret,
-			    pflag, " ", stdout, __db_verify_callback,
-			    is_recno, NULL)) != 0) || (ret =
-			    __db_prdbt(&dataret, pflag, " ", stdout,
-				__db_verify_callback, 0, NULL)) != 0) {
-				dbp->errx(dbp, NULL);
-				failed = 1;
-				goto err;
-			}
-		}
-	}
-	if (ret == ENOMEM) {
-		data.data = realloc(data.data, data.size);
-		if (data.data == NULL) {
-			dbp->err(dbp, ENOMEM, "bulk get buffer");
-			failed = 1;
-			goto err;
-		}
-		data.ulen = data.size;
-		goto retry;
-	}
-
-	if (ret != DB_NOTFOUND) {
-		dbp->err(dbp, ret, "DBcursor->get");
-		failed = 1;
-	}
-
-err:	if (data.data != NULL)
-		free(data.data);
-
-	if ((ret = dbcp->c_close(dbcp)) != 0) {
-		dbp->err(dbp, ret, "DBcursor->close");
-		failed = 1;
-	}
-
-	(void)__db_prfooter(stdout, __db_verify_callback);
-	return (failed);
-}
-
-/*
- * usage --
- *	Display the usage message.
- */
-int
-db_dump_usage()
-{
-	(void)fprintf(stderr, "%s\n\t%s\n",
-	    "usage: db_dump [-klNprRV]",
-    "[-d ahr] [-f output] [-h home] [-P password] [-s database] db_file");
-	return (EXIT_FAILURE);
-}
-
-int
-db_dump_version_check(progname)
-	const char *progname;
-{
-	int v_major, v_minor, v_patch;
-
-	/* Make sure we're loaded with the right version of the DB library. */
-	(void)db_version(&v_major, &v_minor, &v_patch);
-	if (v_major != DB_VERSION_MAJOR ||
-	    v_minor != DB_VERSION_MINOR || v_patch != DB_VERSION_PATCH) {
-		fprintf(stderr,
-	"%s: version %d.%d.%d doesn't match library version %d.%d.%d\n",
-		    progname, DB_VERSION_MAJOR, DB_VERSION_MINOR,
-		    DB_VERSION_PATCH, v_major, v_minor, v_patch);
-		return (EXIT_FAILURE);
-	}
-	return (0);
-}
diff --git a/bdb/build_vxworks/db_dump/db_dump.wpj b/bdb/build_vxworks/db_dump/db_dump.wpj
deleted file mode 100755
index 6813766e5f146dc533b82236a81ddd7a85dce142..0000000000000000000000000000000000000000
--- a/bdb/build_vxworks/db_dump/db_dump.wpj
+++ /dev/null
@@ -1,160 +0,0 @@
-Document file - DO NOT EDIT
-
-<BEGIN> BUILD_PENTIUMgnu_BUILDRULE
-db_dump.out
-<END>
-
-<BEGIN> BUILD_PENTIUMgnu_MACRO_AR
-ar386
-<END>
-
-<BEGIN> BUILD_PENTIUMgnu_MACRO_ARCHIVE
-$(PRJ_DIR)/PENTIUMgnu/db_dump.a
-<END>
-
-<BEGIN> BUILD_PENTIUMgnu_MACRO_AS
-cc386
-<END>
-
-<BEGIN> BUILD_PENTIUMgnu_MACRO_CC
-cc386
-<END>
-
-<BEGIN> BUILD_PENTIUMgnu_MACRO_CFLAGS
--g \
-	-mpentium \
-	-ansi \
-	-nostdinc \
-	-DRW_MULTI_THREAD \
-	-D_REENTRANT \
-	-fvolatile \
-	-nostdlib \
-	-fno-builtin \
-	-fno-defer-pop \
-	-I$(PRJ_DIR)/.. \
-	-I$(PRJ_DIR)/../.. \
-	-I$(WIND_BASE)/target/h \
-	-DCPU=PENTIUM
-<END>
-
-<BEGIN> BUILD_PENTIUMgnu_MACRO_CFLAGS_AS
--g \
-	-mpentium \
-	-ansi \
-	-nostdinc \
-	-fvolatile \
-	-nostdlib \
-	-fno-builtin \
-	-fno-defer-pop \
-	-P \
-	-x \
-	assembler-with-cpp \
-	-I$(WIND_BASE)/target/h \
-	-DCPU=PENTIUM
-<END>
-
-<BEGIN> BUILD_PENTIUMgnu_MACRO_CPP
-cc386 -E -P -xc
-<END>
-
-<BEGIN> BUILD_PENTIUMgnu_MACRO_LD
-ld386
-<END>
-
-<BEGIN> BUILD_PENTIUMgnu_MACRO_LDDEPS
-
-<END>
-
-<BEGIN> BUILD_PENTIUMgnu_MACRO_LDFLAGS
--X -N
-<END>
-
-<BEGIN> BUILD_PENTIUMgnu_MACRO_LD_PARTIAL_FLAGS
--X -r
-<END>
-
-<BEGIN> BUILD_PENTIUMgnu_MACRO_NM
-nm386 -g
-<END>
-
-<BEGIN> BUILD_PENTIUMgnu_MACRO_OPTION_DEFINE_MACRO
--D
-<END>
-
-<BEGIN> BUILD_PENTIUMgnu_MACRO_OPTION_INCLUDE_DIR
--I
-<END>
-
-<BEGIN> BUILD_PENTIUMgnu_MACRO_POST_BUILD_RULE
-
-<END>
-
-<BEGIN> BUILD_PENTIUMgnu_MACRO_PRJ_LIBS
-
-<END>
-
-<BEGIN> BUILD_PENTIUMgnu_MACRO_SIZE
-size386
-<END>
-
-<BEGIN> BUILD_PENTIUMgnu_RO_DEPEND_PATH
-{$(WIND_BASE)/target/h/} \
-	{$(WIND_BASE)/target/src/} \
-	{$(WIND_BASE)/target/config/}
-<END>
-
-<BEGIN> BUILD_PENTIUMgnu_TC
-::tc_PENTIUMgnu
-<END>
-
-<BEGIN> BUILD_RULE_archive
-
-<END>
-
-<BEGIN> BUILD_RULE_db_dump.out
-
-<END>
-
-<BEGIN> BUILD_RULE_objects
-
-<END>
-
-<BEGIN> BUILD__CURRENT
-PENTIUMgnu
-<END>
-
-<BEGIN> BUILD__LIST
-PENTIUMgnu
-<END>
-
-<BEGIN> CORE_INFO_TYPE
-::prj_vxApp
-<END>
-
-<BEGIN> CORE_INFO_VERSION
-2.0
-<END>
-
-<BEGIN> FILE_db_dump.c_dependDone
-FALSE
-<END>
-
-<BEGIN> FILE_db_dump.c_dependencies
-
-<END>
-
-<BEGIN> FILE_db_dump.c_objects
-db_dump.o
-<END>
-
-<BEGIN> FILE_db_dump.c_tool
-C/C++ compiler
-<END>
-
-<BEGIN> PROJECT_FILES
-$(PRJ_DIR)/db_dump.c
-<END>
-
-<BEGIN> userComments
-db_dump
-<END>
diff --git a/bdb/build_vxworks/db_dump/db_dump/Makefile.custom b/bdb/build_vxworks/db_dump/db_dump/Makefile.custom
deleted file mode 100644
index ca781f7b251ef99e49e5fc1859ee6cf3d67c60b0..0000000000000000000000000000000000000000
--- a/bdb/build_vxworks/db_dump/db_dump/Makefile.custom
+++ /dev/null
@@ -1,51 +0,0 @@
-#
-# Custom Makefile shell
-#
-# This file may be edited freely, since it will not be regenerated
-# by the project manager.
-#
-# Use this makefile to define rules to make external binaries
-# and deposit them in the $(EXTERNAL_BINARIES_DIR) directory.
-#
-# If you have specified external modules during your component
-# creation, you will find make rules already in place below.
-# You will likely have to edit these to suit your individual
-# build setup.
-#
-# You may wish to use the CPU, BUILD_SPEC or TOOL make variables in
-# your Makefile to support builds for different architectures.  Use
-# the FORCE_EXTERNAL_MAKE phony target to ensure that your external
-# make always runs.
-#
-# The example below assumes that your custom makefile is in the
-# mySourceTree directory, and that the binary file it produces
-# is placed into the $(BUILD_SPEC) sub-directory.
-#
-# EXTERNAL_SOURCE_BASE = /folk/me/mySourceTree
-# EXTERNAL_MODULE = myLibrary.o
-# EXTERNAL_MAKE = make
-#
-# $(EXTERNAL_BINARIES_DIR)/$(EXTERNAL_MODULE) : FORCE_EXTERNAL_MAKE
-#	$(EXTERNAL_MAKE) -C $(EXTERNAL_SOURCE_BASE) \
-#	-f $(EXTERNAL_SOURCE_BASE)/Makefile \
-#	CPU=$(CPU) BUILD_SPEC=$(BUILD_SPEC) $(@F)
-#	$(CP) $(subst /,$(DIRCHAR),$(EXTERNAL_SOURCE_BASE)/$(BUILD_SPEC)/$(@F) $@)
-#
-# If you are not adding your external modules from the component wizard,
-# you will have to include them in your component yourself:
-#
-# From the GUI, you can do this with the Component's 'Add external module'
-# dialog.
-#
-# If you are using the command line, add the module(s) by editing the
-# MODULES line in component.cdf file, e.g.
-#
-# Component INCLUDE_MYCOMPONENT {
-#
-#   MODULES         foo.o goo.o \
-#         myLibrary.o
-#
-
-
-# rules to build custom libraries
-
diff --git a/bdb/build_vxworks/db_dump/db_dump/component.cdf b/bdb/build_vxworks/db_dump/db_dump/component.cdf
deleted file mode 100755
index 5c1d4ccf3084f10c3c37708a4a1ee63b7991250f..0000000000000000000000000000000000000000
--- a/bdb/build_vxworks/db_dump/db_dump/component.cdf
+++ /dev/null
@@ -1,30 +0,0 @@
-/* component.cdf - dynamically updated configuration */
-
-/*
- * NOTE: you may edit this file to alter the configuration
- * But all non-configuration information, including comments,
- * will be lost upon rebuilding this project.
- */
-
-/* Component information */
-
-Component INCLUDE_DB_DUMP {
-	ENTRY_POINTS	ALL_GLOBAL_SYMBOLS 
-	MODULES		db_dump.o 
-	NAME		db_dump
-	PREF_DOMAIN	ANY
-	_INIT_ORDER	usrComponentsInit
-}
-
-/* EntryPoint information */
-
-/* Module information */
-
-Module db_dump.o {
-
-	NAME		db_dump.o
-	SRC_PATH_NAME	$PRJ_DIR/../db_dump.c
-}
-
-/* Parameter information */
-
diff --git a/bdb/build_vxworks/db_dump/db_dump/component.wpj b/bdb/build_vxworks/db_dump/db_dump/component.wpj
deleted file mode 100755
index e234641f49837d3805c62f491aae6f008427ee46..0000000000000000000000000000000000000000
--- a/bdb/build_vxworks/db_dump/db_dump/component.wpj
+++ /dev/null
@@ -1,475 +0,0 @@
-Document file - DO NOT EDIT
-
-<BEGIN> CORE_INFO_TYPE
-::prj_component
-<END>
-
-<BEGIN> CORE_INFO_VERSION
-AE1.1
-<END>
-
-<BEGIN> BUILD__CURRENT
-PENTIUM2gnu.debug
-<END>
-
-<BEGIN> BUILD_PENTIUM2gnu.debug_CURRENT_TARGET
-default
-<END>
-
-<BEGIN> BUILD_PENTIUM2gnu.debug_DEFAULTFORCPU
-1
-<END>
-
-<BEGIN> BUILD_PENTIUM2gnu.debug_FILE_$(PRJ_DIR)/../db_dump.c_infoTags
-toolMacro objects
-<END>
-
-<BEGIN> BUILD_PENTIUM2gnu.debug_FILE_$(PRJ_DIR)/../db_dump.c_objects
-db_dump.o
-<END>
-
-<BEGIN> BUILD_PENTIUM2gnu.debug_FILE_$(PRJ_DIR)/../db_dump.c_toolMacro
-CC
-<END>
-
-<BEGIN> BUILD_PENTIUM2gnu.debug_FILE_$(PRJ_DIR)/../db_dump.c_objects
-db_dump.o
-<END>
-
-<BEGIN> BUILD_PENTIUM2gnu.debug_FILE_$(PRJ_DIR)/../db_dump.c_toolMacro
-CC
-<END>
-
-<BEGIN> BUILD_PENTIUM2gnu.debug_FILE_$(PRJ_DIR)/compConfig.c_infoTags
-toolMacro objects
-<END>
-
-<BEGIN> BUILD_PENTIUM2gnu.debug_FILE_$(PRJ_DIR)/compConfig.c_objects
-compConfig.o
-<END>
-
-<BEGIN> BUILD_PENTIUM2gnu.debug_FILE_$(PRJ_DIR)/compConfig.c_toolMacro
-CC
-<END>
-
-<BEGIN> BUILD_PENTIUM2gnu.debug_MACRO_AR
-arpentium
-<END>
-
-<BEGIN> BUILD_PENTIUM2gnu.debug_MACRO_AS
-ccpentium
-<END>
-
-<BEGIN> BUILD_PENTIUM2gnu.debug_MACRO_CC
-ccpentium
-<END>
-
-<BEGIN> BUILD_PENTIUM2gnu.debug_MACRO_CFLAGS
--mcpu=pentiumpro \
-	-march=pentiumpro \
-	-ansi \
-	-DRW_MULTI_THREAD \
-	-D_REENTRANT \
-	-g \
-	-nostdlib \
-	-fno-builtin \
-	-fno-defer-pop \
-	-MD \
-	-Wall \
-	-I. \
-	-I$(WIND_BASE)/target/h \
-	-I$(PRJ_DIR)/../.. \
-	-I$(PRJ_DIR)/../../.. \
-	-DCPU=PENTIUM2
-<END>
-
-<BEGIN> BUILD_PENTIUM2gnu.debug_MACRO_CFLAGS_AS
--mcpu=pentiumpro \
-	-march=pentiumpro \
-	-ansi \
-	-g \
-	-nostdlib \
-	-fno-builtin \
-	-fno-defer-pop \
-	-P \
-	-x \
-	assembler-with-cpp \
-	-Wall \
-	-I. \
-	-I$(WIND_BASE)/target/h \
-	-DCPU=PENTIUM2
-<END>
-
-<BEGIN> BUILD_PENTIUM2gnu.debug_MACRO_CPP
-ccpentium -E -P
-<END>
-
-<BEGIN> BUILD_PENTIUM2gnu.debug_MACRO_CPPFILT
-c++filtpentium --strip-underscores
-<END>
-
-<BEGIN> BUILD_PENTIUM2gnu.debug_MACRO_LD
-ldpentium
-<END>
-
-<BEGIN> BUILD_PENTIUM2gnu.debug_MACRO_LDFLAGS
--X
-<END>
-
-<BEGIN> BUILD_PENTIUM2gnu.debug_MACRO_LDPARTIAL
-ccpentium \
-	-B$(WIND_BASE)/host/$(WIND_HOST_TYPE)/lib/gcc-lib/ \
-	-nostdlib \
-	-r \
-	-Wl,-X
-<END>
-
-<BEGIN> BUILD_PENTIUM2gnu.debug_MACRO_LD_PARTIAL_FLAGS
--X -r
-<END>
-
-<BEGIN> BUILD_PENTIUM2gnu.debug_MACRO_NM
-nmpentium -g
-<END>
-
-<BEGIN> BUILD_PENTIUM2gnu.debug_MACRO_OPTION_DEFINE_MACRO
--D
-<END>
-
-<BEGIN> BUILD_PENTIUM2gnu.debug_MACRO_OPTION_GENERATE_DEPENDENCY_FILE
--MD
-<END>
-
-<BEGIN> BUILD_PENTIUM2gnu.debug_MACRO_OPTION_INCLUDE_DIR
--I
-<END>
-
-<BEGIN> BUILD_PENTIUM2gnu.debug_MACRO_RELEASE
-0
-<END>
-
-<BEGIN> BUILD_PENTIUM2gnu.debug_MACRO_SIZE
-sizepentium
-<END>
-
-<BEGIN> BUILD_PENTIUM2gnu.debug_RELEASE
-0
-<END>
-
-<BEGIN> BUILD_PENTIUM2gnu.debug_RO_DEPEND_PATH
-$(WIND_BASE)/target/h/
-<END>
-
-<BEGIN> BUILD_PENTIUM2gnu.debug_TC
-::tc_PENTIUM2gnu.debug
-<END>
-
-<BEGIN> BUILD_PENTIUM2gnu.release_DEFAULTFORCPU
-0
-<END>
-
-<BEGIN> BUILD_PENTIUM2gnu.release_FILE_$(PRJ_DIR)/../db_dump.c_infoTags
-toolMacro objects
-<END>
-
-<BEGIN> BUILD_PENTIUM2gnu.release_FILE_$(PRJ_DIR)/../db_dump.c_objects
-db_dump.o
-<END>
-
-<BEGIN> BUILD_PENTIUM2gnu.release_FILE_$(PRJ_DIR)/../db_dump.c_toolMacro
-CC
-<END>
-
-<BEGIN> BUILD_PENTIUM2gnu.release_FILE_$(PRJ_DIR)/compConfig.c_infoTags
-toolMacro objects
-<END>
-
-<BEGIN> BUILD_PENTIUM2gnu.release_FILE_$(PRJ_DIR)/compConfig.c_objects
-compConfig.o
-<END>
-
-<BEGIN> BUILD_PENTIUM2gnu.release_FILE_$(PRJ_DIR)/compConfig.c_toolMacro
-CC
-<END>
-
-<BEGIN> BUILD_PENTIUM2gnu.release_MACRO_AR
-arpentium
-<END>
-
-<BEGIN> BUILD_PENTIUM2gnu.release_MACRO_AS
-ccpentium
-<END>
-
-<BEGIN> BUILD_PENTIUM2gnu.release_MACRO_CC
-ccpentium
-<END>
-
-<BEGIN> BUILD_PENTIUM2gnu.release_MACRO_CFLAGS
--mcpu=pentiumpro \
-	-march=pentiumpro \
-	-ansi \
-	-DRW_MULTI_THREAD \
-	-D_REENTRANT \
-	-O2 \
-	-nostdlib \
-	-fno-builtin \
-	-fno-defer-pop \
-	-MD \
-	-Wall \
-	-I. \
-	-I$(WIND_BASE)/target/h \
-	-I$(PRJ_DIR)/../.. \
-	-I$(PRJ_DIR)/../../.. \
-	-DCPU=PENTIUM2
-<END>
-
-<BEGIN> BUILD_PENTIUM2gnu.release_MACRO_CFLAGS_AS
--mcpu=pentiumpro \
-	-march=pentiumpro \
-	-ansi \
-	-O2 \
-	-nostdlib \
-	-fno-builtin \
-	-fno-defer-pop \
-	-P \
-	-x \
-	assembler-with-cpp \
-	-Wall \
-	-I. \
-	-I$(WIND_BASE)/target/h \
-	-DCPU=PENTIUM2
-<END>
-
-<BEGIN> BUILD_PENTIUM2gnu.release_MACRO_CPP
-ccpentium -E -P
-<END>
-
-<BEGIN> BUILD_PENTIUM2gnu.release_MACRO_CPPFILT
-c++filtpentium --strip-underscores
-<END>
-
-<BEGIN> BUILD_PENTIUM2gnu.release_MACRO_LD
-ldpentium
-<END>
-
-<BEGIN> BUILD_PENTIUM2gnu.release_MACRO_LDFLAGS
--X
-<END>
-
-<BEGIN> BUILD_PENTIUM2gnu.release_MACRO_LDPARTIAL
-ccpentium \
-	-B$(WIND_BASE)/host/$(WIND_HOST_TYPE)/lib/gcc-lib/ \
-	-nostdlib \
-	-r \
-	-Wl,-X
-<END>
-
-<BEGIN> BUILD_PENTIUM2gnu.release_MACRO_LD_PARTIAL_FLAGS
--X -r
-<END>
-
-<BEGIN> BUILD_PENTIUM2gnu.release_MACRO_NM
-nmpentium -g
-<END>
-
-<BEGIN> BUILD_PENTIUM2gnu.release_MACRO_OPTION_DEFINE_MACRO
--D
-<END>
-
-<BEGIN> BUILD_PENTIUM2gnu.release_MACRO_OPTION_GENERATE_DEPENDENCY_FILE
--MD
-<END>
-
-<BEGIN> BUILD_PENTIUM2gnu.release_MACRO_OPTION_INCLUDE_DIR
--I
-<END>
-
-<BEGIN> BUILD_PENTIUM2gnu.release_MACRO_RELEASE
-1
-<END>
-
-<BEGIN> BUILD_PENTIUM2gnu.release_MACRO_SIZE
-sizepentium
-<END>
-
-<BEGIN> BUILD_PENTIUM2gnu.release_RELEASE
-1
-<END>
-
-<BEGIN> BUILD_PENTIUM2gnu.release_RO_DEPEND_PATH
-$(WIND_BASE)/target/h/
-<END>
-
-<BEGIN> BUILD_PENTIUM2gnu.release_TC
-::tc_PENTIUM2gnu.release
-<END>
-
-<BEGIN> BUILD_PENTIUMgnu.debug_DEFAULTFORCPU
-1
-<END>
-
-<BEGIN> BUILD_PENTIUMgnu.debug_FILE_$(PRJ_DIR)/../db_dump.c_infoTags
-toolMacro objects
-<END>
-
-<BEGIN> BUILD_PENTIUMgnu.debug_FILE_$(PRJ_DIR)/../db_dump.c_objects
-db_dump.o
-<END>
-
-<BEGIN> BUILD_PENTIUMgnu.debug_FILE_$(PRJ_DIR)/../db_dump.c_toolMacro
-CC
-<END>
-
-<BEGIN> BUILD_PENTIUMgnu.debug_FILE_$(PRJ_DIR)/compConfig.c_infoTags
-toolMacro objects
-<END>
-
-<BEGIN> BUILD_PENTIUMgnu.debug_FILE_$(PRJ_DIR)/compConfig.c_objects
-compConfig.o
-<END>
-
-<BEGIN> BUILD_PENTIUMgnu.debug_FILE_$(PRJ_DIR)/compConfig.c_toolMacro
-CC
-<END>
-
-<BEGIN> BUILD_PENTIUMgnu.debug_MACRO_AR
-arpentium
-<END>
-
-<BEGIN> BUILD_PENTIUMgnu.debug_MACRO_AS
-ccpentium
-<END>
-
-<BEGIN> BUILD_PENTIUMgnu.debug_MACRO_CC
-ccpentium
-<END>
-
-<BEGIN> BUILD_PENTIUMgnu.debug_MACRO_CFLAGS
--mcpu=pentium \
-	-march=pentium \
-	-ansi \
-	-DRW_MULTI_THREAD \
-	-D_REENTRANT \
-	-g \
-	-nostdlib \
-	-fno-builtin \
-	-fno-defer-pop \
-	-MD \
-	-Wall \
-	-I. \
-	-I$(WIND_BASE)/target/h \
-	-I$(PRJ_DIR)/../.. \
-	-I$(PRJ_DIR)/../../.. \
-	-DCPU=PENTIUM
-<END>
-
-<BEGIN> BUILD_PENTIUMgnu.debug_MACRO_CFLAGS_AS
--mcpu=pentium \
-	-march=pentium \
-	-ansi \
-	-g \
-	-nostdlib \
-	-fno-builtin \
-	-fno-defer-pop \
-	-P \
-	-x \
-	assembler-with-cpp \
-	-Wall \
-	-I. \
-	-I$(WIND_BASE)/target/h \
-	-DCPU=PENTIUM
-<END>
-
-<BEGIN> BUILD_PENTIUMgnu.debug_MACRO_CPP
-ccpentium -E -P
-<END>
-
-<BEGIN> BUILD_PENTIUMgnu.debug_MACRO_CPPFILT
-c++filtpentium --strip-underscores
-<END>
-
-<BEGIN> BUILD_PENTIUMgnu.debug_MACRO_LD
-ldpentium
-<END>
-
-<BEGIN> BUILD_PENTIUMgnu.debug_MACRO_LDFLAGS
--X
-<END>
-
-<BEGIN> BUILD_PENTIUMgnu.debug_MACRO_LDPARTIAL
-ccpentium \
-	-B$(WIND_BASE)/host/$(WIND_HOST_TYPE)/lib/gcc-lib/ \
-	-nostdlib \
-	-r \
-	-Wl,-X
-<END>
-
-<BEGIN> BUILD_PENTIUMgnu.debug_MACRO_LD_PARTIAL_FLAGS
--X -r
-<END>
-
-<BEGIN> BUILD_PENTIUMgnu.debug_MACRO_NM
-nmpentium -g
-<END>
-
-<BEGIN> BUILD_PENTIUMgnu.debug_MACRO_OPTION_DEFINE_MACRO
--D
-<END>
-
-<BEGIN> BUILD_PENTIUMgnu.debug_MACRO_OPTION_GENERATE_DEPENDENCY_FILE
--MD
-<END>
-
-<BEGIN> BUILD_PENTIUMgnu.debug_MACRO_OPTION_INCLUDE_DIR
--I
-<END>
-
-<BEGIN> BUILD_PENTIUMgnu.debug_MACRO_RELEASE
-0
-<END>
-
-<BEGIN> BUILD_PENTIUMgnu.debug_MACRO_SIZE
-sizepentium
-<END>
-
-<BEGIN> BUILD_PENTIUMgnu.debug_RELEASE
-0
-<END>
-
-<BEGIN> BUILD_PENTIUMgnu.debug_RO_DEPEND_PATH
-$(WIND_BASE)/target/h/
-<END>
-
-<BEGIN> BUILD_PENTIUMgnu.debug_TC
-::tc_PENTIUMgnu.debug
-<END>
-
-<BEGIN> BUILD__LIST
-PENTIUM2gnu.debug PENTIUM2gnu.release PENTIUMgnu.debug
-<END>
-
-<BEGIN> PROJECT_FILES
-$(PRJ_DIR)/../db_dump.c \
-	$(PRJ_DIR)/compConfig.c
-<END>
-
-<BEGIN> WCC__CDF_PATH
-$(PRJ_DIR)
-<END>
-
-<BEGIN> WCC__CURRENT
-PENTIUM2gnu.debug
-<END>
-
-<BEGIN> WCC__LIST
-PENTIUM2gnu.debug
-<END>
-
-<BEGIN> WCC__MXR_LIBS
-lib$(CPU)$(TOOL)vx.a
-<END>
-
-<BEGIN> WCC__OBJS_PATH
-$(WIND_BASE)/target/lib/obj$CPU$TOOLvx
-<END>
-
diff --git a/bdb/build_vxworks/db_load/db_load.c b/bdb/build_vxworks/db_load/db_load.c
deleted file mode 100644
index 6eedae590b1666abc41d8e4340a910a7c3c9c0f4..0000000000000000000000000000000000000000
--- a/bdb/build_vxworks/db_load/db_load.c
+++ /dev/null
@@ -1,1247 +0,0 @@
-/*-
- * See the file LICENSE for redistribution information.
- *
- * Copyright (c) 1996-2002
- *	Sleepycat Software.  All rights reserved.
- */
-
-#include "db_config.h"
-
-#ifndef lint
-static const char copyright[] =
-    "Copyright (c) 1996-2002\nSleepycat Software Inc.  All rights reserved.\n";
-static const char revid[] =
-    "$Id: db_load.c,v 11.71 2002/08/08 03:50:36 bostic Exp $";
-#endif
-
-#ifndef NO_SYSTEM_INCLUDES
-#include <sys/types.h>
-
-#include <limits.h>
-#include <stdio.h>
-#include <stdlib.h>
-#include <string.h>
-#include <unistd.h>
-#endif
-
-#include "db_int.h"
-#include "dbinc/db_page.h"
-#include "dbinc/db_am.h"
-
-typedef struct {			/* XXX: Globals. */
-	const char *progname;		/* Program name. */
-	char	*hdrbuf;		/* Input file header. */
-	u_long	lineno;			/* Input file line number. */
-	u_long	origline;		/* Original file line number. */
-	int	endodata;		/* Reached the end of a database. */
-	int	endofile;		/* Reached the end of the input. */
-	int	version;		/* Input version. */
-	char	*home;			/* Env home. */
-	char	*passwd;		/* Env passwd. */
-	int	private;		/* Private env. */
-	u_int32_t cache;		/* Env cache size. */
-} LDG;
-
-void	db_load_badend __P((DB_ENV *));
-void	db_load_badnum __P((DB_ENV *));
-int	db_load_configure __P((DB_ENV *, DB *, char **, char **, int *));
-int	db_load_convprintable __P((DB_ENV *, char *, char **));
-int	db_load_db_init __P((DB_ENV *, char *, u_int32_t, int *));
-int	db_load_dbt_rdump __P((DB_ENV *, DBT *));
-int	db_load_dbt_rprint __P((DB_ENV *, DBT *));
-int	db_load_dbt_rrecno __P((DB_ENV *, DBT *, int));
-int	db_load_digitize __P((DB_ENV *, int, int *));
-int	db_load_env_create __P((DB_ENV **, LDG *));
-int	db_load_load __P((DB_ENV *, char *, DBTYPE, char **, u_int, LDG *, int *));
-int	db_load_main __P((int, char *[]));
-int	db_load_rheader __P((DB_ENV *, DB *, DBTYPE *, char **, int *, int *));
-int	db_load_usage __P((void));
-int	db_load_version_check __P((const char *));
-
-#define	G(f)	((LDG *)dbenv->app_private)->f
-
-					/* Flags to the load function. */
-#define	LDF_NOHEADER	0x01		/* No dump header. */
-#define	LDF_NOOVERWRITE	0x02		/* Don't overwrite existing rows. */
-#define	LDF_PASSWORD	0x04		/* Encrypt created databases. */
-
-int
-db_load(args)
-	char *args;
-{
-	int argc;
-	char **argv;
-
-	__db_util_arg("db_load", args, &argc, &argv);
-	return (db_load_main(argc, argv) ? EXIT_FAILURE : EXIT_SUCCESS);
-}
-
-#include <stdio.h>
-#define	ERROR_RETURN	ERROR
-
-int
-db_load_main(argc, argv)
-	int argc;
-	char *argv[];
-{
-	extern char *optarg;
-	extern int optind, __db_getopt_reset;
-	DBTYPE dbtype;
-	DB_ENV	*dbenv;
-	LDG ldg;
-	u_int32_t ldf;
-	int ch, existed, exitval, ret;
-	char **clist, **clp;
-
-	ldg.progname = "db_load";
-	ldg.lineno = 0;
-	ldg.endodata = ldg.endofile = 0;
-	ldg.version = 1;
-	ldg.cache = MEGABYTE;
-	ldg.hdrbuf = NULL;
-	ldg.home = NULL;
-	ldg.passwd = NULL;
-
-	if ((ret = db_load_version_check(ldg.progname)) != 0)
-		return (ret);
-
-	ldf = 0;
-	exitval = 0;
-	dbtype = DB_UNKNOWN;
-
-	/* Allocate enough room for configuration arguments. */
-	if ((clp = clist = (char **)calloc(argc + 1, sizeof(char *))) == NULL) {
-		fprintf(stderr, "%s: %s\n", ldg.progname, strerror(ENOMEM));
-		return (EXIT_FAILURE);
-	}
-
-	__db_getopt_reset = 1;
-	while ((ch = getopt(argc, argv, "c:f:h:nP:Tt:V")) != EOF)
-		switch (ch) {
-		case 'c':
-			*clp++ = optarg;
-			break;
-		case 'f':
-			if (freopen(optarg, "r", stdin) == NULL) {
-				fprintf(stderr, "%s: %s: reopen: %s\n",
-				    ldg.progname, optarg, strerror(errno));
-				return (EXIT_FAILURE);
-			}
-			break;
-		case 'h':
-			ldg.home = optarg;
-			break;
-		case 'n':
-			ldf |= LDF_NOOVERWRITE;
-			break;
-		case 'P':
-			ldg.passwd = strdup(optarg);
-			memset(optarg, 0, strlen(optarg));
-			if (ldg.passwd == NULL) {
-				fprintf(stderr, "%s: strdup: %s\n",
-				    ldg.progname, strerror(errno));
-				return (EXIT_FAILURE);
-			}
-			ldf |= LDF_PASSWORD;
-			break;
-		case 'T':
-			ldf |= LDF_NOHEADER;
-			break;
-		case 't':
-			if (strcmp(optarg, "btree") == 0) {
-				dbtype = DB_BTREE;
-				break;
-			}
-			if (strcmp(optarg, "hash") == 0) {
-				dbtype = DB_HASH;
-				break;
-			}
-			if (strcmp(optarg, "recno") == 0) {
-				dbtype = DB_RECNO;
-				break;
-			}
-			if (strcmp(optarg, "queue") == 0) {
-				dbtype = DB_QUEUE;
-				break;
-			}
-			return (db_load_usage());
-		case 'V':
-			printf("%s\n", db_version(NULL, NULL, NULL));
-			return (EXIT_SUCCESS);
-		case '?':
-		default:
-			return (db_load_usage());
-		}
-	argc -= optind;
-	argv += optind;
-
-	if (argc != 1)
-		return (db_load_usage());
-
-	/* Handle possible interruptions. */
-	__db_util_siginit();
-
-	/*
-	 * Create an environment object initialized for error reporting, and
-	 * then open it.
-	 */
-	if (db_load_env_create(&dbenv, &ldg) != 0)
-		goto shutdown;
-
-	while (!ldg.endofile)
-		if (db_load_load(dbenv, argv[0], dbtype, clist, ldf,
-		    &ldg, &existed) != 0)
-			goto shutdown;
-
-	if (0) {
-shutdown:	exitval = 1;
-	}
-	if ((ret = dbenv->close(dbenv, 0)) != 0) {
-		exitval = 1;
-		fprintf(stderr,
-		    "%s: dbenv->close: %s\n", ldg.progname, db_strerror(ret));
-	}
-
-	/* Resend any caught signal. */
-	__db_util_sigresend();
-	free(clist);
-
-	/*
-	 * Return 0 on success, 1 if keys existed already, and 2 on failure.
-	 *
-	 * Technically, this is wrong, because exit of anything other than
-	 * 0 is implementation-defined by the ANSI C standard.  I don't see
-	 * any good solutions that don't involve API changes.
-	 */
-	return (exitval == 0 ? (existed == 0 ? 0 : 1) : 2);
-}
-
-/*
- * load --
- *	Load a database.
- */
-int
-db_load_load(dbenv, name, argtype, clist, flags, ldg, existedp)
-	DB_ENV *dbenv;
-	char *name, **clist;
-	DBTYPE argtype;
-	u_int flags;
-	LDG *ldg;
-	int *existedp;
-{
-	DB *dbp;
-	DBT key, rkey, data, *readp, *writep;
-	DBTYPE dbtype;
-	DB_TXN *ctxn, *txn;
-	db_recno_t recno, datarecno;
-	u_int32_t put_flags;
-	int ascii_recno, checkprint, hexkeys, keyflag, keys, resize, ret, rval;
-	char *subdb;
-
-	*existedp = 0;
-
-	put_flags = LF_ISSET(LDF_NOOVERWRITE) ? DB_NOOVERWRITE : 0;
-	G(endodata) = 0;
-
-	subdb = NULL;
-	ctxn = txn = NULL;
-	memset(&key, 0, sizeof(DBT));
-	memset(&data, 0, sizeof(DBT));
-	memset(&rkey, 0, sizeof(DBT));
-
-retry_db:
-	/* Create the DB object. */
-	if ((ret = db_create(&dbp, dbenv, 0)) != 0) {
-		dbenv->err(dbenv, ret, "db_create");
-		goto err;
-	}
-
-	dbtype = DB_UNKNOWN;
-	keys = -1;
-	hexkeys = -1;
-	keyflag = -1;
-	/* Read the header -- if there's no header, we expect flat text. */
-	if (LF_ISSET(LDF_NOHEADER)) {
-		checkprint = 1;
-		dbtype = argtype;
-	} else {
-		if (db_load_rheader(dbenv,
-		    dbp, &dbtype, &subdb, &checkprint, &keys) != 0)
-			goto err;
-		if (G(endofile))
-			goto done;
-	}
-
-	/*
-	 * Apply command-line configuration changes.  (We apply command-line
-	 * configuration changes to all databases that are loaded, e.g., all
-	 * subdatabases.)
-	 */
-	if (db_load_configure(dbenv, dbp, clist, &subdb, &keyflag))
-		goto err;
-
-	if (keys != 1) {
-		if (keyflag == 1) {
-			dbp->err(dbp, EINVAL, "No keys specified in file");
-			goto err;
-		}
-	}
-	else if (keyflag == 0) {
-		dbp->err(dbp, EINVAL, "Keys specified in file");
-		goto err;
-	}
-	else
-		keyflag = 1;
-
-	if (dbtype == DB_BTREE || dbtype == DB_HASH) {
-		if (keyflag == 0)
-			dbp->err(dbp,
-			    EINVAL, "Btree and Hash must specify keys");
-		else
-			keyflag = 1;
-	}
-
-	if (argtype != DB_UNKNOWN) {
-
-		if (dbtype == DB_RECNO || dbtype == DB_QUEUE)
-			if (keyflag != 1 && argtype != DB_RECNO &&
-			    argtype != DB_QUEUE) {
-				dbenv->errx(dbenv,
-			   "improper database type conversion specified");
-				goto err;
-			}
-		dbtype = argtype;
-	}
-
-	if (dbtype == DB_UNKNOWN) {
-		dbenv->errx(dbenv, "no database type specified");
-		goto err;
-	}
-
-	if (keyflag == -1)
-		keyflag = 0;
-
-	/*
-	 * Recno keys have only been printed in hexadecimal starting
-	 * with db_dump format version 3 (DB 3.2).
-	 *
-	 * !!!
-	 * Note that version is set in db_load_rheader(), which must be called before
-	 * this assignment.
-	 */
-	hexkeys = (G(version) >= 3 && keyflag == 1 && checkprint == 0);
-
-	if (keyflag == 1 && (dbtype == DB_RECNO || dbtype == DB_QUEUE))
-		ascii_recno = 1;
-	else
-		ascii_recno = 0;
-
-	/* If configured with a password, encrypt databases we create. */
-	if (LF_ISSET(LDF_PASSWORD) &&
-	    (ret = dbp->set_flags(dbp, DB_ENCRYPT)) != 0) {
-		dbp->err(dbp, ret, "DB->set_flags: DB_ENCRYPT");
-		goto err;
-	}
-
-	/* Open the DB file. */
-	if ((ret = dbp->open(dbp, NULL, name, subdb, dbtype,
-	    DB_CREATE | (TXN_ON(dbenv) ? DB_AUTO_COMMIT : 0),
-	    __db_omode("rwrwrw"))) != 0) {
-		dbp->err(dbp, ret, "DB->open: %s", name);
-		goto err;
-	}
-	if (ldg->private != 0) {
-		if ((ret =
-		    __db_util_cache(dbenv, dbp, &ldg->cache, &resize)) != 0)
-			goto err;
-		if (resize) {
-			dbp->close(dbp, 0);
-			dbp = NULL;
-			dbenv->close(dbenv, 0);
-			if ((ret = db_load_env_create(&dbenv, ldg)) != 0)
-				goto err;
-			goto retry_db;
-		}
-	}
-
-	/* Initialize the key/data pair. */
-	readp = &key;
-	writep = &key;
-	if (dbtype == DB_RECNO || dbtype == DB_QUEUE) {
-		key.size = sizeof(recno);
-		if (keyflag) {
-			key.data = &datarecno;
-			if (checkprint) {
-				readp = &rkey;
-				goto key_data;
-			}
-		}
-		else
-			key.data = &recno;
-	} else
-key_data:	if ((readp->data =
-		    (void *)malloc(readp->ulen = 1024)) == NULL) {
-			dbenv->err(dbenv, ENOMEM, NULL);
-			goto err;
-		}
-	if ((data.data = (void *)malloc(data.ulen = 1024)) == NULL) {
-		dbenv->err(dbenv, ENOMEM, NULL);
-		goto err;
-	}
-
-	if (TXN_ON(dbenv) &&
-	    (ret = dbenv->txn_begin(dbenv, NULL, &txn, 0)) != 0)
-		goto err;
-
-	/* Get each key/data pair and add them to the database. */
-	for (recno = 1; !__db_util_interrupted(); ++recno) {
-		if (!keyflag)
-			if (checkprint) {
-				if (db_load_dbt_rprint(dbenv, &data))
-					goto err;
-			} else {
-				if (db_load_dbt_rdump(dbenv, &data))
-					goto err;
-			}
-		else
-			if (checkprint) {
-				if (db_load_dbt_rprint(dbenv, readp))
-					goto err;
-				if (!G(endodata) && db_load_dbt_rprint(dbenv, &data))
-					goto fmt;
-			} else {
-				if (ascii_recno) {
-					if (db_load_dbt_rrecno(dbenv, readp, hexkeys))
-						goto err;
-				} else
-					if (db_load_dbt_rdump(dbenv, readp))
-						goto err;
-				if (!G(endodata) && db_load_dbt_rdump(dbenv, &data)) {
-fmt:					dbenv->errx(dbenv,
-					    "odd number of key/data pairs");
-					goto err;
-				}
-			}
-		if (G(endodata))
-			break;
-		if (readp != writep) {
-			if (sscanf(readp->data, "%ud", &datarecno) != 1)
-				dbenv->errx(dbenv,
-				    "%s: non-integer key at line: %d",
-				    name, !keyflag ? recno : recno * 2 - 1);
-			if (datarecno == 0)
-				dbenv->errx(dbenv, "%s: zero key at line: %d",
-				    name,
-				    !keyflag ? recno : recno * 2 - 1);
-		}
-retry:		if (txn != NULL)
-			if ((ret = dbenv->txn_begin(dbenv, txn, &ctxn, 0)) != 0)
-				goto err;
-		switch (ret = dbp->put(dbp, ctxn, writep, &data, put_flags)) {
-		case 0:
-			if (ctxn != NULL) {
-				if ((ret =
-				    ctxn->commit(ctxn, DB_TXN_NOSYNC)) != 0)
-					goto err;
-				ctxn = NULL;
-			}
-			break;
-		case DB_KEYEXIST:
-			*existedp = 1;
-			dbenv->errx(dbenv,
-			    "%s: line %d: key already exists, not loaded:",
-			    name,
-			    !keyflag ? recno : recno * 2 - 1);
-
-			(void)__db_prdbt(&key, checkprint, 0, stderr,
-			    __db_verify_callback, 0, NULL);
-			break;
-		case DB_LOCK_DEADLOCK:
-			/* If we have a child txn, retry--else it's fatal. */
-			if (ctxn != NULL) {
-				if ((ret = ctxn->abort(ctxn)) != 0)
-					goto err;
-				ctxn = NULL;
-				goto retry;
-			}
-			/* FALLTHROUGH */
-		default:
-			dbenv->err(dbenv, ret, NULL);
-			if (ctxn != NULL) {
-				(void)ctxn->abort(ctxn);
-				ctxn = NULL;
-			}
-			goto err;
-		}
-		if (ctxn != NULL) {
-			if ((ret = ctxn->abort(ctxn)) != 0)
-				goto err;
-			ctxn = NULL;
-		}
-	}
-done:	rval = 0;
-	DB_ASSERT(ctxn == NULL);
-	if (txn != NULL && (ret = txn->commit(txn, 0)) != 0) {
-		txn = NULL;
-		goto err;
-	}
-
-	if (0) {
-err:		rval = 1;
-		DB_ASSERT(ctxn == NULL);
-		if (txn != NULL)
-			(void)txn->abort(txn);
-	}
-
-	/* Close the database. */
-	if (dbp != NULL && (ret = dbp->close(dbp, 0)) != 0) {
-		dbenv->err(dbenv, ret, "DB->close");
-		rval = 1;
-	}
-
-	if (G(hdrbuf) != NULL)
-		free(G(hdrbuf));
-	G(hdrbuf) = NULL;
-	/* Free allocated memory. */
-	if (subdb != NULL)
-		free(subdb);
-	if (dbtype != DB_RECNO && dbtype != DB_QUEUE)
-		free(key.data);
-	if (rkey.data != NULL)
-		free(rkey.data);
-	free(data.data);
-
-	return (rval);
-}
-
-/*
- * db_init --
- *	Initialize the environment.
- */
-int
-db_load_db_init(dbenv, home, cache, is_private)
-	DB_ENV *dbenv;
-	char *home;
-	u_int32_t cache;
-	int *is_private;
-{
-	u_int32_t flags;
-	int ret;
-
-	*is_private = 0;
-	/* We may be loading into a live environment.  Try and join. */
-	flags = DB_USE_ENVIRON |
-	    DB_INIT_LOCK | DB_INIT_LOG | DB_INIT_MPOOL | DB_INIT_TXN;
-	if (dbenv->open(dbenv, home, flags, 0) == 0)
-		return (0);
-
-	/*
-	 * We're trying to load a database.
-	 *
-	 * An environment is required because we may be trying to look at
-	 * databases in directories other than the current one.  We could
-	 * avoid using an environment iff the -h option wasn't specified,
-	 * but that seems like more work than it's worth.
-	 *
-	 * No environment exists (or, at least no environment that includes
-	 * an mpool region exists).  Create one, but make it private so that
-	 * no files are actually created.
-	 */
-	LF_CLR(DB_INIT_LOCK | DB_INIT_LOG | DB_INIT_TXN);
-	LF_SET(DB_CREATE | DB_PRIVATE);
-	*is_private = 1;
-	if ((ret = dbenv->set_cachesize(dbenv, 0, cache, 1)) != 0) {
-		dbenv->err(dbenv, ret, "set_cachesize");
-		return (1);
-	}
-	if ((ret = dbenv->open(dbenv, home, flags, 0)) == 0)
-		return (0);
-
-	/* An environment is required. */
-	dbenv->err(dbenv, ret, "DB_ENV->open");
-	return (1);
-}
-
-#define	FLAG(name, value, keyword, flag)				\
-	if (strcmp(name, keyword) == 0) {				\
-		switch (*value) {					\
-		case '1':						\
-			if ((ret = dbp->set_flags(dbp, flag)) != 0) {	\
-				dbp->err(dbp, ret, "%s: set_flags: %s",	\
-				    G(progname), name);			\
-				return (1);				\
-			}						\
-			break;						\
-		case '0':						\
-			break;						\
-		default:						\
-			db_load_badnum(dbenv);					\
-			return (1);					\
-		}							\
-		continue;						\
-	}
-#define	NUMBER(name, value, keyword, func)				\
-	if (strcmp(name, keyword) == 0) {				\
-		if (__db_getlong(dbp,					\
-		    NULL, value, 1, LONG_MAX, &val) != 0)		\
-			return (1);					\
-		if ((ret = dbp->func(dbp, val)) != 0)			\
-			goto nameerr;					\
-		continue;						\
-	}
-#define	STRING(name, value, keyword, func)				\
-	if (strcmp(name, keyword) == 0) {				\
-		if ((ret = dbp->func(dbp, value[0])) != 0)		\
-			goto nameerr;					\
-		continue;						\
-	}
-
-/*
- * configure --
- *	Handle command-line configuration options.
- */
-int
-db_load_configure(dbenv, dbp, clp, subdbp, keysp)
-	DB_ENV *dbenv;
-	DB *dbp;
-	char **clp, **subdbp;
-	int *keysp;
-{
-	long val;
-	int ret, savech;
-	char *name, *value;
-
-	for (; (name = *clp) != NULL; *--value = savech, ++clp) {
-		if ((value = strchr(name, '=')) == NULL) {
-			dbp->errx(dbp,
-		    "command-line configuration uses name=value format");
-			return (1);
-		}
-		savech = *value;
-		*value++ = '\0';
-
-		if (strcmp(name, "database") == 0 ||
-		    strcmp(name, "subdatabase") == 0) {
-			if (*subdbp != NULL)
-				free(*subdbp);
-			if ((*subdbp = strdup(value)) == NULL) {
-				dbp->err(dbp, ENOMEM, NULL);
-				return (1);
-			}
-			continue;
-		}
-		if (strcmp(name, "keys") == 0) {
-			if (strcmp(value, "1") == 0)
-				*keysp = 1;
-			else if (strcmp(value, "0") == 0)
-				*keysp = 0;
-			else {
-				db_load_badnum(dbenv);
-				return (1);
-			}
-			continue;
-		}
-
-#ifdef notyet
-		NUMBER(name, value, "bt_maxkey", set_bt_maxkey);
-#endif
-		NUMBER(name, value, "bt_minkey", set_bt_minkey);
-		NUMBER(name, value, "db_lorder", set_lorder);
-		NUMBER(name, value, "db_pagesize", set_pagesize);
-		FLAG(name, value, "chksum", DB_CHKSUM_SHA1);
-		FLAG(name, value, "duplicates", DB_DUP);
-		FLAG(name, value, "dupsort", DB_DUPSORT);
-		NUMBER(name, value, "h_ffactor", set_h_ffactor);
-		NUMBER(name, value, "h_nelem", set_h_nelem);
-		NUMBER(name, value, "re_len", set_re_len);
-		STRING(name, value, "re_pad", set_re_pad);
-		FLAG(name, value, "recnum", DB_RECNUM);
-		FLAG(name, value, "renumber", DB_RENUMBER);
-
-		dbp->errx(dbp,
-		    "unknown command-line configuration keyword \"%s\"", name);
-		return (1);
-	}
-	return (0);
-
-nameerr:
-	dbp->err(dbp, ret, "%s: %s=%s", G(progname), name, value);
-	return (1);
-}
-
-/*
- * rheader --
- *	Read the header message.
- */
-int
-db_load_rheader(dbenv, dbp, dbtypep, subdbp, checkprintp, keysp)
-	DB_ENV *dbenv;
-	DB *dbp;
-	DBTYPE *dbtypep;
-	char **subdbp;
-	int *checkprintp, *keysp;
-{
-	long val;
-	int ch, first, hdr, linelen, buflen, ret, start;
-	char *buf, *name, *p, *value;
-
-	*dbtypep = DB_UNKNOWN;
-	*checkprintp = 0;
-	name = p = NULL;
-
-	/*
-	 * We start with a smallish buffer;  most headers are small.
-	 * We may need to realloc it for a large subdatabase name.
-	 */
-	buflen = 4096;
-	if (G(hdrbuf) == NULL) {
-		hdr = 0;
-		if ((buf = (char *)malloc(buflen)) == NULL) {
-memerr:			dbp->errx(dbp, "could not allocate buffer %d", buflen);
-			return (1);
-		}
-		G(hdrbuf) = buf;
-		G(origline) = G(lineno);
-	} else {
-		hdr = 1;
-		buf = G(hdrbuf);
-		G(lineno) = G(origline);
-	}
-
-	start = 0;
-	for (first = 1;; first = 0) {
-		++G(lineno);
-
-		/* Read a line, which may be of arbitrary length, into buf. */
-		linelen = 0;
-		buf = &G(hdrbuf)[start];
-		if (hdr == 0) {
-			for (;;) {
-				if ((ch = getchar()) == EOF) {
-					if (!first || ferror(stdin))
-						goto badfmt;
-					G(endofile) = 1;
-					break;
-				}
-
-				if (ch == '\n')
-					break;
-
-				buf[linelen++] = ch;
-
-				/* If the buffer is too small, double it. */
-				if (linelen + start == buflen) {
-					G(hdrbuf) = (char *)realloc(G(hdrbuf),
-					    buflen *= 2);
-					if (G(hdrbuf) == NULL)
-						goto memerr;
-					buf = &G(hdrbuf)[start];
-				}
-			}
-			if (G(endofile) == 1)
-				break;
-			buf[linelen++] = '\0';
-		} else
-			linelen = strlen(buf) + 1;
-		start += linelen;
-
-		if (name != NULL) {
-			*p = '=';
-			free(name);
-			name = NULL;
-		}
-		/* If we don't see the expected information, it's an error. */
-		if ((name = strdup(buf)) == NULL)
-			goto memerr;
-		if ((p = strchr(name, '=')) == NULL)
-			goto badfmt;
-		*p++ = '\0';
-
-		value = p--;
-
-		if (name[0] == '\0' || value[0] == '\0')
-			goto badfmt;
-
-		if (strcmp(name, "HEADER") == 0)
-			break;
-		if (strcmp(name, "VERSION") == 0) {
-			/*
-			 * Version 1 didn't have a "VERSION" header line.  We
-			 * only support versions 1, 2, and 3 of the dump format.
-			 */
-			G(version) = atoi(value);
-
-			if (G(version) > 3) {
-				dbp->errx(dbp,
-				    "line %lu: VERSION %d is unsupported",
-				    G(lineno), G(version));
-				goto err;
-			}
-			continue;
-		}
-		if (strcmp(name, "format") == 0) {
-			if (strcmp(value, "bytevalue") == 0) {
-				*checkprintp = 0;
-				continue;
-			}
-			if (strcmp(value, "print") == 0) {
-				*checkprintp = 1;
-				continue;
-			}
-			goto badfmt;
-		}
-		if (strcmp(name, "type") == 0) {
-			if (strcmp(value, "btree") == 0) {
-				*dbtypep = DB_BTREE;
-				continue;
-			}
-			if (strcmp(value, "hash") == 0) {
-				*dbtypep = DB_HASH;
-				continue;
-			}
-			if (strcmp(value, "recno") == 0) {
-				*dbtypep = DB_RECNO;
-				continue;
-			}
-			if (strcmp(value, "queue") == 0) {
-				*dbtypep = DB_QUEUE;
-				continue;
-			}
-			dbp->errx(dbp, "line %lu: unknown type", G(lineno));
-			goto err;
-		}
-		if (strcmp(name, "database") == 0 ||
-		    strcmp(name, "subdatabase") == 0) {
-			if ((ret = db_load_convprintable(dbenv, value, subdbp)) != 0) {
-				dbp->err(dbp, ret, "error reading db name");
-				goto err;
-			}
-			continue;
-		}
-		if (strcmp(name, "keys") == 0) {
-			if (strcmp(value, "1") == 0)
-				*keysp = 1;
-			else if (strcmp(value, "0") == 0)
-				*keysp = 0;
-			else {
-				db_load_badnum(dbenv);
-				goto err;
-			}
-			continue;
-		}
-
-#ifdef notyet
-		NUMBER(name, value, "bt_maxkey", set_bt_maxkey);
-#endif
-		NUMBER(name, value, "bt_minkey", set_bt_minkey);
-		NUMBER(name, value, "db_lorder", set_lorder);
-		NUMBER(name, value, "db_pagesize", set_pagesize);
-		NUMBER(name, value, "extentsize", set_q_extentsize);
-		FLAG(name, value, "chksum", DB_CHKSUM_SHA1);
-		FLAG(name, value, "duplicates", DB_DUP);
-		FLAG(name, value, "dupsort", DB_DUPSORT);
-		NUMBER(name, value, "h_ffactor", set_h_ffactor);
-		NUMBER(name, value, "h_nelem", set_h_nelem);
-		NUMBER(name, value, "re_len", set_re_len);
-		STRING(name, value, "re_pad", set_re_pad);
-		FLAG(name, value, "recnum", DB_RECNUM);
-		FLAG(name, value, "renumber", DB_RENUMBER);
-
-		dbp->errx(dbp,
-		    "unknown input-file header configuration keyword \"%s\"",
-		    name);
-		goto err;
-	}
-	ret = 0;
-	if (0) {
-nameerr:
-		dbp->err(dbp, ret, "%s: %s=%s", G(progname), name, value);
-		ret = 1;
-	}
-	if (0)
-err:		ret = 1;
-	if (0) {
-badfmt:
-		dbp->errx(dbp, "line %lu: unexpected format", G(lineno));
-		ret = 1;
-	}
-	if (name != NULL) {
-		*p = '=';
-		free(name);
-	}
-	return (ret);
-}
-
-/*
- * convprintable --
- *	Convert a printable-encoded string into a newly allocated string.
- *
- * In an ideal world, this would probably share code with dbt_rprint, but
- * that's set up to read character-by-character (to avoid large memory
- * allocations that aren't likely to be a problem here), and this has fewer
- * special cases to deal with.
- *
- * Note that despite the printable encoding, the char * interface to this
- * function (which is, not coincidentally, also used for database naming)
- * means that outstr cannot contain any nuls.
- */
-int
-db_load_convprintable(dbenv, instr, outstrp)
-	DB_ENV *dbenv;
-	char *instr, **outstrp;
-{
-	char c, *outstr;
-	int e1, e2;
-
-	/*
-	 * Just malloc a string big enough for the whole input string;
-	 * the output string will be smaller (or of equal length).
-	 */
-	if ((outstr = (char *)malloc(strlen(instr))) == NULL)
-		return (ENOMEM);
-
-	*outstrp = outstr;
-
-	e1 = e2 = 0;
-	for ( ; *instr != '\0'; instr++)
-		if (*instr == '\\') {
-			if (*++instr == '\\') {
-				*outstr++ = '\\';
-				continue;
-			}
-			c = db_load_digitize(dbenv, *instr, &e1) << 4;
-			c |= db_load_digitize(dbenv, *++instr, &e2);
-			if (e1 || e2) {
-				db_load_badend(dbenv);
-				return (EINVAL);
-			}
-
-			*outstr++ = c;
-		} else
-			*outstr++ = *instr;
-
-	*outstr = '\0';
-
-	return (0);
-}
-
-/*
- * dbt_rprint --
- *	Read a printable line into a DBT structure.
- */
-int
-db_load_dbt_rprint(dbenv, dbtp)
-	DB_ENV *dbenv;
-	DBT *dbtp;
-{
-	u_int32_t len;
-	u_int8_t *p;
-	int c1, c2, e, escape, first;
-	char buf[32];
-
-	++G(lineno);
-
-	first = 1;
-	e = escape = 0;
-	for (p = dbtp->data, len = 0; (c1 = getchar()) != '\n';) {
-		if (c1 == EOF) {
-			if (len == 0) {
-				G(endofile) = G(endodata) = 1;
-				return (0);
-			}
-			db_load_badend(dbenv);
-			return (1);
-		}
-		if (first) {
-			first = 0;
-			if (G(version) > 1) {
-				if (c1 != ' ') {
-					buf[0] = c1;
-					if (fgets(buf + 1,
-					    sizeof(buf) - 1, stdin) == NULL ||
-					    strcmp(buf, "DATA=END\n") != 0) {
-						db_load_badend(dbenv);
-						return (1);
-					}
-					G(endodata) = 1;
-					return (0);
-				}
-				continue;
-			}
-		}
-		if (escape) {
-			if (c1 != '\\') {
-				if ((c2 = getchar()) == EOF) {
-					db_load_badend(dbenv);
-					return (1);
-				}
-				c1 = db_load_digitize(dbenv,
-				    c1, &e) << 4 | db_load_digitize(dbenv, c2, &e);
-				if (e)
-					return (1);
-			}
-			escape = 0;
-		} else
-			if (c1 == '\\') {
-				escape = 1;
-				continue;
-			}
-		if (len >= dbtp->ulen - 10) {
-			dbtp->ulen *= 2;
-			if ((dbtp->data =
-			    (void *)realloc(dbtp->data, dbtp->ulen)) == NULL) {
-				dbenv->err(dbenv, ENOMEM, NULL);
-				return (1);
-			}
-			p = (u_int8_t *)dbtp->data + len;
-		}
-		++len;
-		*p++ = c1;
-	}
-	dbtp->size = len;
-
-	return (0);
-}
-
-/*
- * dbt_rdump --
- *	Read a byte dump line into a DBT structure.
- */
-int
-db_load_dbt_rdump(dbenv, dbtp)
-	DB_ENV *dbenv;
-	DBT *dbtp;
-{
-	u_int32_t len;
-	u_int8_t *p;
-	int c1, c2, e, first;
-	char buf[32];
-
-	++G(lineno);
-
-	first = 1;
-	e = 0;
-	for (p = dbtp->data, len = 0; (c1 = getchar()) != '\n';) {
-		if (c1 == EOF) {
-			if (len == 0) {
-				G(endofile) = G(endodata) = 1;
-				return (0);
-			}
-			db_load_badend(dbenv);
-			return (1);
-		}
-		if (first) {
-			first = 0;
-			if (G(version) > 1) {
-				if (c1 != ' ') {
-					buf[0] = c1;
-					if (fgets(buf + 1,
-					    sizeof(buf) - 1, stdin) == NULL ||
-					    strcmp(buf, "DATA=END\n") != 0) {
-						db_load_badend(dbenv);
-						return (1);
-					}
-					G(endodata) = 1;
-					return (0);
-				}
-				continue;
-			}
-		}
-		if ((c2 = getchar()) == EOF) {
-			db_load_badend(dbenv);
-			return (1);
-		}
-		if (len >= dbtp->ulen - 10) {
-			dbtp->ulen *= 2;
-			if ((dbtp->data =
-			    (void *)realloc(dbtp->data, dbtp->ulen)) == NULL) {
-				dbenv->err(dbenv, ENOMEM, NULL);
-				return (1);
-			}
-			p = (u_int8_t *)dbtp->data + len;
-		}
-		++len;
-		*p++ = db_load_digitize(dbenv, c1, &e) << 4 | db_load_digitize(dbenv, c2, &e);
-		if (e)
-			return (1);
-	}
-	dbtp->size = len;
-
-	return (0);
-}
-
-/*
- * dbt_rrecno --
- *	Read a record number dump line into a DBT structure.
- */
-int
-db_load_dbt_rrecno(dbenv, dbtp, ishex)
-	DB_ENV *dbenv;
-	DBT *dbtp;
-	int ishex;
-{
-	char buf[32], *p, *q;
-
-	++G(lineno);
-
-	if (fgets(buf, sizeof(buf), stdin) == NULL) {
-		G(endofile) = G(endodata) = 1;
-		return (0);
-	}
-
-	if (strcmp(buf, "DATA=END\n") == 0) {
-		G(endodata) = 1;
-		return (0);
-	}
-
-	if (buf[0] != ' ')
-		goto bad;
-
-	/*
-	 * If we're expecting a hex key, do an in-place conversion
-	 * of hex to straight ASCII before calling __db_getulong().
-	 */
-	if (ishex) {
-		for (p = q = buf + 1; *q != '\0' && *q != '\n';) {
-			/*
-			 * 0-9 in hex are 0x30-0x39, so this is easy.
-			 * We should alternate between 3's and [0-9], and
-			 * if the [0-9] are something unexpected,
-			 * __db_getulong will fail, so we only need to catch
-			 * end-of-string conditions.
-			 */
-			if (*q++ != '3')
-				goto bad;
-			if (*q == '\n' || *q == '\0')
-				goto bad;
-			*p++ = *q++;
-		}
-		*p = '\0';
-	}
-
-	if (__db_getulong(NULL,
-	    G(progname), buf + 1, 0, 0, (u_long *)dbtp->data)) {
-bad:		db_load_badend(dbenv);
-		return (1);
-	}
-
-	dbtp->size = sizeof(db_recno_t);
-	return (0);
-}
-
-/*
- * digitize --
- *	Convert a character to an integer.
- */
-int
-db_load_digitize(dbenv, c, errorp)
-	DB_ENV *dbenv;
-	int c, *errorp;
-{
-	switch (c) {			/* Don't depend on ASCII ordering. */
-	case '0': return (0);
-	case '1': return (1);
-	case '2': return (2);
-	case '3': return (3);
-	case '4': return (4);
-	case '5': return (5);
-	case '6': return (6);
-	case '7': return (7);
-	case '8': return (8);
-	case '9': return (9);
-	case 'a': return (10);
-	case 'b': return (11);
-	case 'c': return (12);
-	case 'd': return (13);
-	case 'e': return (14);
-	case 'f': return (15);
-	}
-
-	dbenv->errx(dbenv, "unexpected hexadecimal value");
-	*errorp = 1;
-
-	return (0);
-}
-
-/*
- * badnum --
- *	Display the bad number message.
- */
-void
-db_load_badnum(dbenv)
-	DB_ENV *dbenv;
-{
-	dbenv->errx(dbenv,
-	    "boolean name=value pairs require a value of 0 or 1");
-}
-
-/*
- * badend --
- *	Display the bad end to input message.
- */
-void
-db_load_badend(dbenv)
-	DB_ENV *dbenv;
-{
-	dbenv->errx(dbenv, "unexpected end of input data or key/data pair");
-}
-
-/*
- * usage --
- *	Display the usage message.
- */
-int
-db_load_usage()
-{
-	(void)fprintf(stderr, "%s\n\t%s\n",
-	    "usage: db_load [-nTV] [-c name=value] [-f file]",
-    "[-h home] [-P password] [-t btree | hash | recno | queue] db_file");
-	return (EXIT_FAILURE);
-}
-
-int
-db_load_version_check(progname)
-	const char *progname;
-{
-	int v_major, v_minor, v_patch;
-
-	/* Make sure we're loaded with the right version of the DB library. */
-	(void)db_version(&v_major, &v_minor, &v_patch);
-	if (v_major != DB_VERSION_MAJOR ||
-	    v_minor != DB_VERSION_MINOR || v_patch != DB_VERSION_PATCH) {
-		fprintf(stderr,
-	"%s: version %d.%d.%d doesn't match library version %d.%d.%d\n",
-		    progname, DB_VERSION_MAJOR, DB_VERSION_MINOR,
-		    DB_VERSION_PATCH, v_major, v_minor, v_patch);
-		return (EXIT_FAILURE);
-	}
-	return (0);
-}
-
-int
-db_load_env_create(dbenvp, ldg)
-	DB_ENV **dbenvp;
-	LDG *ldg;
-{
-	DB_ENV *dbenv;
-	int ret;
-
-	if ((ret = db_env_create(dbenvp, 0)) != 0) {
-		fprintf(stderr,
-		    "%s: db_env_create: %s\n", ldg->progname, db_strerror(ret));
-		return (ret);
-	}
-	dbenv = *dbenvp;
-	dbenv->set_errfile(dbenv, stderr);
-	dbenv->set_errpfx(dbenv, ldg->progname);
-	if (ldg->passwd != NULL && (ret = dbenv->set_encrypt(dbenv,
-	    ldg->passwd, DB_ENCRYPT_AES)) != 0) {
-		dbenv->err(dbenv, ret, "set_passwd");
-		return (ret);
-	}
-	if ((ret = db_load_db_init(dbenv, ldg->home, ldg->cache, &ldg->private)) != 0)
-		return (ret);
-	dbenv->app_private = ldg;
-
-	return (0);
-}
diff --git a/bdb/build_vxworks/db_load/db_load.wpj b/bdb/build_vxworks/db_load/db_load.wpj
deleted file mode 100755
index 59e194ae3860a2e8cb3b6e9f577e1df67ec788cc..0000000000000000000000000000000000000000
--- a/bdb/build_vxworks/db_load/db_load.wpj
+++ /dev/null
@@ -1,160 +0,0 @@
-Document file - DO NOT EDIT
-
-<BEGIN> BUILD_PENTIUMgnu_BUILDRULE
-db_load.out
-<END>
-
-<BEGIN> BUILD_PENTIUMgnu_MACRO_AR
-ar386
-<END>
-
-<BEGIN> BUILD_PENTIUMgnu_MACRO_ARCHIVE
-$(PRJ_DIR)/PENTIUMgnu/db_load.a
-<END>
-
-<BEGIN> BUILD_PENTIUMgnu_MACRO_AS
-cc386
-<END>
-
-<BEGIN> BUILD_PENTIUMgnu_MACRO_CC
-cc386
-<END>
-
-<BEGIN> BUILD_PENTIUMgnu_MACRO_CFLAGS
--g \
-	-mpentium \
-	-ansi \
-	-nostdinc \
-	-DRW_MULTI_THREAD \
-	-D_REENTRANT \
-	-fvolatile \
-	-nostdlib \
-	-fno-builtin \
-	-fno-defer-pop \
-	-I$(PRJ_DIR)/.. \
-	-I$(PRJ_DIR)/../.. \
-	-I$(WIND_BASE)/target/h \
-	-DCPU=PENTIUM
-<END>
-
-<BEGIN> BUILD_PENTIUMgnu_MACRO_CFLAGS_AS
--g \
-	-mpentium \
-	-ansi \
-	-nostdinc \
-	-fvolatile \
-	-nostdlib \
-	-fno-builtin \
-	-fno-defer-pop \
-	-P \
-	-x \
-	assembler-with-cpp \
-	-I$(WIND_BASE)/target/h \
-	-DCPU=PENTIUM
-<END>
-
-<BEGIN> BUILD_PENTIUMgnu_MACRO_CPP
-cc386 -E -P -xc
-<END>
-
-<BEGIN> BUILD_PENTIUMgnu_MACRO_LD
-ld386
-<END>
-
-<BEGIN> BUILD_PENTIUMgnu_MACRO_LDDEPS
-
-<END>
-
-<BEGIN> BUILD_PENTIUMgnu_MACRO_LDFLAGS
--X -N
-<END>
-
-<BEGIN> BUILD_PENTIUMgnu_MACRO_LD_PARTIAL_FLAGS
--X -r
-<END>
-
-<BEGIN> BUILD_PENTIUMgnu_MACRO_NM
-nm386 -g
-<END>
-
-<BEGIN> BUILD_PENTIUMgnu_MACRO_OPTION_DEFINE_MACRO
--D
-<END>
-
-<BEGIN> BUILD_PENTIUMgnu_MACRO_OPTION_INCLUDE_DIR
--I
-<END>
-
-<BEGIN> BUILD_PENTIUMgnu_MACRO_POST_BUILD_RULE
-
-<END>
-
-<BEGIN> BUILD_PENTIUMgnu_MACRO_PRJ_LIBS
-
-<END>
-
-<BEGIN> BUILD_PENTIUMgnu_MACRO_SIZE
-size386
-<END>
-
-<BEGIN> BUILD_PENTIUMgnu_RO_DEPEND_PATH
-{$(WIND_BASE)/target/h/} \
-	{$(WIND_BASE)/target/src/} \
-	{$(WIND_BASE)/target/config/}
-<END>
-
-<BEGIN> BUILD_PENTIUMgnu_TC
-::tc_PENTIUMgnu
-<END>
-
-<BEGIN> BUILD_RULE_archive
-
-<END>
-
-<BEGIN> BUILD_RULE_db_load.out
-
-<END>
-
-<BEGIN> BUILD_RULE_objects
-
-<END>
-
-<BEGIN> BUILD__CURRENT
-PENTIUMgnu
-<END>
-
-<BEGIN> BUILD__LIST
-PENTIUMgnu
-<END>
-
-<BEGIN> CORE_INFO_TYPE
-::prj_vxApp
-<END>
-
-<BEGIN> CORE_INFO_VERSION
-2.0
-<END>
-
-<BEGIN> FILE_db_load.c_dependDone
-FALSE
-<END>
-
-<BEGIN> FILE_db_load.c_dependencies
-
-<END>
-
-<BEGIN> FILE_db_load.c_objects
-db_load.o
-<END>
-
-<BEGIN> FILE_db_load.c_tool
-C/C++ compiler
-<END>
-
-<BEGIN> PROJECT_FILES
-$(PRJ_DIR)/db_load.c
-<END>
-
-<BEGIN> userComments
-db_load
-<END>
diff --git a/bdb/build_vxworks/db_load/db_load/Makefile.custom b/bdb/build_vxworks/db_load/db_load/Makefile.custom
deleted file mode 100644
index ca781f7b251ef99e49e5fc1859ee6cf3d67c60b0..0000000000000000000000000000000000000000
--- a/bdb/build_vxworks/db_load/db_load/Makefile.custom
+++ /dev/null
@@ -1,51 +0,0 @@
-#
-# Custom Makefile shell
-#
-# This file may be edited freely, since it will not be regenerated
-# by the project manager.
-#
-# Use this makefile to define rules to make external binaries
-# and deposit them in the $(EXTERNAL_BINARIES_DIR) directory.
-#
-# If you have specified external modules during your component
-# creation, you will find make rules already in place below.
-# You will likely have to edit these to suit your individual
-# build setup.
-#
-# You may wish to use the CPU, BUILD_SPEC or TOOL make variables in
-# your Makefile to support builds for different architectures.  Use
-# the FORCE_EXTERNAL_MAKE phony target to ensure that your external
-# make always runs.
-#
-# The example below assumes that your custom makefile is in the
-# mySourceTree directory, and that the binary file it produces
-# is placed into the $(BUILD_SPEC) sub-directory.
-#
-# EXTERNAL_SOURCE_BASE = /folk/me/mySourceTree
-# EXTERNAL_MODULE = myLibrary.o
-# EXTERNAL_MAKE = make
-#
-# $(EXTERNAL_BINARIES_DIR)/$(EXTERNAL_MODULE) : FORCE_EXTERNAL_MAKE
-#	$(EXTERNAL_MAKE) -C $(EXTERNAL_SOURCE_BASE) \
-#	-f $(EXTERNAL_SOURCE_BASE)/Makefile \
-#	CPU=$(CPU) BUILD_SPEC=$(BUILD_SPEC) $(@F)
-#	$(CP) $(subst /,$(DIRCHAR),$(EXTERNAL_SOURCE_BASE)/$(BUILD_SPEC)/$(@F) $@)
-#
-# If you are not adding your external modules from the component wizard,
-# you will have to include them in your component yourself:
-#
-# From the GUI, you can do this with the Component's 'Add external module'
-# dialog.
-#
-# If you are using the command line, add the module(s) by editing the
-# MODULES line in component.cdf file, e.g.
-#
-# Component INCLUDE_MYCOMPONENT {
-#
-#   MODULES         foo.o goo.o \
-#         myLibrary.o
-#
-
-
-# rules to build custom libraries
-
diff --git a/bdb/build_vxworks/db_load/db_load/component.cdf b/bdb/build_vxworks/db_load/db_load/component.cdf
deleted file mode 100755
index 7d1d2bc958643f04a64e2d8ddb95b27fe50cf662..0000000000000000000000000000000000000000
--- a/bdb/build_vxworks/db_load/db_load/component.cdf
+++ /dev/null
@@ -1,30 +0,0 @@
-/* component.cdf - dynamically updated configuration */
-
-/*
- * NOTE: you may edit this file to alter the configuration
- * But all non-configuration information, including comments,
- * will be lost upon rebuilding this project.
- */
-
-/* Component information */
-
-Component INCLUDE_DB_LOAD {
-	ENTRY_POINTS	ALL_GLOBAL_SYMBOLS 
-	MODULES		db_load.o 
-	NAME		db_load
-	PREF_DOMAIN	ANY
-	_INIT_ORDER	usrComponentsInit
-}
-
-/* EntryPoint information */
-
-/* Module information */
-
-Module db_load.o {
-
-	NAME		db_load.o
-	SRC_PATH_NAME	$PRJ_DIR/../db_load.c
-}
-
-/* Parameter information */
-
diff --git a/bdb/build_vxworks/db_load/db_load/component.wpj b/bdb/build_vxworks/db_load/db_load/component.wpj
deleted file mode 100755
index 216e7d9786c8400510bec9ff2b1f450bdc2447dc..0000000000000000000000000000000000000000
--- a/bdb/build_vxworks/db_load/db_load/component.wpj
+++ /dev/null
@@ -1,475 +0,0 @@
-Document file - DO NOT EDIT
-
-<BEGIN> CORE_INFO_TYPE
-::prj_component
-<END>
-
-<BEGIN> CORE_INFO_VERSION
-AE1.1
-<END>
-
-<BEGIN> BUILD__CURRENT
-PENTIUM2gnu.debug
-<END>
-
-<BEGIN> BUILD_PENTIUM2gnu.debug_CURRENT_TARGET
-default
-<END>
-
-<BEGIN> BUILD_PENTIUM2gnu.debug_DEFAULTFORCPU
-1
-<END>
-
-<BEGIN> BUILD_PENTIUM2gnu.debug_FILE_$(PRJ_DIR)/../db_load.c_infoTags
-toolMacro objects
-<END>
-
-<BEGIN> BUILD_PENTIUM2gnu.debug_FILE_$(PRJ_DIR)/../db_load.c_objects
-db_load.o
-<END>
-
-<BEGIN> BUILD_PENTIUM2gnu.debug_FILE_$(PRJ_DIR)/../db_load.c_toolMacro
-CC
-<END>
-
-<BEGIN> BUILD_PENTIUM2gnu.debug_FILE_$(PRJ_DIR)/../db_load.c_objects
-db_load.o
-<END>
-
-<BEGIN> BUILD_PENTIUM2gnu.debug_FILE_$(PRJ_DIR)/../db_load.c_toolMacro
-CC
-<END>
-
-<BEGIN> BUILD_PENTIUM2gnu.debug_FILE_$(PRJ_DIR)/compConfig.c_infoTags
-toolMacro objects
-<END>
-
-<BEGIN> BUILD_PENTIUM2gnu.debug_FILE_$(PRJ_DIR)/compConfig.c_objects
-compConfig.o
-<END>
-
-<BEGIN> BUILD_PENTIUM2gnu.debug_FILE_$(PRJ_DIR)/compConfig.c_toolMacro
-CC
-<END>
-
-<BEGIN> BUILD_PENTIUM2gnu.debug_MACRO_AR
-arpentium
-<END>
-
-<BEGIN> BUILD_PENTIUM2gnu.debug_MACRO_AS
-ccpentium
-<END>
-
-<BEGIN> BUILD_PENTIUM2gnu.debug_MACRO_CC
-ccpentium
-<END>
-
-<BEGIN> BUILD_PENTIUM2gnu.debug_MACRO_CFLAGS
--mcpu=pentiumpro \
-	-march=pentiumpro \
-	-ansi \
-	-DRW_MULTI_THREAD \
-	-D_REENTRANT \
-	-g \
-	-nostdlib \
-	-fno-builtin \
-	-fno-defer-pop \
-	-MD \
-	-Wall \
-	-I. \
-	-I$(WIND_BASE)/target/h \
-	-I$(PRJ_DIR)/../.. \
-	-I$(PRJ_DIR)/../../.. \
-	-DCPU=PENTIUM2
-<END>
-
-<BEGIN> BUILD_PENTIUM2gnu.debug_MACRO_CFLAGS_AS
--mcpu=pentiumpro \
-	-march=pentiumpro \
-	-ansi \
-	-g \
-	-nostdlib \
-	-fno-builtin \
-	-fno-defer-pop \
-	-P \
-	-x \
-	assembler-with-cpp \
-	-Wall \
-	-I. \
-	-I$(WIND_BASE)/target/h \
-	-DCPU=PENTIUM2
-<END>
-
-<BEGIN> BUILD_PENTIUM2gnu.debug_MACRO_CPP
-ccpentium -E -P
-<END>
-
-<BEGIN> BUILD_PENTIUM2gnu.debug_MACRO_CPPFILT
-c++filtpentium --strip-underscores
-<END>
-
-<BEGIN> BUILD_PENTIUM2gnu.debug_MACRO_LD
-ldpentium
-<END>
-
-<BEGIN> BUILD_PENTIUM2gnu.debug_MACRO_LDFLAGS
--X
-<END>
-
-<BEGIN> BUILD_PENTIUM2gnu.debug_MACRO_LDPARTIAL
-ccpentium \
-	-B$(WIND_BASE)/host/$(WIND_HOST_TYPE)/lib/gcc-lib/ \
-	-nostdlib \
-	-r \
-	-Wl,-X
-<END>
-
-<BEGIN> BUILD_PENTIUM2gnu.debug_MACRO_LD_PARTIAL_FLAGS
--X -r
-<END>
-
-<BEGIN> BUILD_PENTIUM2gnu.debug_MACRO_NM
-nmpentium -g
-<END>
-
-<BEGIN> BUILD_PENTIUM2gnu.debug_MACRO_OPTION_DEFINE_MACRO
--D
-<END>
-
-<BEGIN> BUILD_PENTIUM2gnu.debug_MACRO_OPTION_GENERATE_DEPENDENCY_FILE
--MD
-<END>
-
-<BEGIN> BUILD_PENTIUM2gnu.debug_MACRO_OPTION_INCLUDE_DIR
--I
-<END>
-
-<BEGIN> BUILD_PENTIUM2gnu.debug_MACRO_RELEASE
-0
-<END>
-
-<BEGIN> BUILD_PENTIUM2gnu.debug_MACRO_SIZE
-sizepentium
-<END>
-
-<BEGIN> BUILD_PENTIUM2gnu.debug_RELEASE
-0
-<END>
-
-<BEGIN> BUILD_PENTIUM2gnu.debug_RO_DEPEND_PATH
-$(WIND_BASE)/target/h/
-<END>
-
-<BEGIN> BUILD_PENTIUM2gnu.debug_TC
-::tc_PENTIUM2gnu.debug
-<END>
-
-<BEGIN> BUILD_PENTIUM2gnu.release_DEFAULTFORCPU
-0
-<END>
-
-<BEGIN> BUILD_PENTIUM2gnu.release_FILE_$(PRJ_DIR)/../db_load.c_infoTags
-toolMacro objects
-<END>
-
-<BEGIN> BUILD_PENTIUM2gnu.release_FILE_$(PRJ_DIR)/../db_load.c_objects
-db_load.o
-<END>
-
-<BEGIN> BUILD_PENTIUM2gnu.release_FILE_$(PRJ_DIR)/../db_load.c_toolMacro
-CC
-<END>
-
-<BEGIN> BUILD_PENTIUM2gnu.release_FILE_$(PRJ_DIR)/compConfig.c_infoTags
-toolMacro objects
-<END>
-
-<BEGIN> BUILD_PENTIUM2gnu.release_FILE_$(PRJ_DIR)/compConfig.c_objects
-compConfig.o
-<END>
-
-<BEGIN> BUILD_PENTIUM2gnu.release_FILE_$(PRJ_DIR)/compConfig.c_toolMacro
-CC
-<END>
-
-<BEGIN> BUILD_PENTIUM2gnu.release_MACRO_AR
-arpentium
-<END>
-
-<BEGIN> BUILD_PENTIUM2gnu.release_MACRO_AS
-ccpentium
-<END>
-
-<BEGIN> BUILD_PENTIUM2gnu.release_MACRO_CC
-ccpentium
-<END>
-
-<BEGIN> BUILD_PENTIUM2gnu.release_MACRO_CFLAGS
--mcpu=pentiumpro \
-	-march=pentiumpro \
-	-ansi \
-	-DRW_MULTI_THREAD \
-	-D_REENTRANT \
-	-O2 \
-	-nostdlib \
-	-fno-builtin \
-	-fno-defer-pop \
-	-MD \
-	-Wall \
-	-I. \
-	-I$(WIND_BASE)/target/h \
-	-I$(PRJ_DIR)/../.. \
-	-I$(PRJ_DIR)/../../.. \
-	-DCPU=PENTIUM2
-<END>
-
-<BEGIN> BUILD_PENTIUM2gnu.release_MACRO_CFLAGS_AS
--mcpu=pentiumpro \
-	-march=pentiumpro \
-	-ansi \
-	-O2 \
-	-nostdlib \
-	-fno-builtin \
-	-fno-defer-pop \
-	-P \
-	-x \
-	assembler-with-cpp \
-	-Wall \
-	-I. \
-	-I$(WIND_BASE)/target/h \
-	-DCPU=PENTIUM2
-<END>
-
-<BEGIN> BUILD_PENTIUM2gnu.release_MACRO_CPP
-ccpentium -E -P
-<END>
-
-<BEGIN> BUILD_PENTIUM2gnu.release_MACRO_CPPFILT
-c++filtpentium --strip-underscores
-<END>
-
-<BEGIN> BUILD_PENTIUM2gnu.release_MACRO_LD
-ldpentium
-<END>
-
-<BEGIN> BUILD_PENTIUM2gnu.release_MACRO_LDFLAGS
--X
-<END>
-
-<BEGIN> BUILD_PENTIUM2gnu.release_MACRO_LDPARTIAL
-ccpentium \
-	-B$(WIND_BASE)/host/$(WIND_HOST_TYPE)/lib/gcc-lib/ \
-	-nostdlib \
-	-r \
-	-Wl,-X
-<END>
-
-<BEGIN> BUILD_PENTIUM2gnu.release_MACRO_LD_PARTIAL_FLAGS
--X -r
-<END>
-
-<BEGIN> BUILD_PENTIUM2gnu.release_MACRO_NM
-nmpentium -g
-<END>
-
-<BEGIN> BUILD_PENTIUM2gnu.release_MACRO_OPTION_DEFINE_MACRO
--D
-<END>
-
-<BEGIN> BUILD_PENTIUM2gnu.release_MACRO_OPTION_GENERATE_DEPENDENCY_FILE
--MD
-<END>
-
-<BEGIN> BUILD_PENTIUM2gnu.release_MACRO_OPTION_INCLUDE_DIR
--I
-<END>
-
-<BEGIN> BUILD_PENTIUM2gnu.release_MACRO_RELEASE
-1
-<END>
-
-<BEGIN> BUILD_PENTIUM2gnu.release_MACRO_SIZE
-sizepentium
-<END>
-
-<BEGIN> BUILD_PENTIUM2gnu.release_RELEASE
-1
-<END>
-
-<BEGIN> BUILD_PENTIUM2gnu.release_RO_DEPEND_PATH
-$(WIND_BASE)/target/h/
-<END>
-
-<BEGIN> BUILD_PENTIUM2gnu.release_TC
-::tc_PENTIUM2gnu.release
-<END>
-
-<BEGIN> BUILD_PENTIUMgnu.debug_DEFAULTFORCPU
-1
-<END>
-
-<BEGIN> BUILD_PENTIUMgnu.debug_FILE_$(PRJ_DIR)/../db_load.c_infoTags
-toolMacro objects
-<END>
-
-<BEGIN> BUILD_PENTIUMgnu.debug_FILE_$(PRJ_DIR)/../db_load.c_objects
-db_load.o
-<END>
-
-<BEGIN> BUILD_PENTIUMgnu.debug_FILE_$(PRJ_DIR)/../db_load.c_toolMacro
-CC
-<END>
-
-<BEGIN> BUILD_PENTIUMgnu.debug_FILE_$(PRJ_DIR)/compConfig.c_infoTags
-toolMacro objects
-<END>
-
-<BEGIN> BUILD_PENTIUMgnu.debug_FILE_$(PRJ_DIR)/compConfig.c_objects
-compConfig.o
-<END>
-
-<BEGIN> BUILD_PENTIUMgnu.debug_FILE_$(PRJ_DIR)/compConfig.c_toolMacro
-CC
-<END>
-
-<BEGIN> BUILD_PENTIUMgnu.debug_MACRO_AR
-arpentium
-<END>
-
-<BEGIN> BUILD_PENTIUMgnu.debug_MACRO_AS
-ccpentium
-<END>
-
-<BEGIN> BUILD_PENTIUMgnu.debug_MACRO_CC
-ccpentium
-<END>
-
-<BEGIN> BUILD_PENTIUMgnu.debug_MACRO_CFLAGS
--mcpu=pentium \
-	-march=pentium \
-	-ansi \
-	-DRW_MULTI_THREAD \
-	-D_REENTRANT \
-	-g \
-	-nostdlib \
-	-fno-builtin \
-	-fno-defer-pop \
-	-MD \
-	-Wall \
-	-I. \
-	-I$(WIND_BASE)/target/h \
-	-I$(PRJ_DIR)/../.. \
-	-I$(PRJ_DIR)/../../.. \
-	-DCPU=PENTIUM
-<END>
-
-<BEGIN> BUILD_PENTIUMgnu.debug_MACRO_CFLAGS_AS
--mcpu=pentium \
-	-march=pentium \
-	-ansi \
-	-g \
-	-nostdlib \
-	-fno-builtin \
-	-fno-defer-pop \
-	-P \
-	-x \
-	assembler-with-cpp \
-	-Wall \
-	-I. \
-	-I$(WIND_BASE)/target/h \
-	-DCPU=PENTIUM
-<END>
-
-<BEGIN> BUILD_PENTIUMgnu.debug_MACRO_CPP
-ccpentium -E -P
-<END>
-
-<BEGIN> BUILD_PENTIUMgnu.debug_MACRO_CPPFILT
-c++filtpentium --strip-underscores
-<END>
-
-<BEGIN> BUILD_PENTIUMgnu.debug_MACRO_LD
-ldpentium
-<END>
-
-<BEGIN> BUILD_PENTIUMgnu.debug_MACRO_LDFLAGS
--X
-<END>
-
-<BEGIN> BUILD_PENTIUMgnu.debug_MACRO_LDPARTIAL
-ccpentium \
-	-B$(WIND_BASE)/host/$(WIND_HOST_TYPE)/lib/gcc-lib/ \
-	-nostdlib \
-	-r \
-	-Wl,-X
-<END>
-
-<BEGIN> BUILD_PENTIUMgnu.debug_MACRO_LD_PARTIAL_FLAGS
--X -r
-<END>
-
-<BEGIN> BUILD_PENTIUMgnu.debug_MACRO_NM
-nmpentium -g
-<END>
-
-<BEGIN> BUILD_PENTIUMgnu.debug_MACRO_OPTION_DEFINE_MACRO
--D
-<END>
-
-<BEGIN> BUILD_PENTIUMgnu.debug_MACRO_OPTION_GENERATE_DEPENDENCY_FILE
--MD
-<END>
-
-<BEGIN> BUILD_PENTIUMgnu.debug_MACRO_OPTION_INCLUDE_DIR
--I
-<END>
-
-<BEGIN> BUILD_PENTIUMgnu.debug_MACRO_RELEASE
-0
-<END>
-
-<BEGIN> BUILD_PENTIUMgnu.debug_MACRO_SIZE
-sizepentium
-<END>
-
-<BEGIN> BUILD_PENTIUMgnu.debug_RELEASE
-0
-<END>
-
-<BEGIN> BUILD_PENTIUMgnu.debug_RO_DEPEND_PATH
-$(WIND_BASE)/target/h/
-<END>
-
-<BEGIN> BUILD_PENTIUMgnu.debug_TC
-::tc_PENTIUMgnu.debug
-<END>
-
-<BEGIN> BUILD__LIST
-PENTIUM2gnu.debug PENTIUM2gnu.release PENTIUMgnu.debug
-<END>
-
-<BEGIN> PROJECT_FILES
-$(PRJ_DIR)/../db_load.c \
-	$(PRJ_DIR)/compConfig.c
-<END>
-
-<BEGIN> WCC__CDF_PATH
-$(PRJ_DIR)
-<END>
-
-<BEGIN> WCC__CURRENT
-PENTIUM2gnu.debug
-<END>
-
-<BEGIN> WCC__LIST
-PENTIUM2gnu.debug
-<END>
-
-<BEGIN> WCC__MXR_LIBS
-lib$(CPU)$(TOOL)vx.a
-<END>
-
-<BEGIN> WCC__OBJS_PATH
-$(WIND_BASE)/target/lib/obj$CPU$TOOLvx
-<END>
-
diff --git a/bdb/build_vxworks/db_printlog/db_printlog.c b/bdb/build_vxworks/db_printlog/db_printlog.c
deleted file mode 100644
index 380e29021f5201d24171d022d9fdeda609f17251..0000000000000000000000000000000000000000
--- a/bdb/build_vxworks/db_printlog/db_printlog.c
+++ /dev/null
@@ -1,375 +0,0 @@
-/*-
- * See the file LICENSE for redistribution information.
- *
- * Copyright (c) 1996-2002
- *	Sleepycat Software.  All rights reserved.
- */
-
-#include "db_config.h"
-
-#ifndef lint
-static const char copyright[] =
-    "Copyright (c) 1996-2002\nSleepycat Software Inc.  All rights reserved.\n";
-static const char revid[] =
-    "$Id: db_printlog.c,v 11.52 2002/08/08 03:50:38 bostic Exp $";
-#endif
-
-#ifndef NO_SYSTEM_INCLUDES
-#include <sys/types.h>
-
-#include <ctype.h>
-#include <stdio.h>
-#include <stdlib.h>
-#include <string.h>
-#include <unistd.h>
-#endif
-
-#include "db_int.h"
-#include "dbinc/db_page.h"
-#include "dbinc/btree.h"
-#include "dbinc/fop.h"
-#include "dbinc/hash.h"
-#include "dbinc/log.h"
-#include "dbinc/qam.h"
-#include "dbinc/rep.h"
-#include "dbinc/txn.h"
-
-int db_printlog_main __P((int, char *[]));
-int db_printlog_usage __P((void));
-int db_printlog_version_check __P((const char *));
-int db_printlog_print_app_record __P((DB_ENV *, DBT *, DB_LSN *, db_recops));
-int db_printlog_open_rep_db __P((DB_ENV *, DB **, DBC **));
-
-int
-db_printlog(args)
-	char *args;
-{
-	int argc;
-	char **argv;
-
-	__db_util_arg("db_printlog", args, &argc, &argv);
-	return (db_printlog_main(argc, argv) ? EXIT_FAILURE : EXIT_SUCCESS);
-}
-
-#include <stdio.h>
-#define	ERROR_RETURN	ERROR
-
-int
-db_printlog_main(argc, argv)
-	int argc;
-	char *argv[];
-{
-	extern char *optarg;
-	extern int optind, __db_getopt_reset;
-	const char *progname = "db_printlog";
-	DB *dbp;
-	DBC *dbc;
-	DB_ENV	*dbenv;
-	DB_LOGC *logc;
-	int (**dtab) __P((DB_ENV *, DBT *, DB_LSN *, db_recops, void *));
-	size_t dtabsize;
-	DBT data, keydbt;
-	DB_LSN key;
-	int ch, e_close, exitval, nflag, rflag, ret, repflag;
-	char *home, *passwd;
-
-	if ((ret = db_printlog_version_check(progname)) != 0)
-		return (ret);
-
-	dbp = NULL;
-	dbc = NULL;
-	logc = NULL;
-	e_close = exitval = nflag = rflag = repflag = 0;
-	home = passwd = NULL;
-	dtabsize = 0;
-	dtab = NULL;
-	__db_getopt_reset = 1;
-	while ((ch = getopt(argc, argv, "h:NP:rRV")) != EOF)
-		switch (ch) {
-		case 'h':
-			home = optarg;
-			break;
-		case 'N':
-			nflag = 1;
-			break;
-		case 'P':
-			passwd = strdup(optarg);
-			memset(optarg, 0, strlen(optarg));
-			if (passwd == NULL) {
-				fprintf(stderr, "%s: strdup: %s\n",
-				    progname, strerror(errno));
-				return (EXIT_FAILURE);
-			}
-			break;
-		case 'r':
-			rflag = 1;
-			break;
-		case 'R':
-			repflag = 1;
-			break;
-		case 'V':
-			printf("%s\n", db_version(NULL, NULL, NULL));
-			return (EXIT_SUCCESS);
-		case '?':
-		default:
-			return (db_printlog_usage());
-		}
-	argc -= optind;
-	argv += optind;
-
-	if (argc > 0)
-		return (db_printlog_usage());
-
-	/* Handle possible interruptions. */
-	__db_util_siginit();
-
-	/*
-	 * Create an environment object and initialize it for error
-	 * reporting.
-	 */
-	if ((ret = db_env_create(&dbenv, 0)) != 0) {
-		fprintf(stderr,
-		    "%s: db_env_create: %s\n", progname, db_strerror(ret));
-		goto shutdown;
-	}
-	e_close = 1;
-
-	dbenv->set_errfile(dbenv, stderr);
-	dbenv->set_errpfx(dbenv, progname);
-
-	if (nflag) {
-		if ((ret = dbenv->set_flags(dbenv, DB_NOLOCKING, 1)) != 0) {
-			dbenv->err(dbenv, ret, "set_flags: DB_NOLOCKING");
-			goto shutdown;
-		}
-		if ((ret = dbenv->set_flags(dbenv, DB_NOPANIC, 1)) != 0) {
-			dbenv->err(dbenv, ret, "set_flags: DB_NOPANIC");
-			goto shutdown;
-		}
-	}
-
-	if (passwd != NULL && (ret = dbenv->set_encrypt(dbenv,
-	    passwd, DB_ENCRYPT_AES)) != 0) {
-		dbenv->err(dbenv, ret, "set_passwd");
-		goto shutdown;
-	}
-
-	/*
-	 * Set up an app-specific dispatch function so that we can gracefully
-	 * handle app-specific log records.
-	 */
-	if ((ret = dbenv->set_app_dispatch(dbenv, db_printlog_print_app_record)) != 0) {
-		dbenv->err(dbenv, ret, "app_dispatch");
-		goto shutdown;
-	}
-
-	/*
-	 * An environment is required, but as all we're doing is reading log
-	 * files, we create one if it doesn't already exist.  If we create
-	 * it, create it private so it automatically goes away when we're done.
-	 * If we are reading the replication database, do not open the env
-	 * with logging, because we don't want to log the opens.
-	 */
-	if (repflag) {
-		if ((ret = dbenv->open(dbenv, home,
-		    DB_INIT_MPOOL | DB_USE_ENVIRON, 0)) != 0 &&
-		    (ret = dbenv->open(dbenv, home,
-		    DB_CREATE | DB_INIT_MPOOL | DB_PRIVATE | DB_USE_ENVIRON, 0))
-		    != 0) {
-			dbenv->err(dbenv, ret, "open");
-			goto shutdown;
-		}
-	} else if ((ret = dbenv->open(dbenv, home,
-	    DB_JOINENV | DB_USE_ENVIRON, 0)) != 0 &&
-	    (ret = dbenv->open(dbenv, home,
-	    DB_CREATE | DB_INIT_LOG | DB_PRIVATE | DB_USE_ENVIRON, 0)) != 0) {
-		dbenv->err(dbenv, ret, "open");
-		goto shutdown;
-	}
-
-	/* Initialize print callbacks. */
-	if ((ret = __bam_init_print(dbenv, &dtab, &dtabsize)) != 0 ||
-	    (ret = __dbreg_init_print(dbenv, &dtab, &dtabsize)) != 0 ||
-	    (ret = __crdel_init_print(dbenv, &dtab, &dtabsize)) != 0 ||
-	    (ret = __db_init_print(dbenv, &dtab, &dtabsize)) != 0 ||
-	    (ret = __fop_init_print(dbenv, &dtab, &dtabsize)) != 0 ||
-	    (ret = __qam_init_print(dbenv, &dtab, &dtabsize)) != 0 ||
-	    (ret = __ham_init_print(dbenv, &dtab, &dtabsize)) != 0 ||
-	    (ret = __txn_init_print(dbenv, &dtab, &dtabsize)) != 0) {
-		dbenv->err(dbenv, ret, "callback: initialization");
-		goto shutdown;
-	}
-
-	/* Allocate a log cursor. */
-	if (repflag) {
-		if ((ret = db_printlog_open_rep_db(dbenv, &dbp, &dbc)) != 0)
-			goto shutdown;
-	} else if ((ret = dbenv->log_cursor(dbenv, &logc, 0)) != 0) {
-		dbenv->err(dbenv, ret, "DB_ENV->log_cursor");
-		goto shutdown;
-	}
-
-	memset(&data, 0, sizeof(data));
-	memset(&keydbt, 0, sizeof(keydbt));
-	while (!__db_util_interrupted()) {
-		if (repflag) {
-			ret = dbc->c_get(dbc,
-			    &keydbt, &data, rflag ? DB_PREV : DB_NEXT);
-			if (ret == 0)
-				key = ((REP_CONTROL *)keydbt.data)->lsn;
-		} else
-			ret = logc->get(logc,
-			    &key, &data, rflag ? DB_PREV : DB_NEXT);
-		if (ret != 0) {
-			if (ret == DB_NOTFOUND)
-				break;
-			dbenv->err(dbenv,
-			    ret, repflag ? "DB_LOGC->get" : "DBC->get");
-			goto shutdown;
-		}
-
-		ret = __db_dispatch(dbenv,
-		    dtab, dtabsize, &data, &key, DB_TXN_PRINT, NULL);
-
-		/*
-		 * XXX
-		 * Just in case the underlying routines don't flush.
-		 */
-		(void)fflush(stdout);
-
-		if (ret != 0) {
-			dbenv->err(dbenv, ret, "tx: dispatch");
-			goto shutdown;
-		}
-	}
-
-	if (0) {
-shutdown:	exitval = 1;
-	}
-	if (logc != NULL && (ret = logc->close(logc, 0)) != 0)
-		exitval = 1;
-
-	if (dbc != NULL && (ret = dbc->c_close(dbc)) != 0)
-		exitval = 1;
-
-	if (dbp != NULL && (ret = dbp->close(dbp, 0)) != 0)
-		exitval = 1;
-
-	/*
-	 * The dtab is allocated by __db_add_recovery (called by *_init_print)
-	 * using the library malloc function (__os_malloc).  It thus needs to be
-	 * freed using the corresponding free (__os_free).
-	 */
-	if (dtab != NULL)
-		__os_free(dbenv, dtab);
-	if (e_close && (ret = dbenv->close(dbenv, 0)) != 0) {
-		exitval = 1;
-		fprintf(stderr,
-		    "%s: dbenv->close: %s\n", progname, db_strerror(ret));
-	}
-
-	/* Resend any caught signal. */
-	__db_util_sigresend();
-
-	return (exitval == 0 ? EXIT_SUCCESS : EXIT_FAILURE);
-}
-
-int
-db_printlog_usage()
-{
-	fprintf(stderr, "%s\n",
-	    "usage: db_printlog [-NrV] [-h home] [-P password]");
-	return (EXIT_FAILURE);
-}
-
-int
-db_printlog_version_check(progname)
-	const char *progname;
-{
-	int v_major, v_minor, v_patch;
-
-	/* Make sure we're loaded with the right version of the DB library. */
-	(void)db_version(&v_major, &v_minor, &v_patch);
-	if (v_major != DB_VERSION_MAJOR ||
-	    v_minor != DB_VERSION_MINOR || v_patch != DB_VERSION_PATCH) {
-		fprintf(stderr,
-	"%s: version %d.%d.%d doesn't match library version %d.%d.%d\n",
-		    progname, DB_VERSION_MAJOR, DB_VERSION_MINOR,
-		    DB_VERSION_PATCH, v_major, v_minor, v_patch);
-		return (EXIT_FAILURE);
-	}
-	return (0);
-}
-
-/* Print an unknown, application-specific log record as best we can. */
-int
-db_printlog_print_app_record(dbenv, dbt, lsnp, op)
-	DB_ENV *dbenv;
-	DBT *dbt;
-	DB_LSN *lsnp;
-	db_recops op;
-{
-	int ch;
-	u_int32_t i, rectype;
-
-	DB_ASSERT(op == DB_TXN_PRINT);
-	COMPQUIET(dbenv, NULL);
-
-	/*
-	 * Fetch the rectype, which always must be at the beginning of the
-	 * record (if dispatching is to work at all).
-	 */
-	memcpy(&rectype, dbt->data, sizeof(rectype));
-
-	/*
-	 * Applications may wish to customize the output here based on the
-	 * rectype.  We just print the entire log record in the generic
-	 * mixed-hex-and-printable format we use for binary data.
-	 */
-	printf("[%lu][%lu]application specific record: rec: %lu\n",
-	    (u_long)lsnp->file, (u_long)lsnp->offset, (u_long)rectype);
-	printf("\tdata: ");
-	for (i = 0; i < dbt->size; i++) {
-		ch = ((u_int8_t *)dbt->data)[i];
-		printf(isprint(ch) || ch == 0x0a ? "%c" : "%#x ", ch);
-	}
-	printf("\n\n");
-
-	return (0);
-}
-
-int
-db_printlog_open_rep_db(dbenv, dbpp, dbcp)
-	DB_ENV *dbenv;
-	DB **dbpp;
-	DBC **dbcp;
-{
-	int ret;
-
-	DB *dbp;
-	*dbpp = NULL;
-	*dbcp = NULL;
-
-	if ((ret = db_create(dbpp, dbenv, 0)) != 0) {
-		dbenv->err(dbenv, ret, "db_create");
-		return (ret);
-	}
-
-	dbp = *dbpp;
-	if ((ret =
-	    dbp->open(dbp, NULL, "__db.rep.db", NULL, DB_BTREE, 0, 0)) != 0) {
-		dbenv->err(dbenv, ret, "DB->open");
-		goto err;
-	}
-
-	if ((ret = dbp->cursor(dbp, NULL, dbcp, 0)) != 0) {
-		dbenv->err(dbenv, ret, "DB->cursor");
-		goto err;
-	}
-
-	return (0);
-
-err:	if (*dbpp != NULL)
-		(void)(*dbpp)->close(*dbpp, 0);
-	return (ret);
-}
diff --git a/bdb/build_vxworks/db_printlog/db_printlog.wpj b/bdb/build_vxworks/db_printlog/db_printlog.wpj
deleted file mode 100755
index 514122e61258795bc88a4046c1981b754378ca13..0000000000000000000000000000000000000000
--- a/bdb/build_vxworks/db_printlog/db_printlog.wpj
+++ /dev/null
@@ -1,160 +0,0 @@
-Document file - DO NOT EDIT
-
-<BEGIN> BUILD_PENTIUMgnu_BUILDRULE
-db_printlog.out
-<END>
-
-<BEGIN> BUILD_PENTIUMgnu_MACRO_AR
-ar386
-<END>
-
-<BEGIN> BUILD_PENTIUMgnu_MACRO_ARCHIVE
-$(PRJ_DIR)/PENTIUMgnu/db_printlog.a
-<END>
-
-<BEGIN> BUILD_PENTIUMgnu_MACRO_AS
-cc386
-<END>
-
-<BEGIN> BUILD_PENTIUMgnu_MACRO_CC
-cc386
-<END>
-
-<BEGIN> BUILD_PENTIUMgnu_MACRO_CFLAGS
--g \
-	-mpentium \
-	-ansi \
-	-nostdinc \
-	-DRW_MULTI_THREAD \
-	-D_REENTRANT \
-	-fvolatile \
-	-nostdlib \
-	-fno-builtin \
-	-fno-defer-pop \
-	-I$(PRJ_DIR)/.. \
-	-I$(PRJ_DIR)/../.. \
-	-I$(WIND_BASE)/target/h \
-	-DCPU=PENTIUM
-<END>
-
-<BEGIN> BUILD_PENTIUMgnu_MACRO_CFLAGS_AS
--g \
-	-mpentium \
-	-ansi \
-	-nostdinc \
-	-fvolatile \
-	-nostdlib \
-	-fno-builtin \
-	-fno-defer-pop \
-	-P \
-	-x \
-	assembler-with-cpp \
-	-I$(WIND_BASE)/target/h \
-	-DCPU=PENTIUM
-<END>
-
-<BEGIN> BUILD_PENTIUMgnu_MACRO_CPP
-cc386 -E -P -xc
-<END>
-
-<BEGIN> BUILD_PENTIUMgnu_MACRO_LD
-ld386
-<END>
-
-<BEGIN> BUILD_PENTIUMgnu_MACRO_LDDEPS
-
-<END>
-
-<BEGIN> BUILD_PENTIUMgnu_MACRO_LDFLAGS
--X -N
-<END>
-
-<BEGIN> BUILD_PENTIUMgnu_MACRO_LD_PARTIAL_FLAGS
--X -r
-<END>
-
-<BEGIN> BUILD_PENTIUMgnu_MACRO_NM
-nm386 -g
-<END>
-
-<BEGIN> BUILD_PENTIUMgnu_MACRO_OPTION_DEFINE_MACRO
--D
-<END>
-
-<BEGIN> BUILD_PENTIUMgnu_MACRO_OPTION_INCLUDE_DIR
--I
-<END>
-
-<BEGIN> BUILD_PENTIUMgnu_MACRO_POST_BUILD_RULE
-
-<END>
-
-<BEGIN> BUILD_PENTIUMgnu_MACRO_PRJ_LIBS
-
-<END>
-
-<BEGIN> BUILD_PENTIUMgnu_MACRO_SIZE
-size386
-<END>
-
-<BEGIN> BUILD_PENTIUMgnu_RO_DEPEND_PATH
-{$(WIND_BASE)/target/h/} \
-	{$(WIND_BASE)/target/src/} \
-	{$(WIND_BASE)/target/config/}
-<END>
-
-<BEGIN> BUILD_PENTIUMgnu_TC
-::tc_PENTIUMgnu
-<END>
-
-<BEGIN> BUILD_RULE_archive
-
-<END>
-
-<BEGIN> BUILD_RULE_db_printlog.out
-
-<END>
-
-<BEGIN> BUILD_RULE_objects
-
-<END>
-
-<BEGIN> BUILD__CURRENT
-PENTIUMgnu
-<END>
-
-<BEGIN> BUILD__LIST
-PENTIUMgnu
-<END>
-
-<BEGIN> CORE_INFO_TYPE
-::prj_vxApp
-<END>
-
-<BEGIN> CORE_INFO_VERSION
-2.0
-<END>
-
-<BEGIN> FILE_db_printlog.c_dependDone
-FALSE
-<END>
-
-<BEGIN> FILE_db_printlog.c_dependencies
-
-<END>
-
-<BEGIN> FILE_db_printlog.c_objects
-db_printlog.o
-<END>
-
-<BEGIN> FILE_db_printlog.c_tool
-C/C++ compiler
-<END>
-
-<BEGIN> PROJECT_FILES
-$(PRJ_DIR)/db_printlog.c
-<END>
-
-<BEGIN> userComments
-db_printlog
-<END>
diff --git a/bdb/build_vxworks/db_printlog/db_printlog/Makefile.custom b/bdb/build_vxworks/db_printlog/db_printlog/Makefile.custom
deleted file mode 100644
index ca781f7b251ef99e49e5fc1859ee6cf3d67c60b0..0000000000000000000000000000000000000000
--- a/bdb/build_vxworks/db_printlog/db_printlog/Makefile.custom
+++ /dev/null
@@ -1,51 +0,0 @@
-#
-# Custom Makefile shell
-#
-# This file may be edited freely, since it will not be regenerated
-# by the project manager.
-#
-# Use this makefile to define rules to make external binaries
-# and deposit them in the $(EXTERNAL_BINARIES_DIR) directory.
-#
-# If you have specified external modules during your component
-# creation, you will find make rules already in place below.
-# You will likely have to edit these to suit your individual
-# build setup.
-#
-# You may wish to use the CPU, BUILD_SPEC or TOOL make variables in
-# your Makefile to support builds for different architectures.  Use
-# the FORCE_EXTERNAL_MAKE phony target to ensure that your external
-# make always runs.
-#
-# The example below assumes that your custom makefile is in the
-# mySourceTree directory, and that the binary file it produces
-# is placed into the $(BUILD_SPEC) sub-directory.
-#
-# EXTERNAL_SOURCE_BASE = /folk/me/mySourceTree
-# EXTERNAL_MODULE = myLibrary.o
-# EXTERNAL_MAKE = make
-#
-# $(EXTERNAL_BINARIES_DIR)/$(EXTERNAL_MODULE) : FORCE_EXTERNAL_MAKE
-#	$(EXTERNAL_MAKE) -C $(EXTERNAL_SOURCE_BASE) \
-#	-f $(EXTERNAL_SOURCE_BASE)/Makefile \
-#	CPU=$(CPU) BUILD_SPEC=$(BUILD_SPEC) $(@F)
-#	$(CP) $(subst /,$(DIRCHAR),$(EXTERNAL_SOURCE_BASE)/$(BUILD_SPEC)/$(@F) $@)
-#
-# If you are not adding your external modules from the component wizard,
-# you will have to include them in your component yourself:
-#
-# From the GUI, you can do this with the Component's 'Add external module'
-# dialog.
-#
-# If you are using the command line, add the module(s) by editing the
-# MODULES line in component.cdf file, e.g.
-#
-# Component INCLUDE_MYCOMPONENT {
-#
-#   MODULES         foo.o goo.o \
-#         myLibrary.o
-#
-
-
-# rules to build custom libraries
-
diff --git a/bdb/build_vxworks/db_printlog/db_printlog/component.cdf b/bdb/build_vxworks/db_printlog/db_printlog/component.cdf
deleted file mode 100755
index 57c645259a47ac59537d097799bfd0bd86ed8e40..0000000000000000000000000000000000000000
--- a/bdb/build_vxworks/db_printlog/db_printlog/component.cdf
+++ /dev/null
@@ -1,30 +0,0 @@
-/* component.cdf - dynamically updated configuration */
-
-/*
- * NOTE: you may edit this file to alter the configuration
- * But all non-configuration information, including comments,
- * will be lost upon rebuilding this project.
- */
-
-/* Component information */
-
-Component INCLUDE_DB_PRINTLOG {
-	ENTRY_POINTS	ALL_GLOBAL_SYMBOLS 
-	MODULES		db_printlog.o 
-	NAME		db_printlog
-	PREF_DOMAIN	ANY
-	_INIT_ORDER	usrComponentsInit
-}
-
-/* EntryPoint information */
-
-/* Module information */
-
-Module db_printlog.o {
-
-	NAME		db_printlog.o
-	SRC_PATH_NAME	$PRJ_DIR/../db_printlog.c
-}
-
-/* Parameter information */
-
diff --git a/bdb/build_vxworks/db_printlog/db_printlog/component.wpj b/bdb/build_vxworks/db_printlog/db_printlog/component.wpj
deleted file mode 100755
index 81d2447459df24b9d43547d0ba5af23abb07aa8a..0000000000000000000000000000000000000000
--- a/bdb/build_vxworks/db_printlog/db_printlog/component.wpj
+++ /dev/null
@@ -1,475 +0,0 @@
-Document file - DO NOT EDIT
-
-<BEGIN> CORE_INFO_TYPE
-::prj_component
-<END>
-
-<BEGIN> CORE_INFO_VERSION
-AE1.1
-<END>
-
-<BEGIN> BUILD__CURRENT
-PENTIUM2gnu.debug
-<END>
-
-<BEGIN> BUILD_PENTIUM2gnu.debug_CURRENT_TARGET
-default
-<END>
-
-<BEGIN> BUILD_PENTIUM2gnu.debug_DEFAULTFORCPU
-1
-<END>
-
-<BEGIN> BUILD_PENTIUM2gnu.debug_FILE_$(PRJ_DIR)/../db_printlog.c_infoTags
-toolMacro objects
-<END>
-
-<BEGIN> BUILD_PENTIUM2gnu.debug_FILE_$(PRJ_DIR)/../db_printlog.c_objects
-db_printlog.o
-<END>
-
-<BEGIN> BUILD_PENTIUM2gnu.debug_FILE_$(PRJ_DIR)/../db_printlog.c_toolMacro
-CC
-<END>
-
-<BEGIN> BUILD_PENTIUM2gnu.debug_FILE_$(PRJ_DIR)/../db_printlog.c_objects
-db_printlog.o
-<END>
-
-<BEGIN> BUILD_PENTIUM2gnu.debug_FILE_$(PRJ_DIR)/../db_printlog.c_toolMacro
-CC
-<END>
-
-<BEGIN> BUILD_PENTIUM2gnu.debug_FILE_$(PRJ_DIR)/compConfig.c_infoTags
-toolMacro objects
-<END>
-
-<BEGIN> BUILD_PENTIUM2gnu.debug_FILE_$(PRJ_DIR)/compConfig.c_objects
-compConfig.o
-<END>
-
-<BEGIN> BUILD_PENTIUM2gnu.debug_FILE_$(PRJ_DIR)/compConfig.c_toolMacro
-CC
-<END>
-
-<BEGIN> BUILD_PENTIUM2gnu.debug_MACRO_AR
-arpentium
-<END>
-
-<BEGIN> BUILD_PENTIUM2gnu.debug_MACRO_AS
-ccpentium
-<END>
-
-<BEGIN> BUILD_PENTIUM2gnu.debug_MACRO_CC
-ccpentium
-<END>
-
-<BEGIN> BUILD_PENTIUM2gnu.debug_MACRO_CFLAGS
--mcpu=pentiumpro \
-	-march=pentiumpro \
-	-ansi \
-	-DRW_MULTI_THREAD \
-	-D_REENTRANT \
-	-g \
-	-nostdlib \
-	-fno-builtin \
-	-fno-defer-pop \
-	-MD \
-	-Wall \
-	-I. \
-	-I$(WIND_BASE)/target/h \
-	-I$(PRJ_DIR)/../.. \
-	-I$(PRJ_DIR)/../../.. \
-	-DCPU=PENTIUM2
-<END>
-
-<BEGIN> BUILD_PENTIUM2gnu.debug_MACRO_CFLAGS_AS
--mcpu=pentiumpro \
-	-march=pentiumpro \
-	-ansi \
-	-g \
-	-nostdlib \
-	-fno-builtin \
-	-fno-defer-pop \
-	-P \
-	-x \
-	assembler-with-cpp \
-	-Wall \
-	-I. \
-	-I$(WIND_BASE)/target/h \
-	-DCPU=PENTIUM2
-<END>
-
-<BEGIN> BUILD_PENTIUM2gnu.debug_MACRO_CPP
-ccpentium -E -P
-<END>
-
-<BEGIN> BUILD_PENTIUM2gnu.debug_MACRO_CPPFILT
-c++filtpentium --strip-underscores
-<END>
-
-<BEGIN> BUILD_PENTIUM2gnu.debug_MACRO_LD
-ldpentium
-<END>
-
-<BEGIN> BUILD_PENTIUM2gnu.debug_MACRO_LDFLAGS
--X
-<END>
-
-<BEGIN> BUILD_PENTIUM2gnu.debug_MACRO_LDPARTIAL
-ccpentium \
-	-B$(WIND_BASE)/host/$(WIND_HOST_TYPE)/lib/gcc-lib/ \
-	-nostdlib \
-	-r \
-	-Wl,-X
-<END>
-
-<BEGIN> BUILD_PENTIUM2gnu.debug_MACRO_LD_PARTIAL_FLAGS
--X -r
-<END>
-
-<BEGIN> BUILD_PENTIUM2gnu.debug_MACRO_NM
-nmpentium -g
-<END>
-
-<BEGIN> BUILD_PENTIUM2gnu.debug_MACRO_OPTION_DEFINE_MACRO
--D
-<END>
-
-<BEGIN> BUILD_PENTIUM2gnu.debug_MACRO_OPTION_GENERATE_DEPENDENCY_FILE
--MD
-<END>
-
-<BEGIN> BUILD_PENTIUM2gnu.debug_MACRO_OPTION_INCLUDE_DIR
--I
-<END>
-
-<BEGIN> BUILD_PENTIUM2gnu.debug_MACRO_RELEASE
-0
-<END>
-
-<BEGIN> BUILD_PENTIUM2gnu.debug_MACRO_SIZE
-sizepentium
-<END>
-
-<BEGIN> BUILD_PENTIUM2gnu.debug_RELEASE
-0
-<END>
-
-<BEGIN> BUILD_PENTIUM2gnu.debug_RO_DEPEND_PATH
-$(WIND_BASE)/target/h/
-<END>
-
-<BEGIN> BUILD_PENTIUM2gnu.debug_TC
-::tc_PENTIUM2gnu.debug
-<END>
-
-<BEGIN> BUILD_PENTIUM2gnu.release_DEFAULTFORCPU
-0
-<END>
-
-<BEGIN> BUILD_PENTIUM2gnu.release_FILE_$(PRJ_DIR)/../db_printlog.c_infoTags
-toolMacro objects
-<END>
-
-<BEGIN> BUILD_PENTIUM2gnu.release_FILE_$(PRJ_DIR)/../db_printlog.c_objects
-db_printlog.o
-<END>
-
-<BEGIN> BUILD_PENTIUM2gnu.release_FILE_$(PRJ_DIR)/../db_printlog.c_toolMacro
-CC
-<END>
-
-<BEGIN> BUILD_PENTIUM2gnu.release_FILE_$(PRJ_DIR)/compConfig.c_infoTags
-toolMacro objects
-<END>
-
-<BEGIN> BUILD_PENTIUM2gnu.release_FILE_$(PRJ_DIR)/compConfig.c_objects
-compConfig.o
-<END>
-
-<BEGIN> BUILD_PENTIUM2gnu.release_FILE_$(PRJ_DIR)/compConfig.c_toolMacro
-CC
-<END>
-
-<BEGIN> BUILD_PENTIUM2gnu.release_MACRO_AR
-arpentium
-<END>
-
-<BEGIN> BUILD_PENTIUM2gnu.release_MACRO_AS
-ccpentium
-<END>
-
-<BEGIN> BUILD_PENTIUM2gnu.release_MACRO_CC
-ccpentium
-<END>
-
-<BEGIN> BUILD_PENTIUM2gnu.release_MACRO_CFLAGS
--mcpu=pentiumpro \
-	-march=pentiumpro \
-	-ansi \
-	-DRW_MULTI_THREAD \
-	-D_REENTRANT \
-	-O2 \
-	-nostdlib \
-	-fno-builtin \
-	-fno-defer-pop \
-	-MD \
-	-Wall \
-	-I. \
-	-I$(WIND_BASE)/target/h \
-	-I$(PRJ_DIR)/../.. \
-	-I$(PRJ_DIR)/../../.. \
-	-DCPU=PENTIUM2
-<END>
-
-<BEGIN> BUILD_PENTIUM2gnu.release_MACRO_CFLAGS_AS
--mcpu=pentiumpro \
-	-march=pentiumpro \
-	-ansi \
-	-O2 \
-	-nostdlib \
-	-fno-builtin \
-	-fno-defer-pop \
-	-P \
-	-x \
-	assembler-with-cpp \
-	-Wall \
-	-I. \
-	-I$(WIND_BASE)/target/h \
-	-DCPU=PENTIUM2
-<END>
-
-<BEGIN> BUILD_PENTIUM2gnu.release_MACRO_CPP
-ccpentium -E -P
-<END>
-
-<BEGIN> BUILD_PENTIUM2gnu.release_MACRO_CPPFILT
-c++filtpentium --strip-underscores
-<END>
-
-<BEGIN> BUILD_PENTIUM2gnu.release_MACRO_LD
-ldpentium
-<END>
-
-<BEGIN> BUILD_PENTIUM2gnu.release_MACRO_LDFLAGS
--X
-<END>
-
-<BEGIN> BUILD_PENTIUM2gnu.release_MACRO_LDPARTIAL
-ccpentium \
-	-B$(WIND_BASE)/host/$(WIND_HOST_TYPE)/lib/gcc-lib/ \
-	-nostdlib \
-	-r \
-	-Wl,-X
-<END>
-
-<BEGIN> BUILD_PENTIUM2gnu.release_MACRO_LD_PARTIAL_FLAGS
--X -r
-<END>
-
-<BEGIN> BUILD_PENTIUM2gnu.release_MACRO_NM
-nmpentium -g
-<END>
-
-<BEGIN> BUILD_PENTIUM2gnu.release_MACRO_OPTION_DEFINE_MACRO
--D
-<END>
-
-<BEGIN> BUILD_PENTIUM2gnu.release_MACRO_OPTION_GENERATE_DEPENDENCY_FILE
--MD
-<END>
-
-<BEGIN> BUILD_PENTIUM2gnu.release_MACRO_OPTION_INCLUDE_DIR
--I
-<END>
-
-<BEGIN> BUILD_PENTIUM2gnu.release_MACRO_RELEASE
-1
-<END>
-
-<BEGIN> BUILD_PENTIUM2gnu.release_MACRO_SIZE
-sizepentium
-<END>
-
-<BEGIN> BUILD_PENTIUM2gnu.release_RELEASE
-1
-<END>
-
-<BEGIN> BUILD_PENTIUM2gnu.release_RO_DEPEND_PATH
-$(WIND_BASE)/target/h/
-<END>
-
-<BEGIN> BUILD_PENTIUM2gnu.release_TC
-::tc_PENTIUM2gnu.release
-<END>
-
-<BEGIN> BUILD_PENTIUMgnu.debug_DEFAULTFORCPU
-1
-<END>
-
-<BEGIN> BUILD_PENTIUMgnu.debug_FILE_$(PRJ_DIR)/../db_printlog.c_infoTags
-toolMacro objects
-<END>
-
-<BEGIN> BUILD_PENTIUMgnu.debug_FILE_$(PRJ_DIR)/../db_printlog.c_objects
-db_printlog.o
-<END>
-
-<BEGIN> BUILD_PENTIUMgnu.debug_FILE_$(PRJ_DIR)/../db_printlog.c_toolMacro
-CC
-<END>
-
-<BEGIN> BUILD_PENTIUMgnu.debug_FILE_$(PRJ_DIR)/compConfig.c_infoTags
-toolMacro objects
-<END>
-
-<BEGIN> BUILD_PENTIUMgnu.debug_FILE_$(PRJ_DIR)/compConfig.c_objects
-compConfig.o
-<END>
-
-<BEGIN> BUILD_PENTIUMgnu.debug_FILE_$(PRJ_DIR)/compConfig.c_toolMacro
-CC
-<END>
-
-<BEGIN> BUILD_PENTIUMgnu.debug_MACRO_AR
-arpentium
-<END>
-
-<BEGIN> BUILD_PENTIUMgnu.debug_MACRO_AS
-ccpentium
-<END>
-
-<BEGIN> BUILD_PENTIUMgnu.debug_MACRO_CC
-ccpentium
-<END>
-
-<BEGIN> BUILD_PENTIUMgnu.debug_MACRO_CFLAGS
--mcpu=pentium \
-	-march=pentium \
-	-ansi \
-	-DRW_MULTI_THREAD \
-	-D_REENTRANT \
-	-g \
-	-nostdlib \
-	-fno-builtin \
-	-fno-defer-pop \
-	-MD \
-	-Wall \
-	-I. \
-	-I$(WIND_BASE)/target/h \
-	-I$(PRJ_DIR)/../.. \
-	-I$(PRJ_DIR)/../../.. \
-	-DCPU=PENTIUM
-<END>
-
-<BEGIN> BUILD_PENTIUMgnu.debug_MACRO_CFLAGS_AS
--mcpu=pentium \
-	-march=pentium \
-	-ansi \
-	-g \
-	-nostdlib \
-	-fno-builtin \
-	-fno-defer-pop \
-	-P \
-	-x \
-	assembler-with-cpp \
-	-Wall \
-	-I. \
-	-I$(WIND_BASE)/target/h \
-	-DCPU=PENTIUM
-<END>
-
-<BEGIN> BUILD_PENTIUMgnu.debug_MACRO_CPP
-ccpentium -E -P
-<END>
-
-<BEGIN> BUILD_PENTIUMgnu.debug_MACRO_CPPFILT
-c++filtpentium --strip-underscores
-<END>
-
-<BEGIN> BUILD_PENTIUMgnu.debug_MACRO_LD
-ldpentium
-<END>
-
-<BEGIN> BUILD_PENTIUMgnu.debug_MACRO_LDFLAGS
--X
-<END>
-
-<BEGIN> BUILD_PENTIUMgnu.debug_MACRO_LDPARTIAL
-ccpentium \
-	-B$(WIND_BASE)/host/$(WIND_HOST_TYPE)/lib/gcc-lib/ \
-	-nostdlib \
-	-r \
-	-Wl,-X
-<END>
-
-<BEGIN> BUILD_PENTIUMgnu.debug_MACRO_LD_PARTIAL_FLAGS
--X -r
-<END>
-
-<BEGIN> BUILD_PENTIUMgnu.debug_MACRO_NM
-nmpentium -g
-<END>
-
-<BEGIN> BUILD_PENTIUMgnu.debug_MACRO_OPTION_DEFINE_MACRO
--D
-<END>
-
-<BEGIN> BUILD_PENTIUMgnu.debug_MACRO_OPTION_GENERATE_DEPENDENCY_FILE
--MD
-<END>
-
-<BEGIN> BUILD_PENTIUMgnu.debug_MACRO_OPTION_INCLUDE_DIR
--I
-<END>
-
-<BEGIN> BUILD_PENTIUMgnu.debug_MACRO_RELEASE
-0
-<END>
-
-<BEGIN> BUILD_PENTIUMgnu.debug_MACRO_SIZE
-sizepentium
-<END>
-
-<BEGIN> BUILD_PENTIUMgnu.debug_RELEASE
-0
-<END>
-
-<BEGIN> BUILD_PENTIUMgnu.debug_RO_DEPEND_PATH
-$(WIND_BASE)/target/h/
-<END>
-
-<BEGIN> BUILD_PENTIUMgnu.debug_TC
-::tc_PENTIUMgnu.debug
-<END>
-
-<BEGIN> BUILD__LIST
-PENTIUM2gnu.debug PENTIUM2gnu.release PENTIUMgnu.debug
-<END>
-
-<BEGIN> PROJECT_FILES
-$(PRJ_DIR)/../db_printlog.c \
-	$(PRJ_DIR)/compConfig.c
-<END>
-
-<BEGIN> WCC__CDF_PATH
-$(PRJ_DIR)
-<END>
-
-<BEGIN> WCC__CURRENT
-PENTIUM2gnu.debug
-<END>
-
-<BEGIN> WCC__LIST
-PENTIUM2gnu.debug
-<END>
-
-<BEGIN> WCC__MXR_LIBS
-lib$(CPU)$(TOOL)vx.a
-<END>
-
-<BEGIN> WCC__OBJS_PATH
-$(WIND_BASE)/target/lib/obj$CPU$TOOLvx
-<END>
-
diff --git a/bdb/build_vxworks/db_recover/db_recover.c b/bdb/build_vxworks/db_recover/db_recover.c
deleted file mode 100644
index 055964c8508fde0eb0fa4c3edab1dae42835759a..0000000000000000000000000000000000000000
--- a/bdb/build_vxworks/db_recover/db_recover.c
+++ /dev/null
@@ -1,328 +0,0 @@
-/*-
- * See the file LICENSE for redistribution information.
- *
- * Copyright (c) 1996-2002
- *	Sleepycat Software.  All rights reserved.
- */
-
-#include "db_config.h"
-
-#ifndef lint
-static const char copyright[] =
-    "Copyright (c) 1996-2002\nSleepycat Software Inc.  All rights reserved.\n";
-static const char revid[] =
-    "$Id: db_recover.c,v 11.33 2002/03/28 20:13:42 bostic Exp $";
-#endif
-
-#ifndef NO_SYSTEM_INCLUDES
-#include <sys/types.h>
-
-#if TIME_WITH_SYS_TIME
-#include <sys/time.h>
-#include <time.h>
-#else
-#if HAVE_SYS_TIME_H
-#include <sys/time.h>
-#else
-#include <time.h>
-#endif
-#endif
-
-#include <stdlib.h>
-#include <string.h>
-#include <unistd.h>
-#endif
-
-#include "db_int.h"
-#include "dbinc/txn.h"
-
-int db_recover_main __P((int, char *[]));
-int db_recover_read_timestamp __P((const char *, char *, time_t *));
-int db_recover_usage __P((void));
-int db_recover_version_check __P((const char *));
-
-int
-db_recover(args)
-	char *args;
-{
-	int argc;
-	char **argv;
-
-	__db_util_arg("db_recover", args, &argc, &argv);
-	return (db_recover_main(argc, argv) ? EXIT_FAILURE : EXIT_SUCCESS);
-}
-
-#include <stdio.h>
-#define	ERROR_RETURN	ERROR
-
-int
-db_recover_main(argc, argv)
-	int argc;
-	char *argv[];
-{
-	extern char *optarg;
-	extern int optind, __db_getopt_reset;
-	const char *progname = "db_recover";
-	DB_ENV	*dbenv;
-	DB_TXNREGION *region;
-	time_t now, timestamp;
-	u_int32_t flags;
-	int ch, exitval, fatal_recover, ret, retain_env, verbose;
-	char *home, *passwd;
-
-	if ((ret = db_recover_version_check(progname)) != 0)
-		return (ret);
-
-	home = passwd = NULL;
-	timestamp = 0;
-	exitval = fatal_recover = retain_env = verbose = 0;
-	__db_getopt_reset = 1;
-	while ((ch = getopt(argc, argv, "ceh:P:t:Vv")) != EOF)
-		switch (ch) {
-		case 'c':
-			fatal_recover = 1;
-			break;
-		case 'e':
-			retain_env = 1;
-			break;
-		case 'h':
-			home = optarg;
-			break;
-		case 'P':
-			passwd = strdup(optarg);
-			memset(optarg, 0, strlen(optarg));
-			if (passwd == NULL) {
-				fprintf(stderr, "%s: strdup: %s\n",
-				    progname, strerror(errno));
-				return (EXIT_FAILURE);
-			}
-			break;
-		case 't':
-			if ((ret =
-			    db_recover_read_timestamp(progname, optarg, &timestamp)) != 0)
-				return (ret);
-			break;
-		case 'V':
-			printf("%s\n", db_version(NULL, NULL, NULL));
-			return (EXIT_SUCCESS);
-		case 'v':
-			verbose = 1;
-			break;
-		case '?':
-		default:
-			return (db_recover_usage());
-		}
-	argc -= optind;
-	argv += optind;
-
-	if (argc != 0)
-		return (db_recover_usage());
-
-	/* Handle possible interruptions. */
-	__db_util_siginit();
-
-	/*
-	 * Create an environment object and initialize it for error
-	 * reporting.
-	 */
-	if ((ret = db_env_create(&dbenv, 0)) != 0) {
-		fprintf(stderr,
-		    "%s: db_env_create: %s\n", progname, db_strerror(ret));
-		return (EXIT_FAILURE);
-	}
-	dbenv->set_errfile(dbenv, stderr);
-	dbenv->set_errpfx(dbenv, progname);
-	if (verbose) {
-		(void)dbenv->set_verbose(dbenv, DB_VERB_RECOVERY, 1);
-		(void)dbenv->set_verbose(dbenv, DB_VERB_CHKPOINT, 1);
-	}
-	if (timestamp &&
-	    (ret = dbenv->set_tx_timestamp(dbenv, &timestamp)) != 0) {
-		dbenv->err(dbenv, ret, "DB_ENV->set_timestamp");
-		goto shutdown;
-	}
-
-	if (passwd != NULL && (ret = dbenv->set_encrypt(dbenv,
-	    passwd, DB_ENCRYPT_AES)) != 0) {
-		dbenv->err(dbenv, ret, "set_passwd");
-		goto shutdown;
-	}
-
-	/*
-	 * Initialize the environment -- we don't actually do anything
-	 * else, that all that's needed to run recovery.
-	 *
-	 * Note that unless the caller specified the -e option, we use a
-	 * private environment, as we're about to create a region, and we
-	 * don't want to to leave it around.  If we leave the region around,
-	 * the application that should create it will simply join it instead,
-	 * and will then be running with incorrectly sized (and probably
-	 * terribly small) caches.  Applications that use -e should almost
-	 * certainly use DB_CONFIG files in the directory.
-	 */
-	flags = 0;
-	LF_SET(DB_CREATE | DB_INIT_LOCK | DB_INIT_LOG |
-	    DB_INIT_MPOOL | DB_INIT_TXN | DB_USE_ENVIRON);
-	LF_SET(fatal_recover ? DB_RECOVER_FATAL : DB_RECOVER);
-	LF_SET(retain_env ? 0 : DB_PRIVATE);
-	if ((ret = dbenv->open(dbenv, home, flags, 0)) != 0) {
-		dbenv->err(dbenv, ret, "DB_ENV->open");
-		goto shutdown;
-	}
-
-	if (verbose) {
-		(void)time(&now);
-		region = ((DB_TXNMGR *)dbenv->tx_handle)->reginfo.primary;
-		dbenv->errx(dbenv, "Recovery complete at %.24s", ctime(&now));
-		dbenv->errx(dbenv, "%s %lx %s [%lu][%lu]",
-		    "Maximum transaction id", (u_long)region->last_txnid,
-		    "Recovery checkpoint", (u_long)region->last_ckp.file,
-		    (u_long)region->last_ckp.offset);
-	}
-
-	if (0) {
-shutdown:	exitval = 1;
-	}
-
-	/* Clean up the environment. */
-	if ((ret = dbenv->close(dbenv, 0)) != 0) {
-		exitval = 1;
-		fprintf(stderr,
-		    "%s: dbenv->close: %s\n", progname, db_strerror(ret));
-	}
-
-	/* Resend any caught signal. */
-	__db_util_sigresend();
-
-	return (exitval == 0 ? EXIT_SUCCESS : EXIT_FAILURE);
-}
-
-#define	ATOI2(ar)	((ar)[0] - '0') * 10 + ((ar)[1] - '0'); (ar) += 2;
-
-/*
- * read_timestamp --
- *	Convert a time argument to Epoch seconds.
- *
- * Copyright (c) 1993
- *	The Regents of the University of California.  All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- *    notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- *    notice, this list of conditions and the following disclaimer in the
- *    documentation and/or other materials provided with the distribution.
- * 3. Neither the name of the University nor the names of its contributors
- *    may be used to endorse or promote products derived from this software
- *    without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
- * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
- * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
- * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
- * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
- * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
- * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
- * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
- * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
- * SUCH DAMAGE.
- */
-int
-db_recover_read_timestamp(progname, arg, timep)
-	const char *progname;
-	char *arg;
-	time_t *timep;
-{
-	struct tm *t;
-	time_t now;
-	int yearset;
-	char *p;
-					/* Start with the current time. */
-	(void)time(&now);
-	if ((t = localtime(&now)) == NULL) {
-		fprintf(stderr,
-		    "%s: localtime: %s\n", progname, strerror(errno));
-		return (EXIT_FAILURE);
-	}
-					/* [[CC]YY]MMDDhhmm[.SS] */
-	if ((p = strchr(arg, '.')) == NULL)
-		t->tm_sec = 0;		/* Seconds defaults to 0. */
-	else {
-		if (strlen(p + 1) != 2)
-			goto terr;
-		*p++ = '\0';
-		t->tm_sec = ATOI2(p);
-	}
-
-	yearset = 0;
-	switch(strlen(arg)) {
-	case 12:			/* CCYYMMDDhhmm */
-		t->tm_year = ATOI2(arg);
-		t->tm_year *= 100;
-		yearset = 1;
-		/* FALLTHROUGH */
-	case 10:			/* YYMMDDhhmm */
-		if (yearset) {
-			yearset = ATOI2(arg);
-			t->tm_year += yearset;
-		} else {
-			yearset = ATOI2(arg);
-			if (yearset < 69)
-				t->tm_year = yearset + 2000;
-			else
-				t->tm_year = yearset + 1900;
-		}
-		t->tm_year -= 1900;	/* Convert to UNIX time. */
-		/* FALLTHROUGH */
-	case 8:				/* MMDDhhmm */
-		t->tm_mon = ATOI2(arg);
-		--t->tm_mon;		/* Convert from 01-12 to 00-11 */
-		t->tm_mday = ATOI2(arg);
-		t->tm_hour = ATOI2(arg);
-		t->tm_min = ATOI2(arg);
-		break;
-	default:
-		goto terr;
-	}
-
-	t->tm_isdst = -1;		/* Figure out DST. */
-
-	*timep = mktime(t);
-	if (*timep == -1) {
-terr:		fprintf(stderr,
-	"%s: out of range or illegal time specification: [[CC]YY]MMDDhhmm[.SS]",
-		    progname);
-		return (EXIT_FAILURE);
-	}
-	return (0);
-}
-
-int
-db_recover_usage()
-{
-	(void)fprintf(stderr, "%s\n",
-"usage: db_recover [-ceVv] [-h home] [-P password] [-t [[CC]YY]MMDDhhmm[.SS]]");
-	return (EXIT_FAILURE);
-}
-
-int
-db_recover_version_check(progname)
-	const char *progname;
-{
-	int v_major, v_minor, v_patch;
-
-	/* Make sure we're loaded with the right version of the DB library. */
-	(void)db_version(&v_major, &v_minor, &v_patch);
-	if (v_major != DB_VERSION_MAJOR ||
-	    v_minor != DB_VERSION_MINOR || v_patch != DB_VERSION_PATCH) {
-		fprintf(stderr,
-	"%s: version %d.%d.%d doesn't match library version %d.%d.%d\n",
-		    progname, DB_VERSION_MAJOR, DB_VERSION_MINOR,
-		    DB_VERSION_PATCH, v_major, v_minor, v_patch);
-		return (EXIT_FAILURE);
-	}
-	return (0);
-}
diff --git a/bdb/build_vxworks/db_recover/db_recover.wpj b/bdb/build_vxworks/db_recover/db_recover.wpj
deleted file mode 100755
index 2df7234233ac4108ed8efbcc4df849df3c1ed353..0000000000000000000000000000000000000000
--- a/bdb/build_vxworks/db_recover/db_recover.wpj
+++ /dev/null
@@ -1,160 +0,0 @@
-Document file - DO NOT EDIT
-
-<BEGIN> BUILD_PENTIUMgnu_BUILDRULE
-db_recover.out
-<END>
-
-<BEGIN> BUILD_PENTIUMgnu_MACRO_AR
-ar386
-<END>
-
-<BEGIN> BUILD_PENTIUMgnu_MACRO_ARCHIVE
-$(PRJ_DIR)/PENTIUMgnu/db_recover.a
-<END>
-
-<BEGIN> BUILD_PENTIUMgnu_MACRO_AS
-cc386
-<END>
-
-<BEGIN> BUILD_PENTIUMgnu_MACRO_CC
-cc386
-<END>
-
-<BEGIN> BUILD_PENTIUMgnu_MACRO_CFLAGS
--g \
-	-mpentium \
-	-ansi \
-	-nostdinc \
-	-DRW_MULTI_THREAD \
-	-D_REENTRANT \
-	-fvolatile \
-	-nostdlib \
-	-fno-builtin \
-	-fno-defer-pop \
-	-I$(PRJ_DIR)/.. \
-	-I$(PRJ_DIR)/../.. \
-	-I$(WIND_BASE)/target/h \
-	-DCPU=PENTIUM
-<END>
-
-<BEGIN> BUILD_PENTIUMgnu_MACRO_CFLAGS_AS
--g \
-	-mpentium \
-	-ansi \
-	-nostdinc \
-	-fvolatile \
-	-nostdlib \
-	-fno-builtin \
-	-fno-defer-pop \
-	-P \
-	-x \
-	assembler-with-cpp \
-	-I$(WIND_BASE)/target/h \
-	-DCPU=PENTIUM
-<END>
-
-<BEGIN> BUILD_PENTIUMgnu_MACRO_CPP
-cc386 -E -P -xc
-<END>
-
-<BEGIN> BUILD_PENTIUMgnu_MACRO_LD
-ld386
-<END>
-
-<BEGIN> BUILD_PENTIUMgnu_MACRO_LDDEPS
-
-<END>
-
-<BEGIN> BUILD_PENTIUMgnu_MACRO_LDFLAGS
--X -N
-<END>
-
-<BEGIN> BUILD_PENTIUMgnu_MACRO_LD_PARTIAL_FLAGS
--X -r
-<END>
-
-<BEGIN> BUILD_PENTIUMgnu_MACRO_NM
-nm386 -g
-<END>
-
-<BEGIN> BUILD_PENTIUMgnu_MACRO_OPTION_DEFINE_MACRO
--D
-<END>
-
-<BEGIN> BUILD_PENTIUMgnu_MACRO_OPTION_INCLUDE_DIR
--I
-<END>
-
-<BEGIN> BUILD_PENTIUMgnu_MACRO_POST_BUILD_RULE
-
-<END>
-
-<BEGIN> BUILD_PENTIUMgnu_MACRO_PRJ_LIBS
-
-<END>
-
-<BEGIN> BUILD_PENTIUMgnu_MACRO_SIZE
-size386
-<END>
-
-<BEGIN> BUILD_PENTIUMgnu_RO_DEPEND_PATH
-{$(WIND_BASE)/target/h/} \
-	{$(WIND_BASE)/target/src/} \
-	{$(WIND_BASE)/target/config/}
-<END>
-
-<BEGIN> BUILD_PENTIUMgnu_TC
-::tc_PENTIUMgnu
-<END>
-
-<BEGIN> BUILD_RULE_archive
-
-<END>
-
-<BEGIN> BUILD_RULE_db_recover.out
-
-<END>
-
-<BEGIN> BUILD_RULE_objects
-
-<END>
-
-<BEGIN> BUILD__CURRENT
-PENTIUMgnu
-<END>
-
-<BEGIN> BUILD__LIST
-PENTIUMgnu
-<END>
-
-<BEGIN> CORE_INFO_TYPE
-::prj_vxApp
-<END>
-
-<BEGIN> CORE_INFO_VERSION
-2.0
-<END>
-
-<BEGIN> FILE_db_recover.c_dependDone
-FALSE
-<END>
-
-<BEGIN> FILE_db_recover.c_dependencies
-
-<END>
-
-<BEGIN> FILE_db_recover.c_objects
-db_recover.o
-<END>
-
-<BEGIN> FILE_db_recover.c_tool
-C/C++ compiler
-<END>
-
-<BEGIN> PROJECT_FILES
-$(PRJ_DIR)/db_recover.c
-<END>
-
-<BEGIN> userComments
-db_recover
-<END>
diff --git a/bdb/build_vxworks/db_recover/db_recover/Makefile.custom b/bdb/build_vxworks/db_recover/db_recover/Makefile.custom
deleted file mode 100644
index ca781f7b251ef99e49e5fc1859ee6cf3d67c60b0..0000000000000000000000000000000000000000
--- a/bdb/build_vxworks/db_recover/db_recover/Makefile.custom
+++ /dev/null
@@ -1,51 +0,0 @@
-#
-# Custom Makefile shell
-#
-# This file may be edited freely, since it will not be regenerated
-# by the project manager.
-#
-# Use this makefile to define rules to make external binaries
-# and deposit them in the $(EXTERNAL_BINARIES_DIR) directory.
-#
-# If you have specified external modules during your component
-# creation, you will find make rules already in place below.
-# You will likely have to edit these to suit your individual
-# build setup.
-#
-# You may wish to use the CPU, BUILD_SPEC or TOOL make variables in
-# your Makefile to support builds for different architectures.  Use
-# the FORCE_EXTERNAL_MAKE phony target to ensure that your external
-# make always runs.
-#
-# The example below assumes that your custom makefile is in the
-# mySourceTree directory, and that the binary file it produces
-# is placed into the $(BUILD_SPEC) sub-directory.
-#
-# EXTERNAL_SOURCE_BASE = /folk/me/mySourceTree
-# EXTERNAL_MODULE = myLibrary.o
-# EXTERNAL_MAKE = make
-#
-# $(EXTERNAL_BINARIES_DIR)/$(EXTERNAL_MODULE) : FORCE_EXTERNAL_MAKE
-#	$(EXTERNAL_MAKE) -C $(EXTERNAL_SOURCE_BASE) \
-#	-f $(EXTERNAL_SOURCE_BASE)/Makefile \
-#	CPU=$(CPU) BUILD_SPEC=$(BUILD_SPEC) $(@F)
-#	$(CP) $(subst /,$(DIRCHAR),$(EXTERNAL_SOURCE_BASE)/$(BUILD_SPEC)/$(@F) $@)
-#
-# If you are not adding your external modules from the component wizard,
-# you will have to include them in your component yourself:
-#
-# From the GUI, you can do this with the Component's 'Add external module'
-# dialog.
-#
-# If you are using the command line, add the module(s) by editing the
-# MODULES line in component.cdf file, e.g.
-#
-# Component INCLUDE_MYCOMPONENT {
-#
-#   MODULES         foo.o goo.o \
-#         myLibrary.o
-#
-
-
-# rules to build custom libraries
-
diff --git a/bdb/build_vxworks/db_recover/db_recover/component.cdf b/bdb/build_vxworks/db_recover/db_recover/component.cdf
deleted file mode 100755
index d322bf4a8fd7249898e9866059a61e2ec861b99d..0000000000000000000000000000000000000000
--- a/bdb/build_vxworks/db_recover/db_recover/component.cdf
+++ /dev/null
@@ -1,30 +0,0 @@
-/* component.cdf - dynamically updated configuration */
-
-/*
- * NOTE: you may edit this file to alter the configuration
- * But all non-configuration information, including comments,
- * will be lost upon rebuilding this project.
- */
-
-/* Component information */
-
-Component INCLUDE_DB_RECOVER {
-	ENTRY_POINTS	ALL_GLOBAL_SYMBOLS 
-	MODULES		db_recover.o 
-	NAME		db_recover
-	PREF_DOMAIN	ANY
-	_INIT_ORDER	usrComponentsInit
-}
-
-/* EntryPoint information */
-
-/* Module information */
-
-Module db_recover.o {
-
-	NAME		db_recover.o
-	SRC_PATH_NAME	$PRJ_DIR/../db_recover.c
-}
-
-/* Parameter information */
-
diff --git a/bdb/build_vxworks/db_recover/db_recover/component.wpj b/bdb/build_vxworks/db_recover/db_recover/component.wpj
deleted file mode 100755
index 0daf9f6ca1e9307e981d5543da0c10f67b0e963c..0000000000000000000000000000000000000000
--- a/bdb/build_vxworks/db_recover/db_recover/component.wpj
+++ /dev/null
@@ -1,475 +0,0 @@
-Document file - DO NOT EDIT
-
-<BEGIN> CORE_INFO_TYPE
-::prj_component
-<END>
-
-<BEGIN> CORE_INFO_VERSION
-AE1.1
-<END>
-
-<BEGIN> BUILD__CURRENT
-PENTIUM2gnu.debug
-<END>
-
-<BEGIN> BUILD_PENTIUM2gnu.debug_CURRENT_TARGET
-default
-<END>
-
-<BEGIN> BUILD_PENTIUM2gnu.debug_DEFAULTFORCPU
-1
-<END>
-
-<BEGIN> BUILD_PENTIUM2gnu.debug_FILE_$(PRJ_DIR)/../db_recover.c_infoTags
-toolMacro objects
-<END>
-
-<BEGIN> BUILD_PENTIUM2gnu.debug_FILE_$(PRJ_DIR)/../db_recover.c_objects
-db_recover.o
-<END>
-
-<BEGIN> BUILD_PENTIUM2gnu.debug_FILE_$(PRJ_DIR)/../db_recover.c_toolMacro
-CC
-<END>
-
-<BEGIN> BUILD_PENTIUM2gnu.debug_FILE_$(PRJ_DIR)/../db_recover.c_objects
-db_recover.o
-<END>
-
-<BEGIN> BUILD_PENTIUM2gnu.debug_FILE_$(PRJ_DIR)/../db_recover.c_toolMacro
-CC
-<END>
-
-<BEGIN> BUILD_PENTIUM2gnu.debug_FILE_$(PRJ_DIR)/compConfig.c_infoTags
-toolMacro objects
-<END>
-
-<BEGIN> BUILD_PENTIUM2gnu.debug_FILE_$(PRJ_DIR)/compConfig.c_objects
-compConfig.o
-<END>
-
-<BEGIN> BUILD_PENTIUM2gnu.debug_FILE_$(PRJ_DIR)/compConfig.c_toolMacro
-CC
-<END>
-
-<BEGIN> BUILD_PENTIUM2gnu.debug_MACRO_AR
-arpentium
-<END>
-
-<BEGIN> BUILD_PENTIUM2gnu.debug_MACRO_AS
-ccpentium
-<END>
-
-<BEGIN> BUILD_PENTIUM2gnu.debug_MACRO_CC
-ccpentium
-<END>
-
-<BEGIN> BUILD_PENTIUM2gnu.debug_MACRO_CFLAGS
--mcpu=pentiumpro \
-	-march=pentiumpro \
-	-ansi \
-	-DRW_MULTI_THREAD \
-	-D_REENTRANT \
-	-g \
-	-nostdlib \
-	-fno-builtin \
-	-fno-defer-pop \
-	-MD \
-	-Wall \
-	-I. \
-	-I$(WIND_BASE)/target/h \
-	-I$(PRJ_DIR)/../.. \
-	-I$(PRJ_DIR)/../../.. \
-	-DCPU=PENTIUM2
-<END>
-
-<BEGIN> BUILD_PENTIUM2gnu.debug_MACRO_CFLAGS_AS
--mcpu=pentiumpro \
-	-march=pentiumpro \
-	-ansi \
-	-g \
-	-nostdlib \
-	-fno-builtin \
-	-fno-defer-pop \
-	-P \
-	-x \
-	assembler-with-cpp \
-	-Wall \
-	-I. \
-	-I$(WIND_BASE)/target/h \
-	-DCPU=PENTIUM2
-<END>
-
-<BEGIN> BUILD_PENTIUM2gnu.debug_MACRO_CPP
-ccpentium -E -P
-<END>
-
-<BEGIN> BUILD_PENTIUM2gnu.debug_MACRO_CPPFILT
-c++filtpentium --strip-underscores
-<END>
-
-<BEGIN> BUILD_PENTIUM2gnu.debug_MACRO_LD
-ldpentium
-<END>
-
-<BEGIN> BUILD_PENTIUM2gnu.debug_MACRO_LDFLAGS
--X
-<END>
-
-<BEGIN> BUILD_PENTIUM2gnu.debug_MACRO_LDPARTIAL
-ccpentium \
-	-B$(WIND_BASE)/host/$(WIND_HOST_TYPE)/lib/gcc-lib/ \
-	-nostdlib \
-	-r \
-	-Wl,-X
-<END>
-
-<BEGIN> BUILD_PENTIUM2gnu.debug_MACRO_LD_PARTIAL_FLAGS
--X -r
-<END>
-
-<BEGIN> BUILD_PENTIUM2gnu.debug_MACRO_NM
-nmpentium -g
-<END>
-
-<BEGIN> BUILD_PENTIUM2gnu.debug_MACRO_OPTION_DEFINE_MACRO
--D
-<END>
-
-<BEGIN> BUILD_PENTIUM2gnu.debug_MACRO_OPTION_GENERATE_DEPENDENCY_FILE
--MD
-<END>
-
-<BEGIN> BUILD_PENTIUM2gnu.debug_MACRO_OPTION_INCLUDE_DIR
--I
-<END>
-
-<BEGIN> BUILD_PENTIUM2gnu.debug_MACRO_RELEASE
-0
-<END>
-
-<BEGIN> BUILD_PENTIUM2gnu.debug_MACRO_SIZE
-sizepentium
-<END>
-
-<BEGIN> BUILD_PENTIUM2gnu.debug_RELEASE
-0
-<END>
-
-<BEGIN> BUILD_PENTIUM2gnu.debug_RO_DEPEND_PATH
-$(WIND_BASE)/target/h/
-<END>
-
-<BEGIN> BUILD_PENTIUM2gnu.debug_TC
-::tc_PENTIUM2gnu.debug
-<END>
-
-<BEGIN> BUILD_PENTIUM2gnu.release_DEFAULTFORCPU
-0
-<END>
-
-<BEGIN> BUILD_PENTIUM2gnu.release_FILE_$(PRJ_DIR)/../db_recover.c_infoTags
-toolMacro objects
-<END>
-
-<BEGIN> BUILD_PENTIUM2gnu.release_FILE_$(PRJ_DIR)/../db_recover.c_objects
-db_recover.o
-<END>
-
-<BEGIN> BUILD_PENTIUM2gnu.release_FILE_$(PRJ_DIR)/../db_recover.c_toolMacro
-CC
-<END>
-
-<BEGIN> BUILD_PENTIUM2gnu.release_FILE_$(PRJ_DIR)/compConfig.c_infoTags
-toolMacro objects
-<END>
-
-<BEGIN> BUILD_PENTIUM2gnu.release_FILE_$(PRJ_DIR)/compConfig.c_objects
-compConfig.o
-<END>
-
-<BEGIN> BUILD_PENTIUM2gnu.release_FILE_$(PRJ_DIR)/compConfig.c_toolMacro
-CC
-<END>
-
-<BEGIN> BUILD_PENTIUM2gnu.release_MACRO_AR
-arpentium
-<END>
-
-<BEGIN> BUILD_PENTIUM2gnu.release_MACRO_AS
-ccpentium
-<END>
-
-<BEGIN> BUILD_PENTIUM2gnu.release_MACRO_CC
-ccpentium
-<END>
-
-<BEGIN> BUILD_PENTIUM2gnu.release_MACRO_CFLAGS
--mcpu=pentiumpro \
-	-march=pentiumpro \
-	-ansi \
-	-DRW_MULTI_THREAD \
-	-D_REENTRANT \
-	-O2 \
-	-nostdlib \
-	-fno-builtin \
-	-fno-defer-pop \
-	-MD \
-	-Wall \
-	-I. \
-	-I$(WIND_BASE)/target/h \
-	-I$(PRJ_DIR)/../.. \
-	-I$(PRJ_DIR)/../../.. \
-	-DCPU=PENTIUM2
-<END>
-
-<BEGIN> BUILD_PENTIUM2gnu.release_MACRO_CFLAGS_AS
--mcpu=pentiumpro \
-	-march=pentiumpro \
-	-ansi \
-	-O2 \
-	-nostdlib \
-	-fno-builtin \
-	-fno-defer-pop \
-	-P \
-	-x \
-	assembler-with-cpp \
-	-Wall \
-	-I. \
-	-I$(WIND_BASE)/target/h \
-	-DCPU=PENTIUM2
-<END>
-
-<BEGIN> BUILD_PENTIUM2gnu.release_MACRO_CPP
-ccpentium -E -P
-<END>
-
-<BEGIN> BUILD_PENTIUM2gnu.release_MACRO_CPPFILT
-c++filtpentium --strip-underscores
-<END>
-
-<BEGIN> BUILD_PENTIUM2gnu.release_MACRO_LD
-ldpentium
-<END>
-
-<BEGIN> BUILD_PENTIUM2gnu.release_MACRO_LDFLAGS
--X
-<END>
-
-<BEGIN> BUILD_PENTIUM2gnu.release_MACRO_LDPARTIAL
-ccpentium \
-	-B$(WIND_BASE)/host/$(WIND_HOST_TYPE)/lib/gcc-lib/ \
-	-nostdlib \
-	-r \
-	-Wl,-X
-<END>
-
-<BEGIN> BUILD_PENTIUM2gnu.release_MACRO_LD_PARTIAL_FLAGS
--X -r
-<END>
-
-<BEGIN> BUILD_PENTIUM2gnu.release_MACRO_NM
-nmpentium -g
-<END>
-
-<BEGIN> BUILD_PENTIUM2gnu.release_MACRO_OPTION_DEFINE_MACRO
--D
-<END>
-
-<BEGIN> BUILD_PENTIUM2gnu.release_MACRO_OPTION_GENERATE_DEPENDENCY_FILE
--MD
-<END>
-
-<BEGIN> BUILD_PENTIUM2gnu.release_MACRO_OPTION_INCLUDE_DIR
--I
-<END>
-
-<BEGIN> BUILD_PENTIUM2gnu.release_MACRO_RELEASE
-1
-<END>
-
-<BEGIN> BUILD_PENTIUM2gnu.release_MACRO_SIZE
-sizepentium
-<END>
-
-<BEGIN> BUILD_PENTIUM2gnu.release_RELEASE
-1
-<END>
-
-<BEGIN> BUILD_PENTIUM2gnu.release_RO_DEPEND_PATH
-$(WIND_BASE)/target/h/
-<END>
-
-<BEGIN> BUILD_PENTIUM2gnu.release_TC
-::tc_PENTIUM2gnu.release
-<END>
-
-<BEGIN> BUILD_PENTIUMgnu.debug_DEFAULTFORCPU
-1
-<END>
-
-<BEGIN> BUILD_PENTIUMgnu.debug_FILE_$(PRJ_DIR)/../db_recover.c_infoTags
-toolMacro objects
-<END>
-
-<BEGIN> BUILD_PENTIUMgnu.debug_FILE_$(PRJ_DIR)/../db_recover.c_objects
-db_recover.o
-<END>
-
-<BEGIN> BUILD_PENTIUMgnu.debug_FILE_$(PRJ_DIR)/../db_recover.c_toolMacro
-CC
-<END>
-
-<BEGIN> BUILD_PENTIUMgnu.debug_FILE_$(PRJ_DIR)/compConfig.c_infoTags
-toolMacro objects
-<END>
-
-<BEGIN> BUILD_PENTIUMgnu.debug_FILE_$(PRJ_DIR)/compConfig.c_objects
-compConfig.o
-<END>
-
-<BEGIN> BUILD_PENTIUMgnu.debug_FILE_$(PRJ_DIR)/compConfig.c_toolMacro
-CC
-<END>
-
-<BEGIN> BUILD_PENTIUMgnu.debug_MACRO_AR
-arpentium
-<END>
-
-<BEGIN> BUILD_PENTIUMgnu.debug_MACRO_AS
-ccpentium
-<END>
-
-<BEGIN> BUILD_PENTIUMgnu.debug_MACRO_CC
-ccpentium
-<END>
-
-<BEGIN> BUILD_PENTIUMgnu.debug_MACRO_CFLAGS
--mcpu=pentium \
-	-march=pentium \
-	-ansi \
-	-DRW_MULTI_THREAD \
-	-D_REENTRANT \
-	-g \
-	-nostdlib \
-	-fno-builtin \
-	-fno-defer-pop \
-	-MD \
-	-Wall \
-	-I. \
-	-I$(WIND_BASE)/target/h \
-	-I$(PRJ_DIR)/../.. \
-	-I$(PRJ_DIR)/../../.. \
-	-DCPU=PENTIUM
-<END>
-
-<BEGIN> BUILD_PENTIUMgnu.debug_MACRO_CFLAGS_AS
--mcpu=pentium \
-	-march=pentium \
-	-ansi \
-	-g \
-	-nostdlib \
-	-fno-builtin \
-	-fno-defer-pop \
-	-P \
-	-x \
-	assembler-with-cpp \
-	-Wall \
-	-I. \
-	-I$(WIND_BASE)/target/h \
-	-DCPU=PENTIUM
-<END>
-
-<BEGIN> BUILD_PENTIUMgnu.debug_MACRO_CPP
-ccpentium -E -P
-<END>
-
-<BEGIN> BUILD_PENTIUMgnu.debug_MACRO_CPPFILT
-c++filtpentium --strip-underscores
-<END>
-
-<BEGIN> BUILD_PENTIUMgnu.debug_MACRO_LD
-ldpentium
-<END>
-
-<BEGIN> BUILD_PENTIUMgnu.debug_MACRO_LDFLAGS
--X
-<END>
-
-<BEGIN> BUILD_PENTIUMgnu.debug_MACRO_LDPARTIAL
-ccpentium \
-	-B$(WIND_BASE)/host/$(WIND_HOST_TYPE)/lib/gcc-lib/ \
-	-nostdlib \
-	-r \
-	-Wl,-X
-<END>
-
-<BEGIN> BUILD_PENTIUMgnu.debug_MACRO_LD_PARTIAL_FLAGS
--X -r
-<END>
-
-<BEGIN> BUILD_PENTIUMgnu.debug_MACRO_NM
-nmpentium -g
-<END>
-
-<BEGIN> BUILD_PENTIUMgnu.debug_MACRO_OPTION_DEFINE_MACRO
--D
-<END>
-
-<BEGIN> BUILD_PENTIUMgnu.debug_MACRO_OPTION_GENERATE_DEPENDENCY_FILE
--MD
-<END>
-
-<BEGIN> BUILD_PENTIUMgnu.debug_MACRO_OPTION_INCLUDE_DIR
--I
-<END>
-
-<BEGIN> BUILD_PENTIUMgnu.debug_MACRO_RELEASE
-0
-<END>
-
-<BEGIN> BUILD_PENTIUMgnu.debug_MACRO_SIZE
-sizepentium
-<END>
-
-<BEGIN> BUILD_PENTIUMgnu.debug_RELEASE
-0
-<END>
-
-<BEGIN> BUILD_PENTIUMgnu.debug_RO_DEPEND_PATH
-$(WIND_BASE)/target/h/
-<END>
-
-<BEGIN> BUILD_PENTIUMgnu.debug_TC
-::tc_PENTIUMgnu.debug
-<END>
-
-<BEGIN> BUILD__LIST
-PENTIUM2gnu.debug PENTIUM2gnu.release PENTIUMgnu.debug
-<END>
-
-<BEGIN> PROJECT_FILES
-$(PRJ_DIR)/../db_recover.c \
-	$(PRJ_DIR)/compConfig.c
-<END>
-
-<BEGIN> WCC__CDF_PATH
-$(PRJ_DIR)
-<END>
-
-<BEGIN> WCC__CURRENT
-PENTIUM2gnu.debug
-<END>
-
-<BEGIN> WCC__LIST
-PENTIUM2gnu.debug
-<END>
-
-<BEGIN> WCC__MXR_LIBS
-lib$(CPU)$(TOOL)vx.a
-<END>
-
-<BEGIN> WCC__OBJS_PATH
-$(WIND_BASE)/target/lib/obj$CPU$TOOLvx
-<END>
-
diff --git a/bdb/build_vxworks/db_stat/db_stat.c b/bdb/build_vxworks/db_stat/db_stat.c
deleted file mode 100644
index 5e9348fa04a9fcfdeee5fbdfac0f2e6c0bbee721..0000000000000000000000000000000000000000
--- a/bdb/build_vxworks/db_stat/db_stat.c
+++ /dev/null
@@ -1,1282 +0,0 @@
-/*-
- * See the file LICENSE for redistribution information.
- *
- * Copyright (c) 1996-2002
- *	Sleepycat Software.  All rights reserved.
- */
-
-#include "db_config.h"
-
-#ifndef lint
-static const char copyright[] =
-    "Copyright (c) 1996-2002\nSleepycat Software Inc.  All rights reserved.\n";
-static const char revid[] =
-    "$Id: db_stat.c,v 11.125 2002/08/08 15:26:15 bostic Exp $";
-#endif
-
-#ifndef NO_SYSTEM_INCLUDES
-#include <sys/types.h>
-
-#if TIME_WITH_SYS_TIME
-#include <sys/time.h>
-#include <time.h>
-#else
-#if HAVE_SYS_TIME_H
-#include <sys/time.h>
-#else
-#include <time.h>
-#endif
-#endif
-
-#include <ctype.h>
-#include <stdlib.h>
-#include <string.h>
-#include <unistd.h>
-#endif
-
-#include "db_int.h"
-#include "dbinc/db_page.h"
-
-#define	PCT(f, t, pgsize)						\
-    ((t) == 0 ? 0 :							\
-    (((double)(((t) * (pgsize)) - (f)) / ((t) * (pgsize))) * 100))
-
-typedef enum { T_NOTSET,
-    T_DB, T_ENV, T_LOCK, T_LOG, T_MPOOL, T_REP, T_TXN } test_t;
-
-int	 db_stat_argcheck __P((char *, const char *));
-int	 db_stat_btree_stats __P((DB_ENV *, DB *, DB_BTREE_STAT *, int));
-int	 db_stat_db_init __P((DB_ENV *, char *, test_t, u_int32_t, int *));
-void	 db_stat_dl __P((const char *, u_long));
-void	 db_stat_dl_bytes __P((const char *, u_long, u_long, u_long));
-int	 db_stat_env_stats __P((DB_ENV *, u_int32_t));
-int	 db_stat_hash_stats __P((DB_ENV *, DB *, int));
-int	 db_stat_lock_stats __P((DB_ENV *, char *, u_int32_t));
-int	 db_stat_log_stats __P((DB_ENV *, u_int32_t));
-int	 db_stat_main __P((int, char *[]));
-int	 db_stat_mpool_stats __P((DB_ENV *, char *, u_int32_t));
-void	 db_stat_prflags __P((u_int32_t, const FN *));
-int	 db_stat_queue_stats __P((DB_ENV *, DB *, int));
-int	 db_stat_rep_stats __P((DB_ENV *, u_int32_t));
-int	 db_stat_txn_compare __P((const void *, const void *));
-int	 db_stat_txn_stats __P((DB_ENV *, u_int32_t));
-int	 db_stat_usage __P((void));
-int	 db_stat_version_check __P((const char *));
-
-int
-db_stat(args)
-	char *args;
-{
-	int argc;
-	char **argv;
-
-	__db_util_arg("db_stat", args, &argc, &argv);
-	return (db_stat_main(argc, argv) ? EXIT_FAILURE : EXIT_SUCCESS);
-}
-
-#include <stdio.h>
-#define	ERROR_RETURN	ERROR
-
-int
-db_stat_main(argc, argv)
-	int argc;
-	char *argv[];
-{
-	extern char *optarg;
-	extern int optind, __db_getopt_reset;
-	const char *progname = "db_stat";
-	DB_ENV	*dbenv;
-	DB_BTREE_STAT *sp;
-	DB *alt_dbp, *dbp;
-	test_t ttype;
-	u_int32_t cache;
-	int ch, checked, d_close, e_close, exitval, fast, flags;
-	int nflag, private, resize, ret;
-	char *db, *home, *internal, *passwd, *subdb;
-
-	if ((ret = db_stat_version_check(progname)) != 0)
-		return (ret);
-
-	dbp = NULL;
-	ttype = T_NOTSET;
-	cache = MEGABYTE;
-	d_close = e_close = exitval = fast = flags = nflag = private = 0;
-	db = home = internal = passwd = subdb = NULL;
-
-	__db_getopt_reset = 1;
-	while ((ch = getopt(argc, argv, "C:cd:efh:lM:mNP:rs:tVZ")) != EOF)
-		switch (ch) {
-		case 'C':
-			if (ttype != T_NOTSET)
-				goto argcombo;
-			ttype = T_LOCK;
-			if (!db_stat_argcheck(internal = optarg, "Aclmop"))
-				return (db_stat_usage());
-			break;
-		case 'c':
-			if (ttype != T_NOTSET)
-				goto argcombo;
-			ttype = T_LOCK;
-			break;
-		case 'd':
-			if (ttype != T_DB && ttype != T_NOTSET)
-				goto argcombo;
-			ttype = T_DB;
-			db = optarg;
-			break;
-		case 'e':
-			if (ttype != T_NOTSET)
-				goto argcombo;
-			ttype = T_ENV;
-			break;
-		case 'f':
-			fast = DB_FAST_STAT;
-			break;
-		case 'h':
-			home = optarg;
-			break;
-		case 'l':
-			if (ttype != T_NOTSET)
-				goto argcombo;
-			ttype = T_LOG;
-			break;
-		case 'M':
-			if (ttype != T_NOTSET)
-				goto argcombo;
-			ttype = T_MPOOL;
-			if (!db_stat_argcheck(internal = optarg, "Ahm"))
-				return (db_stat_usage());
-			break;
-		case 'm':
-			if (ttype != T_NOTSET)
-				goto argcombo;
-			ttype = T_MPOOL;
-			break;
-		case 'N':
-			nflag = 1;
-			break;
-		case 'P':
-			passwd = strdup(optarg);
-			memset(optarg, 0, strlen(optarg));
-			if (passwd == NULL) {
-				fprintf(stderr, "%s: strdup: %s\n",
-				    progname, strerror(errno));
-				return (EXIT_FAILURE);
-			}
-			break;
-		case 'r':
-			if (ttype != T_NOTSET)
-				goto argcombo;
-			ttype = T_REP;
-			break;
-		case 's':
-			if (ttype != T_DB && ttype != T_NOTSET)
-				goto argcombo;
-			ttype = T_DB;
-			subdb = optarg;
-			break;
-		case 't':
-			if (ttype != T_NOTSET) {
-argcombo:			fprintf(stderr,
-				    "%s: illegal option combination\n",
-				    progname);
-				return (EXIT_FAILURE);
-			}
-			ttype = T_TXN;
-			break;
-		case 'V':
-			printf("%s\n", db_version(NULL, NULL, NULL));
-			return (EXIT_SUCCESS);
-		case 'Z':
-			flags |= DB_STAT_CLEAR;
-			break;
-		case '?':
-		default:
-			return (db_stat_usage());
-		}
-	argc -= optind;
-	argv += optind;
-
-	switch (ttype) {
-	case T_DB:
-		if (db == NULL)
-			return (db_stat_usage());
-		break;
-	case T_NOTSET:
-		return (db_stat_usage());
-		/* NOTREACHED */
-	default:
-		if (fast != 0)
-			return (db_stat_usage());
-		break;
-	}
-
-	/* Handle possible interruptions. */
-	__db_util_siginit();
-
-	/*
-	 * Create an environment object and initialize it for error
-	 * reporting.
-	 */
-retry:	if ((ret = db_env_create(&dbenv, 0)) != 0) {
-		fprintf(stderr,
-		    "%s: db_env_create: %s\n", progname, db_strerror(ret));
-		goto shutdown;
-	}
-	e_close = 1;
-
-	dbenv->set_errfile(dbenv, stderr);
-	dbenv->set_errpfx(dbenv, progname);
-
-	if (nflag) {
-		if ((ret = dbenv->set_flags(dbenv, DB_NOLOCKING, 1)) != 0) {
-			dbenv->err(dbenv, ret, "set_flags: DB_NOLOCKING");
-			goto shutdown;
-		}
-		if ((ret = dbenv->set_flags(dbenv, DB_NOPANIC, 1)) != 0) {
-			dbenv->err(dbenv, ret, "set_flags: DB_NOPANIC");
-			goto shutdown;
-		}
-	}
-
-	if (passwd != NULL &&
-	    (ret = dbenv->set_encrypt(dbenv, passwd, DB_ENCRYPT_AES)) != 0) {
-		dbenv->err(dbenv, ret, "set_passwd");
-		goto shutdown;
-	}
-
-	/* Initialize the environment. */
-	if (db_stat_db_init(dbenv, home, ttype, cache, &private) != 0)
-		goto shutdown;
-
-	switch (ttype) {
-	case T_DB:
-		/* Create the DB object and open the file. */
-		if (flags != 0)
-			return (db_stat_usage());
-		if ((ret = db_create(&dbp, dbenv, 0)) != 0) {
-			dbenv->err(dbenv, ret, "db_create");
-			goto shutdown;
-		}
-		d_close = 1;
-
-		if ((ret = dbp->open(dbp,
-		    NULL, db, subdb, DB_UNKNOWN, DB_RDONLY, 0)) != 0) {
-			dbp->err(dbp, ret, "DB->open: %s", db);
-			goto shutdown;
-		}
-
-		/* Check if cache is too small for this DB's pagesize. */
-		if (private) {
-			if ((ret =
-			    __db_util_cache(dbenv, dbp, &cache, &resize)) != 0)
-				goto shutdown;
-			if (resize) {
-				(void)dbp->close(dbp, 0);
-				d_close = 0;
-
-				(void)dbenv->close(dbenv, 0);
-				e_close = 0;
-				goto retry;
-			}
-		}
-
-		/*
-		 * See if we can open this db read/write to update counts.
-		 * If its a master-db then we cannot.  So check to see,
-		 * if its btree then it might be.
-		 */
-		checked = 0;
-		if (subdb == NULL && dbp->type == DB_BTREE) {
-			if ((ret = dbp->stat(dbp, &sp, DB_FAST_STAT)) != 0) {
-				dbp->err(dbp, ret, "DB->stat");
-				goto shutdown;
-			}
-			checked = 1;
-		}
-
-		if (subdb != NULL ||
-		    dbp->type != DB_BTREE ||
-		    (sp->bt_metaflags & BTM_SUBDB) == 0) {
-			if ((ret = db_create(&alt_dbp, dbenv, 0)) != 0) {
-				dbenv->err(dbenv, ret, "db_create");
-				goto shutdown;
-			}
-			if ((ret = dbp->open(alt_dbp, NULL,
-			    db, subdb, DB_UNKNOWN, 0, 0)) != 0) {
-				dbenv->err(dbenv,
-				   ret, "DB->open: %s:%s", db, subdb);
-				(void)alt_dbp->close(alt_dbp, 0);
-				goto shutdown;
-			}
-
-			(void)dbp->close(dbp, 0);
-			dbp = alt_dbp;
-
-			/* Need to run again to update counts */
-			checked = 0;
-		}
-
-		switch (dbp->type) {
-		case DB_BTREE:
-		case DB_RECNO:
-			if (db_stat_btree_stats(
-			    dbenv, dbp, checked == 1 ? sp : NULL, fast))
-				goto shutdown;
-			break;
-		case DB_HASH:
-			if (db_stat_hash_stats(dbenv, dbp, fast))
-				goto shutdown;
-			break;
-		case DB_QUEUE:
-			if (db_stat_queue_stats(dbenv, dbp, fast))
-				goto shutdown;
-			break;
-		case DB_UNKNOWN:
-			dbenv->errx(dbenv, "Unknown database type.");
-			goto shutdown;
-		}
-		break;
-	case T_ENV:
-		if (db_stat_env_stats(dbenv, flags))
-			goto shutdown;
-		break;
-	case T_LOCK:
-		if (db_stat_lock_stats(dbenv, internal, flags))
-			goto shutdown;
-		break;
-	case T_LOG:
-		if (db_stat_log_stats(dbenv, flags))
-			goto shutdown;
-		break;
-	case T_MPOOL:
-		if (db_stat_mpool_stats(dbenv, internal, flags))
-			goto shutdown;
-		break;
-	case T_REP:
-		if (db_stat_rep_stats(dbenv, flags))
-			goto shutdown;
-		break;
-	case T_TXN:
-		if (db_stat_txn_stats(dbenv, flags))
-			goto shutdown;
-		break;
-	case T_NOTSET:
-		dbenv->errx(dbenv, "Unknown statistics flag.");
-		goto shutdown;
-	}
-
-	if (0) {
-shutdown:	exitval = 1;
-	}
-	if (d_close && (ret = dbp->close(dbp, 0)) != 0) {
-		exitval = 1;
-		dbenv->err(dbenv, ret, "close");
-	}
-	if (e_close && (ret = dbenv->close(dbenv, 0)) != 0) {
-		exitval = 1;
-		fprintf(stderr,
-		    "%s: dbenv->close: %s\n", progname, db_strerror(ret));
-	}
-
-	/* Resend any caught signal. */
-	__db_util_sigresend();
-
-	return (exitval == 0 ? EXIT_SUCCESS : EXIT_FAILURE);
-}
-
-/*
- * env_stats --
- *	Display environment statistics.
- */
-int
-db_stat_env_stats(dbenv, flags)
-	DB_ENV *dbenv;
-	u_int32_t flags;
-{
-	REGENV renv;
-	REGION *rp, regs[1024];
-	int n, ret;
-	const char *lable;
-
-	n = sizeof(regs) / sizeof(regs[0]);
-	if ((ret = __db_e_stat(dbenv, &renv, regs, &n, flags)) != 0)  {
-		dbenv->err(dbenv, ret, "__db_e_stat");
-		return (1);
-	}
-
-	printf("%d.%d.%d\tEnvironment version.\n",
-	    renv.majver, renv.minver, renv.patch);
-	printf("%lx\tMagic number.\n", (u_long)renv.magic);
-	printf("%d\tPanic value.\n", renv.envpanic);
-
-	/* Adjust the reference count for us... */
-	printf("%d\tReferences.\n", renv.refcnt - 1);
-
-	db_stat_dl("Locks granted without waiting.\n",
-	    (u_long)renv.mutex.mutex_set_nowait);
-	db_stat_dl("Locks granted after waiting.\n",
-	    (u_long)renv.mutex.mutex_set_wait);
-
-	while (n > 0) {
-		printf("%s\n", DB_LINE);
-		rp = &regs[--n];
-		switch (rp->type) {
-		case REGION_TYPE_ENV:
-			lable = "Environment";
-			break;
-		case REGION_TYPE_LOCK:
-			lable = "Lock";
-			break;
-		case REGION_TYPE_LOG:
-			lable = "Log";
-			break;
-		case REGION_TYPE_MPOOL:
-			lable = "Mpool";
-			break;
-		case REGION_TYPE_MUTEX:
-			lable = "Mutex";
-			break;
-		case REGION_TYPE_TXN:
-			lable = "Txn";
-			break;
-		case INVALID_REGION_TYPE:
-		default:
-			lable = "Invalid";
-			break;
-		}
-		printf("%s Region: %d.\n", lable, rp->id);
-		db_stat_dl_bytes("Size", (u_long)0, (u_long)0, (u_long)rp->size);
-		printf("%ld\tSegment ID.\n", rp->segid);
-		db_stat_dl("Locks granted without waiting.\n",
-		    (u_long)rp->mutex.mutex_set_nowait);
-		db_stat_dl("Locks granted after waiting.\n",
-		    (u_long)rp->mutex.mutex_set_wait);
-	}
-
-	return (0);
-}
-
-/*
- * btree_stats --
- *	Display btree/recno statistics.
- */
-int
-db_stat_btree_stats(dbenv, dbp, msp, fast)
-	DB_ENV *dbenv;
-	DB *dbp;
-	DB_BTREE_STAT *msp;
-	int fast;
-{
-	static const FN fn[] = {
-		{ BTM_DUP,	"duplicates" },
-		{ BTM_FIXEDLEN,	"fixed-length" },
-		{ BTM_RECNO,	"recno" },
-		{ BTM_RECNUM,	"record-numbers" },
-		{ BTM_RENUMBER,	"renumber" },
-		{ BTM_SUBDB,	"multiple-databases" },
-		{ 0,		NULL }
-	};
-	DB_BTREE_STAT *sp;
-	int ret;
-
-	COMPQUIET(dbenv, NULL);
-
-	if (msp != NULL)
-		sp = msp;
-	else if ((ret = dbp->stat(dbp, &sp, fast)) != 0) {
-		dbp->err(dbp, ret, "DB->stat");
-		return (1);
-	}
-
-	printf("%lx\tBtree magic number.\n", (u_long)sp->bt_magic);
-	printf("%lu\tBtree version number.\n", (u_long)sp->bt_version);
-	db_stat_prflags(sp->bt_metaflags, fn);
-	if (dbp->type == DB_BTREE) {
-#ifdef NOT_IMPLEMENTED
-		db_stat_dl("Maximum keys per-page.\n", (u_long)sp->bt_maxkey);
-#endif
-		db_stat_dl("Minimum keys per-page.\n", (u_long)sp->bt_minkey);
-	}
-	if (dbp->type == DB_RECNO) {
-		db_stat_dl("Fixed-length record size.\n", (u_long)sp->bt_re_len);
-		if (isprint(sp->bt_re_pad) && !isspace(sp->bt_re_pad))
-			printf("%c\tFixed-length record pad.\n",
-			    (int)sp->bt_re_pad);
-		else
-			printf("0x%x\tFixed-length record pad.\n",
-			    (int)sp->bt_re_pad);
-	}
-	db_stat_dl("Underlying database page size.\n", (u_long)sp->bt_pagesize);
-	db_stat_dl("Number of levels in the tree.\n", (u_long)sp->bt_levels);
-	db_stat_dl(dbp->type == DB_BTREE ?
-	    "Number of unique keys in the tree.\n" :
-	    "Number of records in the tree.\n", (u_long)sp->bt_nkeys);
-	db_stat_dl("Number of data items in the tree.\n", (u_long)sp->bt_ndata);
-
-	db_stat_dl("Number of tree internal pages.\n", (u_long)sp->bt_int_pg);
-	db_stat_dl("Number of bytes free in tree internal pages",
-	    (u_long)sp->bt_int_pgfree);
-	printf(" (%.0f%% ff).\n",
-	    PCT(sp->bt_int_pgfree, sp->bt_int_pg, sp->bt_pagesize));
-
-	db_stat_dl("Number of tree leaf pages.\n", (u_long)sp->bt_leaf_pg);
-	db_stat_dl("Number of bytes free in tree leaf pages",
-	    (u_long)sp->bt_leaf_pgfree);
-	printf(" (%.0f%% ff).\n",
-	    PCT(sp->bt_leaf_pgfree, sp->bt_leaf_pg, sp->bt_pagesize));
-
-	db_stat_dl("Number of tree duplicate pages.\n", (u_long)sp->bt_dup_pg);
-	db_stat_dl("Number of bytes free in tree duplicate pages",
-	    (u_long)sp->bt_dup_pgfree);
-	printf(" (%.0f%% ff).\n",
-	    PCT(sp->bt_dup_pgfree, sp->bt_dup_pg, sp->bt_pagesize));
-
-	db_stat_dl("Number of tree overflow pages.\n", (u_long)sp->bt_over_pg);
-	db_stat_dl("Number of bytes free in tree overflow pages",
-	    (u_long)sp->bt_over_pgfree);
-	printf(" (%.0f%% ff).\n",
-	    PCT(sp->bt_over_pgfree, sp->bt_over_pg, sp->bt_pagesize));
-
-	db_stat_dl("Number of pages on the free list.\n", (u_long)sp->bt_free);
-
-	free(sp);
-
-	return (0);
-}
-
-/*
- * hash_stats --
- *	Display hash statistics.
- */
-int
-db_stat_hash_stats(dbenv, dbp, fast)
-	DB_ENV *dbenv;
-	DB *dbp;
-	int fast;
-{
-	static const FN fn[] = {
-		{ DB_HASH_DUP,	"duplicates" },
-		{ DB_HASH_SUBDB,"multiple-databases" },
-		{ 0,		NULL }
-	};
-	DB_HASH_STAT *sp;
-	int ret;
-
-	COMPQUIET(dbenv, NULL);
-
-	if ((ret = dbp->stat(dbp, &sp, fast)) != 0) {
-		dbp->err(dbp, ret, "DB->stat");
-		return (1);
-	}
-
-	printf("%lx\tHash magic number.\n", (u_long)sp->hash_magic);
-	printf("%lu\tHash version number.\n", (u_long)sp->hash_version);
-	db_stat_prflags(sp->hash_metaflags, fn);
-	db_stat_dl("Underlying database page size.\n", (u_long)sp->hash_pagesize);
-	db_stat_dl("Specified fill factor.\n", (u_long)sp->hash_ffactor);
-	db_stat_dl("Number of keys in the database.\n", (u_long)sp->hash_nkeys);
-	db_stat_dl("Number of data items in the database.\n", (u_long)sp->hash_ndata);
-
-	db_stat_dl("Number of hash buckets.\n", (u_long)sp->hash_buckets);
-	db_stat_dl("Number of bytes free on bucket pages", (u_long)sp->hash_bfree);
-	printf(" (%.0f%% ff).\n",
-	    PCT(sp->hash_bfree, sp->hash_buckets, sp->hash_pagesize));
-
-	db_stat_dl("Number of overflow pages.\n", (u_long)sp->hash_bigpages);
-	db_stat_dl("Number of bytes free in overflow pages",
-	    (u_long)sp->hash_big_bfree);
-	printf(" (%.0f%% ff).\n",
-	    PCT(sp->hash_big_bfree, sp->hash_bigpages, sp->hash_pagesize));
-
-	db_stat_dl("Number of bucket overflow pages.\n", (u_long)sp->hash_overflows);
-	db_stat_dl("Number of bytes free in bucket overflow pages",
-	    (u_long)sp->hash_ovfl_free);
-	printf(" (%.0f%% ff).\n",
-	    PCT(sp->hash_ovfl_free, sp->hash_overflows, sp->hash_pagesize));
-
-	db_stat_dl("Number of duplicate pages.\n", (u_long)sp->hash_dup);
-	db_stat_dl("Number of bytes free in duplicate pages",
-	    (u_long)sp->hash_dup_free);
-	printf(" (%.0f%% ff).\n",
-	    PCT(sp->hash_dup_free, sp->hash_dup, sp->hash_pagesize));
-
-	db_stat_dl("Number of pages on the free list.\n", (u_long)sp->hash_free);
-
-	free(sp);
-
-	return (0);
-}
-
-/*
- * queue_stats --
- *	Display queue statistics.
- */
-int
-db_stat_queue_stats(dbenv, dbp, fast)
-	DB_ENV *dbenv;
-	DB *dbp;
-	int fast;
-{
-	DB_QUEUE_STAT *sp;
-	int ret;
-
-	COMPQUIET(dbenv, NULL);
-
-	if ((ret = dbp->stat(dbp, &sp, fast)) != 0) {
-		dbp->err(dbp, ret, "DB->stat");
-		return (1);
-	}
-
-	printf("%lx\tQueue magic number.\n", (u_long)sp->qs_magic);
-	printf("%lu\tQueue version number.\n", (u_long)sp->qs_version);
-	db_stat_dl("Fixed-length record size.\n", (u_long)sp->qs_re_len);
-	if (isprint(sp->qs_re_pad) && !isspace(sp->qs_re_pad))
-		printf("%c\tFixed-length record pad.\n", (int)sp->qs_re_pad);
-	else
-		printf("0x%x\tFixed-length record pad.\n", (int)sp->qs_re_pad);
-	db_stat_dl("Underlying database page size.\n", (u_long)sp->qs_pagesize);
-	if (sp->qs_extentsize != 0)
-		db_stat_dl("Underlying database extent size.\n",
-		    (u_long)sp->qs_extentsize);
-	db_stat_dl("Number of records in the database.\n", (u_long)sp->qs_nkeys);
-	db_stat_dl("Number of database pages.\n", (u_long)sp->qs_pages);
-	db_stat_dl("Number of bytes free in database pages", (u_long)sp->qs_pgfree);
-	printf(" (%.0f%% ff).\n",
-	    PCT(sp->qs_pgfree, sp->qs_pages, sp->qs_pagesize));
-	printf("%lu\tFirst undeleted record.\n", (u_long)sp->qs_first_recno);
-	printf(
-	    "%lu\tNext available record number.\n", (u_long)sp->qs_cur_recno);
-
-	free(sp);
-
-	return (0);
-}
-
-/*
- * lock_stats --
- *	Display lock statistics.
- */
-int
-db_stat_lock_stats(dbenv, internal, flags)
-	DB_ENV *dbenv;
-	char *internal;
-	u_int32_t flags;
-{
-	DB_LOCK_STAT *sp;
-	int ret;
-
-	if (internal != NULL) {
-		if ((ret =
-		    dbenv->lock_dump_region(dbenv, internal, stdout)) != 0) {
-			dbenv->err(dbenv, ret, NULL);
-			return (1);
-		}
-		return (0);
-	}
-
-	if ((ret = dbenv->lock_stat(dbenv, &sp, flags)) != 0) {
-		dbenv->err(dbenv, ret, NULL);
-		return (1);
-	}
-
-	db_stat_dl("Last allocated locker ID.\n", (u_long)sp->st_id);
-	db_stat_dl("Current maximum unused locker ID.\n", (u_long)sp->st_cur_maxid);
-	db_stat_dl("Number of lock modes.\n", (u_long)sp->st_nmodes);
-	db_stat_dl("Maximum number of locks possible.\n", (u_long)sp->st_maxlocks);
-	db_stat_dl("Maximum number of lockers possible.\n", (u_long)sp->st_maxlockers);
-	db_stat_dl("Maximum number of lock objects possible.\n",
-	    (u_long)sp->st_maxobjects);
-	db_stat_dl("Number of current locks.\n", (u_long)sp->st_nlocks);
-	db_stat_dl("Maximum number of locks at any one time.\n",
-	    (u_long)sp->st_maxnlocks);
-	db_stat_dl("Number of current lockers.\n", (u_long)sp->st_nlockers);
-	db_stat_dl("Maximum number of lockers at any one time.\n",
-	    (u_long)sp->st_maxnlockers);
-	db_stat_dl("Number of current lock objects.\n", (u_long)sp->st_nobjects);
-	db_stat_dl("Maximum number of lock objects at any one time.\n",
-	    (u_long)sp->st_maxnobjects);
-	db_stat_dl("Total number of locks requested.\n", (u_long)sp->st_nrequests);
-	db_stat_dl("Total number of locks released.\n", (u_long)sp->st_nreleases);
-	db_stat_dl(
-  "Total number of lock requests failing because DB_LOCK_NOWAIT was set.\n",
-	    (u_long)sp->st_nnowaits);
-	db_stat_dl(
-  "Total number of locks not immediately available due to conflicts.\n",
-	    (u_long)sp->st_nconflicts);
-	db_stat_dl("Number of deadlocks.\n", (u_long)sp->st_ndeadlocks);
-	db_stat_dl("Lock timeout value.\n", (u_long)sp->st_locktimeout);
-	db_stat_dl("Number of locks that have timed out.\n",
-	    (u_long)sp->st_nlocktimeouts);
-	db_stat_dl("Transaction timeout value.\n", (u_long)sp->st_txntimeout);
-	db_stat_dl("Number of transactions that have timed out.\n",
-	    (u_long)sp->st_ntxntimeouts);
-
-	db_stat_dl_bytes("The size of the lock region.",
-	    (u_long)0, (u_long)0, (u_long)sp->st_regsize);
-	db_stat_dl("The number of region locks granted after waiting.\n",
-	    (u_long)sp->st_region_wait);
-	db_stat_dl("The number of region locks granted without waiting.\n",
-	    (u_long)sp->st_region_nowait);
-
-	free(sp);
-
-	return (0);
-}
-
-/*
- * log_stats --
- *	Display log statistics.
- */
-int
-db_stat_log_stats(dbenv, flags)
-	DB_ENV *dbenv;
-	u_int32_t flags;
-{
-	DB_LOG_STAT *sp;
-	int ret;
-
-	if ((ret = dbenv->log_stat(dbenv, &sp, flags)) != 0) {
-		dbenv->err(dbenv, ret, NULL);
-		return (1);
-	}
-
-	printf("%lx\tLog magic number.\n", (u_long)sp->st_magic);
-	printf("%lu\tLog version number.\n", (u_long)sp->st_version);
-	db_stat_dl_bytes("Log record cache size",
-	    (u_long)0, (u_long)0, (u_long)sp->st_lg_bsize);
-	printf("%#o\tLog file mode.\n", sp->st_mode);
-	if (sp->st_lg_size % MEGABYTE == 0)
-		printf("%luMb\tCurrent log file size.\n",
-		    (u_long)sp->st_lg_size / MEGABYTE);
-	else if (sp->st_lg_size % 1024 == 0)
-		printf("%luKb\tCurrent log file size.\n",
-		    (u_long)sp->st_lg_size / 1024);
-	else
-		printf("%lu\tCurrent log file size.\n",
-		    (u_long)sp->st_lg_size);
-	db_stat_dl_bytes("Log bytes written",
-	    (u_long)0, (u_long)sp->st_w_mbytes, (u_long)sp->st_w_bytes);
-	db_stat_dl_bytes("Log bytes written since last checkpoint",
-	    (u_long)0, (u_long)sp->st_wc_mbytes, (u_long)sp->st_wc_bytes);
-	db_stat_dl("Total log file writes.\n", (u_long)sp->st_wcount);
-	db_stat_dl("Total log file write due to overflow.\n",
-	    (u_long)sp->st_wcount_fill);
-	db_stat_dl("Total log file flushes.\n", (u_long)sp->st_scount);
-	printf("%lu\tCurrent log file number.\n", (u_long)sp->st_cur_file);
-	printf("%lu\tCurrent log file offset.\n", (u_long)sp->st_cur_offset);
-	printf("%lu\tOn-disk log file number.\n", (u_long)sp->st_disk_file);
-	printf("%lu\tOn-disk log file offset.\n", (u_long)sp->st_disk_offset);
-
-	db_stat_dl("Max commits in a log flush.\n", (u_long)sp->st_maxcommitperflush);
-	db_stat_dl("Min commits in a log flush.\n", (u_long)sp->st_mincommitperflush);
-
-	db_stat_dl_bytes("Log region size",
-	    (u_long)0, (u_long)0, (u_long)sp->st_regsize);
-	db_stat_dl("The number of region locks granted after waiting.\n",
-	    (u_long)sp->st_region_wait);
-	db_stat_dl("The number of region locks granted without waiting.\n",
-	    (u_long)sp->st_region_nowait);
-
-	free(sp);
-
-	return (0);
-}
-
-/*
- * mpool_stats --
- *	Display mpool statistics.
- */
-int
-db_stat_mpool_stats(dbenv, internal, flags)
-	DB_ENV *dbenv;
-	char *internal;
-	u_int32_t flags;
-{
-	DB_MPOOL_FSTAT **fsp;
-	DB_MPOOL_STAT *gsp;
-	int ret;
-
-	if (internal != NULL) {
-		if ((ret =
-		    dbenv->memp_dump_region(dbenv, internal, stdout)) != 0) {
-			dbenv->err(dbenv, ret, NULL);
-			return (1);
-		}
-		return (0);
-	}
-
-	if ((ret = dbenv->memp_stat(dbenv, &gsp, &fsp, flags)) != 0) {
-		dbenv->err(dbenv, ret, NULL);
-		return (1);
-	}
-
-	db_stat_dl_bytes("Total cache size",
-	    (u_long)gsp->st_gbytes, (u_long)0, (u_long)gsp->st_bytes);
-	db_stat_dl("Number of caches.\n", (u_long)gsp->st_ncache);
-	db_stat_dl_bytes("Pool individual cache size",
-	    (u_long)0, (u_long)0, (u_long)gsp->st_regsize);
-	db_stat_dl("Requested pages mapped into the process' address space.\n",
-	    (u_long)gsp->st_map);
-	db_stat_dl("Requested pages found in the cache", (u_long)gsp->st_cache_hit);
-	if (gsp->st_cache_hit + gsp->st_cache_miss != 0)
-		printf(" (%.0f%%)", ((double)gsp->st_cache_hit /
-		    (gsp->st_cache_hit + gsp->st_cache_miss)) * 100);
-	printf(".\n");
-	db_stat_dl("Requested pages not found in the cache.\n",
-	    (u_long)gsp->st_cache_miss);
-	db_stat_dl("Pages created in the cache.\n", (u_long)gsp->st_page_create);
-	db_stat_dl("Pages read into the cache.\n", (u_long)gsp->st_page_in);
-	db_stat_dl("Pages written from the cache to the backing file.\n",
-	    (u_long)gsp->st_page_out);
-	db_stat_dl("Clean pages forced from the cache.\n",
-	    (u_long)gsp->st_ro_evict);
-	db_stat_dl("Dirty pages forced from the cache.\n",
-	    (u_long)gsp->st_rw_evict);
-	db_stat_dl("Dirty pages written by trickle-sync thread.\n",
-	    (u_long)gsp->st_page_trickle);
-	db_stat_dl("Current total page count.\n",
-	    (u_long)gsp->st_pages);
-	db_stat_dl("Current clean page count.\n",
-	    (u_long)gsp->st_page_clean);
-	db_stat_dl("Current dirty page count.\n",
-	    (u_long)gsp->st_page_dirty);
-	db_stat_dl("Number of hash buckets used for page location.\n",
-	    (u_long)gsp->st_hash_buckets);
-	db_stat_dl("Total number of times hash chains searched for a page.\n",
-	    (u_long)gsp->st_hash_searches);
-	db_stat_dl("The longest hash chain searched for a page.\n",
-	    (u_long)gsp->st_hash_longest);
-	db_stat_dl("Total number of hash buckets examined for page location.\n",
-	    (u_long)gsp->st_hash_examined);
-	db_stat_dl("The number of hash bucket locks granted without waiting.\n",
-	    (u_long)gsp->st_hash_nowait);
-	db_stat_dl("The number of hash bucket locks granted after waiting.\n",
-	    (u_long)gsp->st_hash_wait);
-	db_stat_dl("The maximum number of times any hash bucket lock was waited for.\n",
-	    (u_long)gsp->st_hash_max_wait);
-	db_stat_dl("The number of region locks granted without waiting.\n",
-	    (u_long)gsp->st_region_nowait);
-	db_stat_dl("The number of region locks granted after waiting.\n",
-	    (u_long)gsp->st_region_wait);
-	db_stat_dl("The number of page allocations.\n",
-	    (u_long)gsp->st_alloc);
-	db_stat_dl("The number of hash buckets examined during allocations\n",
-	    (u_long)gsp->st_alloc_buckets);
-	db_stat_dl("The max number of hash buckets examined for an allocation\n",
-	    (u_long)gsp->st_alloc_max_buckets);
-	db_stat_dl("The number of pages examined during allocations\n",
-	    (u_long)gsp->st_alloc_pages);
-	db_stat_dl("The max number of pages examined for an allocation\n",
-	    (u_long)gsp->st_alloc_max_pages);
-
-	for (; fsp != NULL && *fsp != NULL; ++fsp) {
-		printf("%s\n", DB_LINE);
-		printf("Pool File: %s\n", (*fsp)->file_name);
-		db_stat_dl("Page size.\n", (u_long)(*fsp)->st_pagesize);
-		db_stat_dl("Requested pages mapped into the process' address space.\n",
-		    (u_long)(*fsp)->st_map);
-		db_stat_dl("Requested pages found in the cache",
-		    (u_long)(*fsp)->st_cache_hit);
-		if ((*fsp)->st_cache_hit + (*fsp)->st_cache_miss != 0)
-			printf(" (%.0f%%)", ((double)(*fsp)->st_cache_hit /
-			    ((*fsp)->st_cache_hit + (*fsp)->st_cache_miss)) *
-			    100);
-		printf(".\n");
-		db_stat_dl("Requested pages not found in the cache.\n",
-		    (u_long)(*fsp)->st_cache_miss);
-		db_stat_dl("Pages created in the cache.\n",
-		    (u_long)(*fsp)->st_page_create);
-		db_stat_dl("Pages read into the cache.\n",
-		    (u_long)(*fsp)->st_page_in);
-		db_stat_dl("Pages written from the cache to the backing file.\n",
-		    (u_long)(*fsp)->st_page_out);
-	}
-
-	free(gsp);
-
-	return (0);
-}
-
-/*
- * rep_stats --
- *	Display replication statistics.
- */
-int
-db_stat_rep_stats(dbenv, flags)
-	DB_ENV *dbenv;
-	u_int32_t flags;
-{
-	DB_REP_STAT *sp;
-	int is_client, ret;
-	const char *p;
-
-	if ((ret = dbenv->rep_stat(dbenv, &sp, flags)) != 0) {
-		dbenv->err(dbenv, ret, NULL);
-		return (1);
-	}
-
-	is_client = 0;
-	switch (sp->st_status) {
-	case DB_REP_MASTER:
-		printf("Environment configured as a replication master.\n");
-		break;
-	case DB_REP_CLIENT:
-		printf("Environment configured as a replication client.\n");
-		is_client = 1;
-		break;
-	case DB_REP_LOGSONLY:
-		printf("Environment configured as a logs-only replica.\n");
-		is_client = 1;
-		break;
-	default:
-		printf("Environment not configured for replication.\n");
-		break;
-	}
-
-	printf("%lu/%lu\t%s\n",
-	    (u_long)sp->st_next_lsn.file, (u_long)sp->st_next_lsn.offset,
-	    is_client ? "Next LSN expected." : "Next LSN to be used.");
-	p = sp->st_waiting_lsn.file == 0 ?
-	    "Not waiting for any missed log records." :
-	    "LSN of first missed log record being waited for.";
-	printf("%lu/%lu\t%s\n",
-	    (u_long)sp->st_waiting_lsn.file, (u_long)sp->st_waiting_lsn.offset,
-	    p);
-
-	db_stat_dl("Number of duplicate master conditions detected.\n",
-	    (u_long)sp->st_dupmasters);
-	if (sp->st_env_id != DB_EID_INVALID)
-		db_stat_dl("Current environment ID.\n", (u_long)sp->st_env_id);
-	else
-		printf("No current environment ID.\n");
-	db_stat_dl("Current environment priority.\n", (u_long)sp->st_env_priority);
-	db_stat_dl("Current generation number.\n", (u_long)sp->st_gen);
-	db_stat_dl("Number of duplicate log records received.\n",
-	    (u_long)sp->st_log_duplicated);
-	db_stat_dl("Number of log records currently queued.\n",
-	    (u_long)sp->st_log_queued);
-	db_stat_dl("Maximum number of log records ever queued at once.\n",
-	    (u_long)sp->st_log_queued_max);
-	db_stat_dl("Total number of log records queued.\n",
-	    (u_long)sp->st_log_queued_total);
-	db_stat_dl("Number of log records received and appended to the log.\n",
-	    (u_long)sp->st_log_records);
-	db_stat_dl("Number of log records missed and requested.\n",
-	    (u_long)sp->st_log_requested);
-	if (sp->st_master != DB_EID_INVALID)
-		db_stat_dl("Current master ID.\n", (u_long)sp->st_master);
-	else
-		printf("No current master ID.\n");
-	db_stat_dl("Number of times the master has changed.\n",
-	    (u_long)sp->st_master_changes);
-	db_stat_dl("Number of messages received with a bad generation number.\n",
-	    (u_long)sp->st_msgs_badgen);
-	db_stat_dl("Number of messages received and processed.\n",
-	    (u_long)sp->st_msgs_processed);
-	db_stat_dl("Number of messages ignored due to pending recovery.\n",
-	    (u_long)sp->st_msgs_recover);
-	db_stat_dl("Number of failed message sends.\n",
-	    (u_long)sp->st_msgs_send_failures);
-	db_stat_dl("Number of messages sent.\n", (u_long)sp->st_msgs_sent);
-	db_stat_dl("Number of new site messages received.\n", (u_long)sp->st_newsites);
-	db_stat_dl("Transmission limited.\n", (u_long)sp->st_nthrottles);
-	db_stat_dl("Number of outdated conditions detected.\n",
-	    (u_long)sp->st_outdated);
-	db_stat_dl("Number of transactions applied.\n", (u_long)sp->st_txns_applied);
-
-	db_stat_dl("Number of elections held.\n", (u_long)sp->st_elections);
-	db_stat_dl("Number of elections won.\n", (u_long)sp->st_elections_won);
-
-	if (sp->st_election_status == 0)
-		printf("No election in progress.\n");
-	else {
-		db_stat_dl("Current election phase.\n", (u_long)sp->st_election_status);
-		db_stat_dl("Election winner.\n",
-		    (u_long)sp->st_election_cur_winner);
-		db_stat_dl("Election generation number.\n",
-		    (u_long)sp->st_election_gen);
-		printf("%lu/%lu\tMaximum LSN of election winner.\n",
-		    (u_long)sp->st_election_lsn.file,
-		    (u_long)sp->st_election_lsn.offset);
-		db_stat_dl("Number of sites expected to participate in elections.\n",
-		    (u_long)sp->st_election_nsites);
-		db_stat_dl("Election priority.\n", (u_long)sp->st_election_priority);
-		db_stat_dl("Election tiebreaker value.\n",
-		    (u_long)sp->st_election_tiebreaker);
-		db_stat_dl("Votes received this election round.\n",
-		    (u_long)sp->st_election_votes);
-	}
-
-	free(sp);
-
-	return (0);
-}
-
-/*
- * txn_stats --
- *	Display transaction statistics.
- */
-int
-db_stat_txn_stats(dbenv, flags)
-	DB_ENV *dbenv;
-	u_int32_t flags;
-{
-	DB_TXN_STAT *sp;
-	u_int32_t i;
-	int ret;
-	const char *p;
-
-	if ((ret = dbenv->txn_stat(dbenv, &sp, flags)) != 0) {
-		dbenv->err(dbenv, ret, NULL);
-		return (1);
-	}
-
-	p = sp->st_last_ckp.file == 0 ?
-	    "No checkpoint LSN." : "File/offset for last checkpoint LSN.";
-	printf("%lu/%lu\t%s\n",
-	    (u_long)sp->st_last_ckp.file, (u_long)sp->st_last_ckp.offset, p);
-	if (sp->st_time_ckp == 0)
-		printf("0\tNo checkpoint timestamp.\n");
-	else
-		printf("%.24s\tCheckpoint timestamp.\n",
-		    ctime(&sp->st_time_ckp));
-	printf("%lx\tLast transaction ID allocated.\n",
-	    (u_long)sp->st_last_txnid);
-	db_stat_dl("Maximum number of active transactions possible.\n",
-	    (u_long)sp->st_maxtxns);
-	db_stat_dl("Active transactions.\n", (u_long)sp->st_nactive);
-	db_stat_dl("Maximum active transactions.\n", (u_long)sp->st_maxnactive);
-	db_stat_dl("Number of transactions begun.\n", (u_long)sp->st_nbegins);
-	db_stat_dl("Number of transactions aborted.\n", (u_long)sp->st_naborts);
-	db_stat_dl("Number of transactions committed.\n", (u_long)sp->st_ncommits);
-	db_stat_dl("Number of transactions restored.\n", (u_long)sp->st_nrestores);
-
-	db_stat_dl_bytes("Transaction region size",
-	    (u_long)0, (u_long)0, (u_long)sp->st_regsize);
-	db_stat_dl("The number of region locks granted after waiting.\n",
-	    (u_long)sp->st_region_wait);
-	db_stat_dl("The number of region locks granted without waiting.\n",
-	    (u_long)sp->st_region_nowait);
-
-	qsort(sp->st_txnarray,
-	    sp->st_nactive, sizeof(sp->st_txnarray[0]), db_stat_txn_compare);
-	for (i = 0; i < sp->st_nactive; ++i) {
-		printf("\tid: %lx; begin LSN: file/offset %lu/%lu",
-		    (u_long)sp->st_txnarray[i].txnid,
-		    (u_long)sp->st_txnarray[i].lsn.file,
-		    (u_long)sp->st_txnarray[i].lsn.offset);
-		if (sp->st_txnarray[i].parentid == 0)
-			printf("\n");
-		else
-			printf(" parent: %lx\n",
-			    (u_long)sp->st_txnarray[i].parentid);
-	}
-
-	free(sp);
-
-	return (0);
-}
-
-int
-db_stat_txn_compare(a1, b1)
-	const void *a1, *b1;
-{
-	const DB_TXN_ACTIVE *a, *b;
-
-	a = a1;
-	b = b1;
-
-	if (a->txnid > b->txnid)
-		return (1);
-	if (a->txnid < b->txnid)
-		return (-1);
-	return (0);
-}
-
-/*
- * dl --
- *	Display a big value.
- */
-void
-db_stat_dl(msg, value)
-	const char *msg;
-	u_long value;
-{
-	/*
-	 * Two formats: if less than 10 million, display as the number, if
-	 * greater than 10 million display as ###M.
-	 */
-	if (value < 10000000)
-		printf("%lu\t%s", value, msg);
-	else
-		printf("%luM\t%s", value / 1000000, msg);
-}
-
-/*
- * dl_bytes --
- *	Display a big number of bytes.
- */
-void
-db_stat_dl_bytes(msg, gbytes, mbytes, bytes)
-	const char *msg;
-	u_long gbytes, mbytes, bytes;
-{
-	const char *sep;
-
-	/* Normalize the values. */
-	while (bytes >= MEGABYTE) {
-		++mbytes;
-		bytes -= MEGABYTE;
-	}
-	while (mbytes >= GIGABYTE / MEGABYTE) {
-		++gbytes;
-		mbytes -= GIGABYTE / MEGABYTE;
-	}
-
-	sep = "";
-	if (gbytes > 0) {
-		printf("%luGB", gbytes);
-		sep = " ";
-	}
-	if (mbytes > 0) {
-		printf("%s%luMB", sep, mbytes);
-		sep = " ";
-	}
-	if (bytes >= 1024) {
-		printf("%s%luKB", sep, bytes / 1024);
-		bytes %= 1024;
-		sep = " ";
-	}
-	if (bytes > 0)
-		printf("%s%luB", sep, bytes);
-
-	printf("\t%s.\n", msg);
-}
-
-/*
- * prflags --
- *	Print out flag values.
- */
-void
-db_stat_prflags(flags, fnp)
-	u_int32_t flags;
-	const FN *fnp;
-{
-	const char *sep;
-
-	sep = "\t";
-	printf("Flags:");
-	for (; fnp->mask != 0; ++fnp)
-		if (fnp->mask & flags) {
-			printf("%s%s", sep, fnp->name);
-			sep = ", ";
-		}
-	printf("\n");
-}
-
-/*
- * db_init --
- *	Initialize the environment.
- */
-int
-db_stat_db_init(dbenv, home, ttype, cache, is_private)
-	DB_ENV *dbenv;
-	char *home;
-	test_t ttype;
-	u_int32_t cache;
-	int *is_private;
-{
-	u_int32_t oflags;
-	int ret;
-
-	/*
-	 * If our environment open fails, and we're trying to look at a
-	 * shared region, it's a hard failure.
-	 *
-	 * We will probably just drop core if the environment we join does
-	 * not include a memory pool.  This is probably acceptable; trying
-	 * to use an existing environment that does not contain a memory
-	 * pool to look at a database can be safely construed as operator
-	 * error, I think.
-	 */
-	*is_private = 0;
-	if ((ret =
-	    dbenv->open(dbenv, home, DB_JOINENV | DB_USE_ENVIRON, 0)) == 0)
-		return (0);
-	if (ttype != T_DB && ttype != T_LOG) {
-		dbenv->err(dbenv, ret, "DB_ENV->open%s%s",
-		    home == NULL ? "" : ": ", home == NULL ? "" : home);
-		return (1);
-	}
-
-	/*
-	 * We're looking at a database or set of log files and no environment
-	 * exists.  Create one, but make it private so no files are actually
-	 * created.  Declare a reasonably large cache so that we don't fail
-	 * when reporting statistics on large databases.
-	 *
-	 * An environment is required to look at databases because we may be
-	 * trying to look at databases in directories other than the current
-	 * one.
-	 */
-	if ((ret = dbenv->set_cachesize(dbenv, 0, cache, 1)) != 0) {
-		dbenv->err(dbenv, ret, "set_cachesize");
-		return (1);
-	}
-	*is_private = 1;
-	oflags = DB_CREATE | DB_PRIVATE | DB_USE_ENVIRON;
-	if (ttype == T_DB)
-		oflags |= DB_INIT_MPOOL;
-	if (ttype == T_LOG)
-		oflags |= DB_INIT_LOG;
-	if ((ret = dbenv->open(dbenv, home, oflags, 0)) == 0)
-		return (0);
-
-	/* An environment is required. */
-	dbenv->err(dbenv, ret, "open");
-	return (1);
-}
-
-/*
- * argcheck --
- *	Return if argument flags are okay.
- */
-int
-db_stat_argcheck(arg, ok_args)
-	char *arg;
-	const char *ok_args;
-{
-	for (; *arg != '\0'; ++arg)
-		if (strchr(ok_args, *arg) == NULL)
-			return (0);
-	return (1);
-}
-
-int
-db_stat_usage()
-{
-	fprintf(stderr, "%s\n\t%s\n",
-	    "usage: db_stat [-celmNrtVZ] [-C Aclmop]",
-	    "[-d file [-f] [-s database]] [-h home] [-M Ahlm] [-P password]");
-	return (EXIT_FAILURE);
-}
-
-int
-db_stat_version_check(progname)
-	const char *progname;
-{
-	int v_major, v_minor, v_patch;
-
-	/* Make sure we're loaded with the right version of the DB library. */
-	(void)db_version(&v_major, &v_minor, &v_patch);
-	if (v_major != DB_VERSION_MAJOR ||
-	    v_minor != DB_VERSION_MINOR || v_patch != DB_VERSION_PATCH) {
-		fprintf(stderr,
-	"%s: version %d.%d.%d doesn't match library version %d.%d.%d\n",
-		    progname, DB_VERSION_MAJOR, DB_VERSION_MINOR,
-		    DB_VERSION_PATCH, v_major, v_minor, v_patch);
-		return (EXIT_FAILURE);
-	}
-	return (0);
-}
diff --git a/bdb/build_vxworks/db_stat/db_stat.wpj b/bdb/build_vxworks/db_stat/db_stat.wpj
deleted file mode 100755
index ba78c4cc3fdcdfbe64f8473d9a23868e2d0995e0..0000000000000000000000000000000000000000
--- a/bdb/build_vxworks/db_stat/db_stat.wpj
+++ /dev/null
@@ -1,160 +0,0 @@
-Document file - DO NOT EDIT
-
-<BEGIN> BUILD_PENTIUMgnu_BUILDRULE
-db_stat.out
-<END>
-
-<BEGIN> BUILD_PENTIUMgnu_MACRO_AR
-ar386
-<END>
-
-<BEGIN> BUILD_PENTIUMgnu_MACRO_ARCHIVE
-$(PRJ_DIR)/PENTIUMgnu/db_stat.a
-<END>
-
-<BEGIN> BUILD_PENTIUMgnu_MACRO_AS
-cc386
-<END>
-
-<BEGIN> BUILD_PENTIUMgnu_MACRO_CC
-cc386
-<END>
-
-<BEGIN> BUILD_PENTIUMgnu_MACRO_CFLAGS
--g \
-	-mpentium \
-	-ansi \
-	-nostdinc \
-	-DRW_MULTI_THREAD \
-	-D_REENTRANT \
-	-fvolatile \
-	-nostdlib \
-	-fno-builtin \
-	-fno-defer-pop \
-	-I$(PRJ_DIR)/.. \
-	-I$(PRJ_DIR)/../.. \
-	-I$(WIND_BASE)/target/h \
-	-DCPU=PENTIUM
-<END>
-
-<BEGIN> BUILD_PENTIUMgnu_MACRO_CFLAGS_AS
--g \
-	-mpentium \
-	-ansi \
-	-nostdinc \
-	-fvolatile \
-	-nostdlib \
-	-fno-builtin \
-	-fno-defer-pop \
-	-P \
-	-x \
-	assembler-with-cpp \
-	-I$(WIND_BASE)/target/h \
-	-DCPU=PENTIUM
-<END>
-
-<BEGIN> BUILD_PENTIUMgnu_MACRO_CPP
-cc386 -E -P -xc
-<END>
-
-<BEGIN> BUILD_PENTIUMgnu_MACRO_LD
-ld386
-<END>
-
-<BEGIN> BUILD_PENTIUMgnu_MACRO_LDDEPS
-
-<END>
-
-<BEGIN> BUILD_PENTIUMgnu_MACRO_LDFLAGS
--X -N
-<END>
-
-<BEGIN> BUILD_PENTIUMgnu_MACRO_LD_PARTIAL_FLAGS
--X -r
-<END>
-
-<BEGIN> BUILD_PENTIUMgnu_MACRO_NM
-nm386 -g
-<END>
-
-<BEGIN> BUILD_PENTIUMgnu_MACRO_OPTION_DEFINE_MACRO
--D
-<END>
-
-<BEGIN> BUILD_PENTIUMgnu_MACRO_OPTION_INCLUDE_DIR
--I
-<END>
-
-<BEGIN> BUILD_PENTIUMgnu_MACRO_POST_BUILD_RULE
-
-<END>
-
-<BEGIN> BUILD_PENTIUMgnu_MACRO_PRJ_LIBS
-
-<END>
-
-<BEGIN> BUILD_PENTIUMgnu_MACRO_SIZE
-size386
-<END>
-
-<BEGIN> BUILD_PENTIUMgnu_RO_DEPEND_PATH
-{$(WIND_BASE)/target/h/} \
-	{$(WIND_BASE)/target/src/} \
-	{$(WIND_BASE)/target/config/}
-<END>
-
-<BEGIN> BUILD_PENTIUMgnu_TC
-::tc_PENTIUMgnu
-<END>
-
-<BEGIN> BUILD_RULE_archive
-
-<END>
-
-<BEGIN> BUILD_RULE_db_stat.out
-
-<END>
-
-<BEGIN> BUILD_RULE_objects
-
-<END>
-
-<BEGIN> BUILD__CURRENT
-PENTIUMgnu
-<END>
-
-<BEGIN> BUILD__LIST
-PENTIUMgnu
-<END>
-
-<BEGIN> CORE_INFO_TYPE
-::prj_vxApp
-<END>
-
-<BEGIN> CORE_INFO_VERSION
-2.0
-<END>
-
-<BEGIN> FILE_db_stat.c_dependDone
-FALSE
-<END>
-
-<BEGIN> FILE_db_stat.c_dependencies
-
-<END>
-
-<BEGIN> FILE_db_stat.c_objects
-db_stat.o
-<END>
-
-<BEGIN> FILE_db_stat.c_tool
-C/C++ compiler
-<END>
-
-<BEGIN> PROJECT_FILES
-$(PRJ_DIR)/db_stat.c
-<END>
-
-<BEGIN> userComments
-db_stat
-<END>
diff --git a/bdb/build_vxworks/db_stat/db_stat/Makefile.custom b/bdb/build_vxworks/db_stat/db_stat/Makefile.custom
deleted file mode 100644
index ca781f7b251ef99e49e5fc1859ee6cf3d67c60b0..0000000000000000000000000000000000000000
--- a/bdb/build_vxworks/db_stat/db_stat/Makefile.custom
+++ /dev/null
@@ -1,51 +0,0 @@
-#
-# Custom Makefile shell
-#
-# This file may be edited freely, since it will not be regenerated
-# by the project manager.
-#
-# Use this makefile to define rules to make external binaries
-# and deposit them in the $(EXTERNAL_BINARIES_DIR) directory.
-#
-# If you have specified external modules during your component
-# creation, you will find make rules already in place below.
-# You will likely have to edit these to suit your individual
-# build setup.
-#
-# You may wish to use the CPU, BUILD_SPEC or TOOL make variables in
-# your Makefile to support builds for different architectures.  Use
-# the FORCE_EXTERNAL_MAKE phony target to ensure that your external
-# make always runs.
-#
-# The example below assumes that your custom makefile is in the
-# mySourceTree directory, and that the binary file it produces
-# is placed into the $(BUILD_SPEC) sub-directory.
-#
-# EXTERNAL_SOURCE_BASE = /folk/me/mySourceTree
-# EXTERNAL_MODULE = myLibrary.o
-# EXTERNAL_MAKE = make
-#
-# $(EXTERNAL_BINARIES_DIR)/$(EXTERNAL_MODULE) : FORCE_EXTERNAL_MAKE
-#	$(EXTERNAL_MAKE) -C $(EXTERNAL_SOURCE_BASE) \
-#	-f $(EXTERNAL_SOURCE_BASE)/Makefile \
-#	CPU=$(CPU) BUILD_SPEC=$(BUILD_SPEC) $(@F)
-#	$(CP) $(subst /,$(DIRCHAR),$(EXTERNAL_SOURCE_BASE)/$(BUILD_SPEC)/$(@F) $@)
-#
-# If you are not adding your external modules from the component wizard,
-# you will have to include them in your component yourself:
-#
-# From the GUI, you can do this with the Component's 'Add external module'
-# dialog.
-#
-# If you are using the command line, add the module(s) by editing the
-# MODULES line in component.cdf file, e.g.
-#
-# Component INCLUDE_MYCOMPONENT {
-#
-#   MODULES         foo.o goo.o \
-#         myLibrary.o
-#
-
-
-# rules to build custom libraries
-
diff --git a/bdb/build_vxworks/db_stat/db_stat/component.cdf b/bdb/build_vxworks/db_stat/db_stat/component.cdf
deleted file mode 100755
index 728544eabff454db93f176ee9abf9a36d8ac62f5..0000000000000000000000000000000000000000
--- a/bdb/build_vxworks/db_stat/db_stat/component.cdf
+++ /dev/null
@@ -1,30 +0,0 @@
-/* component.cdf - dynamically updated configuration */
-
-/*
- * NOTE: you may edit this file to alter the configuration
- * But all non-configuration information, including comments,
- * will be lost upon rebuilding this project.
- */
-
-/* Component information */
-
-Component INCLUDE_DB_STAT {
-	ENTRY_POINTS	ALL_GLOBAL_SYMBOLS 
-	MODULES		db_stat.o 
-	NAME		db_stat
-	PREF_DOMAIN	ANY
-	_INIT_ORDER	usrComponentsInit
-}
-
-/* EntryPoint information */
-
-/* Module information */
-
-Module db_stat.o {
-
-	NAME		db_stat.o
-	SRC_PATH_NAME	$PRJ_DIR/../db_stat.c
-}
-
-/* Parameter information */
-
diff --git a/bdb/build_vxworks/db_stat/db_stat/component.wpj b/bdb/build_vxworks/db_stat/db_stat/component.wpj
deleted file mode 100755
index 2020d712dee3bc19478893b99ece548d787d3174..0000000000000000000000000000000000000000
--- a/bdb/build_vxworks/db_stat/db_stat/component.wpj
+++ /dev/null
@@ -1,475 +0,0 @@
-Document file - DO NOT EDIT
-
-<BEGIN> CORE_INFO_TYPE
-::prj_component
-<END>
-
-<BEGIN> CORE_INFO_VERSION
-AE1.1
-<END>
-
-<BEGIN> BUILD__CURRENT
-PENTIUM2gnu.debug
-<END>
-
-<BEGIN> BUILD_PENTIUM2gnu.debug_CURRENT_TARGET
-default
-<END>
-
-<BEGIN> BUILD_PENTIUM2gnu.debug_DEFAULTFORCPU
-1
-<END>
-
-<BEGIN> BUILD_PENTIUM2gnu.debug_FILE_$(PRJ_DIR)/../db_stat.c_infoTags
-toolMacro objects
-<END>
-
-<BEGIN> BUILD_PENTIUM2gnu.debug_FILE_$(PRJ_DIR)/../db_stat.c_objects
-db_stat.o
-<END>
-
-<BEGIN> BUILD_PENTIUM2gnu.debug_FILE_$(PRJ_DIR)/../db_stat.c_toolMacro
-CC
-<END>
-
-<BEGIN> BUILD_PENTIUM2gnu.debug_FILE_$(PRJ_DIR)/../db_stat.c_objects
-db_stat.o
-<END>
-
-<BEGIN> BUILD_PENTIUM2gnu.debug_FILE_$(PRJ_DIR)/../db_stat.c_toolMacro
-CC
-<END>
-
-<BEGIN> BUILD_PENTIUM2gnu.debug_FILE_$(PRJ_DIR)/compConfig.c_infoTags
-toolMacro objects
-<END>
-
-<BEGIN> BUILD_PENTIUM2gnu.debug_FILE_$(PRJ_DIR)/compConfig.c_objects
-compConfig.o
-<END>
-
-<BEGIN> BUILD_PENTIUM2gnu.debug_FILE_$(PRJ_DIR)/compConfig.c_toolMacro
-CC
-<END>
-
-<BEGIN> BUILD_PENTIUM2gnu.debug_MACRO_AR
-arpentium
-<END>
-
-<BEGIN> BUILD_PENTIUM2gnu.debug_MACRO_AS
-ccpentium
-<END>
-
-<BEGIN> BUILD_PENTIUM2gnu.debug_MACRO_CC
-ccpentium
-<END>
-
-<BEGIN> BUILD_PENTIUM2gnu.debug_MACRO_CFLAGS
--mcpu=pentiumpro \
-	-march=pentiumpro \
-	-ansi \
-	-DRW_MULTI_THREAD \
-	-D_REENTRANT \
-	-g \
-	-nostdlib \
-	-fno-builtin \
-	-fno-defer-pop \
-	-MD \
-	-Wall \
-	-I. \
-	-I$(WIND_BASE)/target/h \
-	-I$(PRJ_DIR)/../.. \
-	-I$(PRJ_DIR)/../../.. \
-	-DCPU=PENTIUM2
-<END>
-
-<BEGIN> BUILD_PENTIUM2gnu.debug_MACRO_CFLAGS_AS
--mcpu=pentiumpro \
-	-march=pentiumpro \
-	-ansi \
-	-g \
-	-nostdlib \
-	-fno-builtin \
-	-fno-defer-pop \
-	-P \
-	-x \
-	assembler-with-cpp \
-	-Wall \
-	-I. \
-	-I$(WIND_BASE)/target/h \
-	-DCPU=PENTIUM2
-<END>
-
-<BEGIN> BUILD_PENTIUM2gnu.debug_MACRO_CPP
-ccpentium -E -P
-<END>
-
-<BEGIN> BUILD_PENTIUM2gnu.debug_MACRO_CPPFILT
-c++filtpentium --strip-underscores
-<END>
-
-<BEGIN> BUILD_PENTIUM2gnu.debug_MACRO_LD
-ldpentium
-<END>
-
-<BEGIN> BUILD_PENTIUM2gnu.debug_MACRO_LDFLAGS
--X
-<END>
-
-<BEGIN> BUILD_PENTIUM2gnu.debug_MACRO_LDPARTIAL
-ccpentium \
-	-B$(WIND_BASE)/host/$(WIND_HOST_TYPE)/lib/gcc-lib/ \
-	-nostdlib \
-	-r \
-	-Wl,-X
-<END>
-
-<BEGIN> BUILD_PENTIUM2gnu.debug_MACRO_LD_PARTIAL_FLAGS
--X -r
-<END>
-
-<BEGIN> BUILD_PENTIUM2gnu.debug_MACRO_NM
-nmpentium -g
-<END>
-
-<BEGIN> BUILD_PENTIUM2gnu.debug_MACRO_OPTION_DEFINE_MACRO
--D
-<END>
-
-<BEGIN> BUILD_PENTIUM2gnu.debug_MACRO_OPTION_GENERATE_DEPENDENCY_FILE
--MD
-<END>
-
-<BEGIN> BUILD_PENTIUM2gnu.debug_MACRO_OPTION_INCLUDE_DIR
--I
-<END>
-
-<BEGIN> BUILD_PENTIUM2gnu.debug_MACRO_RELEASE
-0
-<END>
-
-<BEGIN> BUILD_PENTIUM2gnu.debug_MACRO_SIZE
-sizepentium
-<END>
-
-<BEGIN> BUILD_PENTIUM2gnu.debug_RELEASE
-0
-<END>
-
-<BEGIN> BUILD_PENTIUM2gnu.debug_RO_DEPEND_PATH
-$(WIND_BASE)/target/h/
-<END>
-
-<BEGIN> BUILD_PENTIUM2gnu.debug_TC
-::tc_PENTIUM2gnu.debug
-<END>
-
-<BEGIN> BUILD_PENTIUM2gnu.release_DEFAULTFORCPU
-0
-<END>
-
-<BEGIN> BUILD_PENTIUM2gnu.release_FILE_$(PRJ_DIR)/../db_stat.c_infoTags
-toolMacro objects
-<END>
-
-<BEGIN> BUILD_PENTIUM2gnu.release_FILE_$(PRJ_DIR)/../db_stat.c_objects
-db_stat.o
-<END>
-
-<BEGIN> BUILD_PENTIUM2gnu.release_FILE_$(PRJ_DIR)/../db_stat.c_toolMacro
-CC
-<END>
-
-<BEGIN> BUILD_PENTIUM2gnu.release_FILE_$(PRJ_DIR)/compConfig.c_infoTags
-toolMacro objects
-<END>
-
-<BEGIN> BUILD_PENTIUM2gnu.release_FILE_$(PRJ_DIR)/compConfig.c_objects
-compConfig.o
-<END>
-
-<BEGIN> BUILD_PENTIUM2gnu.release_FILE_$(PRJ_DIR)/compConfig.c_toolMacro
-CC
-<END>
-
-<BEGIN> BUILD_PENTIUM2gnu.release_MACRO_AR
-arpentium
-<END>
-
-<BEGIN> BUILD_PENTIUM2gnu.release_MACRO_AS
-ccpentium
-<END>
-
-<BEGIN> BUILD_PENTIUM2gnu.release_MACRO_CC
-ccpentium
-<END>
-
-<BEGIN> BUILD_PENTIUM2gnu.release_MACRO_CFLAGS
--mcpu=pentiumpro \
-	-march=pentiumpro \
-	-ansi \
-	-DRW_MULTI_THREAD \
-	-D_REENTRANT \
-	-O2 \
-	-nostdlib \
-	-fno-builtin \
-	-fno-defer-pop \
-	-MD \
-	-Wall \
-	-I. \
-	-I$(WIND_BASE)/target/h \
-	-I$(PRJ_DIR)/../.. \
-	-I$(PRJ_DIR)/../../.. \
-	-DCPU=PENTIUM2
-<END>
-
-<BEGIN> BUILD_PENTIUM2gnu.release_MACRO_CFLAGS_AS
--mcpu=pentiumpro \
-	-march=pentiumpro \
-	-ansi \
-	-O2 \
-	-nostdlib \
-	-fno-builtin \
-	-fno-defer-pop \
-	-P \
-	-x \
-	assembler-with-cpp \
-	-Wall \
-	-I. \
-	-I$(WIND_BASE)/target/h \
-	-DCPU=PENTIUM2
-<END>
-
-<BEGIN> BUILD_PENTIUM2gnu.release_MACRO_CPP
-ccpentium -E -P
-<END>
-
-<BEGIN> BUILD_PENTIUM2gnu.release_MACRO_CPPFILT
-c++filtpentium --strip-underscores
-<END>
-
-<BEGIN> BUILD_PENTIUM2gnu.release_MACRO_LD
-ldpentium
-<END>
-
-<BEGIN> BUILD_PENTIUM2gnu.release_MACRO_LDFLAGS
--X
-<END>
-
-<BEGIN> BUILD_PENTIUM2gnu.release_MACRO_LDPARTIAL
-ccpentium \
-	-B$(WIND_BASE)/host/$(WIND_HOST_TYPE)/lib/gcc-lib/ \
-	-nostdlib \
-	-r \
-	-Wl,-X
-<END>
-
-<BEGIN> BUILD_PENTIUM2gnu.release_MACRO_LD_PARTIAL_FLAGS
--X -r
-<END>
-
-<BEGIN> BUILD_PENTIUM2gnu.release_MACRO_NM
-nmpentium -g
-<END>
-
-<BEGIN> BUILD_PENTIUM2gnu.release_MACRO_OPTION_DEFINE_MACRO
--D
-<END>
-
-<BEGIN> BUILD_PENTIUM2gnu.release_MACRO_OPTION_GENERATE_DEPENDENCY_FILE
--MD
-<END>
-
-<BEGIN> BUILD_PENTIUM2gnu.release_MACRO_OPTION_INCLUDE_DIR
--I
-<END>
-
-<BEGIN> BUILD_PENTIUM2gnu.release_MACRO_RELEASE
-1
-<END>
-
-<BEGIN> BUILD_PENTIUM2gnu.release_MACRO_SIZE
-sizepentium
-<END>
-
-<BEGIN> BUILD_PENTIUM2gnu.release_RELEASE
-1
-<END>
-
-<BEGIN> BUILD_PENTIUM2gnu.release_RO_DEPEND_PATH
-$(WIND_BASE)/target/h/
-<END>
-
-<BEGIN> BUILD_PENTIUM2gnu.release_TC
-::tc_PENTIUM2gnu.release
-<END>
-
-<BEGIN> BUILD_PENTIUMgnu.debug_DEFAULTFORCPU
-1
-<END>
-
-<BEGIN> BUILD_PENTIUMgnu.debug_FILE_$(PRJ_DIR)/../db_stat.c_infoTags
-toolMacro objects
-<END>
-
-<BEGIN> BUILD_PENTIUMgnu.debug_FILE_$(PRJ_DIR)/../db_stat.c_objects
-db_stat.o
-<END>
-
-<BEGIN> BUILD_PENTIUMgnu.debug_FILE_$(PRJ_DIR)/../db_stat.c_toolMacro
-CC
-<END>
-
-<BEGIN> BUILD_PENTIUMgnu.debug_FILE_$(PRJ_DIR)/compConfig.c_infoTags
-toolMacro objects
-<END>
-
-<BEGIN> BUILD_PENTIUMgnu.debug_FILE_$(PRJ_DIR)/compConfig.c_objects
-compConfig.o
-<END>
-
-<BEGIN> BUILD_PENTIUMgnu.debug_FILE_$(PRJ_DIR)/compConfig.c_toolMacro
-CC
-<END>
-
-<BEGIN> BUILD_PENTIUMgnu.debug_MACRO_AR
-arpentium
-<END>
-
-<BEGIN> BUILD_PENTIUMgnu.debug_MACRO_AS
-ccpentium
-<END>
-
-<BEGIN> BUILD_PENTIUMgnu.debug_MACRO_CC
-ccpentium
-<END>
-
-<BEGIN> BUILD_PENTIUMgnu.debug_MACRO_CFLAGS
--mcpu=pentium \
-	-march=pentium \
-	-ansi \
-	-DRW_MULTI_THREAD \
-	-D_REENTRANT \
-	-g \
-	-nostdlib \
-	-fno-builtin \
-	-fno-defer-pop \
-	-MD \
-	-Wall \
-	-I. \
-	-I$(WIND_BASE)/target/h \
-	-I$(PRJ_DIR)/../.. \
-	-I$(PRJ_DIR)/../../.. \
-	-DCPU=PENTIUM
-<END>
-
-<BEGIN> BUILD_PENTIUMgnu.debug_MACRO_CFLAGS_AS
--mcpu=pentium \
-	-march=pentium \
-	-ansi \
-	-g \
-	-nostdlib \
-	-fno-builtin \
-	-fno-defer-pop \
-	-P \
-	-x \
-	assembler-with-cpp \
-	-Wall \
-	-I. \
-	-I$(WIND_BASE)/target/h \
-	-DCPU=PENTIUM
-<END>
-
-<BEGIN> BUILD_PENTIUMgnu.debug_MACRO_CPP
-ccpentium -E -P
-<END>
-
-<BEGIN> BUILD_PENTIUMgnu.debug_MACRO_CPPFILT
-c++filtpentium --strip-underscores
-<END>
-
-<BEGIN> BUILD_PENTIUMgnu.debug_MACRO_LD
-ldpentium
-<END>
-
-<BEGIN> BUILD_PENTIUMgnu.debug_MACRO_LDFLAGS
--X
-<END>
-
-<BEGIN> BUILD_PENTIUMgnu.debug_MACRO_LDPARTIAL
-ccpentium \
-	-B$(WIND_BASE)/host/$(WIND_HOST_TYPE)/lib/gcc-lib/ \
-	-nostdlib \
-	-r \
-	-Wl,-X
-<END>
-
-<BEGIN> BUILD_PENTIUMgnu.debug_MACRO_LD_PARTIAL_FLAGS
--X -r
-<END>
-
-<BEGIN> BUILD_PENTIUMgnu.debug_MACRO_NM
-nmpentium -g
-<END>
-
-<BEGIN> BUILD_PENTIUMgnu.debug_MACRO_OPTION_DEFINE_MACRO
--D
-<END>
-
-<BEGIN> BUILD_PENTIUMgnu.debug_MACRO_OPTION_GENERATE_DEPENDENCY_FILE
--MD
-<END>
-
-<BEGIN> BUILD_PENTIUMgnu.debug_MACRO_OPTION_INCLUDE_DIR
--I
-<END>
-
-<BEGIN> BUILD_PENTIUMgnu.debug_MACRO_RELEASE
-0
-<END>
-
-<BEGIN> BUILD_PENTIUMgnu.debug_MACRO_SIZE
-sizepentium
-<END>
-
-<BEGIN> BUILD_PENTIUMgnu.debug_RELEASE
-0
-<END>
-
-<BEGIN> BUILD_PENTIUMgnu.debug_RO_DEPEND_PATH
-$(WIND_BASE)/target/h/
-<END>
-
-<BEGIN> BUILD_PENTIUMgnu.debug_TC
-::tc_PENTIUMgnu.debug
-<END>
-
-<BEGIN> BUILD__LIST
-PENTIUM2gnu.debug PENTIUM2gnu.release PENTIUMgnu.debug
-<END>
-
-<BEGIN> PROJECT_FILES
-$(PRJ_DIR)/../db_stat.c \
-	$(PRJ_DIR)/compConfig.c
-<END>
-
-<BEGIN> WCC__CDF_PATH
-$(PRJ_DIR)
-<END>
-
-<BEGIN> WCC__CURRENT
-PENTIUM2gnu.debug
-<END>
-
-<BEGIN> WCC__LIST
-PENTIUM2gnu.debug
-<END>
-
-<BEGIN> WCC__MXR_LIBS
-lib$(CPU)$(TOOL)vx.a
-<END>
-
-<BEGIN> WCC__OBJS_PATH
-$(WIND_BASE)/target/lib/obj$CPU$TOOLvx
-<END>
-
diff --git a/bdb/build_vxworks/db_upgrade/db_upgrade.c b/bdb/build_vxworks/db_upgrade/db_upgrade.c
deleted file mode 100644
index 6f9138b59b9cbfe1314130e1d81ac6eb0109b0ae..0000000000000000000000000000000000000000
--- a/bdb/build_vxworks/db_upgrade/db_upgrade.c
+++ /dev/null
@@ -1,205 +0,0 @@
-/*-
- * See the file LICENSE for redistribution information.
- *
- * Copyright (c) 1996-2002
- *	Sleepycat Software.  All rights reserved.
- */
-
-#include "db_config.h"
-
-#ifndef lint
-static const char copyright[] =
-    "Copyright (c) 1996-2002\nSleepycat Software Inc.  All rights reserved.\n";
-static const char revid[] =
-    "$Id: db_upgrade.c,v 1.31 2002/03/28 20:13:47 bostic Exp $";
-#endif
-
-#ifndef NO_SYSTEM_INCLUDES
-#include <sys/types.h>
-
-#include <stdio.h>
-#include <stdlib.h>
-#include <string.h>
-#include <unistd.h>
-#endif
-
-#include "db_int.h"
-
-int db_upgrade_main __P((int, char *[]));
-int db_upgrade_usage __P((void));
-int db_upgrade_version_check __P((const char *));
-
-int
-db_upgrade(args)
-	char *args;
-{
-	int argc;
-	char **argv;
-
-	__db_util_arg("db_upgrade", args, &argc, &argv);
-	return (db_upgrade_main(argc, argv) ? EXIT_FAILURE : EXIT_SUCCESS);
-}
-
-#include <stdio.h>
-#define	ERROR_RETURN	ERROR
-
-int
-db_upgrade_main(argc, argv)
-	int argc;
-	char *argv[];
-{
-	extern char *optarg;
-	extern int optind, __db_getopt_reset;
-	const char *progname = "db_upgrade";
-	DB *dbp;
-	DB_ENV *dbenv;
-	u_int32_t flags;
-	int ch, e_close, exitval, nflag, ret, t_ret;
-	char *home, *passwd;
-
-	if ((ret = db_upgrade_version_check(progname)) != 0)
-		return (ret);
-
-	dbenv = NULL;
-	flags = nflag = 0;
-	e_close = exitval = 0;
-	home = passwd = NULL;
-	__db_getopt_reset = 1;
-	while ((ch = getopt(argc, argv, "h:NP:sV")) != EOF)
-		switch (ch) {
-		case 'h':
-			home = optarg;
-			break;
-		case 'N':
-			nflag = 1;
-			break;
-		case 'P':
-			passwd = strdup(optarg);
-			memset(optarg, 0, strlen(optarg));
-			if (passwd == NULL) {
-				fprintf(stderr, "%s: strdup: %s\n",
-				    progname, strerror(errno));
-				return (EXIT_FAILURE);
-			}
-			break;
-		case 's':
-			LF_SET(DB_DUPSORT);
-			break;
-		case 'V':
-			printf("%s\n", db_version(NULL, NULL, NULL));
-			return (EXIT_SUCCESS);
-		case '?':
-		default:
-			return (db_upgrade_usage());
-		}
-	argc -= optind;
-	argv += optind;
-
-	if (argc <= 0)
-		return (db_upgrade_usage());
-
-	/* Handle possible interruptions. */
-	__db_util_siginit();
-
-	/*
-	 * Create an environment object and initialize it for error
-	 * reporting.
-	 */
-	if ((ret = db_env_create(&dbenv, 0)) != 0) {
-		fprintf(stderr, "%s: db_env_create: %s\n",
-		    progname, db_strerror(ret));
-		goto shutdown;
-	}
-	e_close = 1;
-
-	dbenv->set_errfile(dbenv, stderr);
-	dbenv->set_errpfx(dbenv, progname);
-
-	if (nflag) {
-		if ((ret = dbenv->set_flags(dbenv, DB_NOLOCKING, 1)) != 0) {
-			dbenv->err(dbenv, ret, "set_flags: DB_NOLOCKING");
-			goto shutdown;
-		}
-		if ((ret = dbenv->set_flags(dbenv, DB_NOPANIC, 1)) != 0) {
-			dbenv->err(dbenv, ret, "set_flags: DB_NOPANIC");
-			goto shutdown;
-		}
-	}
-
-	if (passwd != NULL && (ret = dbenv->set_encrypt(dbenv,
-	    passwd, DB_ENCRYPT_AES)) != 0) {
-		dbenv->err(dbenv, ret, "set_passwd");
-		goto shutdown;
-	}
-
-	/*
-	 * If attaching to a pre-existing environment fails, create a
-	 * private one and try again.
-	 */
-	if ((ret = dbenv->open(dbenv,
-	    home, DB_JOINENV | DB_USE_ENVIRON, 0)) != 0 &&
-	    (ret = dbenv->open(dbenv, home,
-	    DB_CREATE | DB_INIT_MPOOL | DB_PRIVATE | DB_USE_ENVIRON, 0)) != 0) {
-		dbenv->err(dbenv, ret, "open");
-		goto shutdown;
-	}
-
-	for (; !__db_util_interrupted() && argv[0] != NULL; ++argv) {
-		if ((ret = db_create(&dbp, dbenv, 0)) != 0) {
-			fprintf(stderr,
-			    "%s: db_create: %s\n", progname, db_strerror(ret));
-			goto shutdown;
-		}
-		dbp->set_errfile(dbp, stderr);
-		dbp->set_errpfx(dbp, progname);
-		if ((ret = dbp->upgrade(dbp, argv[0], flags)) != 0)
-			dbp->err(dbp, ret, "DB->upgrade: %s", argv[0]);
-		if ((t_ret = dbp->close(dbp, 0)) != 0 && ret == 0) {
-			dbenv->err(dbenv, ret, "DB->close: %s", argv[0]);
-			ret = t_ret;
-		}
-		if (ret != 0)
-			goto shutdown;
-	}
-
-	if (0) {
-shutdown:	exitval = 1;
-	}
-	if (e_close && (ret = dbenv->close(dbenv, 0)) != 0) {
-		exitval = 1;
-		fprintf(stderr,
-		    "%s: dbenv->close: %s\n", progname, db_strerror(ret));
-	}
-
-	/* Resend any caught signal. */
-	__db_util_sigresend();
-
-	return (exitval == 0 ? EXIT_SUCCESS : EXIT_FAILURE);
-}
-
-int
-db_upgrade_usage()
-{
-	fprintf(stderr, "%s\n",
-	    "usage: db_upgrade [-NsV] [-h home] [-P password] db_file ...");
-	return (EXIT_FAILURE);
-}
-
-int
-db_upgrade_version_check(progname)
-	const char *progname;
-{
-	int v_major, v_minor, v_patch;
-
-	/* Make sure we're loaded with the right version of the DB library. */
-	(void)db_version(&v_major, &v_minor, &v_patch);
-	if (v_major != DB_VERSION_MAJOR ||
-	    v_minor != DB_VERSION_MINOR || v_patch != DB_VERSION_PATCH) {
-		fprintf(stderr,
-	"%s: version %d.%d.%d doesn't match library version %d.%d.%d\n",
-		    progname, DB_VERSION_MAJOR, DB_VERSION_MINOR,
-		    DB_VERSION_PATCH, v_major, v_minor, v_patch);
-		return (EXIT_FAILURE);
-	}
-	return (0);
-}
diff --git a/bdb/build_vxworks/db_upgrade/db_upgrade.wpj b/bdb/build_vxworks/db_upgrade/db_upgrade.wpj
deleted file mode 100755
index 65f834d62d79d24aa9f21a10649860365462d779..0000000000000000000000000000000000000000
--- a/bdb/build_vxworks/db_upgrade/db_upgrade.wpj
+++ /dev/null
@@ -1,160 +0,0 @@
-Document file - DO NOT EDIT
-
-<BEGIN> BUILD_PENTIUMgnu_BUILDRULE
-db_upgrade.out
-<END>
-
-<BEGIN> BUILD_PENTIUMgnu_MACRO_AR
-ar386
-<END>
-
-<BEGIN> BUILD_PENTIUMgnu_MACRO_ARCHIVE
-$(PRJ_DIR)/PENTIUMgnu/db_upgrade.a
-<END>
-
-<BEGIN> BUILD_PENTIUMgnu_MACRO_AS
-cc386
-<END>
-
-<BEGIN> BUILD_PENTIUMgnu_MACRO_CC
-cc386
-<END>
-
-<BEGIN> BUILD_PENTIUMgnu_MACRO_CFLAGS
--g \
-	-mpentium \
-	-ansi \
-	-nostdinc \
-	-DRW_MULTI_THREAD \
-	-D_REENTRANT \
-	-fvolatile \
-	-nostdlib \
-	-fno-builtin \
-	-fno-defer-pop \
-	-I$(PRJ_DIR)/.. \
-	-I$(PRJ_DIR)/../.. \
-	-I$(WIND_BASE)/target/h \
-	-DCPU=PENTIUM
-<END>
-
-<BEGIN> BUILD_PENTIUMgnu_MACRO_CFLAGS_AS
--g \
-	-mpentium \
-	-ansi \
-	-nostdinc \
-	-fvolatile \
-	-nostdlib \
-	-fno-builtin \
-	-fno-defer-pop \
-	-P \
-	-x \
-	assembler-with-cpp \
-	-I$(WIND_BASE)/target/h \
-	-DCPU=PENTIUM
-<END>
-
-<BEGIN> BUILD_PENTIUMgnu_MACRO_CPP
-cc386 -E -P -xc
-<END>
-
-<BEGIN> BUILD_PENTIUMgnu_MACRO_LD
-ld386
-<END>
-
-<BEGIN> BUILD_PENTIUMgnu_MACRO_LDDEPS
-
-<END>
-
-<BEGIN> BUILD_PENTIUMgnu_MACRO_LDFLAGS
--X -N
-<END>
-
-<BEGIN> BUILD_PENTIUMgnu_MACRO_LD_PARTIAL_FLAGS
--X -r
-<END>
-
-<BEGIN> BUILD_PENTIUMgnu_MACRO_NM
-nm386 -g
-<END>
-
-<BEGIN> BUILD_PENTIUMgnu_MACRO_OPTION_DEFINE_MACRO
--D
-<END>
-
-<BEGIN> BUILD_PENTIUMgnu_MACRO_OPTION_INCLUDE_DIR
--I
-<END>
-
-<BEGIN> BUILD_PENTIUMgnu_MACRO_POST_BUILD_RULE
-
-<END>
-
-<BEGIN> BUILD_PENTIUMgnu_MACRO_PRJ_LIBS
-
-<END>
-
-<BEGIN> BUILD_PENTIUMgnu_MACRO_SIZE
-size386
-<END>
-
-<BEGIN> BUILD_PENTIUMgnu_RO_DEPEND_PATH
-{$(WIND_BASE)/target/h/} \
-	{$(WIND_BASE)/target/src/} \
-	{$(WIND_BASE)/target/config/}
-<END>
-
-<BEGIN> BUILD_PENTIUMgnu_TC
-::tc_PENTIUMgnu
-<END>
-
-<BEGIN> BUILD_RULE_archive
-
-<END>
-
-<BEGIN> BUILD_RULE_db_upgrade.out
-
-<END>
-
-<BEGIN> BUILD_RULE_objects
-
-<END>
-
-<BEGIN> BUILD__CURRENT
-PENTIUMgnu
-<END>
-
-<BEGIN> BUILD__LIST
-PENTIUMgnu
-<END>
-
-<BEGIN> CORE_INFO_TYPE
-::prj_vxApp
-<END>
-
-<BEGIN> CORE_INFO_VERSION
-2.0
-<END>
-
-<BEGIN> FILE_db_upgrade.c_dependDone
-FALSE
-<END>
-
-<BEGIN> FILE_db_upgrade.c_dependencies
-
-<END>
-
-<BEGIN> FILE_db_upgrade.c_objects
-db_upgrade.o
-<END>
-
-<BEGIN> FILE_db_upgrade.c_tool
-C/C++ compiler
-<END>
-
-<BEGIN> PROJECT_FILES
-$(PRJ_DIR)/db_upgrade.c
-<END>
-
-<BEGIN> userComments
-db_upgrade
-<END>
diff --git a/bdb/build_vxworks/db_upgrade/db_upgrade/Makefile.custom b/bdb/build_vxworks/db_upgrade/db_upgrade/Makefile.custom
deleted file mode 100644
index ca781f7b251ef99e49e5fc1859ee6cf3d67c60b0..0000000000000000000000000000000000000000
--- a/bdb/build_vxworks/db_upgrade/db_upgrade/Makefile.custom
+++ /dev/null
@@ -1,51 +0,0 @@
-#
-# Custom Makefile shell
-#
-# This file may be edited freely, since it will not be regenerated
-# by the project manager.
-#
-# Use this makefile to define rules to make external binaries
-# and deposit them in the $(EXTERNAL_BINARIES_DIR) directory.
-#
-# If you have specified external modules during your component
-# creation, you will find make rules already in place below.
-# You will likely have to edit these to suit your individual
-# build setup.
-#
-# You may wish to use the CPU, BUILD_SPEC or TOOL make variables in
-# your Makefile to support builds for different architectures.  Use
-# the FORCE_EXTERNAL_MAKE phony target to ensure that your external
-# make always runs.
-#
-# The example below assumes that your custom makefile is in the
-# mySourceTree directory, and that the binary file it produces
-# is placed into the $(BUILD_SPEC) sub-directory.
-#
-# EXTERNAL_SOURCE_BASE = /folk/me/mySourceTree
-# EXTERNAL_MODULE = myLibrary.o
-# EXTERNAL_MAKE = make
-#
-# $(EXTERNAL_BINARIES_DIR)/$(EXTERNAL_MODULE) : FORCE_EXTERNAL_MAKE
-#	$(EXTERNAL_MAKE) -C $(EXTERNAL_SOURCE_BASE) \
-#	-f $(EXTERNAL_SOURCE_BASE)/Makefile \
-#	CPU=$(CPU) BUILD_SPEC=$(BUILD_SPEC) $(@F)
-#	$(CP) $(subst /,$(DIRCHAR),$(EXTERNAL_SOURCE_BASE)/$(BUILD_SPEC)/$(@F) $@)
-#
-# If you are not adding your external modules from the component wizard,
-# you will have to include them in your component yourself:
-#
-# From the GUI, you can do this with the Component's 'Add external module'
-# dialog.
-#
-# If you are using the command line, add the module(s) by editing the
-# MODULES line in component.cdf file, e.g.
-#
-# Component INCLUDE_MYCOMPONENT {
-#
-#   MODULES         foo.o goo.o \
-#         myLibrary.o
-#
-
-
-# rules to build custom libraries
-
diff --git a/bdb/build_vxworks/db_upgrade/db_upgrade/component.cdf b/bdb/build_vxworks/db_upgrade/db_upgrade/component.cdf
deleted file mode 100755
index 7bbdebd4999ba669c5e140350c50913d227f3b52..0000000000000000000000000000000000000000
--- a/bdb/build_vxworks/db_upgrade/db_upgrade/component.cdf
+++ /dev/null
@@ -1,30 +0,0 @@
-/* component.cdf - dynamically updated configuration */
-
-/*
- * NOTE: you may edit this file to alter the configuration
- * But all non-configuration information, including comments,
- * will be lost upon rebuilding this project.
- */
-
-/* Component information */
-
-Component INCLUDE_DB_UPGRADE {
-	ENTRY_POINTS	ALL_GLOBAL_SYMBOLS 
-	MODULES		db_upgrade.o 
-	NAME		db_upgrade
-	PREF_DOMAIN	ANY
-	_INIT_ORDER	usrComponentsInit
-}
-
-/* EntryPoint information */
-
-/* Module information */
-
-Module db_upgrade.o {
-
-	NAME		db_upgrade.o
-	SRC_PATH_NAME	$PRJ_DIR/../db_upgrade.c
-}
-
-/* Parameter information */
-
diff --git a/bdb/build_vxworks/db_upgrade/db_upgrade/component.wpj b/bdb/build_vxworks/db_upgrade/db_upgrade/component.wpj
deleted file mode 100755
index 1cc5f303e5d3c7c8143f44c70491c806a10651c5..0000000000000000000000000000000000000000
--- a/bdb/build_vxworks/db_upgrade/db_upgrade/component.wpj
+++ /dev/null
@@ -1,475 +0,0 @@
-Document file - DO NOT EDIT
-
-<BEGIN> CORE_INFO_TYPE
-::prj_component
-<END>
-
-<BEGIN> CORE_INFO_VERSION
-AE1.1
-<END>
-
-<BEGIN> BUILD__CURRENT
-PENTIUM2gnu.debug
-<END>
-
-<BEGIN> BUILD_PENTIUM2gnu.debug_CURRENT_TARGET
-default
-<END>
-
-<BEGIN> BUILD_PENTIUM2gnu.debug_DEFAULTFORCPU
-1
-<END>
-
-<BEGIN> BUILD_PENTIUM2gnu.debug_FILE_$(PRJ_DIR)/../db_upgrade.c_infoTags
-toolMacro objects
-<END>
-
-<BEGIN> BUILD_PENTIUM2gnu.debug_FILE_$(PRJ_DIR)/../db_upgrade.c_objects
-db_upgrade.o
-<END>
-
-<BEGIN> BUILD_PENTIUM2gnu.debug_FILE_$(PRJ_DIR)/../db_upgrade.c_toolMacro
-CC
-<END>
-
-<BEGIN> BUILD_PENTIUM2gnu.debug_FILE_$(PRJ_DIR)/../db_upgrade.c_objects
-db_upgrade.o
-<END>
-
-<BEGIN> BUILD_PENTIUM2gnu.debug_FILE_$(PRJ_DIR)/../db_upgrade.c_toolMacro
-CC
-<END>
-
-<BEGIN> BUILD_PENTIUM2gnu.debug_FILE_$(PRJ_DIR)/compConfig.c_infoTags
-toolMacro objects
-<END>
-
-<BEGIN> BUILD_PENTIUM2gnu.debug_FILE_$(PRJ_DIR)/compConfig.c_objects
-compConfig.o
-<END>
-
-<BEGIN> BUILD_PENTIUM2gnu.debug_FILE_$(PRJ_DIR)/compConfig.c_toolMacro
-CC
-<END>
-
-<BEGIN> BUILD_PENTIUM2gnu.debug_MACRO_AR
-arpentium
-<END>
-
-<BEGIN> BUILD_PENTIUM2gnu.debug_MACRO_AS
-ccpentium
-<END>
-
-<BEGIN> BUILD_PENTIUM2gnu.debug_MACRO_CC
-ccpentium
-<END>
-
-<BEGIN> BUILD_PENTIUM2gnu.debug_MACRO_CFLAGS
--mcpu=pentiumpro \
-	-march=pentiumpro \
-	-ansi \
-	-DRW_MULTI_THREAD \
-	-D_REENTRANT \
-	-g \
-	-nostdlib \
-	-fno-builtin \
-	-fno-defer-pop \
-	-MD \
-	-Wall \
-	-I. \
-	-I$(WIND_BASE)/target/h \
-	-I$(PRJ_DIR)/../.. \
-	-I$(PRJ_DIR)/../../.. \
-	-DCPU=PENTIUM2
-<END>
-
-<BEGIN> BUILD_PENTIUM2gnu.debug_MACRO_CFLAGS_AS
--mcpu=pentiumpro \
-	-march=pentiumpro \
-	-ansi \
-	-g \
-	-nostdlib \
-	-fno-builtin \
-	-fno-defer-pop \
-	-P \
-	-x \
-	assembler-with-cpp \
-	-Wall \
-	-I. \
-	-I$(WIND_BASE)/target/h \
-	-DCPU=PENTIUM2
-<END>
-
-<BEGIN> BUILD_PENTIUM2gnu.debug_MACRO_CPP
-ccpentium -E -P
-<END>
-
-<BEGIN> BUILD_PENTIUM2gnu.debug_MACRO_CPPFILT
-c++filtpentium --strip-underscores
-<END>
-
-<BEGIN> BUILD_PENTIUM2gnu.debug_MACRO_LD
-ldpentium
-<END>
-
-<BEGIN> BUILD_PENTIUM2gnu.debug_MACRO_LDFLAGS
--X
-<END>
-
-<BEGIN> BUILD_PENTIUM2gnu.debug_MACRO_LDPARTIAL
-ccpentium \
-	-B$(WIND_BASE)/host/$(WIND_HOST_TYPE)/lib/gcc-lib/ \
-	-nostdlib \
-	-r \
-	-Wl,-X
-<END>
-
-<BEGIN> BUILD_PENTIUM2gnu.debug_MACRO_LD_PARTIAL_FLAGS
--X -r
-<END>
-
-<BEGIN> BUILD_PENTIUM2gnu.debug_MACRO_NM
-nmpentium -g
-<END>
-
-<BEGIN> BUILD_PENTIUM2gnu.debug_MACRO_OPTION_DEFINE_MACRO
--D
-<END>
-
-<BEGIN> BUILD_PENTIUM2gnu.debug_MACRO_OPTION_GENERATE_DEPENDENCY_FILE
--MD
-<END>
-
-<BEGIN> BUILD_PENTIUM2gnu.debug_MACRO_OPTION_INCLUDE_DIR
--I
-<END>
-
-<BEGIN> BUILD_PENTIUM2gnu.debug_MACRO_RELEASE
-0
-<END>
-
-<BEGIN> BUILD_PENTIUM2gnu.debug_MACRO_SIZE
-sizepentium
-<END>
-
-<BEGIN> BUILD_PENTIUM2gnu.debug_RELEASE
-0
-<END>
-
-<BEGIN> BUILD_PENTIUM2gnu.debug_RO_DEPEND_PATH
-$(WIND_BASE)/target/h/
-<END>
-
-<BEGIN> BUILD_PENTIUM2gnu.debug_TC
-::tc_PENTIUM2gnu.debug
-<END>
-
-<BEGIN> BUILD_PENTIUM2gnu.release_DEFAULTFORCPU
-0
-<END>
-
-<BEGIN> BUILD_PENTIUM2gnu.release_FILE_$(PRJ_DIR)/../db_upgrade.c_infoTags
-toolMacro objects
-<END>
-
-<BEGIN> BUILD_PENTIUM2gnu.release_FILE_$(PRJ_DIR)/../db_upgrade.c_objects
-db_upgrade.o
-<END>
-
-<BEGIN> BUILD_PENTIUM2gnu.release_FILE_$(PRJ_DIR)/../db_upgrade.c_toolMacro
-CC
-<END>
-
-<BEGIN> BUILD_PENTIUM2gnu.release_FILE_$(PRJ_DIR)/compConfig.c_infoTags
-toolMacro objects
-<END>
-
-<BEGIN> BUILD_PENTIUM2gnu.release_FILE_$(PRJ_DIR)/compConfig.c_objects
-compConfig.o
-<END>
-
-<BEGIN> BUILD_PENTIUM2gnu.release_FILE_$(PRJ_DIR)/compConfig.c_toolMacro
-CC
-<END>
-
-<BEGIN> BUILD_PENTIUM2gnu.release_MACRO_AR
-arpentium
-<END>
-
-<BEGIN> BUILD_PENTIUM2gnu.release_MACRO_AS
-ccpentium
-<END>
-
-<BEGIN> BUILD_PENTIUM2gnu.release_MACRO_CC
-ccpentium
-<END>
-
-<BEGIN> BUILD_PENTIUM2gnu.release_MACRO_CFLAGS
--mcpu=pentiumpro \
-	-march=pentiumpro \
-	-ansi \
-	-DRW_MULTI_THREAD \
-	-D_REENTRANT \
-	-O2 \
-	-nostdlib \
-	-fno-builtin \
-	-fno-defer-pop \
-	-MD \
-	-Wall \
-	-I. \
-	-I$(WIND_BASE)/target/h \
-	-I$(PRJ_DIR)/../.. \
-	-I$(PRJ_DIR)/../../.. \
-	-DCPU=PENTIUM2
-<END>
-
-<BEGIN> BUILD_PENTIUM2gnu.release_MACRO_CFLAGS_AS
--mcpu=pentiumpro \
-	-march=pentiumpro \
-	-ansi \
-	-O2 \
-	-nostdlib \
-	-fno-builtin \
-	-fno-defer-pop \
-	-P \
-	-x \
-	assembler-with-cpp \
-	-Wall \
-	-I. \
-	-I$(WIND_BASE)/target/h \
-	-DCPU=PENTIUM2
-<END>
-
-<BEGIN> BUILD_PENTIUM2gnu.release_MACRO_CPP
-ccpentium -E -P
-<END>
-
-<BEGIN> BUILD_PENTIUM2gnu.release_MACRO_CPPFILT
-c++filtpentium --strip-underscores
-<END>
-
-<BEGIN> BUILD_PENTIUM2gnu.release_MACRO_LD
-ldpentium
-<END>
-
-<BEGIN> BUILD_PENTIUM2gnu.release_MACRO_LDFLAGS
--X
-<END>
-
-<BEGIN> BUILD_PENTIUM2gnu.release_MACRO_LDPARTIAL
-ccpentium \
-	-B$(WIND_BASE)/host/$(WIND_HOST_TYPE)/lib/gcc-lib/ \
-	-nostdlib \
-	-r \
-	-Wl,-X
-<END>
-
-<BEGIN> BUILD_PENTIUM2gnu.release_MACRO_LD_PARTIAL_FLAGS
--X -r
-<END>
-
-<BEGIN> BUILD_PENTIUM2gnu.release_MACRO_NM
-nmpentium -g
-<END>
-
-<BEGIN> BUILD_PENTIUM2gnu.release_MACRO_OPTION_DEFINE_MACRO
--D
-<END>
-
-<BEGIN> BUILD_PENTIUM2gnu.release_MACRO_OPTION_GENERATE_DEPENDENCY_FILE
--MD
-<END>
-
-<BEGIN> BUILD_PENTIUM2gnu.release_MACRO_OPTION_INCLUDE_DIR
--I
-<END>
-
-<BEGIN> BUILD_PENTIUM2gnu.release_MACRO_RELEASE
-1
-<END>
-
-<BEGIN> BUILD_PENTIUM2gnu.release_MACRO_SIZE
-sizepentium
-<END>
-
-<BEGIN> BUILD_PENTIUM2gnu.release_RELEASE
-1
-<END>
-
-<BEGIN> BUILD_PENTIUM2gnu.release_RO_DEPEND_PATH
-$(WIND_BASE)/target/h/
-<END>
-
-<BEGIN> BUILD_PENTIUM2gnu.release_TC
-::tc_PENTIUM2gnu.release
-<END>
-
-<BEGIN> BUILD_PENTIUMgnu.debug_DEFAULTFORCPU
-1
-<END>
-
-<BEGIN> BUILD_PENTIUMgnu.debug_FILE_$(PRJ_DIR)/../db_upgrade.c_infoTags
-toolMacro objects
-<END>
-
-<BEGIN> BUILD_PENTIUMgnu.debug_FILE_$(PRJ_DIR)/../db_upgrade.c_objects
-db_upgrade.o
-<END>
-
-<BEGIN> BUILD_PENTIUMgnu.debug_FILE_$(PRJ_DIR)/../db_upgrade.c_toolMacro
-CC
-<END>
-
-<BEGIN> BUILD_PENTIUMgnu.debug_FILE_$(PRJ_DIR)/compConfig.c_infoTags
-toolMacro objects
-<END>
-
-<BEGIN> BUILD_PENTIUMgnu.debug_FILE_$(PRJ_DIR)/compConfig.c_objects
-compConfig.o
-<END>
-
-<BEGIN> BUILD_PENTIUMgnu.debug_FILE_$(PRJ_DIR)/compConfig.c_toolMacro
-CC
-<END>
-
-<BEGIN> BUILD_PENTIUMgnu.debug_MACRO_AR
-arpentium
-<END>
-
-<BEGIN> BUILD_PENTIUMgnu.debug_MACRO_AS
-ccpentium
-<END>
-
-<BEGIN> BUILD_PENTIUMgnu.debug_MACRO_CC
-ccpentium
-<END>
-
-<BEGIN> BUILD_PENTIUMgnu.debug_MACRO_CFLAGS
--mcpu=pentium \
-	-march=pentium \
-	-ansi \
-	-DRW_MULTI_THREAD \
-	-D_REENTRANT \
-	-g \
-	-nostdlib \
-	-fno-builtin \
-	-fno-defer-pop \
-	-MD \
-	-Wall \
-	-I. \
-	-I$(WIND_BASE)/target/h \
-	-I$(PRJ_DIR)/../.. \
-	-I$(PRJ_DIR)/../../.. \
-	-DCPU=PENTIUM
-<END>
-
-<BEGIN> BUILD_PENTIUMgnu.debug_MACRO_CFLAGS_AS
--mcpu=pentium \
-	-march=pentium \
-	-ansi \
-	-g \
-	-nostdlib \
-	-fno-builtin \
-	-fno-defer-pop \
-	-P \
-	-x \
-	assembler-with-cpp \
-	-Wall \
-	-I. \
-	-I$(WIND_BASE)/target/h \
-	-DCPU=PENTIUM
-<END>
-
-<BEGIN> BUILD_PENTIUMgnu.debug_MACRO_CPP
-ccpentium -E -P
-<END>
-
-<BEGIN> BUILD_PENTIUMgnu.debug_MACRO_CPPFILT
-c++filtpentium --strip-underscores
-<END>
-
-<BEGIN> BUILD_PENTIUMgnu.debug_MACRO_LD
-ldpentium
-<END>
-
-<BEGIN> BUILD_PENTIUMgnu.debug_MACRO_LDFLAGS
--X
-<END>
-
-<BEGIN> BUILD_PENTIUMgnu.debug_MACRO_LDPARTIAL
-ccpentium \
-	-B$(WIND_BASE)/host/$(WIND_HOST_TYPE)/lib/gcc-lib/ \
-	-nostdlib \
-	-r \
-	-Wl,-X
-<END>
-
-<BEGIN> BUILD_PENTIUMgnu.debug_MACRO_LD_PARTIAL_FLAGS
--X -r
-<END>
-
-<BEGIN> BUILD_PENTIUMgnu.debug_MACRO_NM
-nmpentium -g
-<END>
-
-<BEGIN> BUILD_PENTIUMgnu.debug_MACRO_OPTION_DEFINE_MACRO
--D
-<END>
-
-<BEGIN> BUILD_PENTIUMgnu.debug_MACRO_OPTION_GENERATE_DEPENDENCY_FILE
--MD
-<END>
-
-<BEGIN> BUILD_PENTIUMgnu.debug_MACRO_OPTION_INCLUDE_DIR
--I
-<END>
-
-<BEGIN> BUILD_PENTIUMgnu.debug_MACRO_RELEASE
-0
-<END>
-
-<BEGIN> BUILD_PENTIUMgnu.debug_MACRO_SIZE
-sizepentium
-<END>
-
-<BEGIN> BUILD_PENTIUMgnu.debug_RELEASE
-0
-<END>
-
-<BEGIN> BUILD_PENTIUMgnu.debug_RO_DEPEND_PATH
-$(WIND_BASE)/target/h/
-<END>
-
-<BEGIN> BUILD_PENTIUMgnu.debug_TC
-::tc_PENTIUMgnu.debug
-<END>
-
-<BEGIN> BUILD__LIST
-PENTIUM2gnu.debug PENTIUM2gnu.release PENTIUMgnu.debug
-<END>
-
-<BEGIN> PROJECT_FILES
-$(PRJ_DIR)/../db_upgrade.c \
-	$(PRJ_DIR)/compConfig.c
-<END>
-
-<BEGIN> WCC__CDF_PATH
-$(PRJ_DIR)
-<END>
-
-<BEGIN> WCC__CURRENT
-PENTIUM2gnu.debug
-<END>
-
-<BEGIN> WCC__LIST
-PENTIUM2gnu.debug
-<END>
-
-<BEGIN> WCC__MXR_LIBS
-lib$(CPU)$(TOOL)vx.a
-<END>
-
-<BEGIN> WCC__OBJS_PATH
-$(WIND_BASE)/target/lib/obj$CPU$TOOLvx
-<END>
-
diff --git a/bdb/build_vxworks/db_verify/db_verify.c b/bdb/build_vxworks/db_verify/db_verify.c
deleted file mode 100644
index cfa31195a851f1d2234f79150da4098a5a5b55df..0000000000000000000000000000000000000000
--- a/bdb/build_vxworks/db_verify/db_verify.c
+++ /dev/null
@@ -1,263 +0,0 @@
-/*-
- * See the file LICENSE for redistribution information.
- *
- * Copyright (c) 1996-2002
- *	Sleepycat Software.  All rights reserved.
- */
-
-#include "db_config.h"
-
-#ifndef lint
-static const char copyright[] =
-    "Copyright (c) 1996-2002\nSleepycat Software Inc.  All rights reserved.\n";
-static const char revid[] =
-    "$Id: db_verify.c,v 1.38 2002/08/08 03:51:38 bostic Exp $";
-#endif
-
-#ifndef NO_SYSTEM_INCLUDES
-#include <sys/types.h>
-
-#include <stdio.h>
-#include <stdlib.h>
-#include <string.h>
-#include <unistd.h>
-#endif
-
-#include "db_int.h"
-
-int db_verify_main __P((int, char *[]));
-int db_verify_usage __P((void));
-int db_verify_version_check __P((const char *));
-
-int
-db_verify(args)
-	char *args;
-{
-	int argc;
-	char **argv;
-
-	__db_util_arg("db_verify", args, &argc, &argv);
-	return (db_verify_main(argc, argv) ? EXIT_FAILURE : EXIT_SUCCESS);
-}
-
-#include <stdio.h>
-#define	ERROR_RETURN	ERROR
-
-int
-db_verify_main(argc, argv)
-	int argc;
-	char *argv[];
-{
-	extern char *optarg;
-	extern int optind, __db_getopt_reset;
-	const char *progname = "db_verify";
-	DB *dbp, *dbp1;
-	DB_ENV *dbenv;
-	u_int32_t cache;
-	int ch, d_close, e_close, exitval, nflag, oflag, private;
-	int quiet, resize, ret, t_ret;
-	char *home, *passwd;
-
-	if ((ret = db_verify_version_check(progname)) != 0)
-		return (ret);
-
-	dbenv = NULL;
-	cache = MEGABYTE;
-	d_close = e_close = exitval = nflag = oflag = quiet = 0;
-	home = passwd = NULL;
-	__db_getopt_reset = 1;
-	while ((ch = getopt(argc, argv, "h:NoP:qV")) != EOF)
-		switch (ch) {
-		case 'h':
-			home = optarg;
-			break;
-		case 'N':
-			nflag = 1;
-			break;
-		case 'P':
-			passwd = strdup(optarg);
-			memset(optarg, 0, strlen(optarg));
-			if (passwd == NULL) {
-				fprintf(stderr, "%s: strdup: %s\n",
-				    progname, strerror(errno));
-				return (EXIT_FAILURE);
-			}
-			break;
-		case 'o':
-			oflag = 1;
-			break;
-		case 'q':
-			quiet = 1;
-			break;
-		case 'V':
-			printf("%s\n", db_version(NULL, NULL, NULL));
-			return (EXIT_SUCCESS);
-		case '?':
-		default:
-			return (db_verify_usage());
-		}
-	argc -= optind;
-	argv += optind;
-
-	if (argc <= 0)
-		return (db_verify_usage());
-
-	/* Handle possible interruptions. */
-	__db_util_siginit();
-
-	/*
-	 * Create an environment object and initialize it for error
-	 * reporting.
-	 */
-retry:	if ((ret = db_env_create(&dbenv, 0)) != 0) {
-		fprintf(stderr,
-		    "%s: db_env_create: %s\n", progname, db_strerror(ret));
-		goto shutdown;
-	}
-	e_close = 1;
-
-	if (!quiet) {
-		dbenv->set_errfile(dbenv, stderr);
-		dbenv->set_errpfx(dbenv, progname);
-	}
-
-	if (nflag) {
-		if ((ret = dbenv->set_flags(dbenv, DB_NOLOCKING, 1)) != 0) {
-			dbenv->err(dbenv, ret, "set_flags: DB_NOLOCKING");
-			goto shutdown;
-		}
-		if ((ret = dbenv->set_flags(dbenv, DB_NOPANIC, 1)) != 0) {
-			dbenv->err(dbenv, ret, "set_flags: DB_NOPANIC");
-			goto shutdown;
-		}
-	}
-
-	if (passwd != NULL &&
-	    (ret = dbenv->set_encrypt(dbenv, passwd, DB_ENCRYPT_AES)) != 0) {
-		dbenv->err(dbenv, ret, "set_passwd");
-		goto shutdown;
-	}
-	/*
-	 * Attach to an mpool if it exists, but if that fails, attach to a
-	 * private region.  In the latter case, declare a reasonably large
-	 * cache so that we don't fail when verifying large databases.
-	 */
-	private = 0;
-	if ((ret =
-	    dbenv->open(dbenv, home, DB_INIT_MPOOL | DB_USE_ENVIRON, 0)) != 0) {
-		if ((ret = dbenv->set_cachesize(dbenv, 0, cache, 1)) != 0) {
-			dbenv->err(dbenv, ret, "set_cachesize");
-			goto shutdown;
-		}
-		private = 1;
-		if ((ret = dbenv->open(dbenv, home,
-	    DB_CREATE | DB_INIT_MPOOL | DB_PRIVATE | DB_USE_ENVIRON, 0)) != 0) {
-			dbenv->err(dbenv, ret, "open");
-			goto shutdown;
-		}
-	}
-
-	for (; !__db_util_interrupted() && argv[0] != NULL; ++argv) {
-		if ((ret = db_create(&dbp, dbenv, 0)) != 0) {
-			dbenv->err(dbenv, ret, "%s: db_create", progname);
-			goto shutdown;
-		}
-		d_close = 1;
-
-		/*
-		 * We create a 2nd dbp to this database to get its pagesize
-		 * because the dbp we're using for verify cannot be opened.
-		 */
-		if (private) {
-			if ((ret = db_create(&dbp1, dbenv, 0)) != 0) {
-				dbenv->err(
-				    dbenv, ret, "%s: db_create", progname);
-				goto shutdown;
-			}
-
-			if ((ret = dbp1->open(dbp1, NULL,
-			    argv[0], NULL, DB_UNKNOWN, DB_RDONLY, 0)) != 0) {
-				dbenv->err(dbenv, ret, "DB->open: %s", argv[0]);
-				(void)dbp1->close(dbp1, 0);
-				goto shutdown;
-			}
-			/*
-			 * If we get here, we can check the cache/page.
-			 * !!!
-			 * If we have to retry with an env with a larger
-			 * cache, we jump out of this loop.  However, we
-			 * will still be working on the same argv when we
-			 * get back into the for-loop.
-			 */
-			ret = __db_util_cache(dbenv, dbp1, &cache, &resize);
-			(void)dbp1->close(dbp1, 0);
-			if (ret != 0)
-				goto shutdown;
-
-			if (resize) {
-				(void)dbp->close(dbp, 0);
-				d_close = 0;
-
-				(void)dbenv->close(dbenv, 0);
-				e_close = 0;
-				goto retry;
-			}
-		}
-		if ((ret = dbp->verify(dbp,
-		    argv[0], NULL, NULL, oflag ? DB_NOORDERCHK : 0)) != 0)
-			dbp->err(dbp, ret, "DB->verify: %s", argv[0]);
-		if ((t_ret = dbp->close(dbp, 0)) != 0 && ret == 0) {
-			dbenv->err(dbenv, ret, "DB->close: %s", argv[0]);
-			ret = t_ret;
-		}
-		d_close = 0;
-		if (ret != 0)
-			goto shutdown;
-	}
-
-	if (0) {
-shutdown:	exitval = 1;
-	}
-
-	if (d_close && (ret = dbp->close(dbp, 0)) != 0) {
-		exitval = 1;
-		dbenv->err(dbenv, ret, "close");
-	}
-	if (e_close && (ret = dbenv->close(dbenv, 0)) != 0) {
-		exitval = 1;
-		fprintf(stderr,
-		    "%s: dbenv->close: %s\n", progname, db_strerror(ret));
-	}
-
-	/* Resend any caught signal. */
-	__db_util_sigresend();
-
-	return (exitval == 0 ? EXIT_SUCCESS : EXIT_FAILURE);
-}
-
-int
-db_verify_usage()
-{
-	fprintf(stderr, "%s\n",
-	    "usage: db_verify [-NoqV] [-h home] [-P password] db_file ...");
-	return (EXIT_FAILURE);
-}
-
-int
-db_verify_version_check(progname)
-	const char *progname;
-{
-	int v_major, v_minor, v_patch;
-
-	/* Make sure we're loaded with the right version of the DB library. */
-	(void)db_version(&v_major, &v_minor, &v_patch);
-	if (v_major != DB_VERSION_MAJOR ||
-	    v_minor != DB_VERSION_MINOR || v_patch != DB_VERSION_PATCH) {
-		fprintf(stderr,
-	"%s: version %d.%d.%d doesn't match library version %d.%d.%d\n",
-		    progname, DB_VERSION_MAJOR, DB_VERSION_MINOR,
-		    DB_VERSION_PATCH, v_major, v_minor, v_patch);
-		return (EXIT_FAILURE);
-	}
-	return (0);
-}
diff --git a/bdb/build_vxworks/db_verify/db_verify.wpj b/bdb/build_vxworks/db_verify/db_verify.wpj
deleted file mode 100755
index d807c9853bfe6b259a0f40f01fa3717e269a9f6a..0000000000000000000000000000000000000000
--- a/bdb/build_vxworks/db_verify/db_verify.wpj
+++ /dev/null
@@ -1,160 +0,0 @@
-Document file - DO NOT EDIT
-
-<BEGIN> BUILD_PENTIUMgnu_BUILDRULE
-db_verify.out
-<END>
-
-<BEGIN> BUILD_PENTIUMgnu_MACRO_AR
-ar386
-<END>
-
-<BEGIN> BUILD_PENTIUMgnu_MACRO_ARCHIVE
-$(PRJ_DIR)/PENTIUMgnu/db_verify.a
-<END>
-
-<BEGIN> BUILD_PENTIUMgnu_MACRO_AS
-cc386
-<END>
-
-<BEGIN> BUILD_PENTIUMgnu_MACRO_CC
-cc386
-<END>
-
-<BEGIN> BUILD_PENTIUMgnu_MACRO_CFLAGS
--g \
-	-mpentium \
-	-ansi \
-	-nostdinc \
-	-DRW_MULTI_THREAD \
-	-D_REENTRANT \
-	-fvolatile \
-	-nostdlib \
-	-fno-builtin \
-	-fno-defer-pop \
-	-I$(PRJ_DIR)/.. \
-	-I$(PRJ_DIR)/../.. \
-	-I$(WIND_BASE)/target/h \
-	-DCPU=PENTIUM
-<END>
-
-<BEGIN> BUILD_PENTIUMgnu_MACRO_CFLAGS_AS
--g \
-	-mpentium \
-	-ansi \
-	-nostdinc \
-	-fvolatile \
-	-nostdlib \
-	-fno-builtin \
-	-fno-defer-pop \
-	-P \
-	-x \
-	assembler-with-cpp \
-	-I$(WIND_BASE)/target/h \
-	-DCPU=PENTIUM
-<END>
-
-<BEGIN> BUILD_PENTIUMgnu_MACRO_CPP
-cc386 -E -P -xc
-<END>
-
-<BEGIN> BUILD_PENTIUMgnu_MACRO_LD
-ld386
-<END>
-
-<BEGIN> BUILD_PENTIUMgnu_MACRO_LDDEPS
-
-<END>
-
-<BEGIN> BUILD_PENTIUMgnu_MACRO_LDFLAGS
--X -N
-<END>
-
-<BEGIN> BUILD_PENTIUMgnu_MACRO_LD_PARTIAL_FLAGS
--X -r
-<END>
-
-<BEGIN> BUILD_PENTIUMgnu_MACRO_NM
-nm386 -g
-<END>
-
-<BEGIN> BUILD_PENTIUMgnu_MACRO_OPTION_DEFINE_MACRO
--D
-<END>
-
-<BEGIN> BUILD_PENTIUMgnu_MACRO_OPTION_INCLUDE_DIR
--I
-<END>
-
-<BEGIN> BUILD_PENTIUMgnu_MACRO_POST_BUILD_RULE
-
-<END>
-
-<BEGIN> BUILD_PENTIUMgnu_MACRO_PRJ_LIBS
-
-<END>
-
-<BEGIN> BUILD_PENTIUMgnu_MACRO_SIZE
-size386
-<END>
-
-<BEGIN> BUILD_PENTIUMgnu_RO_DEPEND_PATH
-{$(WIND_BASE)/target/h/} \
-	{$(WIND_BASE)/target/src/} \
-	{$(WIND_BASE)/target/config/}
-<END>
-
-<BEGIN> BUILD_PENTIUMgnu_TC
-::tc_PENTIUMgnu
-<END>
-
-<BEGIN> BUILD_RULE_archive
-
-<END>
-
-<BEGIN> BUILD_RULE_db_verify.out
-
-<END>
-
-<BEGIN> BUILD_RULE_objects
-
-<END>
-
-<BEGIN> BUILD__CURRENT
-PENTIUMgnu
-<END>
-
-<BEGIN> BUILD__LIST
-PENTIUMgnu
-<END>
-
-<BEGIN> CORE_INFO_TYPE
-::prj_vxApp
-<END>
-
-<BEGIN> CORE_INFO_VERSION
-2.0
-<END>
-
-<BEGIN> FILE_db_verify.c_dependDone
-FALSE
-<END>
-
-<BEGIN> FILE_db_verify.c_dependencies
-
-<END>
-
-<BEGIN> FILE_db_verify.c_objects
-db_verify.o
-<END>
-
-<BEGIN> FILE_db_verify.c_tool
-C/C++ compiler
-<END>
-
-<BEGIN> PROJECT_FILES
-$(PRJ_DIR)/db_verify.c
-<END>
-
-<BEGIN> userComments
-db_verify
-<END>
diff --git a/bdb/build_vxworks/db_verify/db_verify/Makefile.custom b/bdb/build_vxworks/db_verify/db_verify/Makefile.custom
deleted file mode 100644
index ca781f7b251ef99e49e5fc1859ee6cf3d67c60b0..0000000000000000000000000000000000000000
--- a/bdb/build_vxworks/db_verify/db_verify/Makefile.custom
+++ /dev/null
@@ -1,51 +0,0 @@
-#
-# Custom Makefile shell
-#
-# This file may be edited freely, since it will not be regenerated
-# by the project manager.
-#
-# Use this makefile to define rules to make external binaries
-# and deposit them in the $(EXTERNAL_BINARIES_DIR) directory.
-#
-# If you have specified external modules during your component
-# creation, you will find make rules already in place below.
-# You will likely have to edit these to suit your individual
-# build setup.
-#
-# You may wish to use the CPU, BUILD_SPEC or TOOL make variables in
-# your Makefile to support builds for different architectures.  Use
-# the FORCE_EXTERNAL_MAKE phony target to ensure that your external
-# make always runs.
-#
-# The example below assumes that your custom makefile is in the
-# mySourceTree directory, and that the binary file it produces
-# is placed into the $(BUILD_SPEC) sub-directory.
-#
-# EXTERNAL_SOURCE_BASE = /folk/me/mySourceTree
-# EXTERNAL_MODULE = myLibrary.o
-# EXTERNAL_MAKE = make
-#
-# $(EXTERNAL_BINARIES_DIR)/$(EXTERNAL_MODULE) : FORCE_EXTERNAL_MAKE
-#	$(EXTERNAL_MAKE) -C $(EXTERNAL_SOURCE_BASE) \
-#	-f $(EXTERNAL_SOURCE_BASE)/Makefile \
-#	CPU=$(CPU) BUILD_SPEC=$(BUILD_SPEC) $(@F)
-#	$(CP) $(subst /,$(DIRCHAR),$(EXTERNAL_SOURCE_BASE)/$(BUILD_SPEC)/$(@F) $@)
-#
-# If you are not adding your external modules from the component wizard,
-# you will have to include them in your component yourself:
-#
-# From the GUI, you can do this with the Component's 'Add external module'
-# dialog.
-#
-# If you are using the command line, add the module(s) by editing the
-# MODULES line in component.cdf file, e.g.
-#
-# Component INCLUDE_MYCOMPONENT {
-#
-#   MODULES         foo.o goo.o \
-#         myLibrary.o
-#
-
-
-# rules to build custom libraries
-
diff --git a/bdb/build_vxworks/db_verify/db_verify/component.cdf b/bdb/build_vxworks/db_verify/db_verify/component.cdf
deleted file mode 100755
index f29f8246b570639de8fa051bfb6c5cd466386608..0000000000000000000000000000000000000000
--- a/bdb/build_vxworks/db_verify/db_verify/component.cdf
+++ /dev/null
@@ -1,30 +0,0 @@
-/* component.cdf - dynamically updated configuration */
-
-/*
- * NOTE: you may edit this file to alter the configuration
- * But all non-configuration information, including comments,
- * will be lost upon rebuilding this project.
- */
-
-/* Component information */
-
-Component INCLUDE_DB_VERIFY {
-	ENTRY_POINTS	ALL_GLOBAL_SYMBOLS 
-	MODULES		db_verify.o 
-	NAME		db_verify
-	PREF_DOMAIN	ANY
-	_INIT_ORDER	usrComponentsInit
-}
-
-/* EntryPoint information */
-
-/* Module information */
-
-Module db_verify.o {
-
-	NAME		db_verify.o
-	SRC_PATH_NAME	$PRJ_DIR/../db_verify.c
-}
-
-/* Parameter information */
-
diff --git a/bdb/build_vxworks/db_verify/db_verify/component.wpj b/bdb/build_vxworks/db_verify/db_verify/component.wpj
deleted file mode 100755
index aca3ae8cb75baab7df2c2f212a0be93aab4a3ec7..0000000000000000000000000000000000000000
--- a/bdb/build_vxworks/db_verify/db_verify/component.wpj
+++ /dev/null
@@ -1,475 +0,0 @@
-Document file - DO NOT EDIT
-
-<BEGIN> CORE_INFO_TYPE
-::prj_component
-<END>
-
-<BEGIN> CORE_INFO_VERSION
-AE1.1
-<END>
-
-<BEGIN> BUILD__CURRENT
-PENTIUM2gnu.debug
-<END>
-
-<BEGIN> BUILD_PENTIUM2gnu.debug_CURRENT_TARGET
-default
-<END>
-
-<BEGIN> BUILD_PENTIUM2gnu.debug_DEFAULTFORCPU
-1
-<END>
-
-<BEGIN> BUILD_PENTIUM2gnu.debug_FILE_$(PRJ_DIR)/../db_verify.c_infoTags
-toolMacro objects
-<END>
-
-<BEGIN> BUILD_PENTIUM2gnu.debug_FILE_$(PRJ_DIR)/../db_verify.c_objects
-db_verify.o
-<END>
-
-<BEGIN> BUILD_PENTIUM2gnu.debug_FILE_$(PRJ_DIR)/../db_verify.c_toolMacro
-CC
-<END>
-
-<BEGIN> BUILD_PENTIUM2gnu.debug_FILE_$(PRJ_DIR)/../db_verify.c_objects
-db_verify.o
-<END>
-
-<BEGIN> BUILD_PENTIUM2gnu.debug_FILE_$(PRJ_DIR)/../db_verify.c_toolMacro
-CC
-<END>
-
-<BEGIN> BUILD_PENTIUM2gnu.debug_FILE_$(PRJ_DIR)/compConfig.c_infoTags
-toolMacro objects
-<END>
-
-<BEGIN> BUILD_PENTIUM2gnu.debug_FILE_$(PRJ_DIR)/compConfig.c_objects
-compConfig.o
-<END>
-
-<BEGIN> BUILD_PENTIUM2gnu.debug_FILE_$(PRJ_DIR)/compConfig.c_toolMacro
-CC
-<END>
-
-<BEGIN> BUILD_PENTIUM2gnu.debug_MACRO_AR
-arpentium
-<END>
-
-<BEGIN> BUILD_PENTIUM2gnu.debug_MACRO_AS
-ccpentium
-<END>
-
-<BEGIN> BUILD_PENTIUM2gnu.debug_MACRO_CC
-ccpentium
-<END>
-
-<BEGIN> BUILD_PENTIUM2gnu.debug_MACRO_CFLAGS
--mcpu=pentiumpro \
-	-march=pentiumpro \
-	-ansi \
-	-DRW_MULTI_THREAD \
-	-D_REENTRANT \
-	-g \
-	-nostdlib \
-	-fno-builtin \
-	-fno-defer-pop \
-	-MD \
-	-Wall \
-	-I. \
-	-I$(WIND_BASE)/target/h \
-	-I$(PRJ_DIR)/../.. \
-	-I$(PRJ_DIR)/../../.. \
-	-DCPU=PENTIUM2
-<END>
-
-<BEGIN> BUILD_PENTIUM2gnu.debug_MACRO_CFLAGS_AS
--mcpu=pentiumpro \
-	-march=pentiumpro \
-	-ansi \
-	-g \
-	-nostdlib \
-	-fno-builtin \
-	-fno-defer-pop \
-	-P \
-	-x \
-	assembler-with-cpp \
-	-Wall \
-	-I. \
-	-I$(WIND_BASE)/target/h \
-	-DCPU=PENTIUM2
-<END>
-
-<BEGIN> BUILD_PENTIUM2gnu.debug_MACRO_CPP
-ccpentium -E -P
-<END>
-
-<BEGIN> BUILD_PENTIUM2gnu.debug_MACRO_CPPFILT
-c++filtpentium --strip-underscores
-<END>
-
-<BEGIN> BUILD_PENTIUM2gnu.debug_MACRO_LD
-ldpentium
-<END>
-
-<BEGIN> BUILD_PENTIUM2gnu.debug_MACRO_LDFLAGS
--X
-<END>
-
-<BEGIN> BUILD_PENTIUM2gnu.debug_MACRO_LDPARTIAL
-ccpentium \
-	-B$(WIND_BASE)/host/$(WIND_HOST_TYPE)/lib/gcc-lib/ \
-	-nostdlib \
-	-r \
-	-Wl,-X
-<END>
-
-<BEGIN> BUILD_PENTIUM2gnu.debug_MACRO_LD_PARTIAL_FLAGS
--X -r
-<END>
-
-<BEGIN> BUILD_PENTIUM2gnu.debug_MACRO_NM
-nmpentium -g
-<END>
-
-<BEGIN> BUILD_PENTIUM2gnu.debug_MACRO_OPTION_DEFINE_MACRO
--D
-<END>
-
-<BEGIN> BUILD_PENTIUM2gnu.debug_MACRO_OPTION_GENERATE_DEPENDENCY_FILE
--MD
-<END>
-
-<BEGIN> BUILD_PENTIUM2gnu.debug_MACRO_OPTION_INCLUDE_DIR
--I
-<END>
-
-<BEGIN> BUILD_PENTIUM2gnu.debug_MACRO_RELEASE
-0
-<END>
-
-<BEGIN> BUILD_PENTIUM2gnu.debug_MACRO_SIZE
-sizepentium
-<END>
-
-<BEGIN> BUILD_PENTIUM2gnu.debug_RELEASE
-0
-<END>
-
-<BEGIN> BUILD_PENTIUM2gnu.debug_RO_DEPEND_PATH
-$(WIND_BASE)/target/h/
-<END>
-
-<BEGIN> BUILD_PENTIUM2gnu.debug_TC
-::tc_PENTIUM2gnu.debug
-<END>
-
-<BEGIN> BUILD_PENTIUM2gnu.release_DEFAULTFORCPU
-0
-<END>
-
-<BEGIN> BUILD_PENTIUM2gnu.release_FILE_$(PRJ_DIR)/../db_verify.c_infoTags
-toolMacro objects
-<END>
-
-<BEGIN> BUILD_PENTIUM2gnu.release_FILE_$(PRJ_DIR)/../db_verify.c_objects
-db_verify.o
-<END>
-
-<BEGIN> BUILD_PENTIUM2gnu.release_FILE_$(PRJ_DIR)/../db_verify.c_toolMacro
-CC
-<END>
-
-<BEGIN> BUILD_PENTIUM2gnu.release_FILE_$(PRJ_DIR)/compConfig.c_infoTags
-toolMacro objects
-<END>
-
-<BEGIN> BUILD_PENTIUM2gnu.release_FILE_$(PRJ_DIR)/compConfig.c_objects
-compConfig.o
-<END>
-
-<BEGIN> BUILD_PENTIUM2gnu.release_FILE_$(PRJ_DIR)/compConfig.c_toolMacro
-CC
-<END>
-
-<BEGIN> BUILD_PENTIUM2gnu.release_MACRO_AR
-arpentium
-<END>
-
-<BEGIN> BUILD_PENTIUM2gnu.release_MACRO_AS
-ccpentium
-<END>
-
-<BEGIN> BUILD_PENTIUM2gnu.release_MACRO_CC
-ccpentium
-<END>
-
-<BEGIN> BUILD_PENTIUM2gnu.release_MACRO_CFLAGS
--mcpu=pentiumpro \
-	-march=pentiumpro \
-	-ansi \
-	-DRW_MULTI_THREAD \
-	-D_REENTRANT \
-	-O2 \
-	-nostdlib \
-	-fno-builtin \
-	-fno-defer-pop \
-	-MD \
-	-Wall \
-	-I. \
-	-I$(WIND_BASE)/target/h \
-	-I$(PRJ_DIR)/../.. \
-	-I$(PRJ_DIR)/../../.. \
-	-DCPU=PENTIUM2
-<END>
-
-<BEGIN> BUILD_PENTIUM2gnu.release_MACRO_CFLAGS_AS
--mcpu=pentiumpro \
-	-march=pentiumpro \
-	-ansi \
-	-O2 \
-	-nostdlib \
-	-fno-builtin \
-	-fno-defer-pop \
-	-P \
-	-x \
-	assembler-with-cpp \
-	-Wall \
-	-I. \
-	-I$(WIND_BASE)/target/h \
-	-DCPU=PENTIUM2
-<END>
-
-<BEGIN> BUILD_PENTIUM2gnu.release_MACRO_CPP
-ccpentium -E -P
-<END>
-
-<BEGIN> BUILD_PENTIUM2gnu.release_MACRO_CPPFILT
-c++filtpentium --strip-underscores
-<END>
-
-<BEGIN> BUILD_PENTIUM2gnu.release_MACRO_LD
-ldpentium
-<END>
-
-<BEGIN> BUILD_PENTIUM2gnu.release_MACRO_LDFLAGS
--X
-<END>
-
-<BEGIN> BUILD_PENTIUM2gnu.release_MACRO_LDPARTIAL
-ccpentium \
-	-B$(WIND_BASE)/host/$(WIND_HOST_TYPE)/lib/gcc-lib/ \
-	-nostdlib \
-	-r \
-	-Wl,-X
-<END>
-
-<BEGIN> BUILD_PENTIUM2gnu.release_MACRO_LD_PARTIAL_FLAGS
--X -r
-<END>
-
-<BEGIN> BUILD_PENTIUM2gnu.release_MACRO_NM
-nmpentium -g
-<END>
-
-<BEGIN> BUILD_PENTIUM2gnu.release_MACRO_OPTION_DEFINE_MACRO
--D
-<END>
-
-<BEGIN> BUILD_PENTIUM2gnu.release_MACRO_OPTION_GENERATE_DEPENDENCY_FILE
--MD
-<END>
-
-<BEGIN> BUILD_PENTIUM2gnu.release_MACRO_OPTION_INCLUDE_DIR
--I
-<END>
-
-<BEGIN> BUILD_PENTIUM2gnu.release_MACRO_RELEASE
-1
-<END>
-
-<BEGIN> BUILD_PENTIUM2gnu.release_MACRO_SIZE
-sizepentium
-<END>
-
-<BEGIN> BUILD_PENTIUM2gnu.release_RELEASE
-1
-<END>
-
-<BEGIN> BUILD_PENTIUM2gnu.release_RO_DEPEND_PATH
-$(WIND_BASE)/target/h/
-<END>
-
-<BEGIN> BUILD_PENTIUM2gnu.release_TC
-::tc_PENTIUM2gnu.release
-<END>
-
-<BEGIN> BUILD_PENTIUMgnu.debug_DEFAULTFORCPU
-1
-<END>
-
-<BEGIN> BUILD_PENTIUMgnu.debug_FILE_$(PRJ_DIR)/../db_verify.c_infoTags
-toolMacro objects
-<END>
-
-<BEGIN> BUILD_PENTIUMgnu.debug_FILE_$(PRJ_DIR)/../db_verify.c_objects
-db_verify.o
-<END>
-
-<BEGIN> BUILD_PENTIUMgnu.debug_FILE_$(PRJ_DIR)/../db_verify.c_toolMacro
-CC
-<END>
-
-<BEGIN> BUILD_PENTIUMgnu.debug_FILE_$(PRJ_DIR)/compConfig.c_infoTags
-toolMacro objects
-<END>
-
-<BEGIN> BUILD_PENTIUMgnu.debug_FILE_$(PRJ_DIR)/compConfig.c_objects
-compConfig.o
-<END>
-
-<BEGIN> BUILD_PENTIUMgnu.debug_FILE_$(PRJ_DIR)/compConfig.c_toolMacro
-CC
-<END>
-
-<BEGIN> BUILD_PENTIUMgnu.debug_MACRO_AR
-arpentium
-<END>
-
-<BEGIN> BUILD_PENTIUMgnu.debug_MACRO_AS
-ccpentium
-<END>
-
-<BEGIN> BUILD_PENTIUMgnu.debug_MACRO_CC
-ccpentium
-<END>
-
-<BEGIN> BUILD_PENTIUMgnu.debug_MACRO_CFLAGS
--mcpu=pentium \
-	-march=pentium \
-	-ansi \
-	-DRW_MULTI_THREAD \
-	-D_REENTRANT \
-	-g \
-	-nostdlib \
-	-fno-builtin \
-	-fno-defer-pop \
-	-MD \
-	-Wall \
-	-I. \
-	-I$(WIND_BASE)/target/h \
-	-I$(PRJ_DIR)/../.. \
-	-I$(PRJ_DIR)/../../.. \
-	-DCPU=PENTIUM
-<END>
-
-<BEGIN> BUILD_PENTIUMgnu.debug_MACRO_CFLAGS_AS
--mcpu=pentium \
-	-march=pentium \
-	-ansi \
-	-g \
-	-nostdlib \
-	-fno-builtin \
-	-fno-defer-pop \
-	-P \
-	-x \
-	assembler-with-cpp \
-	-Wall \
-	-I. \
-	-I$(WIND_BASE)/target/h \
-	-DCPU=PENTIUM
-<END>
-
-<BEGIN> BUILD_PENTIUMgnu.debug_MACRO_CPP
-ccpentium -E -P
-<END>
-
-<BEGIN> BUILD_PENTIUMgnu.debug_MACRO_CPPFILT
-c++filtpentium --strip-underscores
-<END>
-
-<BEGIN> BUILD_PENTIUMgnu.debug_MACRO_LD
-ldpentium
-<END>
-
-<BEGIN> BUILD_PENTIUMgnu.debug_MACRO_LDFLAGS
--X
-<END>
-
-<BEGIN> BUILD_PENTIUMgnu.debug_MACRO_LDPARTIAL
-ccpentium \
-	-B$(WIND_BASE)/host/$(WIND_HOST_TYPE)/lib/gcc-lib/ \
-	-nostdlib \
-	-r \
-	-Wl,-X
-<END>
-
-<BEGIN> BUILD_PENTIUMgnu.debug_MACRO_LD_PARTIAL_FLAGS
--X -r
-<END>
-
-<BEGIN> BUILD_PENTIUMgnu.debug_MACRO_NM
-nmpentium -g
-<END>
-
-<BEGIN> BUILD_PENTIUMgnu.debug_MACRO_OPTION_DEFINE_MACRO
--D
-<END>
-
-<BEGIN> BUILD_PENTIUMgnu.debug_MACRO_OPTION_GENERATE_DEPENDENCY_FILE
--MD
-<END>
-
-<BEGIN> BUILD_PENTIUMgnu.debug_MACRO_OPTION_INCLUDE_DIR
--I
-<END>
-
-<BEGIN> BUILD_PENTIUMgnu.debug_MACRO_RELEASE
-0
-<END>
-
-<BEGIN> BUILD_PENTIUMgnu.debug_MACRO_SIZE
-sizepentium
-<END>
-
-<BEGIN> BUILD_PENTIUMgnu.debug_RELEASE
-0
-<END>
-
-<BEGIN> BUILD_PENTIUMgnu.debug_RO_DEPEND_PATH
-$(WIND_BASE)/target/h/
-<END>
-
-<BEGIN> BUILD_PENTIUMgnu.debug_TC
-::tc_PENTIUMgnu.debug
-<END>
-
-<BEGIN> BUILD__LIST
-PENTIUM2gnu.debug PENTIUM2gnu.release PENTIUMgnu.debug
-<END>
-
-<BEGIN> PROJECT_FILES
-$(PRJ_DIR)/../db_verify.c \
-	$(PRJ_DIR)/compConfig.c
-<END>
-
-<BEGIN> WCC__CDF_PATH
-$(PRJ_DIR)
-<END>
-
-<BEGIN> WCC__CURRENT
-PENTIUM2gnu.debug
-<END>
-
-<BEGIN> WCC__LIST
-PENTIUM2gnu.debug
-<END>
-
-<BEGIN> WCC__MXR_LIBS
-lib$(CPU)$(TOOL)vx.a
-<END>
-
-<BEGIN> WCC__OBJS_PATH
-$(WIND_BASE)/target/lib/obj$CPU$TOOLvx
-<END>
-
diff --git a/bdb/build_vxworks/dbdemo/dbdemo.c b/bdb/build_vxworks/dbdemo/dbdemo.c
deleted file mode 100644
index 6dd2a25c54ebee4de1d8f469416f0d6c6243ce94..0000000000000000000000000000000000000000
--- a/bdb/build_vxworks/dbdemo/dbdemo.c
+++ /dev/null
@@ -1,178 +0,0 @@
-/*-
- * See the file LICENSE for redistribution information.
- *
- * Copyright (c) 1997-2002
- *	Sleepycat Software.  All rights reserved.
- *
- * $Id: ex_access.c,v 11.22 2002/09/03 12:54:26 bostic Exp $
- */
-
-#include <sys/types.h>
-
-#include <stdio.h>
-#include <stdlib.h>
-#include <string.h>
-
-#ifdef _WIN32
-extern int getopt(int, char * const *, const char *);
-#else
-#include <unistd.h>
-#endif
-
-#include <db_config.h>
-#include <db_int.h>
-
-#define	DATABASE	"access.db"
-int dbdemo_main __P((int, char *[]));
-int dbdemo_usage __P((void));
-
-int
-dbdemo(args)
-	char *args;
-{
-	int argc;
-	char **argv;
-
-	__db_util_arg("dbdemo", args, &argc, &argv);
-	return (dbdemo_main(argc, argv) ? EXIT_FAILURE : EXIT_SUCCESS);
-}
-
-#include <stdio.h>
-#define	ERROR_RETURN	ERROR
-
-int
-dbdemo_main(argc, argv)
-	int argc;
-	char *argv[];
-{
-	extern int optind, __db_getopt_reset;
-	DB *dbp;
-	DBC *dbcp;
-	DBT key, data;
-	u_int32_t len;
-	int ch, ret, rflag;
-	char *database, *p, *t, buf[1024], rbuf[1024];
-	const char *progname = "dbdemo";		/* Program name. */
-
-	rflag = 0;
-	__db_getopt_reset = 1;
-	while ((ch = getopt(argc, argv, "r")) != EOF)
-		switch (ch) {
-		case 'r':
-			rflag = 1;
-			break;
-		case '?':
-		default:
-			return (dbdemo_usage());
-		}
-	argc -= optind;
-	argv += optind;
-
-	/* Accept optional database name. */
-	database = *argv == NULL ? DATABASE : argv[0];
-
-	/* Optionally discard the database. */
-	if (rflag)
-		(void)remove(database);
-
-	/* Create and initialize database object, open the database. */
-	if ((ret = db_create(&dbp, NULL, 0)) != 0) {
-		fprintf(stderr,
-		    "%s: db_create: %s\n", progname, db_strerror(ret));
-		return (EXIT_FAILURE);
-	}
-	dbp->set_errfile(dbp, stderr);
-	dbp->set_errpfx(dbp, progname);
-	if ((ret = dbp->set_pagesize(dbp, 1024)) != 0) {
-		dbp->err(dbp, ret, "set_pagesize");
-		goto err1;
-	}
-	if ((ret = dbp->set_cachesize(dbp, 0, 32 * 1024, 0)) != 0) {
-		dbp->err(dbp, ret, "set_cachesize");
-		goto err1;
-	}
-	if ((ret = dbp->open(dbp,
-	    NULL, database, NULL, DB_BTREE, DB_CREATE, 0664)) != 0) {
-		dbp->err(dbp, ret, "%s: open", database);
-		goto err1;
-	}
-
-	/*
-	 * Insert records into the database, where the key is the user
-	 * input and the data is the user input in reverse order.
-	 */
-	memset(&key, 0, sizeof(DBT));
-	memset(&data, 0, sizeof(DBT));
-	for (;;) {
-		printf("input> ");
-		fflush(stdout);
-		if (fgets(buf, sizeof(buf), stdin) == NULL)
-			break;
-		if (strcmp(buf, "exit\n") == 0 || strcmp(buf, "quit\n") == 0)
-			break;
-		if ((len = strlen(buf)) <= 1)
-			continue;
-		for (t = rbuf, p = buf + (len - 2); p >= buf;)
-			*t++ = *p--;
-		*t++ = '\0';
-
-		key.data = buf;
-		data.data = rbuf;
-		data.size = key.size = len - 1;
-
-		switch (ret =
-		    dbp->put(dbp, NULL, &key, &data, DB_NOOVERWRITE)) {
-		case 0:
-			break;
-		default:
-			dbp->err(dbp, ret, "DB->put");
-			if (ret != DB_KEYEXIST)
-				goto err1;
-			break;
-		}
-	}
-	printf("\n");
-
-	/* Acquire a cursor for the database. */
-	if ((ret = dbp->cursor(dbp, NULL, &dbcp, 0)) != 0) {
-		dbp->err(dbp, ret, "DB->cursor");
-		goto err1;
-	}
-
-	/* Initialize the key/data pair so the flags aren't set. */
-	memset(&key, 0, sizeof(key));
-	memset(&data, 0, sizeof(data));
-
-	/* Walk through the database and print out the key/data pairs. */
-	while ((ret = dbcp->c_get(dbcp, &key, &data, DB_NEXT)) == 0)
-		printf("%.*s : %.*s\n",
-		    (int)key.size, (char *)key.data,
-		    (int)data.size, (char *)data.data);
-	if (ret != DB_NOTFOUND) {
-		dbp->err(dbp, ret, "DBcursor->get");
-		goto err2;
-	}
-
-	/* Close everything down. */
-	if ((ret = dbcp->c_close(dbcp)) != 0) {
-		dbp->err(dbp, ret, "DBcursor->close");
-		goto err1;
-	}
-	if ((ret = dbp->close(dbp, 0)) != 0) {
-		fprintf(stderr,
-		    "%s: DB->close: %s\n", progname, db_strerror(ret));
-		return (EXIT_FAILURE);
-	}
-	return (EXIT_SUCCESS);
-
-err2:	(void)dbcp->c_close(dbcp);
-err1:	(void)dbp->close(dbp, 0);
-	return (EXIT_FAILURE);
-}
-
-int
-dbdemo_usage()
-{
-	(void)fprintf(stderr, "usage: ex_access [-r] [database]\n");
-	return (EXIT_FAILURE);
-}
diff --git a/bdb/build_vxworks/dbdemo/dbdemo.wpj b/bdb/build_vxworks/dbdemo/dbdemo.wpj
deleted file mode 100755
index 52eec5ed9455cd3bfbef2462c7a37a861e11a2bf..0000000000000000000000000000000000000000
--- a/bdb/build_vxworks/dbdemo/dbdemo.wpj
+++ /dev/null
@@ -1,160 +0,0 @@
-Document file - DO NOT EDIT
-
-<BEGIN> BUILD_PENTIUMgnu_BUILDRULE
-dbdemo.out
-<END>
-
-<BEGIN> BUILD_PENTIUMgnu_MACRO_AR
-ar386
-<END>
-
-<BEGIN> BUILD_PENTIUMgnu_MACRO_ARCHIVE
-$(PRJ_DIR)/PENTIUMgnu/dbdemo.a
-<END>
-
-<BEGIN> BUILD_PENTIUMgnu_MACRO_AS
-cc386
-<END>
-
-<BEGIN> BUILD_PENTIUMgnu_MACRO_CC
-cc386
-<END>
-
-<BEGIN> BUILD_PENTIUMgnu_MACRO_CFLAGS
--g \
-	-mpentium \
-	-ansi \
-	-nostdinc \
-	-DRW_MULTI_THREAD \
-	-D_REENTRANT \
-	-fvolatile \
-	-nostdlib \
-	-fno-builtin \
-	-fno-defer-pop \
-	-I$(PRJ_DIR)/.. \
-	-I$(PRJ_DIR)/../.. \
-	-I$(WIND_BASE)/target/h \
-	-DCPU=PENTIUM
-<END>
-
-<BEGIN> BUILD_PENTIUMgnu_MACRO_CFLAGS_AS
--g \
-	-mpentium \
-	-ansi \
-	-nostdinc \
-	-fvolatile \
-	-nostdlib \
-	-fno-builtin \
-	-fno-defer-pop \
-	-P \
-	-x \
-	assembler-with-cpp \
-	-I$(WIND_BASE)/target/h \
-	-DCPU=PENTIUM
-<END>
-
-<BEGIN> BUILD_PENTIUMgnu_MACRO_CPP
-cc386 -E -P -xc
-<END>
-
-<BEGIN> BUILD_PENTIUMgnu_MACRO_LD
-ld386
-<END>
-
-<BEGIN> BUILD_PENTIUMgnu_MACRO_LDDEPS
-
-<END>
-
-<BEGIN> BUILD_PENTIUMgnu_MACRO_LDFLAGS
--X -N
-<END>
-
-<BEGIN> BUILD_PENTIUMgnu_MACRO_LD_PARTIAL_FLAGS
--X -r
-<END>
-
-<BEGIN> BUILD_PENTIUMgnu_MACRO_NM
-nm386 -g
-<END>
-
-<BEGIN> BUILD_PENTIUMgnu_MACRO_OPTION_DEFINE_MACRO
--D
-<END>
-
-<BEGIN> BUILD_PENTIUMgnu_MACRO_OPTION_INCLUDE_DIR
--I
-<END>
-
-<BEGIN> BUILD_PENTIUMgnu_MACRO_POST_BUILD_RULE
-
-<END>
-
-<BEGIN> BUILD_PENTIUMgnu_MACRO_PRJ_LIBS
-
-<END>
-
-<BEGIN> BUILD_PENTIUMgnu_MACRO_SIZE
-size386
-<END>
-
-<BEGIN> BUILD_PENTIUMgnu_RO_DEPEND_PATH
-{$(WIND_BASE)/target/h/} \
-	{$(WIND_BASE)/target/src/} \
-	{$(WIND_BASE)/target/config/}
-<END>
-
-<BEGIN> BUILD_PENTIUMgnu_TC
-::tc_PENTIUMgnu
-<END>
-
-<BEGIN> BUILD_RULE_archive
-
-<END>
-
-<BEGIN> BUILD_RULE_dbdemo.out
-
-<END>
-
-<BEGIN> BUILD_RULE_objects
-
-<END>
-
-<BEGIN> BUILD__CURRENT
-PENTIUMgnu
-<END>
-
-<BEGIN> BUILD__LIST
-PENTIUMgnu
-<END>
-
-<BEGIN> CORE_INFO_TYPE
-::prj_vxApp
-<END>
-
-<BEGIN> CORE_INFO_VERSION
-2.0
-<END>
-
-<BEGIN> FILE_dbdemo.c_dependDone
-FALSE
-<END>
-
-<BEGIN> FILE_dbdemo.c_dependencies
-
-<END>
-
-<BEGIN> FILE_dbdemo.c_objects
-dbdemo.o
-<END>
-
-<BEGIN> FILE_dbdemo.c_tool
-C/C++ compiler
-<END>
-
-<BEGIN> PROJECT_FILES
-$(PRJ_DIR)/dbdemo.c
-<END>
-
-<BEGIN> userComments
-dbdemo
-<END>
diff --git a/bdb/build_vxworks/dbdemo/dbdemo/Makefile.custom b/bdb/build_vxworks/dbdemo/dbdemo/Makefile.custom
deleted file mode 100644
index ca781f7b251ef99e49e5fc1859ee6cf3d67c60b0..0000000000000000000000000000000000000000
--- a/bdb/build_vxworks/dbdemo/dbdemo/Makefile.custom
+++ /dev/null
@@ -1,51 +0,0 @@
-#
-# Custom Makefile shell
-#
-# This file may be edited freely, since it will not be regenerated
-# by the project manager.
-#
-# Use this makefile to define rules to make external binaries
-# and deposit them in the $(EXTERNAL_BINARIES_DIR) directory.
-#
-# If you have specified external modules during your component
-# creation, you will find make rules already in place below.
-# You will likely have to edit these to suit your individual
-# build setup.
-#
-# You may wish to use the CPU, BUILD_SPEC or TOOL make variables in
-# your Makefile to support builds for different architectures.  Use
-# the FORCE_EXTERNAL_MAKE phony target to ensure that your external
-# make always runs.
-#
-# The example below assumes that your custom makefile is in the
-# mySourceTree directory, and that the binary file it produces
-# is placed into the $(BUILD_SPEC) sub-directory.
-#
-# EXTERNAL_SOURCE_BASE = /folk/me/mySourceTree
-# EXTERNAL_MODULE = myLibrary.o
-# EXTERNAL_MAKE = make
-#
-# $(EXTERNAL_BINARIES_DIR)/$(EXTERNAL_MODULE) : FORCE_EXTERNAL_MAKE
-#	$(EXTERNAL_MAKE) -C $(EXTERNAL_SOURCE_BASE) \
-#	-f $(EXTERNAL_SOURCE_BASE)/Makefile \
-#	CPU=$(CPU) BUILD_SPEC=$(BUILD_SPEC) $(@F)
-#	$(CP) $(subst /,$(DIRCHAR),$(EXTERNAL_SOURCE_BASE)/$(BUILD_SPEC)/$(@F) $@)
-#
-# If you are not adding your external modules from the component wizard,
-# you will have to include them in your component yourself:
-#
-# From the GUI, you can do this with the Component's 'Add external module'
-# dialog.
-#
-# If you are using the command line, add the module(s) by editing the
-# MODULES line in component.cdf file, e.g.
-#
-# Component INCLUDE_MYCOMPONENT {
-#
-#   MODULES         foo.o goo.o \
-#         myLibrary.o
-#
-
-
-# rules to build custom libraries
-
diff --git a/bdb/build_vxworks/dbdemo/dbdemo/component.cdf b/bdb/build_vxworks/dbdemo/dbdemo/component.cdf
deleted file mode 100755
index 188b63bfa4add5ab2a5a35bcaa37ebe25edcf473..0000000000000000000000000000000000000000
--- a/bdb/build_vxworks/dbdemo/dbdemo/component.cdf
+++ /dev/null
@@ -1,30 +0,0 @@
-/* component.cdf - dynamically updated configuration */
-
-/*
- * NOTE: you may edit this file to alter the configuration
- * But all non-configuration information, including comments,
- * will be lost upon rebuilding this project.
- */
-
-/* Component information */
-
-Component INCLUDE_DBDEMO {
-	ENTRY_POINTS	ALL_GLOBAL_SYMBOLS 
-	MODULES		dbdemo.o 
-	NAME		dbdemo
-	PREF_DOMAIN	ANY
-	_INIT_ORDER	usrComponentsInit
-}
-
-/* EntryPoint information */
-
-/* Module information */
-
-Module dbdemo.o {
-
-	NAME		dbdemo.o
-	SRC_PATH_NAME	$PRJ_DIR/../dbdemo.c
-}
-
-/* Parameter information */
-
diff --git a/bdb/build_vxworks/dbdemo/dbdemo/component.wpj b/bdb/build_vxworks/dbdemo/dbdemo/component.wpj
deleted file mode 100755
index b51ebce106e173f62bceb32e0e4ce46f20e21a4a..0000000000000000000000000000000000000000
--- a/bdb/build_vxworks/dbdemo/dbdemo/component.wpj
+++ /dev/null
@@ -1,475 +0,0 @@
-Document file - DO NOT EDIT
-
-<BEGIN> CORE_INFO_TYPE
-::prj_component
-<END>
-
-<BEGIN> CORE_INFO_VERSION
-AE1.1
-<END>
-
-<BEGIN> BUILD__CURRENT
-PENTIUM2gnu.debug
-<END>
-
-<BEGIN> BUILD_PENTIUM2gnu.debug_CURRENT_TARGET
-default
-<END>
-
-<BEGIN> BUILD_PENTIUM2gnu.debug_DEFAULTFORCPU
-1
-<END>
-
-<BEGIN> BUILD_PENTIUM2gnu.debug_FILE_$(PRJ_DIR)/../dbdemo.c_infoTags
-toolMacro objects
-<END>
-
-<BEGIN> BUILD_PENTIUM2gnu.debug_FILE_$(PRJ_DIR)/../dbdemo.c_objects
-dbdemo.o
-<END>
-
-<BEGIN> BUILD_PENTIUM2gnu.debug_FILE_$(PRJ_DIR)/../dbdemo.c_toolMacro
-CC
-<END>
-
-<BEGIN> BUILD_PENTIUM2gnu.debug_FILE_$(PRJ_DIR)/../dbdemo.c_objects
-dbdemo.o
-<END>
-
-<BEGIN> BUILD_PENTIUM2gnu.debug_FILE_$(PRJ_DIR)/../dbdemo.c_toolMacro
-CC
-<END>
-
-<BEGIN> BUILD_PENTIUM2gnu.debug_FILE_$(PRJ_DIR)/compConfig.c_infoTags
-toolMacro objects
-<END>
-
-<BEGIN> BUILD_PENTIUM2gnu.debug_FILE_$(PRJ_DIR)/compConfig.c_objects
-compConfig.o
-<END>
-
-<BEGIN> BUILD_PENTIUM2gnu.debug_FILE_$(PRJ_DIR)/compConfig.c_toolMacro
-CC
-<END>
-
-<BEGIN> BUILD_PENTIUM2gnu.debug_MACRO_AR
-arpentium
-<END>
-
-<BEGIN> BUILD_PENTIUM2gnu.debug_MACRO_AS
-ccpentium
-<END>
-
-<BEGIN> BUILD_PENTIUM2gnu.debug_MACRO_CC
-ccpentium
-<END>
-
-<BEGIN> BUILD_PENTIUM2gnu.debug_MACRO_CFLAGS
--mcpu=pentiumpro \
-	-march=pentiumpro \
-	-ansi \
-	-DRW_MULTI_THREAD \
-	-D_REENTRANT \
-	-g \
-	-nostdlib \
-	-fno-builtin \
-	-fno-defer-pop \
-	-MD \
-	-Wall \
-	-I. \
-	-I$(WIND_BASE)/target/h \
-	-I$(PRJ_DIR)/../.. \
-	-I$(PRJ_DIR)/../../.. \
-	-DCPU=PENTIUM2
-<END>
-
-<BEGIN> BUILD_PENTIUM2gnu.debug_MACRO_CFLAGS_AS
--mcpu=pentiumpro \
-	-march=pentiumpro \
-	-ansi \
-	-g \
-	-nostdlib \
-	-fno-builtin \
-	-fno-defer-pop \
-	-P \
-	-x \
-	assembler-with-cpp \
-	-Wall \
-	-I. \
-	-I$(WIND_BASE)/target/h \
-	-DCPU=PENTIUM2
-<END>
-
-<BEGIN> BUILD_PENTIUM2gnu.debug_MACRO_CPP
-ccpentium -E -P
-<END>
-
-<BEGIN> BUILD_PENTIUM2gnu.debug_MACRO_CPPFILT
-c++filtpentium --strip-underscores
-<END>
-
-<BEGIN> BUILD_PENTIUM2gnu.debug_MACRO_LD
-ldpentium
-<END>
-
-<BEGIN> BUILD_PENTIUM2gnu.debug_MACRO_LDFLAGS
--X
-<END>
-
-<BEGIN> BUILD_PENTIUM2gnu.debug_MACRO_LDPARTIAL
-ccpentium \
-	-B$(WIND_BASE)/host/$(WIND_HOST_TYPE)/lib/gcc-lib/ \
-	-nostdlib \
-	-r \
-	-Wl,-X
-<END>
-
-<BEGIN> BUILD_PENTIUM2gnu.debug_MACRO_LD_PARTIAL_FLAGS
--X -r
-<END>
-
-<BEGIN> BUILD_PENTIUM2gnu.debug_MACRO_NM
-nmpentium -g
-<END>
-
-<BEGIN> BUILD_PENTIUM2gnu.debug_MACRO_OPTION_DEFINE_MACRO
--D
-<END>
-
-<BEGIN> BUILD_PENTIUM2gnu.debug_MACRO_OPTION_GENERATE_DEPENDENCY_FILE
--MD
-<END>
-
-<BEGIN> BUILD_PENTIUM2gnu.debug_MACRO_OPTION_INCLUDE_DIR
--I
-<END>
-
-<BEGIN> BUILD_PENTIUM2gnu.debug_MACRO_RELEASE
-0
-<END>
-
-<BEGIN> BUILD_PENTIUM2gnu.debug_MACRO_SIZE
-sizepentium
-<END>
-
-<BEGIN> BUILD_PENTIUM2gnu.debug_RELEASE
-0
-<END>
-
-<BEGIN> BUILD_PENTIUM2gnu.debug_RO_DEPEND_PATH
-$(WIND_BASE)/target/h/
-<END>
-
-<BEGIN> BUILD_PENTIUM2gnu.debug_TC
-::tc_PENTIUM2gnu.debug
-<END>
-
-<BEGIN> BUILD_PENTIUM2gnu.release_DEFAULTFORCPU
-0
-<END>
-
-<BEGIN> BUILD_PENTIUM2gnu.release_FILE_$(PRJ_DIR)/../dbdemo.c_infoTags
-toolMacro objects
-<END>
-
-<BEGIN> BUILD_PENTIUM2gnu.release_FILE_$(PRJ_DIR)/../dbdemo.c_objects
-dbdemo.o
-<END>
-
-<BEGIN> BUILD_PENTIUM2gnu.release_FILE_$(PRJ_DIR)/../dbdemo.c_toolMacro
-CC
-<END>
-
-<BEGIN> BUILD_PENTIUM2gnu.release_FILE_$(PRJ_DIR)/compConfig.c_infoTags
-toolMacro objects
-<END>
-
-<BEGIN> BUILD_PENTIUM2gnu.release_FILE_$(PRJ_DIR)/compConfig.c_objects
-compConfig.o
-<END>
-
-<BEGIN> BUILD_PENTIUM2gnu.release_FILE_$(PRJ_DIR)/compConfig.c_toolMacro
-CC
-<END>
-
-<BEGIN> BUILD_PENTIUM2gnu.release_MACRO_AR
-arpentium
-<END>
-
-<BEGIN> BUILD_PENTIUM2gnu.release_MACRO_AS
-ccpentium
-<END>
-
-<BEGIN> BUILD_PENTIUM2gnu.release_MACRO_CC
-ccpentium
-<END>
-
-<BEGIN> BUILD_PENTIUM2gnu.release_MACRO_CFLAGS
--mcpu=pentiumpro \
-	-march=pentiumpro \
-	-ansi \
-	-DRW_MULTI_THREAD \
-	-D_REENTRANT \
-	-O2 \
-	-nostdlib \
-	-fno-builtin \
-	-fno-defer-pop \
-	-MD \
-	-Wall \
-	-I. \
-	-I$(WIND_BASE)/target/h \
-	-I$(PRJ_DIR)/../.. \
-	-I$(PRJ_DIR)/../../.. \
-	-DCPU=PENTIUM2
-<END>
-
-<BEGIN> BUILD_PENTIUM2gnu.release_MACRO_CFLAGS_AS
--mcpu=pentiumpro \
-	-march=pentiumpro \
-	-ansi \
-	-O2 \
-	-nostdlib \
-	-fno-builtin \
-	-fno-defer-pop \
-	-P \
-	-x \
-	assembler-with-cpp \
-	-Wall \
-	-I. \
-	-I$(WIND_BASE)/target/h \
-	-DCPU=PENTIUM2
-<END>
-
-<BEGIN> BUILD_PENTIUM2gnu.release_MACRO_CPP
-ccpentium -E -P
-<END>
-
-<BEGIN> BUILD_PENTIUM2gnu.release_MACRO_CPPFILT
-c++filtpentium --strip-underscores
-<END>
-
-<BEGIN> BUILD_PENTIUM2gnu.release_MACRO_LD
-ldpentium
-<END>
-
-<BEGIN> BUILD_PENTIUM2gnu.release_MACRO_LDFLAGS
--X
-<END>
-
-<BEGIN> BUILD_PENTIUM2gnu.release_MACRO_LDPARTIAL
-ccpentium \
-	-B$(WIND_BASE)/host/$(WIND_HOST_TYPE)/lib/gcc-lib/ \
-	-nostdlib \
-	-r \
-	-Wl,-X
-<END>
-
-<BEGIN> BUILD_PENTIUM2gnu.release_MACRO_LD_PARTIAL_FLAGS
--X -r
-<END>
-
-<BEGIN> BUILD_PENTIUM2gnu.release_MACRO_NM
-nmpentium -g
-<END>
-
-<BEGIN> BUILD_PENTIUM2gnu.release_MACRO_OPTION_DEFINE_MACRO
--D
-<END>
-
-<BEGIN> BUILD_PENTIUM2gnu.release_MACRO_OPTION_GENERATE_DEPENDENCY_FILE
--MD
-<END>
-
-<BEGIN> BUILD_PENTIUM2gnu.release_MACRO_OPTION_INCLUDE_DIR
--I
-<END>
-
-<BEGIN> BUILD_PENTIUM2gnu.release_MACRO_RELEASE
-1
-<END>
-
-<BEGIN> BUILD_PENTIUM2gnu.release_MACRO_SIZE
-sizepentium
-<END>
-
-<BEGIN> BUILD_PENTIUM2gnu.release_RELEASE
-1
-<END>
-
-<BEGIN> BUILD_PENTIUM2gnu.release_RO_DEPEND_PATH
-$(WIND_BASE)/target/h/
-<END>
-
-<BEGIN> BUILD_PENTIUM2gnu.release_TC
-::tc_PENTIUM2gnu.release
-<END>
-
-<BEGIN> BUILD_PENTIUMgnu.debug_DEFAULTFORCPU
-1
-<END>
-
-<BEGIN> BUILD_PENTIUMgnu.debug_FILE_$(PRJ_DIR)/../dbdemo.c_infoTags
-toolMacro objects
-<END>
-
-<BEGIN> BUILD_PENTIUMgnu.debug_FILE_$(PRJ_DIR)/../dbdemo.c_objects
-dbdemo.o
-<END>
-
-<BEGIN> BUILD_PENTIUMgnu.debug_FILE_$(PRJ_DIR)/../dbdemo.c_toolMacro
-CC
-<END>
-
-<BEGIN> BUILD_PENTIUMgnu.debug_FILE_$(PRJ_DIR)/compConfig.c_infoTags
-toolMacro objects
-<END>
-
-<BEGIN> BUILD_PENTIUMgnu.debug_FILE_$(PRJ_DIR)/compConfig.c_objects
-compConfig.o
-<END>
-
-<BEGIN> BUILD_PENTIUMgnu.debug_FILE_$(PRJ_DIR)/compConfig.c_toolMacro
-CC
-<END>
-
-<BEGIN> BUILD_PENTIUMgnu.debug_MACRO_AR
-arpentium
-<END>
-
-<BEGIN> BUILD_PENTIUMgnu.debug_MACRO_AS
-ccpentium
-<END>
-
-<BEGIN> BUILD_PENTIUMgnu.debug_MACRO_CC
-ccpentium
-<END>
-
-<BEGIN> BUILD_PENTIUMgnu.debug_MACRO_CFLAGS
--mcpu=pentium \
-	-march=pentium \
-	-ansi \
-	-DRW_MULTI_THREAD \
-	-D_REENTRANT \
-	-g \
-	-nostdlib \
-	-fno-builtin \
-	-fno-defer-pop \
-	-MD \
-	-Wall \
-	-I. \
-	-I$(WIND_BASE)/target/h \
-	-I$(PRJ_DIR)/../.. \
-	-I$(PRJ_DIR)/../../.. \
-	-DCPU=PENTIUM
-<END>
-
-<BEGIN> BUILD_PENTIUMgnu.debug_MACRO_CFLAGS_AS
--mcpu=pentium \
-	-march=pentium \
-	-ansi \
-	-g \
-	-nostdlib \
-	-fno-builtin \
-	-fno-defer-pop \
-	-P \
-	-x \
-	assembler-with-cpp \
-	-Wall \
-	-I. \
-	-I$(WIND_BASE)/target/h \
-	-DCPU=PENTIUM
-<END>
-
-<BEGIN> BUILD_PENTIUMgnu.debug_MACRO_CPP
-ccpentium -E -P
-<END>
-
-<BEGIN> BUILD_PENTIUMgnu.debug_MACRO_CPPFILT
-c++filtpentium --strip-underscores
-<END>
-
-<BEGIN> BUILD_PENTIUMgnu.debug_MACRO_LD
-ldpentium
-<END>
-
-<BEGIN> BUILD_PENTIUMgnu.debug_MACRO_LDFLAGS
--X
-<END>
-
-<BEGIN> BUILD_PENTIUMgnu.debug_MACRO_LDPARTIAL
-ccpentium \
-	-B$(WIND_BASE)/host/$(WIND_HOST_TYPE)/lib/gcc-lib/ \
-	-nostdlib \
-	-r \
-	-Wl,-X
-<END>
-
-<BEGIN> BUILD_PENTIUMgnu.debug_MACRO_LD_PARTIAL_FLAGS
--X -r
-<END>
-
-<BEGIN> BUILD_PENTIUMgnu.debug_MACRO_NM
-nmpentium -g
-<END>
-
-<BEGIN> BUILD_PENTIUMgnu.debug_MACRO_OPTION_DEFINE_MACRO
--D
-<END>
-
-<BEGIN> BUILD_PENTIUMgnu.debug_MACRO_OPTION_GENERATE_DEPENDENCY_FILE
--MD
-<END>
-
-<BEGIN> BUILD_PENTIUMgnu.debug_MACRO_OPTION_INCLUDE_DIR
--I
-<END>
-
-<BEGIN> BUILD_PENTIUMgnu.debug_MACRO_RELEASE
-0
-<END>
-
-<BEGIN> BUILD_PENTIUMgnu.debug_MACRO_SIZE
-sizepentium
-<END>
-
-<BEGIN> BUILD_PENTIUMgnu.debug_RELEASE
-0
-<END>
-
-<BEGIN> BUILD_PENTIUMgnu.debug_RO_DEPEND_PATH
-$(WIND_BASE)/target/h/
-<END>
-
-<BEGIN> BUILD_PENTIUMgnu.debug_TC
-::tc_PENTIUMgnu.debug
-<END>
-
-<BEGIN> BUILD__LIST
-PENTIUM2gnu.debug PENTIUM2gnu.release PENTIUMgnu.debug
-<END>
-
-<BEGIN> PROJECT_FILES
-$(PRJ_DIR)/../dbdemo.c \
-	$(PRJ_DIR)/compConfig.c
-<END>
-
-<BEGIN> WCC__CDF_PATH
-$(PRJ_DIR)
-<END>
-
-<BEGIN> WCC__CURRENT
-PENTIUM2gnu.debug
-<END>
-
-<BEGIN> WCC__LIST
-PENTIUM2gnu.debug
-<END>
-
-<BEGIN> WCC__MXR_LIBS
-lib$(CPU)$(TOOL)vx.a
-<END>
-
-<BEGIN> WCC__OBJS_PATH
-$(WIND_BASE)/target/lib/obj$CPU$TOOLvx
-<END>
-
diff --git a/bdb/build_win32/db_config.h b/bdb/build_win32/db_config.h
deleted file mode 100644
index 76ce0b5095f619b790081bd8a8c295e8ee7793d3..0000000000000000000000000000000000000000
--- a/bdb/build_win32/db_config.h
+++ /dev/null
@@ -1,440 +0,0 @@
-/* DO NOT EDIT: automatically built by dist/s_win32. */
-/* Define to 1 if you want to build a version for running the test suite. */
-/* #undef CONFIG_TEST */
-
-/* Define to 1 if you want a debugging version. */
-/* #undef DEBUG */
-#if defined(_DEBUG)
-#if !defined(DEBUG)
-#define DEBUG 1
-#endif
-#endif
-
-/* Define to 1 if you want a version that logs read operations. */
-/* #undef DEBUG_ROP */
-
-/* Define to 1 if you want a version that logs write operations. */
-/* #undef DEBUG_WOP */
-
-/* Define to 1 if you want a version with run-time diagnostic checking. */
-/* #undef DIAGNOSTIC */
-
-/* Define to 1 if you have the `clock_gettime' function. */
-/* #undef HAVE_CLOCK_GETTIME */
-
-/* Define to 1 if Berkeley DB release includes strong cryptography. */
-/* #undef HAVE_CRYPTO */
-
-/* Define to 1 if you have the `directio' function. */
-/* #undef HAVE_DIRECTIO */
-
-/* Define to 1 if you have the <dirent.h> header file, and it defines `DIR'.
-   */
-/* #undef HAVE_DIRENT_H */
-
-/* Define to 1 if you have the <dlfcn.h> header file. */
-/* #undef HAVE_DLFCN_H */
-
-/* Define to 1 if you have EXIT_SUCCESS/EXIT_FAILURE #defines. */
-#define HAVE_EXIT_SUCCESS 1
-
-/* Define to 1 if fcntl/F_SETFD denies child access to file descriptors. */
-/* #undef HAVE_FCNTL_F_SETFD */
-
-/* Define to 1 if allocated filesystem blocks are not zeroed. */
-#define HAVE_FILESYSTEM_NOTZERO 1
-
-/* Define to 1 if you have the `getcwd' function. */
-#define HAVE_GETCWD 1
-
-/* Define to 1 if you have the `getopt' function. */
-/* #undef HAVE_GETOPT */
-
-/* Define to 1 if you have the `gettimeofday' function. */
-/* #undef HAVE_GETTIMEOFDAY */
-
-/* Define to 1 if you have the `getuid' function. */
-/* #undef HAVE_GETUID */
-
-/* Define to 1 if you have the <inttypes.h> header file. */
-/* #undef HAVE_INTTYPES_H */
-
-/* Define to 1 if you have the `nsl' library (-lnsl). */
-/* #undef HAVE_LIBNSL */
-
-/* Define to 1 if you have the `memcmp' function. */
-#define HAVE_MEMCMP 1
-
-/* Define to 1 if you have the `memcpy' function. */
-#define HAVE_MEMCPY 1
-
-/* Define to 1 if you have the `memmove' function. */
-#define HAVE_MEMMOVE 1
-
-/* Define to 1 if you have the <memory.h> header file. */
-#define HAVE_MEMORY_H 1
-
-/* Define to 1 if you have the `mlock' function. */
-/* #undef HAVE_MLOCK */
-
-/* Define to 1 if you have the `mmap' function. */
-/* #undef HAVE_MMAP */
-
-/* Define to 1 if you have the `munlock' function. */
-/* #undef HAVE_MUNLOCK */
-
-/* Define to 1 if you have the `munmap' function. */
-/* #undef HAVE_MUNMAP */
-
-/* Define to 1 to use the GCC compiler and 68K assembly language mutexes. */
-/* #undef HAVE_MUTEX_68K_GCC_ASSEMBLY */
-
-/* Define to 1 to use the AIX _check_lock mutexes. */
-/* #undef HAVE_MUTEX_AIX_CHECK_LOCK */
-
-/* Define to 1 to use the GCC compiler and Alpha assembly language mutexes. */
-/* #undef HAVE_MUTEX_ALPHA_GCC_ASSEMBLY */
-
-/* Define to 1 to use the GCC compiler and ARM assembly language mutexes. */
-/* #undef HAVE_MUTEX_ARM_GCC_ASSEMBLY */
-
-/* Define to 1 to use the UNIX fcntl system call mutexes. */
-/* #undef HAVE_MUTEX_FCNTL */
-
-/* Define to 1 to use the GCC compiler and PaRisc assembly language mutexes.
-   */
-/* #undef HAVE_MUTEX_HPPA_GCC_ASSEMBLY */
-
-/* Define to 1 to use the msem_XXX mutexes on HP-UX. */
-/* #undef HAVE_MUTEX_HPPA_MSEM_INIT */
-
-/* Define to 1 to use the GCC compiler and IA64 assembly language mutexes. */
-/* #undef HAVE_MUTEX_IA64_GCC_ASSEMBLY */
-
-/* Define to 1 to use the msem_XXX mutexes on systems other than HP-UX. */
-/* #undef HAVE_MUTEX_MSEM_INIT */
-
-/* Define to 1 to use the GCC compiler and Apple PowerPC assembly language. */
-/* #undef HAVE_MUTEX_PPC_APPLE_GCC_ASSEMBLY */
-
-/* Define to 1 to use the GCC compiler and generic PowerPC assembly language.
-   */
-/* #undef HAVE_MUTEX_PPC_GENERIC_GCC_ASSEMBLY */
-
-/* Define to 1 to use POSIX 1003.1 pthread_XXX mutexes. */
-/* #undef HAVE_MUTEX_PTHREADS */
-
-/* Define to 1 to use Reliant UNIX initspin mutexes. */
-/* #undef HAVE_MUTEX_RELIANTUNIX_INITSPIN */
-
-/* Define to 1 to use the GCC compiler and S/390 assembly language mutexes. */
-/* #undef HAVE_MUTEX_S390_GCC_ASSEMBLY */
-
-/* Define to 1 to use the SCO compiler and x86 assembly language mutexes. */
-/* #undef HAVE_MUTEX_SCO_X86_CC_ASSEMBLY */
-
-/* Define to 1 to use the obsolete POSIX 1003.1 sema_XXX mutexes. */
-/* #undef HAVE_MUTEX_SEMA_INIT */
-
-/* Define to 1 to use the SGI XXX_lock mutexes. */
-/* #undef HAVE_MUTEX_SGI_INIT_LOCK */
-
-/* Define to 1 to use the Solaris _lock_XXX mutexes. */
-/* #undef HAVE_MUTEX_SOLARIS_LOCK_TRY */
-
-/* Define to 1 to use the Solaris lwp threads mutexes. */
-/* #undef HAVE_MUTEX_SOLARIS_LWP */
-
-/* Define to 1 to use the GCC compiler and Sparc assembly language mutexes. */
-/* #undef HAVE_MUTEX_SPARC_GCC_ASSEMBLY */
-
-/* Define to 1 if mutexes hold system resources. */
-/* #undef HAVE_MUTEX_SYSTEM_RESOURCES */
-
-/* Define to 1 if fast mutexes are available. */
-#define HAVE_MUTEX_THREADS 1
-
-/* Define to 1 to configure mutexes intra-process only. */
-/* #undef HAVE_MUTEX_THREAD_ONLY */
-
-/* Define to 1 to use the UNIX International mutexes. */
-/* #undef HAVE_MUTEX_UI_THREADS */
-
-/* Define to 1 to use the UTS compiler and assembly language mutexes. */
-/* #undef HAVE_MUTEX_UTS_CC_ASSEMBLY */
-
-/* Define to 1 to use VMS mutexes. */
-/* #undef HAVE_MUTEX_VMS */
-
-/* Define to 1 to use VxWorks mutexes. */
-/* #undef HAVE_MUTEX_VXWORKS */
-
-/* Define to 1 to use Windows mutexes. */
-#define HAVE_MUTEX_WIN32 1
-
-/* Define to 1 to use the GCC compiler and x86 assembly language mutexes. */
-/* #undef HAVE_MUTEX_X86_GCC_ASSEMBLY */
-
-/* Define to 1 if you have the <ndir.h> header file, and it defines `DIR'. */
-/* #undef HAVE_NDIR_H */
-
-/* Define to 1 if you have the O_DIRECT flag. */
-/* #undef HAVE_O_DIRECT */
-
-/* Define to 1 if you have the `pread' function. */
-/* #undef HAVE_PREAD */
-
-/* Define to 1 if you have the `pstat_getdynamic' function. */
-/* #undef HAVE_PSTAT_GETDYNAMIC */
-
-/* Define to 1 if you have the `pwrite' function. */
-/* #undef HAVE_PWRITE */
-
-/* Define to 1 if building on QNX. */
-/* #undef HAVE_QNX */
-
-/* Define to 1 if you have the `qsort' function. */
-#define HAVE_QSORT 1
-
-/* Define to 1 if you have the `raise' function. */
-#define HAVE_RAISE 1
-
-/* Define to 1 if building RPC client/server. */
-/* #undef HAVE_RPC */
-
-/* Define to 1 if you have the `sched_yield' function. */
-/* #undef HAVE_SCHED_YIELD */
-
-/* Define to 1 if you have the `select' function. */
-/* #undef HAVE_SELECT */
-
-/* Define to 1 if you have the `shmget' function. */
-/* #undef HAVE_SHMGET */
-
-/* Define to 1 if you have the `snprintf' function. */
-#define HAVE_SNPRINTF 1
-
-/* Define to 1 if you have the <stdint.h> header file. */
-/* #undef HAVE_STDINT_H */
-
-/* Define to 1 if you have the <stdlib.h> header file. */
-#define HAVE_STDLIB_H 1
-
-/* Define to 1 if you have the `strcasecmp' function. */
-/* #undef HAVE_STRCASECMP */
-
-/* Define to 1 if you have the `strdup' function. */
-#define HAVE_STRDUP 1
-
-/* Define to 1 if you have the `strerror' function. */
-#define HAVE_STRERROR 1
-
-/* Define to 1 if you have the <strings.h> header file. */
-#define HAVE_STRINGS_H 1
-
-/* Define to 1 if you have the <string.h> header file. */
-#define HAVE_STRING_H 1
-
-/* Define to 1 if you have the `strtoul' function. */
-#define HAVE_STRTOUL 1
-
-/* Define to 1 if `st_blksize' is member of `struct stat'. */
-/* #undef HAVE_STRUCT_STAT_ST_BLKSIZE */
-
-/* Define to 1 if you have the `sysconf' function. */
-/* #undef HAVE_SYSCONF */
-
-/* Define to 1 if you have the <sys/dir.h> header file, and it defines `DIR'.
-   */
-/* #undef HAVE_SYS_DIR_H */
-
-/* Define to 1 if you have the <sys/ndir.h> header file, and it defines `DIR'.
-   */
-/* #undef HAVE_SYS_NDIR_H */
-
-/* Define to 1 if you have the <sys/select.h> header file. */
-/* #undef HAVE_SYS_SELECT_H */
-
-/* Define to 1 if you have the <sys/stat.h> header file. */
-#define HAVE_SYS_STAT_H 1
-
-/* Define to 1 if you have the <sys/time.h> header file. */
-/* #undef HAVE_SYS_TIME_H */
-
-/* Define to 1 if you have the <sys/types.h> header file. */
-#define HAVE_SYS_TYPES_H 1
-
-/* Define to 1 if you have the <unistd.h> header file. */
-/* #undef HAVE_UNISTD_H */
-
-/* Define to 1 if unlink of file with open file descriptors will fail. */
-/* #undef HAVE_UNLINK_WITH_OPEN_FAILURE */
-
-/* Define to 1 if you have the `vsnprintf' function. */
-#define HAVE_VSNPRINTF 1
-
-/* Define to 1 if building VxWorks. */
-/* #undef HAVE_VXWORKS */
-
-/* Define to 1 if you have the `yield' function. */
-/* #undef HAVE_YIELD */
-
-/* Define to 1 if you have the `_fstati64' function. */
-#define HAVE__FSTATI64 1
-
-/* Define to the address where bug reports for this package should be sent. */
-#define PACKAGE_BUGREPORT "support@sleepycat.com"
-
-/* Define to the full name of this package. */
-#define PACKAGE_NAME "Berkeley DB"
-
-/* Define to the full name and version of this package. */
-#define PACKAGE_STRING "Berkeley DB 4.1.24"
-
-/* Define to the one symbol short name of this package. */
-#define PACKAGE_TARNAME "db-4.1.24"
-
-/* Define to the version of this package. */
-#define PACKAGE_VERSION "4.1.24"
-
-/* Define to 1 if the `S_IS*' macros in <sys/stat.h> do not work properly. */
-/* #undef STAT_MACROS_BROKEN */
-
-/* Define to 1 if you have the ANSI C header files. */
-#define STDC_HEADERS 1
-
-/* Define to 1 if you can safely include both <sys/time.h> and <time.h>. */
-/* #undef TIME_WITH_SYS_TIME */
-
-/* Define to 1 to mask harmless unitialized memory read/writes. */
-/* #undef UMRW */
-
-/* Number of bits in a file offset, on hosts where this is settable. */
-/* #undef _FILE_OFFSET_BITS */
-
-/* Define for large files, on AIX-style hosts. */
-/* #undef _LARGE_FILES */
-
-/* Define to empty if `const' does not conform to ANSI C. */
-/* #undef const */
-
-/*
- * Exit success/failure macros.
- */
-#ifndef	HAVE_EXIT_SUCCESS
-#define	EXIT_FAILURE	1
-#define	EXIT_SUCCESS	0
-#endif
-
-/*
- * Don't step on the namespace.  Other libraries may have their own
- * implementations of these functions, we don't want to use their
- * implementations or force them to use ours based on the load order.
- */
-#ifndef	HAVE_GETCWD
-#define	getcwd		__db_Cgetcwd
-#endif
-#ifndef	HAVE_MEMCMP
-#define	memcmp		__db_Cmemcmp
-#endif
-#ifndef	HAVE_MEMCPY
-#define	memcpy		__db_Cmemcpy
-#endif
-#ifndef	HAVE_MEMMOVE
-#define	memmove		__db_Cmemmove
-#endif
-#ifndef	HAVE_RAISE
-#define	raise		__db_Craise
-#endif
-#ifndef	HAVE_SNPRINTF
-#define	snprintf	__db_Csnprintf
-#endif
-#ifndef	HAVE_STRCASECMP
-#define	strcasecmp	__db_Cstrcasecmp
-#define	strncasecmp	__db_Cstrncasecmp
-#endif
-#ifndef	HAVE_STRERROR
-#define	strerror	__db_Cstrerror
-#endif
-#ifndef	HAVE_VSNPRINTF
-#define	vsnprintf	__db_Cvsnprintf
-#endif
-
-/*
- * XXX
- * The following is not part of the automatic configuration setup, but
- * provides the information necessary to build Berkeley DB on Windows.
- */
-#include <sys/types.h>
-#include <sys/stat.h>
-
-#include <direct.h>
-#include <fcntl.h>
-#include <io.h>
-#include <limits.h>
-#include <memory.h>
-#include <process.h>
-#include <signal.h>
-#include <stdio.h>
-#include <stdlib.h>
-#include <time.h>
-#include <errno.h>
-
-/*
- * To build Tcl interface libraries, the include path must be configured to
- * use the directory containing <tcl.h>, usually the include directory in
- * the Tcl distribution.
- */
-#ifdef DB_TCL_SUPPORT
-#include <tcl.h>
-#endif
-
-#define	WIN32_LEAN_AND_MEAN
-#include <windows.h>
-
-/*
- * All of the necessary includes have been included, ignore the #includes
- * in the Berkeley DB source files.
- */
-#define	NO_SYSTEM_INCLUDES
-
-/*
- * Win32 has getcwd, snprintf and vsnprintf, but under different names.
- */
-#define	getcwd(buf, size)	_getcwd(buf, size)
-#define	snprintf		_snprintf
-#define	vsnprintf		_vsnprintf
-
-/*
- * Win32 does not define getopt and friends in any header file, so we must.
- */
-#if defined(__cplusplus)
-extern "C" {
-#endif
-extern int optind;
-extern char *optarg;
-extern int getopt(int, char * const *, const char *);
-#if defined(__cplusplus)
-}
-#endif
-
-/*
- * We use DB_WIN32 much as one would use _WIN32, to determine that we're
- * using an operating system environment that supports Win32 calls
- * and semantics.  We don't use _WIN32 because cygwin/gcc also defines
- * that, even though it closely emulates the Unix environment.
- */
-#define DB_WIN32 1
-
-/*
- * This is a grievous hack -- once we've included windows.h, we have no choice
- * but to use ANSI-style varargs (because it pulls in stdarg.h for us).  DB's
- * code decides which type of varargs to use based on the state of __STDC__.
- * Sensible.  Unfortunately, Microsoft's compiler _doesn't_ define __STDC__
- * unless you invoke it with arguments turning OFF all vendor extensions.  Even
- * more unfortunately, if we do that, it fails to parse windows.h!!!!!  So, we
- * define __STDC__ here, after windows.h comes in.  Note: the compiler knows
- * we've defined it, and starts enforcing strict ANSI compilance from this point
- * on.
- */
-#define __STDC__ 1
diff --git a/bdb/build_win32/db_cxx.h b/bdb/build_win32/db_cxx.h
deleted file mode 100644
index 1b72f310f824c83193d41918353ee9f72b8925a9..0000000000000000000000000000000000000000
--- a/bdb/build_win32/db_cxx.h
+++ /dev/null
@@ -1,796 +0,0 @@
-/* DO NOT EDIT: automatically built by dist/s_win32. */
-/*-
- * See the file LICENSE for redistribution information.
- *
- * Copyright (c) 1997-2002
- *	Sleepycat Software.  All rights reserved.
- *
- * $Id: db_cxx.in,v 11.113 2002/08/23 13:02:27 mjc Exp $
- */
-
-#ifndef _DB_CXX_H_
-#define	_DB_CXX_H_
-//
-// C++ assumptions:
-//
-// To ensure portability to many platforms, both new and old, we make
-// few assumptions about the C++ compiler and library.  For example,
-// we do not expect STL, templates or namespaces to be available.  The
-// "newest" C++ feature used is exceptions, which are used liberally
-// to transmit error information.  Even the use of exceptions can be
-// disabled at runtime, to do so, use the DB_CXX_NO_EXCEPTIONS flags
-// with the DbEnv or Db constructor.
-//
-// C++ naming conventions:
-//
-//  - All top level class names start with Db.
-//  - All class members start with lower case letter.
-//  - All private data members are suffixed with underscore.
-//  - Use underscores to divide names into multiple words.
-//  - Simple data accessors are named with get_ or set_ prefix.
-//  - All method names are taken from names of functions in the C
-//    layer of db (usually by dropping a prefix like "db_").
-//    These methods have the same argument types and order,
-//    other than dropping the explicit arg that acts as "this".
-//
-// As a rule, each DbFoo object has exactly one underlying DB_FOO struct
-// (defined in db.h) associated with it.  In some cases, we inherit directly
-// from the DB_FOO structure to make this relationship explicit.  Often,
-// the underlying C layer allocates and deallocates these structures, so
-// there is no easy way to add any data to the DbFoo class.  When you see
-// a comment about whether data is permitted to be added, this is what
-// is going on.  Of course, if we need to add data to such C++ classes
-// in the future, we will arrange to have an indirect pointer to the
-// DB_FOO struct (as some of the classes already have).
-//
-
-////////////////////////////////////////////////////////////////
-////////////////////////////////////////////////////////////////
-//
-// Forward declarations
-//
-
-#include <stdarg.h>
-
-#define	HAVE_CXX_STDHEADERS 1
-#ifdef HAVE_CXX_STDHEADERS
-#include <iostream>
-#define	__DB_OSTREAMCLASS	std::ostream
-#else
-#include <iostream.h>
-#define	__DB_OSTREAMCLASS	ostream
-#endif
-
-#include "db.h"
-#include "cxx_common.h"
-#include "cxx_except.h"
-
-class Db;                                        // forward
-class Dbc;                                       // forward
-class DbEnv;                                     // forward
-class DbInfo;                                    // forward
-class DbLock;                                    // forward
-class DbLogc;                                    // forward
-class DbLsn;                                     // forward
-class DbMpoolFile;                               // forward
-class DbPreplist;                                // forward
-class Dbt;                                       // forward
-class DbTxn;                                     // forward
-
-// These classes are not defined here and should be invisible
-// to the user, but some compilers require forward references.
-// There is one for each use of the DEFINE_DB_CLASS macro.
-
-class DbImp;
-class DbEnvImp;
-class DbMpoolFileImp;
-class DbTxnImp;
-
-// DEFINE_DB_CLASS defines an imp_ data member and imp() accessor.
-// The underlying type is a pointer to an opaque *Imp class, that
-// gets converted to the correct implementation class by the implementation.
-//
-// Since these defines use "private/public" labels, and leave the access
-// being "private", we always use these by convention before any data
-// members in the private section of a class.  Keeping them in the
-// private section also emphasizes that they are off limits to user code.
-//
-#define	DEFINE_DB_CLASS(name) \
-	public: class name##Imp* imp() { return (imp_); } \
-	public: const class name##Imp* constimp() const { return (imp_); } \
-	private: class name##Imp* imp_
-
-////////////////////////////////////////////////////////////////
-////////////////////////////////////////////////////////////////
-//
-// Turn off inappropriate compiler warnings
-//
-
-#ifdef _MSC_VER
-
-// These are level 4 warnings that are explicitly disabled.
-// With Visual C++, by default you do not see above level 3 unless
-// you use /W4.  But we like to compile with the highest level
-// warnings to catch other errors.
-//
-// 4201: nameless struct/union
-//       triggered by standard include file <winnt.h>
-//
-// 4514: unreferenced inline function has been removed
-//       certain include files in MSVC define methods that are not called
-//
-#pragma warning(disable: 4201 4514)
-
-#endif
-
-// Some interfaces can be customized by allowing users to define
-// callback functions.  For performance and logistical reasons, some
-// callback functions must be declared in extern "C" blocks.  For others,
-// we allow you to declare the callbacks in C++ or C (or an extern "C"
-// block) as you wish.  See the set methods for the callbacks for
-// the choices.
-//
-extern "C" {
-	typedef void * (*db_malloc_fcn_type)
-		(size_t);
-	typedef void * (*db_realloc_fcn_type)
-		(void *, size_t);
-	typedef void (*db_free_fcn_type)
-		(void *);
-	typedef int (*bt_compare_fcn_type)          /*C++ version available*/
-		(DB *, const DBT *, const DBT *);
-	typedef size_t (*bt_prefix_fcn_type)        /*C++ version available*/
-		(DB *, const DBT *, const DBT *);
-	typedef int (*dup_compare_fcn_type)         /*C++ version available*/
-		(DB *, const DBT *, const DBT *);
-	typedef u_int32_t (*h_hash_fcn_type)        /*C++ version available*/
-		(DB *, const void *, u_int32_t);
-	typedef int (*pgin_fcn_type)
-		(DB_ENV *dbenv, db_pgno_t pgno, void *pgaddr, DBT *pgcookie);
-	typedef int (*pgout_fcn_type)
-		(DB_ENV *dbenv, db_pgno_t pgno, void *pgaddr, DBT *pgcookie);
-};
-
-////////////////////////////////////////////////////////////////
-////////////////////////////////////////////////////////////////
-//
-// Lock classes
-//
-
-class _exported DbLock
-{
-	friend class DbEnv;
-
-public:
-	DbLock();
-	DbLock(const DbLock &);
-	DbLock &operator = (const DbLock &);
-
-protected:
-	// We can add data to this class if needed
-	// since its contained class is not allocated by db.
-	// (see comment at top)
-
-	DbLock(DB_LOCK);
-	DB_LOCK lock_;
-};
-
-////////////////////////////////////////////////////////////////
-////////////////////////////////////////////////////////////////
-//
-// Log classes
-//
-
-class _exported DbLsn : protected DB_LSN
-{
-	friend class DbEnv;          // friendship needed to cast to base class
-	friend class DbLogc;         // friendship needed to cast to base class
-};
-
-////////////////////////////////////////////////////////////////
-////////////////////////////////////////////////////////////////
-//
-// Memory pool classes
-//
-
-class _exported DbMpoolFile
-{
-	friend class DbEnv;
-
-private:
-	// Put this first to allow inlining with some C++ compilers (g++-2.95)
-	DEFINE_DB_CLASS(DbMpoolFile);
-
-public:
-	int close(u_int32_t flags);
-	int get(db_pgno_t *pgnoaddr, u_int32_t flags, void *pagep);
-	void last_pgno(db_pgno_t *pgnoaddr);
-	int open(const char *file, u_int32_t flags, int mode, size_t pagesize);
-	int put(void *pgaddr, u_int32_t flags);
-	void refcnt(db_pgno_t *pgnoaddr);
-	int set(void *pgaddr, u_int32_t flags);
-	int set_clear_len(u_int32_t len);
-	int set_fileid(u_int8_t *fileid);
-	int set_ftype(int ftype);
-	int set_lsn_offset(int32_t offset);
-	int set_pgcookie(DBT *dbt);
-	void set_unlink(int);
-	int sync();
-
-	virtual DB_MPOOLFILE *get_DB_MPOOLFILE()
-	{
-		return (DB_MPOOLFILE *)imp();
-	}
-
-	virtual const DB_MPOOLFILE *get_const_DB_MPOOLFILE() const
-	{
-		return (const DB_MPOOLFILE *)constimp();
-	}
-
-private:
-	// We can add data to this class if needed
-	// since it is implemented via a pointer.
-	// (see comment at top)
-
-	// Note: use DbEnv::memp_fcreate() to get pointers to a DbMpoolFile,
-	// and call DbMpoolFile::close() rather than delete to release them.
-	//
-	DbMpoolFile();
-
-	// Shut g++ up.
-protected:
-	virtual ~DbMpoolFile();
-
-private:
-	// no copying
-	DbMpoolFile(const DbMpoolFile &);
-	void operator = (const DbMpoolFile &);
-};
-
-////////////////////////////////////////////////////////////////
-////////////////////////////////////////////////////////////////
-//
-// This is filled in and returned by the DbEnv::txn_recover() method.
-//
-
-class _exported DbPreplist
-{
-public:
-	DbTxn *txn;
-	u_int8_t gid[DB_XIDDATASIZE];
-};
-
-////////////////////////////////////////////////////////////////
-////////////////////////////////////////////////////////////////
-//
-// Transaction classes
-//
-
-class _exported DbTxn
-{
-	friend class DbEnv;
-
-private:
-	// Put this first to allow inlining with some C++ compilers (g++-2.95)
-	DEFINE_DB_CLASS(DbTxn);
-
-public:
-	int abort();
-	int commit(u_int32_t flags);
-	int discard(u_int32_t flags);
-	u_int32_t id();
-	int prepare(u_int8_t *gid);
-	int set_timeout(db_timeout_t timeout, u_int32_t flags);
-
-	virtual DB_TXN *get_DB_TXN()
-	{
-		return (DB_TXN *)imp();
-	}
-
-	virtual const DB_TXN *get_const_DB_TXN() const
-	{
-		return (const DB_TXN *)constimp();
-	}
-
-	static DbTxn* get_DbTxn(DB_TXN *txn)
-	{
-		return (DbTxn *)txn->api_internal;
-	}
-
-	static const DbTxn* get_const_DbTxn(const DB_TXN *txn)
-	{
-		return (const DbTxn *)txn->api_internal;
-	}
-
-	// For internal use only.
-	static DbTxn* wrap_DB_TXN(DB_TXN *txn);
-
-private:
-	// We can add data to this class if needed
-	// since it is implemented via a pointer.
-	// (see comment at top)
-
-	// Note: use DbEnv::txn_begin() to get pointers to a DbTxn,
-	// and call DbTxn::abort() or DbTxn::commit rather than
-	// delete to release them.
-	//
-	DbTxn();
-	// For internal use only.
-	DbTxn(DB_TXN *txn);
-	virtual ~DbTxn();
-
-	// no copying
-	DbTxn(const DbTxn &);
-	void operator = (const DbTxn &);
-};
-
-//
-// Berkeley DB environment class.  Provides functions for opening databases.
-// User of this library can use this class as a starting point for
-// developing a DB application - derive their application class from
-// this one, add application control logic.
-//
-// Note that if you use the default constructor, you must explicitly
-// call appinit() before any other db activity (e.g. opening files)
-//
-class _exported DbEnv
-{
-	friend class Db;
-	friend class DbLock;
-	friend class DbMpoolFile;
-
-private:
-	// Put this first to allow inlining with some C++ compilers (g++-2.95)
-	DEFINE_DB_CLASS(DbEnv);
-
-public:
-	// After using this constructor, you can set any needed
-	// parameters for the environment using the set_* methods.
-	// Then call open() to finish initializing the environment
-	// and attaching it to underlying files.
-	//
-	DbEnv(u_int32_t flags);
-
-	virtual ~DbEnv();
-
-	// These methods match those in the C interface.
-	//
-	virtual int close(u_int32_t);
-	virtual int dbremove(DbTxn *txn, const char *name, const char *subdb,
-	    u_int32_t flags);
-	virtual int dbrename(DbTxn *txn, const char *name, const char *subdb,
-	    const char *newname, u_int32_t flags);
-	virtual void err(int, const char *, ...);
-	virtual void errx(const char *, ...);
-	virtual void *get_app_private() const;
-	virtual int open(const char *, u_int32_t, int);
-	virtual int remove(const char *, u_int32_t);
-	virtual int set_alloc(db_malloc_fcn_type, db_realloc_fcn_type,
-		      db_free_fcn_type);
-	virtual void set_app_private(void *);
-	virtual int set_cachesize(u_int32_t, u_int32_t, int);
-	virtual int set_data_dir(const char *);
-	virtual int set_encrypt(const char *, int);
-	virtual void set_errcall(void (*)(const char *, char *));
-	virtual void set_errfile(FILE *);
-	virtual void set_errpfx(const char *);
-	virtual int set_flags(u_int32_t, int);
-	virtual int set_feedback(void (*)(DbEnv *, int, int));
-	virtual int set_lg_bsize(u_int32_t);
-	virtual int set_lg_dir(const char *);
-	virtual int set_lg_max(u_int32_t);
-	virtual int set_lg_regionmax(u_int32_t);
-	virtual int set_lk_conflicts(u_int8_t *, int);
-	virtual int set_lk_detect(u_int32_t);
-	virtual int set_lk_max(u_int32_t);
-	virtual int set_lk_max_lockers(u_int32_t);
-	virtual int set_lk_max_locks(u_int32_t);
-	virtual int set_lk_max_objects(u_int32_t);
-	virtual int set_mp_mmapsize(size_t);
-	virtual int set_paniccall(void (*)(DbEnv *, int));
-	virtual int set_rpc_server(void *, char *, long, long, u_int32_t);
-	virtual int set_shm_key(long);
-	virtual int set_timeout(db_timeout_t timeout, u_int32_t flags);
-	virtual int set_tmp_dir(const char *);
-	virtual int set_tas_spins(u_int32_t);
-	virtual int set_tx_max(u_int32_t);
-	virtual int set_app_dispatch(int (*)(DbEnv *,
-	    Dbt *, DbLsn *, db_recops));
-	virtual int set_tx_timestamp(time_t *);
-	virtual int set_verbose(u_int32_t which, int onoff);
-
-	// Version information.  A static method so it can be obtained anytime.
-	//
-	static char *version(int *major, int *minor, int *patch);
-
-	// Convert DB errors to strings
-	static char *strerror(int);
-
-	// If an error is detected and the error call function
-	// or stream is set, a message is dispatched or printed.
-	// If a prefix is set, each message is prefixed.
-	//
-	// You can use set_errcall() or set_errfile() above to control
-	// error functionality.  Alternatively, you can call
-	// set_error_stream() to force all errors to a C++ stream.
-	// It is unwise to mix these approaches.
-	//
-	virtual void set_error_stream(__DB_OSTREAMCLASS *);
-
-	// used internally
-	static void runtime_error(const char *caller, int err,
-				  int error_policy);
-	static void runtime_error_dbt(const char *caller, Dbt *dbt,
-				  int error_policy);
-	static void runtime_error_lock_get(const char *caller, int err,
-				  db_lockop_t op, db_lockmode_t mode,
-				  const Dbt *obj, DbLock lock, int index,
-				  int error_policy);
-
-	// Lock functions
-	//
-	virtual int lock_detect(u_int32_t flags, u_int32_t atype, int *aborted);
-	virtual int lock_get(u_int32_t locker, u_int32_t flags, const Dbt *obj,
-		     db_lockmode_t lock_mode, DbLock *lock);
-	virtual int lock_id(u_int32_t *idp);
-	virtual int lock_id_free(u_int32_t id);
-	virtual int lock_put(DbLock *lock);
-	virtual int lock_stat(DB_LOCK_STAT **statp, u_int32_t flags);
-	virtual int lock_vec(u_int32_t locker, u_int32_t flags, DB_LOCKREQ list[],
-		     int nlist, DB_LOCKREQ **elistp);
-
-	// Log functions
-	//
-	virtual int log_archive(char **list[], u_int32_t flags);
-	static int log_compare(const DbLsn *lsn0, const DbLsn *lsn1);
-	virtual int log_cursor(DbLogc **cursorp, u_int32_t flags);
-	virtual int log_file(DbLsn *lsn, char *namep, size_t len);
-	virtual int log_flush(const DbLsn *lsn);
-	virtual int log_put(DbLsn *lsn, const Dbt *data, u_int32_t flags);
-
-	virtual int log_stat(DB_LOG_STAT **spp, u_int32_t flags);
-
-	// Mpool functions
-	//
-	virtual int memp_fcreate(DbMpoolFile **dbmfp, u_int32_t flags);
-	virtual int memp_register(int ftype,
-			  pgin_fcn_type pgin_fcn,
-			  pgout_fcn_type pgout_fcn);
-	virtual int memp_stat(DB_MPOOL_STAT
-		      **gsp, DB_MPOOL_FSTAT ***fsp, u_int32_t flags);
-	virtual int memp_sync(DbLsn *lsn);
-	virtual int memp_trickle(int pct, int *nwrotep);
-
-	// Transaction functions
-	//
-	virtual int txn_begin(DbTxn *pid, DbTxn **tid, u_int32_t flags);
-	virtual int txn_checkpoint(u_int32_t kbyte, u_int32_t min, u_int32_t flags);
-	virtual int txn_recover(DbPreplist *preplist, long count,
-			long *retp, u_int32_t flags);
-	virtual int txn_stat(DB_TXN_STAT **statp, u_int32_t flags);
-
-	// Replication functions
-	//
-	virtual int rep_elect(int, int, u_int32_t, int *);
-	virtual int rep_process_message(Dbt *, Dbt *, int *);
-	virtual int rep_start(Dbt *, u_int32_t);
-	virtual int rep_stat(DB_REP_STAT **statp, u_int32_t flags);
-	virtual int set_rep_limit(u_int32_t, u_int32_t);
-	virtual int set_rep_transport(u_int32_t,
-	    int (*)(DbEnv *, const Dbt *, const Dbt *, int, u_int32_t));
-
-	// Conversion functions
-	//
-	virtual DB_ENV *get_DB_ENV()
-	{
-		return (DB_ENV *)imp();
-	}
-
-	virtual const DB_ENV *get_const_DB_ENV() const
-	{
-		return (const DB_ENV *)constimp();
-	}
-
-	static DbEnv* get_DbEnv(DB_ENV *dbenv)
-	{
-		return (DbEnv *)dbenv->api1_internal;
-	}
-
-	static const DbEnv* get_const_DbEnv(const DB_ENV *dbenv)
-	{
-		return (const DbEnv *)dbenv->api1_internal;
-	}
-
-	// For internal use only.
-	static DbEnv* wrap_DB_ENV(DB_ENV *dbenv);
-
-	// These are public only because they need to be called
-	// via C functions.  They should never be called by users
-	// of this class.
-	//
-	static void _stream_error_function(const char *, char *);
-	static int _app_dispatch_intercept(DB_ENV *env, DBT *dbt, DB_LSN *lsn,
-					db_recops op);
-	static void _paniccall_intercept(DB_ENV *env, int errval);
-	static void _feedback_intercept(DB_ENV *env, int opcode, int pct);
-	static int _rep_send_intercept(DB_ENV *env,
-				       const DBT *cntrl, const DBT *data,
-				       int id, u_int32_t flags);
-
-private:
-	void cleanup();
-	int initialize(DB_ENV *env);
-	int error_policy();
-
-	// For internal use only.
-	DbEnv(DB_ENV *, u_int32_t flags);
-
-	// no copying
-	DbEnv(const DbEnv &);
-	void operator = (const DbEnv &);
-
-	// instance data
-	int construct_error_;
-	u_int32_t construct_flags_;
-	int (*app_dispatch_callback_)(DbEnv *, Dbt *, DbLsn *, db_recops);
-	void (*feedback_callback_)(DbEnv *, int, int);
-	void (*paniccall_callback_)(DbEnv *, int);
-	int (*pgin_callback_)(DbEnv *dbenv, db_pgno_t pgno,
-			      void *pgaddr, Dbt *pgcookie);
-	int (*pgout_callback_)(DbEnv *dbenv, db_pgno_t pgno,
-			       void *pgaddr, Dbt *pgcookie);
-	int (*rep_send_callback_)(DbEnv *,
-	    const Dbt *, const Dbt *, int, u_int32_t);
-
-	// class data
-	static __DB_OSTREAMCLASS *error_stream_;
-};
-
-////////////////////////////////////////////////////////////////
-////////////////////////////////////////////////////////////////
-//
-// Table access classes
-//
-
-//
-// Represents a database table = a set of keys with associated values.
-//
-class _exported Db
-{
-	friend class DbEnv;
-
-private:
-	// Put this first to allow inlining with some C++ compilers (g++-2.95)
-	DEFINE_DB_CLASS(Db);
-
-public:
-	Db(DbEnv*, u_int32_t);      // create a Db object, then call open()
-	virtual ~Db();              // does *not* call close.
-
-	// These methods exactly match those in the C interface.
-	//
-	virtual int associate(DbTxn *txn, Db *secondary,
-	    int (*callback)(Db *, const Dbt *, const Dbt *, Dbt *),
-	    u_int32_t flags);
-	virtual int close(u_int32_t flags);
-        virtual int cursor(DbTxn *txnid, Dbc **cursorp, u_int32_t flags);
-	virtual int del(DbTxn *txnid, Dbt *key, u_int32_t flags);
-	virtual void err(int, const char *, ...);
-	virtual void errx(const char *, ...);
-	virtual int fd(int *fdp);
-	virtual int get(DbTxn *txnid, Dbt *key, Dbt *data, u_int32_t flags);
-	virtual void *get_app_private() const;
-	virtual int get_byteswapped(int *);
-	virtual int get_type(DBTYPE *);
-	virtual int join(Dbc **curslist, Dbc **dbcp, u_int32_t flags);
-	virtual int key_range(DbTxn *, Dbt *, DB_KEY_RANGE *, u_int32_t);
-	virtual int open(DbTxn *txnid,
-	    const char *, const char *subname, DBTYPE, u_int32_t, int);
-	virtual int pget(DbTxn *txnid, Dbt *key, Dbt *pkey, Dbt *data,
-		 u_int32_t flags);
-	virtual int put(DbTxn *, Dbt *, Dbt *, u_int32_t);
-	virtual int remove(const char *, const char *, u_int32_t);
-	virtual int rename(const char *, const char *, const char *, u_int32_t);
-	virtual int set_alloc(db_malloc_fcn_type, db_realloc_fcn_type,
-		      db_free_fcn_type);
-	virtual void set_app_private(void *);
-	virtual int set_append_recno(int (*)(Db *, Dbt *, db_recno_t));
-	virtual int set_bt_compare(bt_compare_fcn_type); /*deprecated*/
-	virtual int set_bt_compare(int (*)(Db *, const Dbt *, const Dbt *));
-	virtual int set_bt_maxkey(u_int32_t);
-	virtual int set_bt_minkey(u_int32_t);
-	virtual int set_bt_prefix(bt_prefix_fcn_type); /*deprecated*/
-	virtual int set_bt_prefix(size_t (*)(Db *, const Dbt *, const Dbt *));
-	virtual int set_cachesize(u_int32_t, u_int32_t, int);
-	virtual int set_cache_priority(DB_CACHE_PRIORITY);
-	virtual int set_dup_compare(dup_compare_fcn_type); /*deprecated*/
-	virtual int set_dup_compare(int (*)(Db *, const Dbt *, const Dbt *));
-	virtual int set_encrypt(const char *, int);
-	virtual void set_errcall(void (*)(const char *, char *));
-	virtual void set_errfile(FILE *);
-	virtual void set_errpfx(const char *);
-	virtual int set_feedback(void (*)(Db *, int, int));
-	virtual int set_flags(u_int32_t);
-	virtual int set_h_ffactor(u_int32_t);
-	virtual int set_h_hash(h_hash_fcn_type); /*deprecated*/
-	virtual int set_h_hash(u_int32_t (*)(Db *, const void *, u_int32_t));
-	virtual int set_h_nelem(u_int32_t);
-	virtual int set_lorder(int);
-	virtual int set_pagesize(u_int32_t);
-	virtual int set_paniccall(void (*)(DbEnv *, int));
-	virtual int set_re_delim(int);
-	virtual int set_re_len(u_int32_t);
-	virtual int set_re_pad(int);
-	virtual int set_re_source(char *);
-	virtual int set_q_extentsize(u_int32_t);
-	virtual int stat(void *sp, u_int32_t flags);
-	virtual int sync(u_int32_t flags);
-	virtual int truncate(DbTxn *, u_int32_t *, u_int32_t);
-	virtual int upgrade(const char *name, u_int32_t flags);
-	virtual int verify(const char *, const char *, __DB_OSTREAMCLASS *, u_int32_t);
-
-	// These additional methods are not in the C interface, and
-	// are only available for C++.
-	//
-	virtual void set_error_stream(__DB_OSTREAMCLASS *);
-
-	virtual DB *get_DB()
-	{
-		return (DB *)imp();
-	}
-
-	virtual const DB *get_const_DB() const
-	{
-		return (const DB *)constimp();
-	}
-
-	static Db* get_Db(DB *db)
-	{
-		return (Db *)db->api_internal;
-	}
-
-	static const Db* get_const_Db(const DB *db)
-	{
-		return (const Db *)db->api_internal;
-	}
-
-private:
-	// no copying
-	Db(const Db &);
-	Db &operator = (const Db &);
-
-	void cleanup();
-	int initialize();
-	int error_policy();
-
-	// instance data
-	DbEnv *env_;
-	int construct_error_;
-	u_int32_t flags_;
-	u_int32_t construct_flags_;
-
-public:
-	// These are public only because they need to be called
-	// via C callback functions.  They should never be used by
-	// external users of this class.
-	//
-	int (*append_recno_callback_)(Db *, Dbt *, db_recno_t);
-	int (*associate_callback_)(Db *, const Dbt *, const Dbt *, Dbt *);
-	int (*bt_compare_callback_)(Db *, const Dbt *, const Dbt *);
-	size_t (*bt_prefix_callback_)(Db *, const Dbt *, const Dbt *);
-	int (*dup_compare_callback_)(Db *, const Dbt *, const Dbt *);
-	void (*feedback_callback_)(Db *, int, int);
-	u_int32_t (*h_hash_callback_)(Db *, const void *, u_int32_t);
-};
-
-//
-// A chunk of data, maybe a key or value.
-//
-class _exported Dbt : private DBT
-{
-	friend class Dbc;
-	friend class Db;
-	friend class DbEnv;
-	friend class DbLogc;
-
-public:
-
-	// key/data
-	void *get_data() const                 { return data; }
-	void set_data(void *value)             { data = value; }
-
-	// key/data length
-	u_int32_t get_size() const             { return size; }
-	void set_size(u_int32_t value)         { size = value; }
-
-	// RO: length of user buffer.
-	u_int32_t get_ulen() const             { return ulen; }
-	void set_ulen(u_int32_t value)         { ulen = value; }
-
-	// RO: get/put record length.
-	u_int32_t get_dlen() const             { return dlen; }
-	void set_dlen(u_int32_t value)         { dlen = value; }
-
-	// RO: get/put record offset.
-	u_int32_t get_doff() const             { return doff; }
-	void set_doff(u_int32_t value)         { doff = value; }
-
-	// flags
-	u_int32_t get_flags() const            { return flags; }
-	void set_flags(u_int32_t value)        { flags = value; }
-
-	// Conversion functions
-	DBT *get_DBT()                         { return (DBT *)this; }
-	const DBT *get_const_DBT() const       { return (const DBT *)this; }
-
-	static Dbt* get_Dbt(DBT *dbt)          { return (Dbt *)dbt; }
-	static const Dbt* get_const_Dbt(const DBT *dbt)
-					       { return (const Dbt *)dbt; }
-
-	Dbt(void *data, u_int32_t size);
-	Dbt();
-	~Dbt();
-	Dbt(const Dbt &);
-	Dbt &operator = (const Dbt &);
-
-private:
-	// Note: no extra data appears in this class (other than
-	// inherited from DBT) since we need DBT and Dbt objects
-	// to have interchangable pointers.
-	//
-	// When subclassing this class, remember that callback
-	// methods like bt_compare, bt_prefix, dup_compare may
-	// internally manufacture DBT objects (which later are
-	// cast to Dbt), so such callbacks might receive objects
-	// not of your subclassed type.
-};
-
-class _exported Dbc : protected DBC
-{
-	friend class Db;
-
-public:
-	int close();
-	int count(db_recno_t *countp, u_int32_t flags);
-	int del(u_int32_t flags);
-	int dup(Dbc** cursorp, u_int32_t flags);
-	int get(Dbt* key, Dbt *data, u_int32_t flags);
-	int pget(Dbt* key, Dbt* pkey, Dbt *data, u_int32_t flags);
-	int put(Dbt* key, Dbt *data, u_int32_t flags);
-
-private:
-	// No data is permitted in this class (see comment at top)
-
-	// Note: use Db::cursor() to get pointers to a Dbc,
-	// and call Dbc::close() rather than delete to release them.
-	//
-	Dbc();
-	~Dbc();
-
-	// no copying
-	Dbc(const Dbc &);
-	Dbc &operator = (const Dbc &);
-};
-
-class _exported DbLogc : protected DB_LOGC
-{
-	friend class DbEnv;
-
-public:
-	int close(u_int32_t _flags);
-	int get(DbLsn *lsn, Dbt *data, u_int32_t _flags);
-
-private:
-	// No data is permitted in this class (see comment at top)
-
-	// Note: use Db::cursor() to get pointers to a Dbc,
-	// and call Dbc::close() rather than delete to release them.
-	//
-	DbLogc();
-	~DbLogc();
-
-	// no copying
-	DbLogc(const Dbc &);
-	DbLogc &operator = (const Dbc &);
-};
-#endif /* !_DB_CXX_H_ */
diff --git a/bdb/build_win32/db_perf.dsp b/bdb/build_win32/db_perf.dsp
deleted file mode 100644
index 21b79ed9e19c53dcd30d762a4d6a8b8f8e3f3aeb..0000000000000000000000000000000000000000
--- a/bdb/build_win32/db_perf.dsp
+++ /dev/null
@@ -1,216 +0,0 @@
-# Microsoft Developer Studio Project File - Name="db_perf" - Package Owner=<4>
-# Microsoft Developer Studio Generated Build File, Format Version 6.00
-# ** DO NOT EDIT **
-
-# TARGTYPE "Win32 (x86) Console Application" 0x0103
-
-CFG=db_perf - Win32 Debug Static
-!MESSAGE This is not a valid makefile. To build this project using NMAKE,
-!MESSAGE use the Export Makefile command and run
-!MESSAGE 
-!MESSAGE NMAKE /f "db_perf.mak".
-!MESSAGE 
-!MESSAGE You can specify a configuration when running NMAKE
-!MESSAGE by defining the macro CFG on the command line. For example:
-!MESSAGE 
-!MESSAGE NMAKE /f "db_perf.mak" CFG="db_perf - Win32 Debug Static"
-!MESSAGE 
-!MESSAGE Possible choices for configuration are:
-!MESSAGE 
-!MESSAGE "db_perf - Win32 Release" (based on "Win32 (x86) Console Application")
-!MESSAGE "db_perf - Win32 Debug" (based on "Win32 (x86) Console Application")
-!MESSAGE "db_perf - Win32 Release Static" (based on "Win32 (x86) Console Application")
-!MESSAGE "db_perf - Win32 Debug Static" (based on "Win32 (x86) Console Application")
-!MESSAGE 
-
-# Begin Project
-# PROP AllowPerConfigDependencies 0
-# PROP Scc_ProjName ""
-# PROP Scc_LocalPath ""
-CPP=cl.exe
-RSC=rc.exe
-
-!IF  "$(CFG)" == "db_perf - Win32 Release"
-
-# PROP BASE Use_MFC 0
-# PROP BASE Use_Debug_Libraries 0
-# PROP BASE Output_Dir "Release"
-# PROP BASE Intermediate_Dir "Release"
-# PROP BASE Target_Dir ""
-# PROP Use_MFC 0
-# PROP Use_Debug_Libraries 0
-# PROP Output_Dir "Release"
-# PROP Intermediate_Dir "Release"
-# PROP Ignore_Export_Lib 0
-# PROP Target_Dir ""
-# ADD BASE CPP /nologo /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /c
-# ADD CPP /nologo /MD /W3 /GX /O2 /I "." /I ".." /I "../dbinc" /D "WIN32" /D "NDEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /c
-# ADD BASE RSC /l 0x409 /d "NDEBUG"
-# ADD RSC /l 0x409 /d "NDEBUG"
-BSC32=bscmake.exe
-# ADD BASE BSC32 /nologo
-# ADD BSC32 /nologo
-LINK32=link.exe
-# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /machine:I386
-# ADD LINK32 Release/libdb41.lib /nologo /subsystem:console /machine:I386 /nodefaultlib:"libcmt"
-
-!ELSEIF  "$(CFG)" == "db_perf - Win32 Debug"
-
-# PROP BASE Use_MFC 0
-# PROP BASE Use_Debug_Libraries 1
-# PROP BASE Output_Dir "Debug"
-# PROP BASE Intermediate_Dir "Debug"
-# PROP BASE Target_Dir ""
-# PROP Use_MFC 0
-# PROP Use_Debug_Libraries 1
-# PROP Output_Dir "Debug"
-# PROP Intermediate_Dir "Debug"
-# PROP Ignore_Export_Lib 0
-# PROP Target_Dir ""
-# ADD BASE CPP /nologo /W3 /Gm /GX /Zi /Od /D "WIN32" /D "_DEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /c
-# ADD CPP /nologo /MDd /W3 /GX /Z7 /Od /I "." /I ".." /I "../dbinc" /D "WIN32" /D "_DEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /c
-# ADD BASE RSC /l 0x409 /d "_DEBUG"
-# ADD RSC /l 0x409 /d "_DEBUG"
-BSC32=bscmake.exe
-# ADD BASE BSC32 /nologo
-# ADD BSC32 /nologo
-LINK32=link.exe
-# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /debug /machine:I386 /pdbtype:sept
-# ADD LINK32 Debug/libdb41d.lib /nologo /subsystem:console /pdb:none /debug /machine:I386 /nodefaultlib:"libcmtd" /fixed:no
-
-!ELSEIF  "$(CFG)" == "db_perf - Win32 Release Static"
-
-# PROP BASE Use_MFC 0
-# PROP BASE Use_Debug_Libraries 0
-# PROP BASE Output_Dir "Release"
-# PROP BASE Intermediate_Dir "Release"
-# PROP BASE Ignore_Export_Lib 0
-# PROP BASE Target_Dir ""
-# PROP Use_MFC 0
-# PROP Use_Debug_Libraries 0
-# PROP Output_Dir "Release_static"
-# PROP Intermediate_Dir "Release_static"
-# PROP Ignore_Export_Lib 0
-# PROP Target_Dir ""
-# ADD BASE CPP /nologo /MD /W3 /GX /O2 /I "." /I ".." /I "../dbinc" /D "WIN32" /D "NDEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /c
-# ADD CPP /nologo /MT /W3 /GX /O2 /I "." /I ".." /I "../dbinc" /D "WIN32" /D "NDEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /c
-# ADD BASE RSC /l 0x409 /d "NDEBUG"
-# ADD RSC /l 0x409 /d "NDEBUG"
-BSC32=bscmake.exe
-# ADD BASE BSC32 /nologo
-# ADD BSC32 /nologo
-LINK32=link.exe
-# ADD BASE LINK32 Release_static/libdb41.lib /nologo /subsystem:console /machine:I386
-# ADD LINK32 Release_static/libdb41s.lib /nologo /subsystem:console /machine:I386
-
-!ELSEIF  "$(CFG)" == "db_perf - Win32 Debug Static"
-
-# PROP BASE Use_MFC 0
-# PROP BASE Use_Debug_Libraries 1
-# PROP BASE Output_Dir "Debug"
-# PROP BASE Intermediate_Dir "Debug"
-# PROP BASE Ignore_Export_Lib 0
-# PROP BASE Target_Dir ""
-# PROP Use_MFC 0
-# PROP Use_Debug_Libraries 1
-# PROP Output_Dir "Debug_static"
-# PROP Intermediate_Dir "Debug_static"
-# PROP Ignore_Export_Lib 0
-# PROP Target_Dir ""
-# ADD BASE CPP /nologo /MDd /W3 /GX /Z7 /Od /I "." /I ".." /I "../dbinc" /D "WIN32" /D "_DEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /c
-# ADD CPP /nologo /MTd /W3 /GX /Z7 /Od /I "." /I ".." /I "../dbinc" /D "WIN32" /D "_DEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /c
-# ADD BASE RSC /l 0x409 /d "_DEBUG"
-# ADD RSC /l 0x409 /d "_DEBUG"
-BSC32=bscmake.exe
-# ADD BASE BSC32 /nologo
-# ADD BSC32 /nologo
-LINK32=link.exe
-# ADD BASE LINK32 Debug_static/libdb41d.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /pdb:none /debug /machine:I386 /fixed:no
-# ADD LINK32 Debug_static/libdb41sd.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /pdb:none /debug /machine:I386 /fixed:no
-
-!ENDIF 
-
-# Begin Target
-
-# Name "db_perf - Win32 Release"
-# Name "db_perf - Win32 Debug"
-# Name "db_perf - Win32 Release Static"
-# Name "db_perf - Win32 Debug Static"
-# Begin Source File
-
-SOURCE=..\test_perf\db_perf.c
-# End Source File
-# Begin Source File
-
-SOURCE=..\test_perf\perf_cache_check.c
-# End Source File
-# Begin Source File
-
-SOURCE=..\test_perf\perf_checkpoint.c
-# End Source File
-# Begin Source File
-
-SOURCE=..\test_perf\perf_config.c
-# End Source File
-# Begin Source File
-
-SOURCE=..\test_perf\perf_dbs.c
-# End Source File
-# Begin Source File
-
-SOURCE=..\test_perf\perf_debug.c
-# End Source File
-# Begin Source File
-
-SOURCE=..\test_perf\perf_file.c
-# End Source File
-# Begin Source File
-
-SOURCE=..\test_perf\perf_key.c
-# End Source File
-# Begin Source File
-
-SOURCE=..\test_perf\perf_log.c
-# End Source File
-# Begin Source File
-
-SOURCE=..\test_perf\perf_misc.c
-# End Source File
-# Begin Source File
-
-SOURCE=..\test_perf\perf_op.c
-# End Source File
-# Begin Source File
-
-SOURCE=..\test_perf\perf_parse.c
-# End Source File
-# Begin Source File
-
-SOURCE=..\test_perf\perf_rand.c
-# End Source File
-# Begin Source File
-
-SOURCE=..\test_perf\perf_spawn.c
-# End Source File
-# Begin Source File
-
-SOURCE=..\test_perf\perf_thread.c
-# End Source File
-# Begin Source File
-
-SOURCE=..\test_perf\perf_trickle.c
-# End Source File
-# Begin Source File
-
-SOURCE=..\test_perf\perf_txn.c
-# End Source File
-# Begin Source File
-
-SOURCE=..\test_perf\perf_util.c
-# End Source File
-# Begin Source File
-
-SOURCE=..\clib\getopt.c
-# End Source File
-# End Target
-# End Project
diff --git a/bdb/build_win32/db_test.dsp b/bdb/build_win32/db_test.dsp
deleted file mode 100644
index f014aa95bcf8bf4e962c41f167c97378dabc55a3..0000000000000000000000000000000000000000
--- a/bdb/build_win32/db_test.dsp
+++ /dev/null
@@ -1,100 +0,0 @@
-# Microsoft Developer Studio Project File - Name="db_test" - Package Owner=<4>
-# Microsoft Developer Studio Generated Build File, Format Version 6.00
-# ** DO NOT EDIT **
-
-# TARGTYPE "Win32 (x86) Console Application" 0x0103
-
-CFG=db_test - Win32 Debug
-!MESSAGE This is not a valid makefile. To build this project using NMAKE,
-!MESSAGE use the Export Makefile command and run
-!MESSAGE 
-!MESSAGE NMAKE /f "db_test.mak".
-!MESSAGE 
-!MESSAGE You can specify a configuration when running NMAKE
-!MESSAGE by defining the macro CFG on the command line. For example:
-!MESSAGE 
-!MESSAGE NMAKE /f "db_test.mak" CFG="db_test - Win32 Debug"
-!MESSAGE 
-!MESSAGE Possible choices for configuration are:
-!MESSAGE 
-!MESSAGE "db_test - Win32 Release" (based on "Win32 (x86) Console Application")
-!MESSAGE "db_test - Win32 Debug" (based on "Win32 (x86) Console Application")
-!MESSAGE 
-
-# Begin Project
-# PROP AllowPerConfigDependencies 0
-# PROP Scc_ProjName ""
-# PROP Scc_LocalPath ""
-CPP=cl.exe
-RSC=rc.exe
-
-!IF  "$(CFG)" == "db_test - Win32 Release"
-
-# PROP BASE Use_MFC 0
-# PROP BASE Use_Debug_Libraries 0
-# PROP BASE Output_Dir "Release"
-# PROP BASE Intermediate_Dir "Release"
-# PROP BASE Target_Dir ""
-# PROP Use_MFC 0
-# PROP Use_Debug_Libraries 0
-# PROP Output_Dir "Release"
-# PROP Intermediate_Dir "Release"
-# PROP Ignore_Export_Lib 0
-# PROP Target_Dir ""
-# ADD BASE CPP /nologo /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /c
-# ADD CPP /nologo /MD /W3 /GX /O2 /I "." /I ".." /I "../dbinc" /D "WIN32" /D "NDEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /c
-# ADD BASE RSC /l 0x409 /d "NDEBUG"
-# ADD RSC /l 0x409 /d "NDEBUG"
-BSC32=bscmake.exe
-# ADD BASE BSC32 /nologo
-# ADD BSC32 /nologo
-LINK32=link.exe
-# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /machine:I386
-# ADD LINK32 Release/libdb41.lib /nologo /subsystem:console /machine:I386
-# Begin Special Build Tool
-SOURCE="$(InputPath)"
-PostBuild_Desc=Copy built executable files.
-PostBuild_Cmds=copy Release\*.exe .
-# End Special Build Tool
-
-!ELSEIF  "$(CFG)" == "db_test - Win32 Debug"
-
-# PROP BASE Use_MFC 0
-# PROP BASE Use_Debug_Libraries 1
-# PROP BASE Output_Dir "Debug"
-# PROP BASE Intermediate_Dir "Debug"
-# PROP BASE Target_Dir ""
-# PROP Use_MFC 0
-# PROP Use_Debug_Libraries 1
-# PROP Output_Dir "Debug"
-# PROP Intermediate_Dir "Debug"
-# PROP Ignore_Export_Lib 0
-# PROP Target_Dir ""
-# ADD BASE CPP /nologo /W3 /Gm /GX /Zi /Od /D "WIN32" /D "_DEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /c
-# ADD CPP /nologo /MDd /W3 /GX /Z7 /Od /I "." /I ".." /I "../dbinc" /D "WIN32" /D "_DEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /c
-# ADD BASE RSC /l 0x409 /d "_DEBUG"
-# ADD RSC /l 0x409 /d "_DEBUG"
-BSC32=bscmake.exe
-# ADD BASE BSC32 /nologo
-# ADD BSC32 /nologo
-LINK32=link.exe
-# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /debug /machine:I386 /pdbtype:sept
-# ADD LINK32 Debug/libdb41d.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /pdb:none /debug /machine:I386 /out:"Debug/dbkill.exe" /fixed:no
-# Begin Special Build Tool
-SOURCE="$(InputPath)"
-PostBuild_Desc=Copy built executable files.
-PostBuild_Cmds=copy Debug\*.exe .
-# End Special Build Tool
-
-!ENDIF 
-
-# Begin Target
-
-# Name "db_test - Win32 Release"
-# Name "db_test - Win32 Debug"
-# Begin Source File
-
-SOURCE=.\dbkill.cpp
-# End Source File
-# End Target
-# End Project
diff --git a/bdb/build_win32/libdb.def b/bdb/build_win32/libdb.def
deleted file mode 100644
index afcb092382ef4d185fbf8907ec0a43f1643066ef..0000000000000000000000000000000000000000
--- a/bdb/build_win32/libdb.def
+++ /dev/null
@@ -1,128 +0,0 @@
-; DO NOT EDIT: automatically built by dist/s_win32.
-
-DESCRIPTION	'Berkeley DB 4.1 Library'
-
-EXPORTS
-	db_create	@1
-	db_env_create	@2
-	db_strerror	@3
-	db_version	@4
-	db_xa_switch	@5
-	log_compare	@6
-	txn_abort	@7
-	txn_begin	@8
-	txn_commit	@9
-	db_env_set_func_close	@10
-	db_env_set_func_dirfree	@11
-	db_env_set_func_dirlist	@12
-	db_env_set_func_exists	@13
-	db_env_set_func_free	@14
-	db_env_set_func_fsync	@15
-	db_env_set_func_ioinfo	@16
-	db_env_set_func_malloc	@17
-	db_env_set_func_map	@18
-	db_env_set_func_open	@19
-	db_env_set_func_read	@20
-	db_env_set_func_realloc	@21
-	db_env_set_func_rename	@22
-	db_env_set_func_seek	@23
-	db_env_set_func_sleep	@24
-	db_env_set_func_unlink	@25
-	db_env_set_func_unmap	@26
-	db_env_set_func_write	@27
-	db_env_set_func_yield	@28
-	__db_add_recovery	@29
-	__db_dbm_close	@30
-	__db_dbm_delete	@31
-	__db_dbm_fetch	@32
-	__db_dbm_firstkey	@33
-	__db_dbm_init	@34
-	__db_dbm_nextkey	@35
-	__db_dbm_store	@36
-	__db_hcreate	@37
-	__db_hdestroy	@38
-	__db_hsearch	@39
-	__db_loadme	@40
-	__db_ndbm_clearerr	@41
-	__db_ndbm_close	@42
-	__db_ndbm_delete	@43
-	__db_ndbm_dirfno	@44
-	__db_ndbm_error	@45
-	__db_ndbm_fetch	@46
-	__db_ndbm_firstkey	@47
-	__db_ndbm_nextkey	@48
-	__db_ndbm_open	@49
-	__db_ndbm_pagfno	@50
-	__db_ndbm_rdonly	@51
-	__db_ndbm_store	@52
-	__db_panic	@53
-	__db_r_attach	@54
-	__db_r_detach	@55
-	__db_win32_mutex_init	@56
-	__db_win32_mutex_lock	@57
-	__db_win32_mutex_unlock	@58
-	__ham_func2	@59
-	__ham_func3	@60
-	__ham_func4	@61
-	__ham_func5	@62
-	__ham_test	@63
-	__lock_dump_region	@64
-	__memp_dump_region	@65
-	__os_calloc	@66
-	__os_closehandle	@67
-	__os_free	@68
-	__os_ioinfo	@69
-	__os_malloc	@70
-	__os_open	@71
-	__os_openhandle	@72
-	__os_read	@73
-	__os_realloc	@74
-	__os_strdup	@75
-	__os_umalloc	@76
-	__os_write	@77
-	__bam_init_print	@78
-	__bam_pgin	@79
-	__bam_pgout	@80
-	__crdel_init_print	@81
-	__db_dispatch	@82
-	__db_dump	@83
-	__db_e_stat	@84
-	__db_err	@85
-	__db_getlong	@86
-	__db_getulong	@87
-	__db_global_values	@88
-	__db_init_print	@89
-	__db_inmemdbflags	@90
-	__db_isbigendian	@91
-	__db_omode	@92
-	__db_overwrite	@93
-	__db_pgin	@94
-	__db_pgout	@95
-	__db_prdbt	@96
-	__db_prfooter	@97
-	__db_prheader	@98
-	__db_rpath	@99
-	__db_util_cache	@100
-	__db_util_interrupted	@101
-	__db_util_logset	@102
-	__db_util_siginit	@103
-	__db_util_sigresend	@104
-	__db_verify_callback	@105
-	__db_verify_internal	@106
-	__dbreg_init_print	@107
-	__fop_init_print	@108
-	__ham_get_meta	@109
-	__ham_init_print	@110
-	__ham_pgin	@111
-	__ham_pgout	@112
-	__ham_release_meta	@113
-	__os_clock	@114
-	__os_get_errno	@115
-	__os_id	@116
-	__os_set_errno	@117
-	__os_sleep	@118
-	__os_ufree	@119
-	__os_yield	@120
-	__qam_init_print	@121
-	__qam_pgin_out	@122
-	__txn_init_print	@123
diff --git a/bdb/dbinc_auto/btree_auto.h b/bdb/dbinc_auto/btree_auto.h
deleted file mode 100644
index 4feb07ad94c4509c7ee0b82d7238e0a5479ebeb9..0000000000000000000000000000000000000000
--- a/bdb/dbinc_auto/btree_auto.h
+++ /dev/null
@@ -1,128 +0,0 @@
-/* Do not edit: automatically built by gen_rec.awk. */
-
-#ifndef	__bam_AUTO_H
-#define	__bam_AUTO_H
-#define	DB___bam_split	62
-typedef struct ___bam_split_args {
-	u_int32_t type;
-	DB_TXN *txnid;
-	DB_LSN prev_lsn;
-	int32_t	fileid;
-	db_pgno_t	left;
-	DB_LSN	llsn;
-	db_pgno_t	right;
-	DB_LSN	rlsn;
-	u_int32_t	indx;
-	db_pgno_t	npgno;
-	DB_LSN	nlsn;
-	db_pgno_t	root_pgno;
-	DBT	pg;
-	u_int32_t	opflags;
-} __bam_split_args;
-
-#define	DB___bam_rsplit	63
-typedef struct ___bam_rsplit_args {
-	u_int32_t type;
-	DB_TXN *txnid;
-	DB_LSN prev_lsn;
-	int32_t	fileid;
-	db_pgno_t	pgno;
-	DBT	pgdbt;
-	db_pgno_t	root_pgno;
-	db_pgno_t	nrec;
-	DBT	rootent;
-	DB_LSN	rootlsn;
-} __bam_rsplit_args;
-
-#define	DB___bam_adj	55
-typedef struct ___bam_adj_args {
-	u_int32_t type;
-	DB_TXN *txnid;
-	DB_LSN prev_lsn;
-	int32_t	fileid;
-	db_pgno_t	pgno;
-	DB_LSN	lsn;
-	u_int32_t	indx;
-	u_int32_t	indx_copy;
-	u_int32_t	is_insert;
-} __bam_adj_args;
-
-#define	DB___bam_cadjust	56
-typedef struct ___bam_cadjust_args {
-	u_int32_t type;
-	DB_TXN *txnid;
-	DB_LSN prev_lsn;
-	int32_t	fileid;
-	db_pgno_t	pgno;
-	DB_LSN	lsn;
-	u_int32_t	indx;
-	int32_t	adjust;
-	u_int32_t	opflags;
-} __bam_cadjust_args;
-
-#define	DB___bam_cdel	57
-typedef struct ___bam_cdel_args {
-	u_int32_t type;
-	DB_TXN *txnid;
-	DB_LSN prev_lsn;
-	int32_t	fileid;
-	db_pgno_t	pgno;
-	DB_LSN	lsn;
-	u_int32_t	indx;
-} __bam_cdel_args;
-
-#define	DB___bam_repl	58
-typedef struct ___bam_repl_args {
-	u_int32_t type;
-	DB_TXN *txnid;
-	DB_LSN prev_lsn;
-	int32_t	fileid;
-	db_pgno_t	pgno;
-	DB_LSN	lsn;
-	u_int32_t	indx;
-	u_int32_t	isdeleted;
-	DBT	orig;
-	DBT	repl;
-	u_int32_t	prefix;
-	u_int32_t	suffix;
-} __bam_repl_args;
-
-#define	DB___bam_root	59
-typedef struct ___bam_root_args {
-	u_int32_t type;
-	DB_TXN *txnid;
-	DB_LSN prev_lsn;
-	int32_t	fileid;
-	db_pgno_t	meta_pgno;
-	db_pgno_t	root_pgno;
-	DB_LSN	meta_lsn;
-} __bam_root_args;
-
-#define	DB___bam_curadj	64
-typedef struct ___bam_curadj_args {
-	u_int32_t type;
-	DB_TXN *txnid;
-	DB_LSN prev_lsn;
-	int32_t	fileid;
-	db_ca_mode	mode;
-	db_pgno_t	from_pgno;
-	db_pgno_t	to_pgno;
-	db_pgno_t	left_pgno;
-	u_int32_t	first_indx;
-	u_int32_t	from_indx;
-	u_int32_t	to_indx;
-} __bam_curadj_args;
-
-#define	DB___bam_rcuradj	65
-typedef struct ___bam_rcuradj_args {
-	u_int32_t type;
-	DB_TXN *txnid;
-	DB_LSN prev_lsn;
-	int32_t	fileid;
-	ca_recno_arg	mode;
-	db_pgno_t	root;
-	db_recno_t	recno;
-	u_int32_t	order;
-} __bam_rcuradj_args;
-
-#endif
diff --git a/bdb/dbinc_auto/btree_ext.h b/bdb/dbinc_auto/btree_ext.h
deleted file mode 100644
index ec5468acf1c051c09060406d899044dc1b188f11..0000000000000000000000000000000000000000
--- a/bdb/dbinc_auto/btree_ext.h
+++ /dev/null
@@ -1,132 +0,0 @@
-/* DO NOT EDIT: automatically built by dist/s_include. */
-#ifndef	_btree_ext_h_
-#define	_btree_ext_h_
-
-#if defined(__cplusplus)
-extern "C" {
-#endif
-
-int __bam_cmp __P((DB *, const DBT *, PAGE *, u_int32_t, int (*)(DB *, const DBT *, const DBT *), int *));
-int __bam_defcmp __P((DB *, const DBT *, const DBT *));
-size_t __bam_defpfx __P((DB *, const DBT *, const DBT *));
-int __bam_pgin __P((DB_ENV *, DB *, db_pgno_t, void *, DBT *));
-int __bam_pgout __P((DB_ENV *, DB *, db_pgno_t, void *, DBT *));
-int __bam_mswap __P((PAGE *));
-void __bam_cprint __P((DBC *));
-int __bam_ca_delete __P((DB *, db_pgno_t, u_int32_t, int));
-int __ram_ca_delete __P((DB *, db_pgno_t));
-int __bam_ca_di __P((DBC *, db_pgno_t, u_int32_t, int));
-int __bam_ca_dup __P((DBC *, u_int32_t, db_pgno_t, u_int32_t, db_pgno_t, u_int32_t));
-int __bam_ca_undodup __P((DB *, u_int32_t, db_pgno_t, u_int32_t, u_int32_t));
-int __bam_ca_rsplit __P((DBC *, db_pgno_t, db_pgno_t));
-int __bam_ca_split __P((DBC *, db_pgno_t, db_pgno_t, db_pgno_t, u_int32_t, int));
-void __bam_ca_undosplit __P((DB *, db_pgno_t, db_pgno_t, db_pgno_t, u_int32_t));
-int __bam_c_init __P((DBC *, DBTYPE));
-int __bam_c_refresh __P((DBC *));
-int __bam_c_count __P((DBC *, db_recno_t *));
-int __bam_c_dup __P((DBC *, DBC *));
-int __bam_bulk_overflow __P((DBC *, u_int32_t, db_pgno_t, u_int8_t *));
-int __bam_bulk_duplicates __P((DBC *, db_pgno_t, u_int8_t *, int32_t *, int32_t **, u_int8_t **, u_int32_t *, int));
-int __bam_c_rget __P((DBC *, DBT *));
-int __bam_ditem __P((DBC *, PAGE *, u_int32_t));
-int __bam_adjindx __P((DBC *, PAGE *, u_int32_t, u_int32_t, int));
-int __bam_dpages __P((DBC *, EPG *));
-int __bam_db_create __P((DB *));
-int __bam_db_close __P((DB *));
-int __bam_set_flags __P((DB *, u_int32_t *flagsp));
-int __ram_set_flags __P((DB *, u_int32_t *flagsp));
-int __bam_open __P((DB *, DB_TXN *, const char *, db_pgno_t, u_int32_t));
-int __bam_metachk __P((DB *, const char *, BTMETA *));
-int __bam_read_root __P((DB *, DB_TXN *, db_pgno_t, u_int32_t));
-int __bam_new_file __P((DB *, DB_TXN *, DB_FH *, const char *));
-int __bam_new_subdb __P((DB *, DB *, DB_TXN *));
-int __bam_iitem __P((DBC *, DBT *, DBT *, u_int32_t, u_int32_t));
-int __bam_ritem __P((DBC *, PAGE *, u_int32_t, DBT *));
-int __bam_split_recover __P((DB_ENV *, DBT *, DB_LSN *, db_recops, void *));
-int __bam_rsplit_recover __P((DB_ENV *, DBT *, DB_LSN *, db_recops, void *));
-int __bam_adj_recover __P((DB_ENV *, DBT *, DB_LSN *, db_recops, void *));
-int __bam_cadjust_recover __P((DB_ENV *, DBT *, DB_LSN *, db_recops, void *));
-int __bam_cdel_recover __P((DB_ENV *, DBT *, DB_LSN *, db_recops, void *));
-int __bam_repl_recover __P((DB_ENV *, DBT *, DB_LSN *, db_recops, void *));
-int __bam_root_recover __P((DB_ENV *, DBT *, DB_LSN *, db_recops, void *));
-int __bam_curadj_recover __P((DB_ENV *, DBT *, DB_LSN *, db_recops, void *));
-int __bam_rcuradj_recover __P((DB_ENV *, DBT *, DB_LSN *, db_recops, void *));
-int __bam_reclaim __P((DB *, DB_TXN *));
-int __bam_truncate __P((DB *, DB_TXN *, u_int32_t *));
-int __ram_open __P((DB *, DB_TXN *, const char *, db_pgno_t, u_int32_t));
-int __ram_append __P((DBC *, DBT *, DBT *));
-int __ram_c_del __P((DBC *));
-int __ram_c_get __P((DBC *, DBT *, DBT *, u_int32_t, db_pgno_t *));
-int __ram_c_put __P((DBC *, DBT *, DBT *, u_int32_t, db_pgno_t *));
-int __ram_ca __P((DBC *, ca_recno_arg));
-int __ram_getno __P((DBC *, const DBT *, db_recno_t *, int));
-int __ram_writeback __P((DB *));
-int __bam_rsearch __P((DBC *, db_recno_t *, u_int32_t, int, int *));
-int __bam_adjust __P((DBC *, int32_t));
-int __bam_nrecs __P((DBC *, db_recno_t *));
-db_recno_t __bam_total __P((DB *, PAGE *));
-int __bam_search __P((DBC *, db_pgno_t, const DBT *, u_int32_t, int, db_recno_t *, int *));
-int __bam_stkrel __P((DBC *, u_int32_t));
-int __bam_stkgrow __P((DB_ENV *, BTREE_CURSOR *));
-int __bam_split __P((DBC *, void *, db_pgno_t *));
-int __bam_copy __P((DB *, PAGE *, PAGE *, u_int32_t, u_int32_t));
-int __bam_stat __P((DB *, void *, u_int32_t));
-int __bam_traverse __P((DBC *, db_lockmode_t, db_pgno_t, int (*)(DB *, PAGE *, void *, int *), void *));
-int __bam_stat_callback __P((DB *, PAGE *, void *, int *));
-int __bam_key_range __P((DB *, DB_TXN *, DBT *, DB_KEY_RANGE *, u_int32_t));
-int __bam_30_btreemeta __P((DB *, char *, u_int8_t *));
-int __bam_31_btreemeta __P((DB *, char *, u_int32_t, DB_FH *, PAGE *, int *));
-int __bam_31_lbtree __P((DB *, char *, u_int32_t, DB_FH *, PAGE *, int *));
-int __bam_vrfy_meta __P((DB *, VRFY_DBINFO *, BTMETA *, db_pgno_t, u_int32_t));
-int __ram_vrfy_leaf __P((DB *, VRFY_DBINFO *, PAGE *, db_pgno_t, u_int32_t));
-int __bam_vrfy __P((DB *, VRFY_DBINFO *, PAGE *, db_pgno_t, u_int32_t));
-int __bam_vrfy_itemorder __P((DB *, VRFY_DBINFO *, PAGE *, db_pgno_t, u_int32_t, int, int, u_int32_t));
-int __bam_vrfy_structure __P((DB *, VRFY_DBINFO *, db_pgno_t, u_int32_t));
-int __bam_vrfy_subtree __P((DB *, VRFY_DBINFO *, db_pgno_t, void *, void *, u_int32_t, u_int32_t *, u_int32_t *, u_int32_t *));
-int __bam_salvage __P((DB *, VRFY_DBINFO *, db_pgno_t, u_int32_t, PAGE *, void *, int (*)(void *, const void *), DBT *, u_int32_t));
-int __bam_salvage_walkdupint __P((DB *, VRFY_DBINFO *, PAGE *, DBT *, void *, int (*)(void *, const void *), u_int32_t));
-int __bam_meta2pgset __P((DB *, VRFY_DBINFO *, BTMETA *, u_int32_t, DB *));
-int __bam_split_log __P((DB *, DB_TXN *, DB_LSN *, u_int32_t, db_pgno_t, DB_LSN *, db_pgno_t, DB_LSN *, u_int32_t, db_pgno_t, DB_LSN *, db_pgno_t, const DBT *, u_int32_t));
-int __bam_split_getpgnos __P((DB_ENV *, DBT *, DB_LSN *, db_recops, void *));
-int __bam_split_print __P((DB_ENV *, DBT *, DB_LSN *, db_recops, void *));
-int __bam_split_read __P((DB_ENV *, void *, __bam_split_args **));
-int __bam_rsplit_log __P((DB *, DB_TXN *, DB_LSN *, u_int32_t, db_pgno_t, const DBT *, db_pgno_t, db_pgno_t, const DBT *, DB_LSN *));
-int __bam_rsplit_getpgnos __P((DB_ENV *, DBT *, DB_LSN *, db_recops, void *));
-int __bam_rsplit_print __P((DB_ENV *, DBT *, DB_LSN *, db_recops, void *));
-int __bam_rsplit_read __P((DB_ENV *, void *, __bam_rsplit_args **));
-int __bam_adj_log __P((DB *, DB_TXN *, DB_LSN *, u_int32_t, db_pgno_t, DB_LSN *, u_int32_t, u_int32_t, u_int32_t));
-int __bam_adj_getpgnos __P((DB_ENV *, DBT *, DB_LSN *, db_recops, void *));
-int __bam_adj_print __P((DB_ENV *, DBT *, DB_LSN *, db_recops, void *));
-int __bam_adj_read __P((DB_ENV *, void *, __bam_adj_args **));
-int __bam_cadjust_log __P((DB *, DB_TXN *, DB_LSN *, u_int32_t, db_pgno_t, DB_LSN *, u_int32_t, int32_t, u_int32_t));
-int __bam_cadjust_getpgnos __P((DB_ENV *, DBT *, DB_LSN *, db_recops, void *));
-int __bam_cadjust_print __P((DB_ENV *, DBT *, DB_LSN *, db_recops, void *));
-int __bam_cadjust_read __P((DB_ENV *, void *, __bam_cadjust_args **));
-int __bam_cdel_log __P((DB *, DB_TXN *, DB_LSN *, u_int32_t, db_pgno_t, DB_LSN *, u_int32_t));
-int __bam_cdel_getpgnos __P((DB_ENV *, DBT *, DB_LSN *, db_recops, void *));
-int __bam_cdel_print __P((DB_ENV *, DBT *, DB_LSN *, db_recops, void *));
-int __bam_cdel_read __P((DB_ENV *, void *, __bam_cdel_args **));
-int __bam_repl_log __P((DB *, DB_TXN *, DB_LSN *, u_int32_t, db_pgno_t, DB_LSN *, u_int32_t, u_int32_t, const DBT *, const DBT *, u_int32_t, u_int32_t));
-int __bam_repl_getpgnos __P((DB_ENV *, DBT *, DB_LSN *, db_recops, void *));
-int __bam_repl_print __P((DB_ENV *, DBT *, DB_LSN *, db_recops, void *));
-int __bam_repl_read __P((DB_ENV *, void *, __bam_repl_args **));
-int __bam_root_log __P((DB *, DB_TXN *, DB_LSN *, u_int32_t, db_pgno_t, db_pgno_t, DB_LSN *));
-int __bam_root_getpgnos __P((DB_ENV *, DBT *, DB_LSN *, db_recops, void *));
-int __bam_root_print __P((DB_ENV *, DBT *, DB_LSN *, db_recops, void *));
-int __bam_root_read __P((DB_ENV *, void *, __bam_root_args **));
-int __bam_curadj_log __P((DB *, DB_TXN *, DB_LSN *, u_int32_t, db_ca_mode, db_pgno_t, db_pgno_t, db_pgno_t, u_int32_t, u_int32_t, u_int32_t));
-int __bam_curadj_getpgnos __P((DB_ENV *, DBT *, DB_LSN *, db_recops, void *));
-int __bam_curadj_print __P((DB_ENV *, DBT *, DB_LSN *, db_recops, void *));
-int __bam_curadj_read __P((DB_ENV *, void *, __bam_curadj_args **));
-int __bam_rcuradj_log __P((DB *, DB_TXN *, DB_LSN *, u_int32_t, ca_recno_arg, db_pgno_t, db_recno_t, u_int32_t));
-int __bam_rcuradj_getpgnos __P((DB_ENV *, DBT *, DB_LSN *, db_recops, void *));
-int __bam_rcuradj_print __P((DB_ENV *, DBT *, DB_LSN *, db_recops, void *));
-int __bam_rcuradj_read __P((DB_ENV *, void *, __bam_rcuradj_args **));
-int __bam_init_print __P((DB_ENV *, int (***)(DB_ENV *, DBT *, DB_LSN *, db_recops, void *), size_t *));
-int __bam_init_getpgnos __P((DB_ENV *, int (***)(DB_ENV *, DBT *, DB_LSN *, db_recops, void *), size_t *));
-int __bam_init_recover __P((DB_ENV *, int (***)(DB_ENV *, DBT *, DB_LSN *, db_recops, void *), size_t *));
-
-#if defined(__cplusplus)
-}
-#endif
-#endif /* !_btree_ext_h_ */
diff --git a/bdb/dbinc_auto/clib_ext.h b/bdb/dbinc_auto/clib_ext.h
deleted file mode 100644
index 7e2817d620e183f603800710439c38fa601f667b..0000000000000000000000000000000000000000
--- a/bdb/dbinc_auto/clib_ext.h
+++ /dev/null
@@ -1,49 +0,0 @@
-/* DO NOT EDIT: automatically built by dist/s_include. */
-#ifndef	_clib_ext_h_
-#define	_clib_ext_h_
-
-#if defined(__cplusplus)
-extern "C" {
-#endif
-
-#ifndef HAVE_GETCWD
-char *getcwd __P((char *, size_t));
-#endif
-#ifndef HAVE_GETOPT
-int getopt __P((int, char * const *, const char *));
-#endif
-#ifndef HAVE_MEMCMP
-int memcmp __P((const void *, const void *, size_t));
-#endif
-#ifndef HAVE_MEMCPY
-void *memcpy __P((void *, const void *, size_t));
-#endif
-#ifndef HAVE_MEMMOVE
-void *memmove __P((void *, const void *, size_t));
-#endif
-#ifndef HAVE_RAISE
-int raise __P((int));
-#endif
-#ifndef HAVE_SNPRINTF
-int snprintf __P((char *, size_t, const char *, ...));
-#endif
-#ifndef HAVE_STRCASECMP
-int strcasecmp __P((const char *, const char *));
-#endif
-#ifndef HAVE_STRCASECMP
-int strncasecmp __P((const char *, const char *, size_t));
-#endif
-#ifndef HAVE_STRDUP
-char *strdup __P((const char *));
-#endif
-#ifndef HAVE_STRERROR
-char *strerror __P((int));
-#endif
-#ifndef HAVE_VSNPRINTF
-int vsnprintf __P((char *, size_t, const char *, va_list));
-#endif
-
-#if defined(__cplusplus)
-}
-#endif
-#endif /* !_clib_ext_h_ */
diff --git a/bdb/dbinc_auto/common_ext.h b/bdb/dbinc_auto/common_ext.h
deleted file mode 100644
index 7744982fe41392370d0e34acf1a94a690fadeecf..0000000000000000000000000000000000000000
--- a/bdb/dbinc_auto/common_ext.h
+++ /dev/null
@@ -1,44 +0,0 @@
-/* DO NOT EDIT: automatically built by dist/s_include. */
-#ifndef	_common_ext_h_
-#define	_common_ext_h_
-
-#if defined(__cplusplus)
-extern "C" {
-#endif
-
-int __db_isbigendian __P((void));
-int __db_byteorder __P((DB_ENV *, int));
-int __db_fchk __P((DB_ENV *, const char *, u_int32_t, u_int32_t));
-int __db_fcchk __P((DB_ENV *, const char *, u_int32_t, u_int32_t, u_int32_t));
-int __db_ferr __P((const DB_ENV *, const char *, int));
-void __db_pgerr __P((DB *, db_pgno_t, int));
-int __db_pgfmt __P((DB_ENV *, db_pgno_t));
-int __db_eopnotsup __P((const DB_ENV *));
-#ifdef DIAGNOSTIC
-void __db_assert __P((const char *, const char *, int));
-#endif
-int __db_panic_msg __P((DB_ENV *));
-int __db_panic __P((DB_ENV *, int));
-void __db_err __P((const DB_ENV *, const char *, ...));
-void __db_errcall __P((const DB_ENV *, int, int, const char *, va_list));
-void __db_errfile __P((const DB_ENV *, int, int, const char *, va_list));
-void __db_logmsg __P((const DB_ENV *, DB_TXN *, const char *, u_int32_t, const char *, ...));
-int __db_unknown_flag __P((DB_ENV *, char *, u_int32_t));
-int __db_unknown_type __P((DB_ENV *, char *, DBTYPE));
-int __db_check_txn __P((DB *, DB_TXN *, u_int32_t, int));
-int __db_not_txn_env __P((DB_ENV *));
-int __db_getlong __P((DB *, const char *, char *, long, long, long *));
-int __db_getulong __P((DB *, const char *, char *, u_long, u_long, u_long *));
-void __db_idspace __P((u_int32_t *, int, u_int32_t *, u_int32_t *));
-u_int32_t __db_log2 __P((u_int32_t));
-int __db_util_arg __P((char *, char *, int *, char ***));
-int __db_util_cache __P((DB_ENV *, DB *, u_int32_t *, int *));
-int __db_util_logset __P((const char *, char *));
-void __db_util_siginit __P((void));
-int __db_util_interrupted __P((void));
-void __db_util_sigresend __P((void));
-
-#if defined(__cplusplus)
-}
-#endif
-#endif /* !_common_ext_h_ */
diff --git a/bdb/dbinc_auto/crdel_auto.h b/bdb/dbinc_auto/crdel_auto.h
deleted file mode 100644
index bdae193fac8080b8943e794e445f0f5351824343..0000000000000000000000000000000000000000
--- a/bdb/dbinc_auto/crdel_auto.h
+++ /dev/null
@@ -1,16 +0,0 @@
-/* Do not edit: automatically built by gen_rec.awk. */
-
-#ifndef	__crdel_AUTO_H
-#define	__crdel_AUTO_H
-#define	DB___crdel_metasub	142
-typedef struct ___crdel_metasub_args {
-	u_int32_t type;
-	DB_TXN *txnid;
-	DB_LSN prev_lsn;
-	int32_t	fileid;
-	db_pgno_t	pgno;
-	DBT	page;
-	DB_LSN	lsn;
-} __crdel_metasub_args;
-
-#endif
diff --git a/bdb/dbinc_auto/db_auto.h b/bdb/dbinc_auto/db_auto.h
deleted file mode 100644
index e56f38b384bff080cf5ddbbdff2c9d0aac3fd4c5..0000000000000000000000000000000000000000
--- a/bdb/dbinc_auto/db_auto.h
+++ /dev/null
@@ -1,118 +0,0 @@
-/* Do not edit: automatically built by gen_rec.awk. */
-
-#ifndef	__db_AUTO_H
-#define	__db_AUTO_H
-#define	DB___db_addrem	41
-typedef struct ___db_addrem_args {
-	u_int32_t type;
-	DB_TXN *txnid;
-	DB_LSN prev_lsn;
-	u_int32_t	opcode;
-	int32_t	fileid;
-	db_pgno_t	pgno;
-	u_int32_t	indx;
-	u_int32_t	nbytes;
-	DBT	hdr;
-	DBT	dbt;
-	DB_LSN	pagelsn;
-} __db_addrem_args;
-
-#define	DB___db_big	43
-typedef struct ___db_big_args {
-	u_int32_t type;
-	DB_TXN *txnid;
-	DB_LSN prev_lsn;
-	u_int32_t	opcode;
-	int32_t	fileid;
-	db_pgno_t	pgno;
-	db_pgno_t	prev_pgno;
-	db_pgno_t	next_pgno;
-	DBT	dbt;
-	DB_LSN	pagelsn;
-	DB_LSN	prevlsn;
-	DB_LSN	nextlsn;
-} __db_big_args;
-
-#define	DB___db_ovref	44
-typedef struct ___db_ovref_args {
-	u_int32_t type;
-	DB_TXN *txnid;
-	DB_LSN prev_lsn;
-	int32_t	fileid;
-	db_pgno_t	pgno;
-	int32_t	adjust;
-	DB_LSN	lsn;
-} __db_ovref_args;
-
-#define	DB___db_relink	45
-typedef struct ___db_relink_args {
-	u_int32_t type;
-	DB_TXN *txnid;
-	DB_LSN prev_lsn;
-	u_int32_t	opcode;
-	int32_t	fileid;
-	db_pgno_t	pgno;
-	DB_LSN	lsn;
-	db_pgno_t	prev;
-	DB_LSN	lsn_prev;
-	db_pgno_t	next;
-	DB_LSN	lsn_next;
-} __db_relink_args;
-
-#define	DB___db_debug	47
-typedef struct ___db_debug_args {
-	u_int32_t type;
-	DB_TXN *txnid;
-	DB_LSN prev_lsn;
-	DBT	op;
-	int32_t	fileid;
-	DBT	key;
-	DBT	data;
-	u_int32_t	arg_flags;
-} __db_debug_args;
-
-#define	DB___db_noop	48
-typedef struct ___db_noop_args {
-	u_int32_t type;
-	DB_TXN *txnid;
-	DB_LSN prev_lsn;
-	int32_t	fileid;
-	db_pgno_t	pgno;
-	DB_LSN	prevlsn;
-} __db_noop_args;
-
-#define	DB___db_pg_alloc	49
-typedef struct ___db_pg_alloc_args {
-	u_int32_t type;
-	DB_TXN *txnid;
-	DB_LSN prev_lsn;
-	int32_t	fileid;
-	DB_LSN	meta_lsn;
-	db_pgno_t	meta_pgno;
-	DB_LSN	page_lsn;
-	db_pgno_t	pgno;
-	u_int32_t	ptype;
-	db_pgno_t	next;
-} __db_pg_alloc_args;
-
-#define	DB___db_pg_free	50
-typedef struct ___db_pg_free_args {
-	u_int32_t type;
-	DB_TXN *txnid;
-	DB_LSN prev_lsn;
-	int32_t	fileid;
-	db_pgno_t	pgno;
-	DB_LSN	meta_lsn;
-	db_pgno_t	meta_pgno;
-	DBT	header;
-	db_pgno_t	next;
-} __db_pg_free_args;
-
-#define	DB___db_cksum	51
-typedef struct ___db_cksum_args {
-	u_int32_t type;
-	DB_TXN *txnid;
-	DB_LSN prev_lsn;
-} __db_cksum_args;
-
-#endif
diff --git a/bdb/dbinc_auto/db_ext.h b/bdb/dbinc_auto/db_ext.h
deleted file mode 100644
index 24a13975c89a2e065ad3d85006a232677fad82af..0000000000000000000000000000000000000000
--- a/bdb/dbinc_auto/db_ext.h
+++ /dev/null
@@ -1,224 +0,0 @@
-/* DO NOT EDIT: automatically built by dist/s_include. */
-#ifndef	_db_ext_h_
-#define	_db_ext_h_
-
-#if defined(__cplusplus)
-extern "C" {
-#endif
-
-int __crdel_metasub_log __P((DB *, DB_TXN *, DB_LSN *, u_int32_t, db_pgno_t, const DBT *, DB_LSN *));
-int __crdel_metasub_getpgnos __P((DB_ENV *, DBT *, DB_LSN *, db_recops, void *));
-int __crdel_metasub_print __P((DB_ENV *, DBT *, DB_LSN *, db_recops, void *));
-int __crdel_metasub_read __P((DB_ENV *, void *, __crdel_metasub_args **));
-int __crdel_init_print __P((DB_ENV *, int (***)(DB_ENV *, DBT *, DB_LSN *, db_recops, void *), size_t *));
-int __crdel_init_getpgnos __P((DB_ENV *, int (***)(DB_ENV *, DBT *, DB_LSN *, db_recops, void *), size_t *));
-int __crdel_init_recover __P((DB_ENV *, int (***)(DB_ENV *, DBT *, DB_LSN *, db_recops, void *), size_t *));
-int __crdel_metasub_recover __P((DB_ENV *, DBT *, DB_LSN *, db_recops, void *));
-int __db_master_open __P((DB *, DB_TXN *, const char *, u_int32_t, int, DB **));
-int __db_master_update __P((DB *, DB *, DB_TXN *, const char *, DBTYPE, mu_action, const char *, u_int32_t));
-int __db_dbenv_setup __P((DB *, DB_TXN *, const char *, u_int32_t, u_int32_t));
-int __db_close __P((DB *, u_int32_t));
-int __db_close_i __P((DB *, DB_TXN *, u_int32_t));
-int __db_refresh __P((DB *, DB_TXN *, u_int32_t));
-int __db_log_page __P((DB *, DB_TXN *, DB_LSN *, db_pgno_t, PAGE *));
-int __db_backup_name __P((DB_ENV *, const char *, DB_TXN *, char **));
-DB *__dblist_get __P((DB_ENV *, u_int32_t));
-#if CONFIG_TEST
-int __db_testcopy __P((DB_ENV *, DB *, const char *));
-#endif
-int __db_cursor __P((DB *, DB_TXN *, DBC **, u_int32_t));
-int __db_icursor __P((DB *, DB_TXN *, DBTYPE, db_pgno_t, int, u_int32_t, DBC **));
-int __db_cprint __P((DB *));
-int __db_fd __P((DB *, int *));
-int __db_get __P((DB *, DB_TXN *, DBT *, DBT *, u_int32_t));
-int __db_put __P((DB *, DB_TXN *, DBT *, DBT *, u_int32_t));
-int __db_delete __P((DB *, DB_TXN *, DBT *, u_int32_t));
-int __db_sync __P((DB *, u_int32_t));
-int __db_associate __P((DB *, DB_TXN *, DB *, int (*)(DB *, const DBT *, const DBT *, DBT *), u_int32_t));
-int __db_pget __P((DB *, DB_TXN *, DBT *, DBT *, DBT *, u_int32_t));
-int __db_addrem_log __P((DB *, DB_TXN *, DB_LSN *, u_int32_t, u_int32_t, db_pgno_t, u_int32_t, u_int32_t, const DBT *, const DBT *, DB_LSN *));
-int __db_addrem_getpgnos __P((DB_ENV *, DBT *, DB_LSN *, db_recops, void *));
-int __db_addrem_print __P((DB_ENV *, DBT *, DB_LSN *, db_recops, void *));
-int __db_addrem_read __P((DB_ENV *, void *, __db_addrem_args **));
-int __db_big_log __P((DB *, DB_TXN *, DB_LSN *, u_int32_t, u_int32_t, db_pgno_t, db_pgno_t, db_pgno_t, const DBT *, DB_LSN *, DB_LSN *, DB_LSN *));
-int __db_big_getpgnos __P((DB_ENV *, DBT *, DB_LSN *, db_recops, void *));
-int __db_big_print __P((DB_ENV *, DBT *, DB_LSN *, db_recops, void *));
-int __db_big_read __P((DB_ENV *, void *, __db_big_args **));
-int __db_ovref_log __P((DB *, DB_TXN *, DB_LSN *, u_int32_t, db_pgno_t, int32_t, DB_LSN *));
-int __db_ovref_getpgnos __P((DB_ENV *, DBT *, DB_LSN *, db_recops, void *));
-int __db_ovref_print __P((DB_ENV *, DBT *, DB_LSN *, db_recops, void *));
-int __db_ovref_read __P((DB_ENV *, void *, __db_ovref_args **));
-int __db_relink_log __P((DB *, DB_TXN *, DB_LSN *, u_int32_t, u_int32_t, db_pgno_t, DB_LSN *, db_pgno_t, DB_LSN *, db_pgno_t, DB_LSN *));
-int __db_relink_getpgnos __P((DB_ENV *, DBT *, DB_LSN *, db_recops, void *));
-int __db_relink_print __P((DB_ENV *, DBT *, DB_LSN *, db_recops, void *));
-int __db_relink_read __P((DB_ENV *, void *, __db_relink_args **));
-int __db_debug_log __P((DB_ENV *, DB_TXN *, DB_LSN *, u_int32_t, const DBT *, int32_t, const DBT *, const DBT *, u_int32_t));
-int __db_debug_getpgnos __P((DB_ENV *, DBT *, DB_LSN *, db_recops, void *));
-int __db_debug_print __P((DB_ENV *, DBT *, DB_LSN *, db_recops, void *));
-int __db_debug_read __P((DB_ENV *, void *, __db_debug_args **));
-int __db_noop_log __P((DB *, DB_TXN *, DB_LSN *, u_int32_t, db_pgno_t, DB_LSN *));
-int __db_noop_getpgnos __P((DB_ENV *, DBT *, DB_LSN *, db_recops, void *));
-int __db_noop_print __P((DB_ENV *, DBT *, DB_LSN *, db_recops, void *));
-int __db_noop_read __P((DB_ENV *, void *, __db_noop_args **));
-int __db_pg_alloc_log __P((DB *, DB_TXN *, DB_LSN *, u_int32_t, DB_LSN *, db_pgno_t, DB_LSN *, db_pgno_t, u_int32_t, db_pgno_t));
-int __db_pg_alloc_getpgnos __P((DB_ENV *, DBT *, DB_LSN *, db_recops, void *));
-int __db_pg_alloc_print __P((DB_ENV *, DBT *, DB_LSN *, db_recops, void *));
-int __db_pg_alloc_read __P((DB_ENV *, void *, __db_pg_alloc_args **));
-int __db_pg_free_log __P((DB *, DB_TXN *, DB_LSN *, u_int32_t, db_pgno_t, DB_LSN *, db_pgno_t, const DBT *, db_pgno_t));
-int __db_pg_free_getpgnos __P((DB_ENV *, DBT *, DB_LSN *, db_recops, void *));
-int __db_pg_free_print __P((DB_ENV *, DBT *, DB_LSN *, db_recops, void *));
-int __db_pg_free_read __P((DB_ENV *, void *, __db_pg_free_args **));
-int __db_cksum_log __P((DB_ENV *, DB_TXN *, DB_LSN *, u_int32_t));
-int __db_cksum_getpgnos __P((DB_ENV *, DBT *, DB_LSN *, db_recops, void *));
-int __db_cksum_print __P((DB_ENV *, DBT *, DB_LSN *, db_recops, void *));
-int __db_cksum_read __P((DB_ENV *, void *, __db_cksum_args **));
-int __db_init_print __P((DB_ENV *, int (***)(DB_ENV *, DBT *, DB_LSN *, db_recops, void *), size_t *));
-int __db_init_getpgnos __P((DB_ENV *, int (***)(DB_ENV *, DBT *, DB_LSN *, db_recops, void *), size_t *));
-int __db_init_recover __P((DB_ENV *, int (***)(DB_ENV *, DBT *, DB_LSN *, db_recops, void *), size_t *));
-int __db_c_close __P((DBC *));
-int __db_c_destroy __P((DBC *));
-int __db_c_count __P((DBC *, db_recno_t *, u_int32_t));
-int __db_c_del __P((DBC *, u_int32_t));
-int __db_c_dup __P((DBC *, DBC **, u_int32_t));
-int __db_c_idup __P((DBC *, DBC **, u_int32_t));
-int __db_c_newopd __P((DBC *, db_pgno_t, DBC *, DBC **));
-int __db_c_get __P((DBC *, DBT *, DBT *, u_int32_t));
-int __db_c_put __P((DBC *, DBT *, DBT *, u_int32_t));
-int __db_duperr __P((DB *, u_int32_t));
-int __db_c_secondary_get __P((DBC *, DBT *, DBT *, u_int32_t));
-int __db_c_pget __P((DBC *, DBT *, DBT *, DBT *, u_int32_t));
-int __db_c_del_primary __P((DBC *));
-DB *__db_s_first __P((DB *));
-int __db_s_next __P((DB **));
-int __db_s_done __P((DB *));
-u_int32_t __db_partsize __P((u_int32_t, DBT *));
-int __db_pgin __P((DB_ENV *, db_pgno_t, void *, DBT *));
-int __db_pgout __P((DB_ENV *, db_pgno_t, void *, DBT *));
-void __db_metaswap __P((PAGE *));
-int __db_byteswap __P((DB_ENV *, DB *, db_pgno_t, PAGE *, size_t, int));
-int __db_dispatch __P((DB_ENV *, int (**)__P((DB_ENV *, DBT *, DB_LSN *, db_recops, void *)), size_t, DBT *, DB_LSN *, db_recops, void *));
-int __db_add_recovery __P((DB_ENV *, int (***)(DB_ENV *, DBT *, DB_LSN *, db_recops, void *), size_t *, int (*)(DB_ENV *, DBT *, DB_LSN *, db_recops, void *), u_int32_t));
-int __db_txnlist_init __P((DB_ENV *, u_int32_t, u_int32_t, DB_LSN *, void *));
-int __db_txnlist_add __P((DB_ENV *, void *, u_int32_t, int32_t, DB_LSN *));
-int __db_txnlist_remove __P((DB_ENV *, void *, u_int32_t));
-void __db_txnlist_ckp __P((DB_ENV *, void *, DB_LSN *));
-void __db_txnlist_end __P((DB_ENV *, void *));
-int __db_txnlist_find __P((DB_ENV *, void *, u_int32_t));
-int __db_txnlist_update __P((DB_ENV *, void *, u_int32_t, u_int32_t, DB_LSN *));
-int __db_txnlist_gen __P((DB_ENV *, void *, int, u_int32_t, u_int32_t));
-int __db_txnlist_lsnadd __P((DB_ENV *, void *, DB_LSN *, u_int32_t));
-int __db_txnlist_lsninit __P((DB_ENV *, DB_TXNHEAD *, DB_LSN *));
-int __db_add_limbo __P((DB_ENV *, void *, int32_t, db_pgno_t, int32_t));
-int __db_do_the_limbo __P((DB_ENV *, DB_TXN *, DB_TXN *, DB_TXNHEAD *));
-void __db_txnlist_print __P((void *));
-int __db_ditem __P((DBC *, PAGE *, u_int32_t, u_int32_t));
-int __db_pitem __P((DBC *, PAGE *, u_int32_t, u_int32_t, DBT *, DBT *));
-int __db_relink __P((DBC *, u_int32_t, PAGE *, PAGE **, int));
-int __db_cursorchk __P((const DB *, u_int32_t));
-int __db_ccountchk __P((const DB *, u_int32_t, int));
-int __db_cdelchk __P((const DB *, u_int32_t, int));
-int __db_cgetchk __P((const DB *, DBT *, DBT *, u_int32_t, int));
-int __db_cputchk __P((const DB *, const DBT *, DBT *, u_int32_t, int));
-int __db_pgetchk __P((const DB *, const DBT *, DBT *, DBT *, u_int32_t));
-int __db_cpgetchk __P((const DB *, DBT *, DBT *, DBT *, u_int32_t, int));
-int __db_delchk __P((const DB *, DBT *, u_int32_t));
-int __db_getchk __P((const DB *, const DBT *, DBT *, u_int32_t));
-int __db_joinchk __P((const DB *, DBC * const *, u_int32_t));
-int __db_joingetchk __P((const DB *, DBT *, u_int32_t));
-int __db_putchk __P((const DB *, DBT *, const DBT *, u_int32_t, int));
-int __db_statchk __P((const DB *, u_int32_t));
-int __db_syncchk __P((const DB *, u_int32_t));
-int __db_secondary_corrupt __P((DB *));
-int __db_associatechk __P((DB *, DB *, int (*)(DB *, const DBT *, const DBT *, DBT *), u_int32_t));
-int __db_txn_auto __P((DB *, DB_TXN **));
-int __db_join __P((DB *, DBC **, DBC **, u_int32_t));
-int __db_new __P((DBC *, u_int32_t, PAGE **));
-int __db_free __P((DBC *, PAGE *));
-int __db_lprint __P((DBC *));
-int __db_lget __P((DBC *, int, db_pgno_t, db_lockmode_t, u_int32_t, DB_LOCK *));
-int __db_lput __P((DBC *, DB_LOCK *));
-int __dbh_am_chk __P((DB *, u_int32_t));
-int  __db_set_lorder __P((DB *, int));
-int __db_open __P((DB *, DB_TXN *, const char *, const char *, DBTYPE, u_int32_t, int));
-int __db_dbopen __P((DB *, DB_TXN *, const char *, const char *, u_int32_t, int, db_pgno_t));
-int __db_new_file __P((DB *, DB_TXN *, DB_FH *, const char *));
-int __db_init_subdb __P((DB *, DB *, const char *, DB_TXN *));
-int __db_chk_meta __P((DB_ENV *, DB *, DBMETA *, int));
-int __db_meta_setup __P((DB_ENV *, DB *, const char *, DBMETA *, u_int32_t, int));
-int __db_goff __P((DB *, DBT *, u_int32_t, db_pgno_t, void **, u_int32_t *));
-int __db_poff __P((DBC *, const DBT *, db_pgno_t *));
-int __db_ovref __P((DBC *, db_pgno_t, int32_t));
-int __db_doff __P((DBC *, db_pgno_t));
-int __db_moff __P((DB *, const DBT *, db_pgno_t, u_int32_t, int (*)(DB *, const DBT *, const DBT *), int *));
-int __db_vrfy_overflow __P((DB *, VRFY_DBINFO *, PAGE *, db_pgno_t, u_int32_t));
-int __db_vrfy_ovfl_structure __P((DB *, VRFY_DBINFO *, db_pgno_t, u_int32_t, u_int32_t));
-int __db_safe_goff __P((DB *, VRFY_DBINFO *, db_pgno_t, DBT *, void **, u_int32_t));
-void __db_loadme __P((void));
-int __db_dump __P((DB *, char *, char *));
-void __db_inmemdbflags __P((u_int32_t, void *, void (*)(u_int32_t, const FN *, void *)));
-int __db_prnpage __P((DB *, db_pgno_t, FILE *));
-int __db_prpage __P((DB *, PAGE *, FILE *, u_int32_t));
-void __db_pr __P((u_int8_t *, u_int32_t, FILE *));
-int __db_prdbt __P((DBT *, int, const char *, void *, int (*)(void *, const void *), int, VRFY_DBINFO *));
-void __db_prflags __P((u_int32_t, const FN *, void *));
-const char * __db_dbtype_to_string __P((DBTYPE));
-int	__db_prheader __P((DB *, char *, int, int, void *, int (*)(void *, const void *), VRFY_DBINFO *, db_pgno_t));
-int __db_prfooter __P((void *, int (*)(void *, const void *)));
-int __db_addrem_recover __P((DB_ENV *, DBT *, DB_LSN *, db_recops, void *));
-int __db_big_recover __P((DB_ENV *, DBT *, DB_LSN *, db_recops, void *));
-int __db_ovref_recover __P((DB_ENV *, DBT *, DB_LSN *, db_recops, void *));
-int __db_relink_recover __P((DB_ENV *, DBT *, DB_LSN *, db_recops, void *));
-int __db_debug_recover __P((DB_ENV *, DBT *, DB_LSN *, db_recops, void *));
-int __db_noop_recover __P((DB_ENV *, DBT *, DB_LSN *, db_recops, void *));
-int __db_pg_alloc_recover __P((DB_ENV *, DBT *, DB_LSN *, db_recops, void *));
-int __db_pg_free_recover __P((DB_ENV *, DBT *, DB_LSN *, db_recops, void *));
-int __db_cksum_recover __P((DB_ENV *, DBT *, DB_LSN *, db_recops, void *));
-int __db_traverse_big __P((DB *, db_pgno_t, int (*)(DB *, PAGE *, void *, int *), void *));
-int __db_reclaim_callback __P((DB *, PAGE *, void *, int *));
-int __db_truncate_callback __P((DB *, PAGE *, void *, int *));
-int __dbenv_dbremove __P((DB_ENV *, DB_TXN *, const char *, const char *, u_int32_t));
-int __db_remove __P((DB *, const char *, const char *, u_int32_t));
-int __db_remove_i __P((DB *, DB_TXN *, const char *, const char *));
-int __dbenv_dbrename __P((DB_ENV *, DB_TXN *, const char *, const char *, const char *, u_int32_t));
-int __db_rename __P((DB *, const char *, const char *, const char *, u_int32_t));
-int __db_rename_i __P((DB *, DB_TXN *, const char *, const char *, const char *));
-int __db_ret __P((DB *, PAGE *, u_int32_t, DBT *, void **, u_int32_t *));
-int __db_retcopy __P((DB_ENV *, DBT *, void *, u_int32_t, void **, u_int32_t *));
-int __db_truncate __P((DB *, DB_TXN *, u_int32_t *, u_int32_t));
-int __db_upgrade __P((DB *, const char *, u_int32_t));
-int __db_lastpgno __P((DB *, char *, DB_FH *, db_pgno_t *));
-int __db_31_offdup __P((DB *, char *, DB_FH *, int, db_pgno_t *));
-int __db_verify __P((DB *, const char *, const char *, FILE *, u_int32_t));
-int  __db_verify_callback __P((void *, const void *));
-int __db_verify_internal __P((DB *, const char *, const char *, void *, int (*)(void *, const void *), u_int32_t));
-int __db_vrfy_datapage __P((DB *, VRFY_DBINFO *, PAGE *, db_pgno_t, u_int32_t));
-int __db_vrfy_meta __P((DB *, VRFY_DBINFO *, DBMETA *, db_pgno_t, u_int32_t));
-void __db_vrfy_struct_feedback __P((DB *, VRFY_DBINFO *));
-int __db_vrfy_inpitem __P((DB *, PAGE *, db_pgno_t, u_int32_t, int, u_int32_t, u_int32_t *, u_int32_t *));
-int __db_vrfy_duptype __P((DB *, VRFY_DBINFO *, db_pgno_t, u_int32_t));
-int __db_salvage_duptree __P((DB *, VRFY_DBINFO *, db_pgno_t, DBT *, void *, int (*)(void *, const void *), u_int32_t));
-int __db_vrfy_dbinfo_create __P((DB_ENV *, u_int32_t, VRFY_DBINFO **));
-int __db_vrfy_dbinfo_destroy __P((DB_ENV *, VRFY_DBINFO *));
-int __db_vrfy_getpageinfo __P((VRFY_DBINFO *, db_pgno_t, VRFY_PAGEINFO **));
-int __db_vrfy_putpageinfo __P((DB_ENV *, VRFY_DBINFO *, VRFY_PAGEINFO *));
-int __db_vrfy_pgset __P((DB_ENV *, u_int32_t, DB **));
-int __db_vrfy_pgset_get __P((DB *, db_pgno_t, int *));
-int __db_vrfy_pgset_inc __P((DB *, db_pgno_t));
-int __db_vrfy_pgset_dec __P((DB *, db_pgno_t));
-int __db_vrfy_pgset_next __P((DBC *, db_pgno_t *));
-int __db_vrfy_childcursor __P((VRFY_DBINFO *, DBC **));
-int __db_vrfy_childput __P((VRFY_DBINFO *, db_pgno_t, VRFY_CHILDINFO *));
-int __db_vrfy_ccset __P((DBC *, db_pgno_t, VRFY_CHILDINFO **));
-int __db_vrfy_ccnext __P((DBC *, VRFY_CHILDINFO **));
-int __db_vrfy_ccclose __P((DBC *));
-int  __db_salvage_init __P((VRFY_DBINFO *));
-void  __db_salvage_destroy __P((VRFY_DBINFO *));
-int __db_salvage_getnext __P((VRFY_DBINFO *, db_pgno_t *, u_int32_t *));
-int __db_salvage_isdone __P((VRFY_DBINFO *, db_pgno_t));
-int __db_salvage_markdone __P((VRFY_DBINFO *, db_pgno_t));
-int __db_salvage_markneeded __P((VRFY_DBINFO *, db_pgno_t, u_int32_t));
-
-#if defined(__cplusplus)
-}
-#endif
-#endif /* !_db_ext_h_ */
diff --git a/bdb/dbinc_auto/db_server.h b/bdb/dbinc_auto/db_server.h
deleted file mode 100644
index 3409eed1a9f1bf83e278c902eda5f80aa63a9bb6..0000000000000000000000000000000000000000
--- a/bdb/dbinc_auto/db_server.h
+++ /dev/null
@@ -1,1006 +0,0 @@
-/*
- * Please do not edit this file.
- * It was generated using rpcgen.
- */
-
-#ifndef _DB_SERVER_H_RPCGEN
-#define	_DB_SERVER_H_RPCGEN
-
-
-struct __env_cachesize_msg {
-	u_int dbenvcl_id;
-	u_int gbytes;
-	u_int bytes;
-	u_int ncache;
-};
-typedef struct __env_cachesize_msg __env_cachesize_msg;
-
-struct __env_cachesize_reply {
-	int status;
-};
-typedef struct __env_cachesize_reply __env_cachesize_reply;
-
-struct __env_close_msg {
-	u_int dbenvcl_id;
-	u_int flags;
-};
-typedef struct __env_close_msg __env_close_msg;
-
-struct __env_close_reply {
-	int status;
-};
-typedef struct __env_close_reply __env_close_reply;
-
-struct __env_create_msg {
-	u_int timeout;
-};
-typedef struct __env_create_msg __env_create_msg;
-
-struct __env_create_reply {
-	int status;
-	u_int envcl_id;
-};
-typedef struct __env_create_reply __env_create_reply;
-
-struct __env_dbremove_msg {
-	u_int dbenvcl_id;
-	u_int txnpcl_id;
-	char *name;
-	char *subdb;
-	u_int flags;
-};
-typedef struct __env_dbremove_msg __env_dbremove_msg;
-
-struct __env_dbremove_reply {
-	int status;
-};
-typedef struct __env_dbremove_reply __env_dbremove_reply;
-
-struct __env_dbrename_msg {
-	u_int dbenvcl_id;
-	u_int txnpcl_id;
-	char *name;
-	char *subdb;
-	char *newname;
-	u_int flags;
-};
-typedef struct __env_dbrename_msg __env_dbrename_msg;
-
-struct __env_dbrename_reply {
-	int status;
-};
-typedef struct __env_dbrename_reply __env_dbrename_reply;
-
-struct __env_encrypt_msg {
-	u_int dbenvcl_id;
-	char *passwd;
-	u_int flags;
-};
-typedef struct __env_encrypt_msg __env_encrypt_msg;
-
-struct __env_encrypt_reply {
-	int status;
-};
-typedef struct __env_encrypt_reply __env_encrypt_reply;
-
-struct __env_flags_msg {
-	u_int dbenvcl_id;
-	u_int flags;
-	u_int onoff;
-};
-typedef struct __env_flags_msg __env_flags_msg;
-
-struct __env_flags_reply {
-	int status;
-};
-typedef struct __env_flags_reply __env_flags_reply;
-
-struct __env_open_msg {
-	u_int dbenvcl_id;
-	char *home;
-	u_int flags;
-	u_int mode;
-};
-typedef struct __env_open_msg __env_open_msg;
-
-struct __env_open_reply {
-	int status;
-	u_int envcl_id;
-};
-typedef struct __env_open_reply __env_open_reply;
-
-struct __env_remove_msg {
-	u_int dbenvcl_id;
-	char *home;
-	u_int flags;
-};
-typedef struct __env_remove_msg __env_remove_msg;
-
-struct __env_remove_reply {
-	int status;
-};
-typedef struct __env_remove_reply __env_remove_reply;
-
-struct __txn_abort_msg {
-	u_int txnpcl_id;
-};
-typedef struct __txn_abort_msg __txn_abort_msg;
-
-struct __txn_abort_reply {
-	int status;
-};
-typedef struct __txn_abort_reply __txn_abort_reply;
-
-struct __txn_begin_msg {
-	u_int dbenvcl_id;
-	u_int parentcl_id;
-	u_int flags;
-};
-typedef struct __txn_begin_msg __txn_begin_msg;
-
-struct __txn_begin_reply {
-	int status;
-	u_int txnidcl_id;
-};
-typedef struct __txn_begin_reply __txn_begin_reply;
-
-struct __txn_commit_msg {
-	u_int txnpcl_id;
-	u_int flags;
-};
-typedef struct __txn_commit_msg __txn_commit_msg;
-
-struct __txn_commit_reply {
-	int status;
-};
-typedef struct __txn_commit_reply __txn_commit_reply;
-
-struct __txn_discard_msg {
-	u_int txnpcl_id;
-	u_int flags;
-};
-typedef struct __txn_discard_msg __txn_discard_msg;
-
-struct __txn_discard_reply {
-	int status;
-};
-typedef struct __txn_discard_reply __txn_discard_reply;
-
-struct __txn_prepare_msg {
-	u_int txnpcl_id;
-	char gid[128];
-};
-typedef struct __txn_prepare_msg __txn_prepare_msg;
-
-struct __txn_prepare_reply {
-	int status;
-};
-typedef struct __txn_prepare_reply __txn_prepare_reply;
-
-struct __txn_recover_msg {
-	u_int dbenvcl_id;
-	u_int count;
-	u_int flags;
-};
-typedef struct __txn_recover_msg __txn_recover_msg;
-
-struct __txn_recover_reply {
-	int status;
-	struct {
-		u_int txn_len;
-		u_int *txn_val;
-	} txn;
-	struct {
-		u_int gid_len;
-		char *gid_val;
-	} gid;
-	u_int retcount;
-};
-typedef struct __txn_recover_reply __txn_recover_reply;
-
-struct __db_associate_msg {
-	u_int dbpcl_id;
-	u_int txnpcl_id;
-	u_int sdbpcl_id;
-	u_int flags;
-};
-typedef struct __db_associate_msg __db_associate_msg;
-
-struct __db_associate_reply {
-	int status;
-};
-typedef struct __db_associate_reply __db_associate_reply;
-
-struct __db_bt_maxkey_msg {
-	u_int dbpcl_id;
-	u_int maxkey;
-};
-typedef struct __db_bt_maxkey_msg __db_bt_maxkey_msg;
-
-struct __db_bt_maxkey_reply {
-	int status;
-};
-typedef struct __db_bt_maxkey_reply __db_bt_maxkey_reply;
-
-struct __db_bt_minkey_msg {
-	u_int dbpcl_id;
-	u_int minkey;
-};
-typedef struct __db_bt_minkey_msg __db_bt_minkey_msg;
-
-struct __db_bt_minkey_reply {
-	int status;
-};
-typedef struct __db_bt_minkey_reply __db_bt_minkey_reply;
-
-struct __db_close_msg {
-	u_int dbpcl_id;
-	u_int flags;
-};
-typedef struct __db_close_msg __db_close_msg;
-
-struct __db_close_reply {
-	int status;
-};
-typedef struct __db_close_reply __db_close_reply;
-
-struct __db_create_msg {
-	u_int dbenvcl_id;
-	u_int flags;
-};
-typedef struct __db_create_msg __db_create_msg;
-
-struct __db_create_reply {
-	int status;
-	u_int dbcl_id;
-};
-typedef struct __db_create_reply __db_create_reply;
-
-struct __db_del_msg {
-	u_int dbpcl_id;
-	u_int txnpcl_id;
-	u_int keydlen;
-	u_int keydoff;
-	u_int keyulen;
-	u_int keyflags;
-	struct {
-		u_int keydata_len;
-		char *keydata_val;
-	} keydata;
-	u_int flags;
-};
-typedef struct __db_del_msg __db_del_msg;
-
-struct __db_del_reply {
-	int status;
-};
-typedef struct __db_del_reply __db_del_reply;
-
-struct __db_encrypt_msg {
-	u_int dbpcl_id;
-	char *passwd;
-	u_int flags;
-};
-typedef struct __db_encrypt_msg __db_encrypt_msg;
-
-struct __db_encrypt_reply {
-	int status;
-};
-typedef struct __db_encrypt_reply __db_encrypt_reply;
-
-struct __db_extentsize_msg {
-	u_int dbpcl_id;
-	u_int extentsize;
-};
-typedef struct __db_extentsize_msg __db_extentsize_msg;
-
-struct __db_extentsize_reply {
-	int status;
-};
-typedef struct __db_extentsize_reply __db_extentsize_reply;
-
-struct __db_flags_msg {
-	u_int dbpcl_id;
-	u_int flags;
-};
-typedef struct __db_flags_msg __db_flags_msg;
-
-struct __db_flags_reply {
-	int status;
-};
-typedef struct __db_flags_reply __db_flags_reply;
-
-struct __db_get_msg {
-	u_int dbpcl_id;
-	u_int txnpcl_id;
-	u_int keydlen;
-	u_int keydoff;
-	u_int keyulen;
-	u_int keyflags;
-	struct {
-		u_int keydata_len;
-		char *keydata_val;
-	} keydata;
-	u_int datadlen;
-	u_int datadoff;
-	u_int dataulen;
-	u_int dataflags;
-	struct {
-		u_int datadata_len;
-		char *datadata_val;
-	} datadata;
-	u_int flags;
-};
-typedef struct __db_get_msg __db_get_msg;
-
-struct __db_get_reply {
-	int status;
-	struct {
-		u_int keydata_len;
-		char *keydata_val;
-	} keydata;
-	struct {
-		u_int datadata_len;
-		char *datadata_val;
-	} datadata;
-};
-typedef struct __db_get_reply __db_get_reply;
-
-struct __db_h_ffactor_msg {
-	u_int dbpcl_id;
-	u_int ffactor;
-};
-typedef struct __db_h_ffactor_msg __db_h_ffactor_msg;
-
-struct __db_h_ffactor_reply {
-	int status;
-};
-typedef struct __db_h_ffactor_reply __db_h_ffactor_reply;
-
-struct __db_h_nelem_msg {
-	u_int dbpcl_id;
-	u_int nelem;
-};
-typedef struct __db_h_nelem_msg __db_h_nelem_msg;
-
-struct __db_h_nelem_reply {
-	int status;
-};
-typedef struct __db_h_nelem_reply __db_h_nelem_reply;
-
-struct __db_key_range_msg {
-	u_int dbpcl_id;
-	u_int txnpcl_id;
-	u_int keydlen;
-	u_int keydoff;
-	u_int keyulen;
-	u_int keyflags;
-	struct {
-		u_int keydata_len;
-		char *keydata_val;
-	} keydata;
-	u_int flags;
-};
-typedef struct __db_key_range_msg __db_key_range_msg;
-
-struct __db_key_range_reply {
-	int status;
-	double less;
-	double equal;
-	double greater;
-};
-typedef struct __db_key_range_reply __db_key_range_reply;
-
-struct __db_lorder_msg {
-	u_int dbpcl_id;
-	u_int lorder;
-};
-typedef struct __db_lorder_msg __db_lorder_msg;
-
-struct __db_lorder_reply {
-	int status;
-};
-typedef struct __db_lorder_reply __db_lorder_reply;
-
-struct __db_open_msg {
-	u_int dbpcl_id;
-	u_int txnpcl_id;
-	char *name;
-	char *subdb;
-	u_int type;
-	u_int flags;
-	u_int mode;
-};
-typedef struct __db_open_msg __db_open_msg;
-
-struct __db_open_reply {
-	int status;
-	u_int dbcl_id;
-	u_int type;
-	u_int dbflags;
-	u_int lorder;
-};
-typedef struct __db_open_reply __db_open_reply;
-
-struct __db_pagesize_msg {
-	u_int dbpcl_id;
-	u_int pagesize;
-};
-typedef struct __db_pagesize_msg __db_pagesize_msg;
-
-struct __db_pagesize_reply {
-	int status;
-};
-typedef struct __db_pagesize_reply __db_pagesize_reply;
-
-struct __db_pget_msg {
-	u_int dbpcl_id;
-	u_int txnpcl_id;
-	u_int skeydlen;
-	u_int skeydoff;
-	u_int skeyulen;
-	u_int skeyflags;
-	struct {
-		u_int skeydata_len;
-		char *skeydata_val;
-	} skeydata;
-	u_int pkeydlen;
-	u_int pkeydoff;
-	u_int pkeyulen;
-	u_int pkeyflags;
-	struct {
-		u_int pkeydata_len;
-		char *pkeydata_val;
-	} pkeydata;
-	u_int datadlen;
-	u_int datadoff;
-	u_int dataulen;
-	u_int dataflags;
-	struct {
-		u_int datadata_len;
-		char *datadata_val;
-	} datadata;
-	u_int flags;
-};
-typedef struct __db_pget_msg __db_pget_msg;
-
-struct __db_pget_reply {
-	int status;
-	struct {
-		u_int skeydata_len;
-		char *skeydata_val;
-	} skeydata;
-	struct {
-		u_int pkeydata_len;
-		char *pkeydata_val;
-	} pkeydata;
-	struct {
-		u_int datadata_len;
-		char *datadata_val;
-	} datadata;
-};
-typedef struct __db_pget_reply __db_pget_reply;
-
-struct __db_put_msg {
-	u_int dbpcl_id;
-	u_int txnpcl_id;
-	u_int keydlen;
-	u_int keydoff;
-	u_int keyulen;
-	u_int keyflags;
-	struct {
-		u_int keydata_len;
-		char *keydata_val;
-	} keydata;
-	u_int datadlen;
-	u_int datadoff;
-	u_int dataulen;
-	u_int dataflags;
-	struct {
-		u_int datadata_len;
-		char *datadata_val;
-	} datadata;
-	u_int flags;
-};
-typedef struct __db_put_msg __db_put_msg;
-
-struct __db_put_reply {
-	int status;
-	struct {
-		u_int keydata_len;
-		char *keydata_val;
-	} keydata;
-};
-typedef struct __db_put_reply __db_put_reply;
-
-struct __db_re_delim_msg {
-	u_int dbpcl_id;
-	u_int delim;
-};
-typedef struct __db_re_delim_msg __db_re_delim_msg;
-
-struct __db_re_delim_reply {
-	int status;
-};
-typedef struct __db_re_delim_reply __db_re_delim_reply;
-
-struct __db_re_len_msg {
-	u_int dbpcl_id;
-	u_int len;
-};
-typedef struct __db_re_len_msg __db_re_len_msg;
-
-struct __db_re_len_reply {
-	int status;
-};
-typedef struct __db_re_len_reply __db_re_len_reply;
-
-struct __db_re_pad_msg {
-	u_int dbpcl_id;
-	u_int pad;
-};
-typedef struct __db_re_pad_msg __db_re_pad_msg;
-
-struct __db_re_pad_reply {
-	int status;
-};
-typedef struct __db_re_pad_reply __db_re_pad_reply;
-
-struct __db_remove_msg {
-	u_int dbpcl_id;
-	char *name;
-	char *subdb;
-	u_int flags;
-};
-typedef struct __db_remove_msg __db_remove_msg;
-
-struct __db_remove_reply {
-	int status;
-};
-typedef struct __db_remove_reply __db_remove_reply;
-
-struct __db_rename_msg {
-	u_int dbpcl_id;
-	char *name;
-	char *subdb;
-	char *newname;
-	u_int flags;
-};
-typedef struct __db_rename_msg __db_rename_msg;
-
-struct __db_rename_reply {
-	int status;
-};
-typedef struct __db_rename_reply __db_rename_reply;
-
-struct __db_stat_msg {
-	u_int dbpcl_id;
-	u_int flags;
-};
-typedef struct __db_stat_msg __db_stat_msg;
-
-struct __db_stat_reply {
-	int status;
-	struct {
-		u_int stats_len;
-		u_int *stats_val;
-	} stats;
-};
-typedef struct __db_stat_reply __db_stat_reply;
-
-struct __db_sync_msg {
-	u_int dbpcl_id;
-	u_int flags;
-};
-typedef struct __db_sync_msg __db_sync_msg;
-
-struct __db_sync_reply {
-	int status;
-};
-typedef struct __db_sync_reply __db_sync_reply;
-
-struct __db_truncate_msg {
-	u_int dbpcl_id;
-	u_int txnpcl_id;
-	u_int flags;
-};
-typedef struct __db_truncate_msg __db_truncate_msg;
-
-struct __db_truncate_reply {
-	int status;
-	u_int count;
-};
-typedef struct __db_truncate_reply __db_truncate_reply;
-
-struct __db_cursor_msg {
-	u_int dbpcl_id;
-	u_int txnpcl_id;
-	u_int flags;
-};
-typedef struct __db_cursor_msg __db_cursor_msg;
-
-struct __db_cursor_reply {
-	int status;
-	u_int dbcidcl_id;
-};
-typedef struct __db_cursor_reply __db_cursor_reply;
-
-struct __db_join_msg {
-	u_int dbpcl_id;
-	struct {
-		u_int curs_len;
-		u_int *curs_val;
-	} curs;
-	u_int flags;
-};
-typedef struct __db_join_msg __db_join_msg;
-
-struct __db_join_reply {
-	int status;
-	u_int dbcidcl_id;
-};
-typedef struct __db_join_reply __db_join_reply;
-
-struct __dbc_close_msg {
-	u_int dbccl_id;
-};
-typedef struct __dbc_close_msg __dbc_close_msg;
-
-struct __dbc_close_reply {
-	int status;
-};
-typedef struct __dbc_close_reply __dbc_close_reply;
-
-struct __dbc_count_msg {
-	u_int dbccl_id;
-	u_int flags;
-};
-typedef struct __dbc_count_msg __dbc_count_msg;
-
-struct __dbc_count_reply {
-	int status;
-	u_int dupcount;
-};
-typedef struct __dbc_count_reply __dbc_count_reply;
-
-struct __dbc_del_msg {
-	u_int dbccl_id;
-	u_int flags;
-};
-typedef struct __dbc_del_msg __dbc_del_msg;
-
-struct __dbc_del_reply {
-	int status;
-};
-typedef struct __dbc_del_reply __dbc_del_reply;
-
-struct __dbc_dup_msg {
-	u_int dbccl_id;
-	u_int flags;
-};
-typedef struct __dbc_dup_msg __dbc_dup_msg;
-
-struct __dbc_dup_reply {
-	int status;
-	u_int dbcidcl_id;
-};
-typedef struct __dbc_dup_reply __dbc_dup_reply;
-
-struct __dbc_get_msg {
-	u_int dbccl_id;
-	u_int keydlen;
-	u_int keydoff;
-	u_int keyulen;
-	u_int keyflags;
-	struct {
-		u_int keydata_len;
-		char *keydata_val;
-	} keydata;
-	u_int datadlen;
-	u_int datadoff;
-	u_int dataulen;
-	u_int dataflags;
-	struct {
-		u_int datadata_len;
-		char *datadata_val;
-	} datadata;
-	u_int flags;
-};
-typedef struct __dbc_get_msg __dbc_get_msg;
-
-struct __dbc_get_reply {
-	int status;
-	struct {
-		u_int keydata_len;
-		char *keydata_val;
-	} keydata;
-	struct {
-		u_int datadata_len;
-		char *datadata_val;
-	} datadata;
-};
-typedef struct __dbc_get_reply __dbc_get_reply;
-
-struct __dbc_pget_msg {
-	u_int dbccl_id;
-	u_int skeydlen;
-	u_int skeydoff;
-	u_int skeyulen;
-	u_int skeyflags;
-	struct {
-		u_int skeydata_len;
-		char *skeydata_val;
-	} skeydata;
-	u_int pkeydlen;
-	u_int pkeydoff;
-	u_int pkeyulen;
-	u_int pkeyflags;
-	struct {
-		u_int pkeydata_len;
-		char *pkeydata_val;
-	} pkeydata;
-	u_int datadlen;
-	u_int datadoff;
-	u_int dataulen;
-	u_int dataflags;
-	struct {
-		u_int datadata_len;
-		char *datadata_val;
-	} datadata;
-	u_int flags;
-};
-typedef struct __dbc_pget_msg __dbc_pget_msg;
-
-struct __dbc_pget_reply {
-	int status;
-	struct {
-		u_int skeydata_len;
-		char *skeydata_val;
-	} skeydata;
-	struct {
-		u_int pkeydata_len;
-		char *pkeydata_val;
-	} pkeydata;
-	struct {
-		u_int datadata_len;
-		char *datadata_val;
-	} datadata;
-};
-typedef struct __dbc_pget_reply __dbc_pget_reply;
-
-struct __dbc_put_msg {
-	u_int dbccl_id;
-	u_int keydlen;
-	u_int keydoff;
-	u_int keyulen;
-	u_int keyflags;
-	struct {
-		u_int keydata_len;
-		char *keydata_val;
-	} keydata;
-	u_int datadlen;
-	u_int datadoff;
-	u_int dataulen;
-	u_int dataflags;
-	struct {
-		u_int datadata_len;
-		char *datadata_val;
-	} datadata;
-	u_int flags;
-};
-typedef struct __dbc_put_msg __dbc_put_msg;
-
-struct __dbc_put_reply {
-	int status;
-	struct {
-		u_int keydata_len;
-		char *keydata_val;
-	} keydata;
-};
-typedef struct __dbc_put_reply __dbc_put_reply;
-
-#define	__DB_env_cachesize ((unsigned long)(1))
-extern  __env_cachesize_reply * __db_env_cachesize_4001();
-#define	__DB_env_close ((unsigned long)(2))
-extern  __env_close_reply * __db_env_close_4001();
-#define	__DB_env_create ((unsigned long)(3))
-extern  __env_create_reply * __db_env_create_4001();
-#define	__DB_env_dbremove ((unsigned long)(4))
-extern  __env_dbremove_reply * __db_env_dbremove_4001();
-#define	__DB_env_dbrename ((unsigned long)(5))
-extern  __env_dbrename_reply * __db_env_dbrename_4001();
-#define	__DB_env_encrypt ((unsigned long)(6))
-extern  __env_encrypt_reply * __db_env_encrypt_4001();
-#define	__DB_env_flags ((unsigned long)(7))
-extern  __env_flags_reply * __db_env_flags_4001();
-#define	__DB_env_open ((unsigned long)(8))
-extern  __env_open_reply * __db_env_open_4001();
-#define	__DB_env_remove ((unsigned long)(9))
-extern  __env_remove_reply * __db_env_remove_4001();
-#define	__DB_txn_abort ((unsigned long)(10))
-extern  __txn_abort_reply * __db_txn_abort_4001();
-#define	__DB_txn_begin ((unsigned long)(11))
-extern  __txn_begin_reply * __db_txn_begin_4001();
-#define	__DB_txn_commit ((unsigned long)(12))
-extern  __txn_commit_reply * __db_txn_commit_4001();
-#define	__DB_txn_discard ((unsigned long)(13))
-extern  __txn_discard_reply * __db_txn_discard_4001();
-#define	__DB_txn_prepare ((unsigned long)(14))
-extern  __txn_prepare_reply * __db_txn_prepare_4001();
-#define	__DB_txn_recover ((unsigned long)(15))
-extern  __txn_recover_reply * __db_txn_recover_4001();
-#define	__DB_db_associate ((unsigned long)(16))
-extern  __db_associate_reply * __db_db_associate_4001();
-#define	__DB_db_bt_maxkey ((unsigned long)(17))
-extern  __db_bt_maxkey_reply * __db_db_bt_maxkey_4001();
-#define	__DB_db_bt_minkey ((unsigned long)(18))
-extern  __db_bt_minkey_reply * __db_db_bt_minkey_4001();
-#define	__DB_db_close ((unsigned long)(19))
-extern  __db_close_reply * __db_db_close_4001();
-#define	__DB_db_create ((unsigned long)(20))
-extern  __db_create_reply * __db_db_create_4001();
-#define	__DB_db_del ((unsigned long)(21))
-extern  __db_del_reply * __db_db_del_4001();
-#define	__DB_db_encrypt ((unsigned long)(22))
-extern  __db_encrypt_reply * __db_db_encrypt_4001();
-#define	__DB_db_extentsize ((unsigned long)(23))
-extern  __db_extentsize_reply * __db_db_extentsize_4001();
-#define	__DB_db_flags ((unsigned long)(24))
-extern  __db_flags_reply * __db_db_flags_4001();
-#define	__DB_db_get ((unsigned long)(25))
-extern  __db_get_reply * __db_db_get_4001();
-#define	__DB_db_h_ffactor ((unsigned long)(26))
-extern  __db_h_ffactor_reply * __db_db_h_ffactor_4001();
-#define	__DB_db_h_nelem ((unsigned long)(27))
-extern  __db_h_nelem_reply * __db_db_h_nelem_4001();
-#define	__DB_db_key_range ((unsigned long)(28))
-extern  __db_key_range_reply * __db_db_key_range_4001();
-#define	__DB_db_lorder ((unsigned long)(29))
-extern  __db_lorder_reply * __db_db_lorder_4001();
-#define	__DB_db_open ((unsigned long)(30))
-extern  __db_open_reply * __db_db_open_4001();
-#define	__DB_db_pagesize ((unsigned long)(31))
-extern  __db_pagesize_reply * __db_db_pagesize_4001();
-#define	__DB_db_pget ((unsigned long)(32))
-extern  __db_pget_reply * __db_db_pget_4001();
-#define	__DB_db_put ((unsigned long)(33))
-extern  __db_put_reply * __db_db_put_4001();
-#define	__DB_db_re_delim ((unsigned long)(34))
-extern  __db_re_delim_reply * __db_db_re_delim_4001();
-#define	__DB_db_re_len ((unsigned long)(35))
-extern  __db_re_len_reply * __db_db_re_len_4001();
-#define	__DB_db_re_pad ((unsigned long)(36))
-extern  __db_re_pad_reply * __db_db_re_pad_4001();
-#define	__DB_db_remove ((unsigned long)(37))
-extern  __db_remove_reply * __db_db_remove_4001();
-#define	__DB_db_rename ((unsigned long)(38))
-extern  __db_rename_reply * __db_db_rename_4001();
-#define	__DB_db_stat ((unsigned long)(39))
-extern  __db_stat_reply * __db_db_stat_4001();
-#define	__DB_db_sync ((unsigned long)(40))
-extern  __db_sync_reply * __db_db_sync_4001();
-#define	__DB_db_truncate ((unsigned long)(41))
-extern  __db_truncate_reply * __db_db_truncate_4001();
-#define	__DB_db_cursor ((unsigned long)(42))
-extern  __db_cursor_reply * __db_db_cursor_4001();
-#define	__DB_db_join ((unsigned long)(43))
-extern  __db_join_reply * __db_db_join_4001();
-#define	__DB_dbc_close ((unsigned long)(44))
-extern  __dbc_close_reply * __db_dbc_close_4001();
-#define	__DB_dbc_count ((unsigned long)(45))
-extern  __dbc_count_reply * __db_dbc_count_4001();
-#define	__DB_dbc_del ((unsigned long)(46))
-extern  __dbc_del_reply * __db_dbc_del_4001();
-#define	__DB_dbc_dup ((unsigned long)(47))
-extern  __dbc_dup_reply * __db_dbc_dup_4001();
-#define	__DB_dbc_get ((unsigned long)(48))
-extern  __dbc_get_reply * __db_dbc_get_4001();
-#define	__DB_dbc_pget ((unsigned long)(49))
-extern  __dbc_pget_reply * __db_dbc_pget_4001();
-#define	__DB_dbc_put ((unsigned long)(50))
-extern  __dbc_put_reply * __db_dbc_put_4001();
-extern int db_rpc_serverprog_4001_freeresult();
-
-/* the xdr functions */
-extern bool_t xdr___env_cachesize_msg();
-extern bool_t xdr___env_cachesize_reply();
-extern bool_t xdr___env_close_msg();
-extern bool_t xdr___env_close_reply();
-extern bool_t xdr___env_create_msg();
-extern bool_t xdr___env_create_reply();
-extern bool_t xdr___env_dbremove_msg();
-extern bool_t xdr___env_dbremove_reply();
-extern bool_t xdr___env_dbrename_msg();
-extern bool_t xdr___env_dbrename_reply();
-extern bool_t xdr___env_encrypt_msg();
-extern bool_t xdr___env_encrypt_reply();
-extern bool_t xdr___env_flags_msg();
-extern bool_t xdr___env_flags_reply();
-extern bool_t xdr___env_open_msg();
-extern bool_t xdr___env_open_reply();
-extern bool_t xdr___env_remove_msg();
-extern bool_t xdr___env_remove_reply();
-extern bool_t xdr___txn_abort_msg();
-extern bool_t xdr___txn_abort_reply();
-extern bool_t xdr___txn_begin_msg();
-extern bool_t xdr___txn_begin_reply();
-extern bool_t xdr___txn_commit_msg();
-extern bool_t xdr___txn_commit_reply();
-extern bool_t xdr___txn_discard_msg();
-extern bool_t xdr___txn_discard_reply();
-extern bool_t xdr___txn_prepare_msg();
-extern bool_t xdr___txn_prepare_reply();
-extern bool_t xdr___txn_recover_msg();
-extern bool_t xdr___txn_recover_reply();
-extern bool_t xdr___db_associate_msg();
-extern bool_t xdr___db_associate_reply();
-extern bool_t xdr___db_bt_maxkey_msg();
-extern bool_t xdr___db_bt_maxkey_reply();
-extern bool_t xdr___db_bt_minkey_msg();
-extern bool_t xdr___db_bt_minkey_reply();
-extern bool_t xdr___db_close_msg();
-extern bool_t xdr___db_close_reply();
-extern bool_t xdr___db_create_msg();
-extern bool_t xdr___db_create_reply();
-extern bool_t xdr___db_del_msg();
-extern bool_t xdr___db_del_reply();
-extern bool_t xdr___db_encrypt_msg();
-extern bool_t xdr___db_encrypt_reply();
-extern bool_t xdr___db_extentsize_msg();
-extern bool_t xdr___db_extentsize_reply();
-extern bool_t xdr___db_flags_msg();
-extern bool_t xdr___db_flags_reply();
-extern bool_t xdr___db_get_msg();
-extern bool_t xdr___db_get_reply();
-extern bool_t xdr___db_h_ffactor_msg();
-extern bool_t xdr___db_h_ffactor_reply();
-extern bool_t xdr___db_h_nelem_msg();
-extern bool_t xdr___db_h_nelem_reply();
-extern bool_t xdr___db_key_range_msg();
-extern bool_t xdr___db_key_range_reply();
-extern bool_t xdr___db_lorder_msg();
-extern bool_t xdr___db_lorder_reply();
-extern bool_t xdr___db_open_msg();
-extern bool_t xdr___db_open_reply();
-extern bool_t xdr___db_pagesize_msg();
-extern bool_t xdr___db_pagesize_reply();
-extern bool_t xdr___db_pget_msg();
-extern bool_t xdr___db_pget_reply();
-extern bool_t xdr___db_put_msg();
-extern bool_t xdr___db_put_reply();
-extern bool_t xdr___db_re_delim_msg();
-extern bool_t xdr___db_re_delim_reply();
-extern bool_t xdr___db_re_len_msg();
-extern bool_t xdr___db_re_len_reply();
-extern bool_t xdr___db_re_pad_msg();
-extern bool_t xdr___db_re_pad_reply();
-extern bool_t xdr___db_remove_msg();
-extern bool_t xdr___db_remove_reply();
-extern bool_t xdr___db_rename_msg();
-extern bool_t xdr___db_rename_reply();
-extern bool_t xdr___db_stat_msg();
-extern bool_t xdr___db_stat_reply();
-extern bool_t xdr___db_sync_msg();
-extern bool_t xdr___db_sync_reply();
-extern bool_t xdr___db_truncate_msg();
-extern bool_t xdr___db_truncate_reply();
-extern bool_t xdr___db_cursor_msg();
-extern bool_t xdr___db_cursor_reply();
-extern bool_t xdr___db_join_msg();
-extern bool_t xdr___db_join_reply();
-extern bool_t xdr___dbc_close_msg();
-extern bool_t xdr___dbc_close_reply();
-extern bool_t xdr___dbc_count_msg();
-extern bool_t xdr___dbc_count_reply();
-extern bool_t xdr___dbc_del_msg();
-extern bool_t xdr___dbc_del_reply();
-extern bool_t xdr___dbc_dup_msg();
-extern bool_t xdr___dbc_dup_reply();
-extern bool_t xdr___dbc_get_msg();
-extern bool_t xdr___dbc_get_reply();
-extern bool_t xdr___dbc_pget_msg();
-extern bool_t xdr___dbc_pget_reply();
-extern bool_t xdr___dbc_put_msg();
-extern bool_t xdr___dbc_put_reply();
-
-#endif /* !_DB_SERVER_H_RPCGEN */
diff --git a/bdb/dbinc_auto/dbreg_auto.h b/bdb/dbinc_auto/dbreg_auto.h
deleted file mode 100644
index 4d7d4a91b45013cb894b97ef31168ac68a25f8cc..0000000000000000000000000000000000000000
--- a/bdb/dbinc_auto/dbreg_auto.h
+++ /dev/null
@@ -1,19 +0,0 @@
-/* Do not edit: automatically built by gen_rec.awk. */
-
-#ifndef	__dbreg_AUTO_H
-#define	__dbreg_AUTO_H
-#define	DB___dbreg_register	2
-typedef struct ___dbreg_register_args {
-	u_int32_t type;
-	DB_TXN *txnid;
-	DB_LSN prev_lsn;
-	u_int32_t	opcode;
-	DBT	name;
-	DBT	uid;
-	int32_t	fileid;
-	DBTYPE	ftype;
-	db_pgno_t	meta_pgno;
-	u_int32_t	id;
-} __dbreg_register_args;
-
-#endif
diff --git a/bdb/dbinc_auto/dbreg_ext.h b/bdb/dbinc_auto/dbreg_ext.h
deleted file mode 100644
index eda26206d86e012813a511348fc2ad616b4c3676..0000000000000000000000000000000000000000
--- a/bdb/dbinc_auto/dbreg_ext.h
+++ /dev/null
@@ -1,43 +0,0 @@
-/* DO NOT EDIT: automatically built by dist/s_include. */
-#ifndef	_dbreg_ext_h_
-#define	_dbreg_ext_h_
-
-#if defined(__cplusplus)
-extern "C" {
-#endif
-
-int __dbreg_setup __P((DB *, const char *, u_int32_t));
-int __dbreg_teardown __P((DB *));
-int __dbreg_new_id __P((DB *, DB_TXN *));
-int __dbreg_assign_id __P((DB *, int32_t));
-int __dbreg_revoke_id __P((DB *, int));
-int __dbreg_close_id __P((DB *, DB_TXN *));
-int __dbreg_register_log __P((DB_ENV *, DB_TXN *, DB_LSN *, u_int32_t, u_int32_t, const DBT *, const DBT *, int32_t, DBTYPE, db_pgno_t, u_int32_t));
-int __dbreg_register_getpgnos __P((DB_ENV *, DBT *, DB_LSN *, db_recops, void *));
-int __dbreg_register_print __P((DB_ENV *, DBT *, DB_LSN *, db_recops, void *));
-int __dbreg_register_read __P((DB_ENV *, void *, __dbreg_register_args **));
-int __dbreg_init_print __P((DB_ENV *, int (***)(DB_ENV *, DBT *, DB_LSN *, db_recops, void *), size_t *));
-int __dbreg_init_getpgnos __P((DB_ENV *, int (***)(DB_ENV *, DBT *, DB_LSN *, db_recops, void *), size_t *));
-int __dbreg_init_recover __P((DB_ENV *, int (***)(DB_ENV *, DBT *, DB_LSN *, db_recops, void *), size_t *));
-int __dbreg_register_recover __P((DB_ENV *, DBT *, DB_LSN *, db_recops, void *));
-int __dbreg_add_dbentry __P((DB_ENV *, DB_LOG *, DB *, int32_t));
-void __dbreg_rem_dbentry __P((DB_LOG *, int32_t));
-int __dbreg_open_files __P((DB_ENV *));
-int __dbreg_close_files __P((DB_ENV *));
-int __dbreg_nofiles __P((DB_ENV *));
-int __dbreg_id_to_db __P((DB_ENV *, DB_TXN *, DB **, int32_t, int));
-int __dbreg_id_to_db_int __P((DB_ENV *, DB_TXN *, DB **, int32_t, int, int));
-int __dbreg_id_to_fname __P((DB_LOG *, int32_t, int, FNAME **));
-int __dbreg_fid_to_fname __P((DB_LOG *, u_int8_t *, int, FNAME **));
-int __dbreg_get_name __P((DB_ENV *, u_int8_t *, char **));
-int __dbreg_do_open __P((DB_ENV *, DB_TXN *, DB_LOG *, u_int8_t *, char *, DBTYPE, int32_t, db_pgno_t, void *, u_int32_t));
-int __dbreg_lazy_id __P((DB *));
-int __dbreg_push_id __P((DB_ENV *, int32_t));
-int __dbreg_pop_id __P((DB_ENV *, int32_t *));
-int __dbreg_pluck_id __P((DB_ENV *, int32_t));
-void __dbreg_print_dblist __P((DB_ENV *));
-
-#if defined(__cplusplus)
-}
-#endif
-#endif /* !_dbreg_ext_h_ */
diff --git a/bdb/dbinc_auto/env_ext.h b/bdb/dbinc_auto/env_ext.h
deleted file mode 100644
index 4bd0eee4a83a52d10c73428cf58838b895b6d664..0000000000000000000000000000000000000000
--- a/bdb/dbinc_auto/env_ext.h
+++ /dev/null
@@ -1,39 +0,0 @@
-/* DO NOT EDIT: automatically built by dist/s_include. */
-#ifndef	_env_ext_h_
-#define	_env_ext_h_
-
-#if defined(__cplusplus)
-extern "C" {
-#endif
-
-void __db_shalloc_init __P((void *, size_t));
-int __db_shalloc_size __P((size_t, size_t));
-int __db_shalloc __P((void *, size_t, size_t, void *));
-void __db_shalloc_free __P((void *, void *));
-size_t __db_shsizeof __P((void *));
-void __db_shalloc_dump __P((void *, FILE *));
-int __db_tablesize __P((u_int32_t));
-void __db_hashinit __P((void *, u_int32_t));
-int __db_fileinit __P((DB_ENV *, DB_FH *, size_t, int));
-int __db_overwrite __P((DB_ENV *, const char *));
-int __db_mi_env __P((DB_ENV *, const char *));
-int __db_mi_open __P((DB_ENV *, const char *, int));
-int __db_env_config __P((DB_ENV *, char *, u_int32_t));
-int __dbenv_open __P((DB_ENV *, const char *, u_int32_t, int));
-int __dbenv_remove __P((DB_ENV *, const char *, u_int32_t));
-int __dbenv_close __P((DB_ENV *, u_int32_t));
-int __db_appname __P((DB_ENV *, APPNAME, const char *, u_int32_t, DB_FH *, char **));
-int __db_home __P((DB_ENV *, const char *, u_int32_t));
-int __db_apprec __P((DB_ENV *, DB_LSN *, u_int32_t));
-int __env_openfiles __P((DB_ENV *, DB_LOGC *, void *, DBT *, DB_LSN *, DB_LSN *, double, int));
-int __db_e_attach __P((DB_ENV *, u_int32_t *));
-int __db_e_detach __P((DB_ENV *, int));
-int __db_e_remove __P((DB_ENV *, u_int32_t));
-int __db_e_stat __P((DB_ENV *, REGENV *, REGION *, int *, u_int32_t));
-int __db_r_attach __P((DB_ENV *, REGINFO *, size_t));
-int __db_r_detach __P((DB_ENV *, REGINFO *, int));
-
-#if defined(__cplusplus)
-}
-#endif
-#endif /* !_env_ext_h_ */
diff --git a/bdb/dbinc_auto/ext_185_def.in b/bdb/dbinc_auto/ext_185_def.in
deleted file mode 100644
index 8da68a8df9d45394535cd7322d26b770289cec20..0000000000000000000000000000000000000000
--- a/bdb/dbinc_auto/ext_185_def.in
+++ /dev/null
@@ -1,12 +0,0 @@
-
-/* DO NOT EDIT: automatically built by dist/s_include. */
-#ifndef	_DB_EXT_185_DEF_IN_
-#define	_DB_EXT_185_DEF_IN_
-
-#ifdef _DB185_INT_H_
-#define	__db185_open __db185_open@DB_VERSION_UNIQUE_NAME@
-#else
-#define	__db185_open __db185_open@DB_VERSION_UNIQUE_NAME@
-#endif
-
-#endif /* !_DB_EXT_185_DEF_IN_ */
diff --git a/bdb/dbinc_auto/ext_185_prot.in b/bdb/dbinc_auto/ext_185_prot.in
deleted file mode 100644
index dfd8d3d476effebe23fd201d89c32758c5099150..0000000000000000000000000000000000000000
--- a/bdb/dbinc_auto/ext_185_prot.in
+++ /dev/null
@@ -1,19 +0,0 @@
-
-/* DO NOT EDIT: automatically built by dist/s_include. */
-#ifndef	_DB_EXT_185_PROT_IN_
-#define	_DB_EXT_185_PROT_IN_
-
-#if defined(__cplusplus)
-extern "C" {
-#endif
-
-#ifdef _DB185_INT_H_
-DB185 *__db185_open __P((const char *, int, int, DBTYPE, const void *));
-#else
-DB *__db185_open __P((const char *, int, int, DBTYPE, const void *));
-#endif
-
-#if defined(__cplusplus)
-}
-#endif
-#endif /* !_DB_EXT_185_PROT_IN_ */
diff --git a/bdb/dbinc_auto/ext_def.in b/bdb/dbinc_auto/ext_def.in
deleted file mode 100644
index 7bef2465645f6c893c641f48445772482e205984..0000000000000000000000000000000000000000
--- a/bdb/dbinc_auto/ext_def.in
+++ /dev/null
@@ -1,61 +0,0 @@
-
-/* DO NOT EDIT: automatically built by dist/s_include. */
-#ifndef	_DB_EXT_DEF_IN_
-#define	_DB_EXT_DEF_IN_
-
-#define	db_create db_create@DB_VERSION_UNIQUE_NAME@
-#define	db_strerror db_strerror@DB_VERSION_UNIQUE_NAME@
-#define	db_env_create db_env_create@DB_VERSION_UNIQUE_NAME@
-#define	db_version db_version@DB_VERSION_UNIQUE_NAME@
-#define	log_compare log_compare@DB_VERSION_UNIQUE_NAME@
-#define	db_env_set_func_close db_env_set_func_close@DB_VERSION_UNIQUE_NAME@
-#define	db_env_set_func_dirfree db_env_set_func_dirfree@DB_VERSION_UNIQUE_NAME@
-#define	db_env_set_func_dirlist db_env_set_func_dirlist@DB_VERSION_UNIQUE_NAME@
-#define	db_env_set_func_exists db_env_set_func_exists@DB_VERSION_UNIQUE_NAME@
-#define	db_env_set_func_free db_env_set_func_free@DB_VERSION_UNIQUE_NAME@
-#define	db_env_set_func_fsync db_env_set_func_fsync@DB_VERSION_UNIQUE_NAME@
-#define	db_env_set_func_ioinfo db_env_set_func_ioinfo@DB_VERSION_UNIQUE_NAME@
-#define	db_env_set_func_malloc db_env_set_func_malloc@DB_VERSION_UNIQUE_NAME@
-#define	db_env_set_func_map db_env_set_func_map@DB_VERSION_UNIQUE_NAME@
-#define	db_env_set_func_open db_env_set_func_open@DB_VERSION_UNIQUE_NAME@
-#define	db_env_set_func_read db_env_set_func_read@DB_VERSION_UNIQUE_NAME@
-#define	db_env_set_func_realloc db_env_set_func_realloc@DB_VERSION_UNIQUE_NAME@
-#define	db_env_set_func_rename db_env_set_func_rename@DB_VERSION_UNIQUE_NAME@
-#define	db_env_set_func_seek db_env_set_func_seek@DB_VERSION_UNIQUE_NAME@
-#define	db_env_set_func_sleep db_env_set_func_sleep@DB_VERSION_UNIQUE_NAME@
-#define	db_env_set_func_unlink db_env_set_func_unlink@DB_VERSION_UNIQUE_NAME@
-#define	db_env_set_func_unmap db_env_set_func_unmap@DB_VERSION_UNIQUE_NAME@
-#define	db_env_set_func_write db_env_set_func_write@DB_VERSION_UNIQUE_NAME@
-#define	db_env_set_func_yield db_env_set_func_yield@DB_VERSION_UNIQUE_NAME@
-#if DB_DBM_HSEARCH != 0
-#define	__db_ndbm_clearerr __db_ndbm_clearerr@DB_VERSION_UNIQUE_NAME@
-#define	__db_ndbm_close __db_ndbm_close@DB_VERSION_UNIQUE_NAME@
-#define	__db_ndbm_delete __db_ndbm_delete@DB_VERSION_UNIQUE_NAME@
-#define	__db_ndbm_dirfno __db_ndbm_dirfno@DB_VERSION_UNIQUE_NAME@
-#define	__db_ndbm_error __db_ndbm_error@DB_VERSION_UNIQUE_NAME@
-#define	__db_ndbm_fetch __db_ndbm_fetch@DB_VERSION_UNIQUE_NAME@
-#define	__db_ndbm_firstkey __db_ndbm_firstkey@DB_VERSION_UNIQUE_NAME@
-#define	__db_ndbm_nextkey __db_ndbm_nextkey@DB_VERSION_UNIQUE_NAME@
-#define	__db_ndbm_open __db_ndbm_open@DB_VERSION_UNIQUE_NAME@
-#define	__db_ndbm_pagfno __db_ndbm_pagfno@DB_VERSION_UNIQUE_NAME@
-#define	__db_ndbm_rdonly __db_ndbm_rdonly@DB_VERSION_UNIQUE_NAME@
-#define	__db_ndbm_store __db_ndbm_store@DB_VERSION_UNIQUE_NAME@
-#define	__db_dbm_close __db_dbm_close@DB_VERSION_UNIQUE_NAME@
-#define	__db_dbm_dbrdonly __db_dbm_dbrdonly@DB_VERSION_UNIQUE_NAME@
-#define	__db_dbm_delete __db_dbm_delete@DB_VERSION_UNIQUE_NAME@
-#define	__db_dbm_dirf __db_dbm_dirf@DB_VERSION_UNIQUE_NAME@
-#define	__db_dbm_fetch __db_dbm_fetch@DB_VERSION_UNIQUE_NAME@
-#define	__db_dbm_firstkey __db_dbm_firstkey@DB_VERSION_UNIQUE_NAME@
-#define	__db_dbm_init __db_dbm_init@DB_VERSION_UNIQUE_NAME@
-#define	__db_dbm_nextkey __db_dbm_nextkey@DB_VERSION_UNIQUE_NAME@
-#define	__db_dbm_pagf __db_dbm_pagf@DB_VERSION_UNIQUE_NAME@
-#define	__db_dbm_store __db_dbm_store@DB_VERSION_UNIQUE_NAME@
-#endif
-#if DB_DBM_HSEARCH != 0
-#define	__db_hcreate __db_hcreate@DB_VERSION_UNIQUE_NAME@
-#define	__db_hsearch __db_hsearch@DB_VERSION_UNIQUE_NAME@
-#define	__db_hdestroy __db_hdestroy@DB_VERSION_UNIQUE_NAME@
-#endif
-#define db_xa_switch db_xa_switch@DB_VERSION_UNIQUE_NAME@
-
-#endif /* !_DB_EXT_DEF_IN_ */
diff --git a/bdb/dbinc_auto/ext_prot.in b/bdb/dbinc_auto/ext_prot.in
deleted file mode 100644
index 42c77a1f7637fa0fa7d12ba92157c2f4c4f185ad..0000000000000000000000000000000000000000
--- a/bdb/dbinc_auto/ext_prot.in
+++ /dev/null
@@ -1,70 +0,0 @@
-
-/* DO NOT EDIT: automatically built by dist/s_include. */
-#ifndef	_DB_EXT_PROT_IN_
-#define	_DB_EXT_PROT_IN_
-
-#if defined(__cplusplus)
-extern "C" {
-#endif
-
-int db_create __P((DB **, DB_ENV *, u_int32_t));
-char *db_strerror __P((int));
-int db_env_create __P((DB_ENV **, u_int32_t));
-char *db_version __P((int *, int *, int *));
-int log_compare __P((const DB_LSN *, const DB_LSN *));
-int db_env_set_func_close __P((int (*)(int)));
-int db_env_set_func_dirfree __P((void (*)(char **, int)));
-int db_env_set_func_dirlist __P((int (*)(const char *, char ***, int *)));
-int db_env_set_func_exists __P((int (*)(const char *, int *)));
-int db_env_set_func_free __P((void (*)(void *)));
-int db_env_set_func_fsync __P((int (*)(int)));
-int db_env_set_func_ioinfo __P((int (*)(const char *, int, u_int32_t *, u_int32_t *, u_int32_t *)));
-int db_env_set_func_malloc __P((void *(*)(size_t)));
-int db_env_set_func_map __P((int (*)(char *, size_t, int, int, void **)));
-int db_env_set_func_open __P((int (*)(const char *, int, ...)));
-int db_env_set_func_read __P((ssize_t (*)(int, void *, size_t)));
-int db_env_set_func_realloc __P((void *(*)(void *, size_t)));
-int db_env_set_func_rename __P((int (*)(const char *, const char *)));
-int db_env_set_func_seek __P((int (*)(int, size_t, db_pgno_t, u_int32_t, int, int)));
-int db_env_set_func_sleep __P((int (*)(u_long, u_long)));
-int db_env_set_func_unlink __P((int (*)(const char *)));
-int db_env_set_func_unmap __P((int (*)(void *, size_t)));
-int db_env_set_func_write __P((ssize_t (*)(int, const void *, size_t)));
-int db_env_set_func_yield __P((int (*)(void)));
-int txn_abort __P((DB_TXN *));
-int txn_begin __P((DB_ENV *, DB_TXN *, DB_TXN **, u_int32_t));
-int txn_commit __P((DB_TXN *, u_int32_t));
-#if DB_DBM_HSEARCH != 0
-int	 __db_ndbm_clearerr __P((DBM *));
-void	 __db_ndbm_close __P((DBM *));
-int	 __db_ndbm_delete __P((DBM *, datum));
-int	 __db_ndbm_dirfno __P((DBM *));
-int	 __db_ndbm_error __P((DBM *));
-datum __db_ndbm_fetch __P((DBM *, datum));
-datum __db_ndbm_firstkey __P((DBM *));
-datum __db_ndbm_nextkey __P((DBM *));
-DBM	*__db_ndbm_open __P((const char *, int, int));
-int	 __db_ndbm_pagfno __P((DBM *));
-int	 __db_ndbm_rdonly __P((DBM *));
-int	 __db_ndbm_store __P((DBM *, datum, datum, int));
-int	 __db_dbm_close __P((void));
-int	 __db_dbm_dbrdonly __P((void));
-int	 __db_dbm_delete __P((datum));
-int	 __db_dbm_dirf __P((void));
-datum __db_dbm_fetch __P((datum));
-datum __db_dbm_firstkey __P((void));
-int	 __db_dbm_init __P((char *));
-datum __db_dbm_nextkey __P((datum));
-int	 __db_dbm_pagf __P((void));
-int	 __db_dbm_store __P((datum, datum));
-#endif
-#if DB_DBM_HSEARCH != 0
-int __db_hcreate __P((size_t));
-ENTRY *__db_hsearch __P((ENTRY, ACTION));
-void __db_hdestroy __P((void));
-#endif
-
-#if defined(__cplusplus)
-}
-#endif
-#endif /* !_DB_EXT_PROT_IN_ */
diff --git a/bdb/dbinc_auto/fileops_auto.h b/bdb/dbinc_auto/fileops_auto.h
deleted file mode 100644
index ee1f58616cef046ea1a420b2018b2bb79605dbfc..0000000000000000000000000000000000000000
--- a/bdb/dbinc_auto/fileops_auto.h
+++ /dev/null
@@ -1,60 +0,0 @@
-/* Do not edit: automatically built by gen_rec.awk. */
-
-#ifndef	__fop_AUTO_H
-#define	__fop_AUTO_H
-#define	DB___fop_create	143
-typedef struct ___fop_create_args {
-	u_int32_t type;
-	DB_TXN *txnid;
-	DB_LSN prev_lsn;
-	DBT	name;
-	u_int32_t	appname;
-	u_int32_t	mode;
-} __fop_create_args;
-
-#define	DB___fop_remove	144
-typedef struct ___fop_remove_args {
-	u_int32_t type;
-	DB_TXN *txnid;
-	DB_LSN prev_lsn;
-	DBT	name;
-	DBT	fid;
-	u_int32_t	appname;
-} __fop_remove_args;
-
-#define	DB___fop_write	145
-typedef struct ___fop_write_args {
-	u_int32_t type;
-	DB_TXN *txnid;
-	DB_LSN prev_lsn;
-	DBT	name;
-	u_int32_t	appname;
-	u_int32_t	offset;
-	DBT	page;
-	u_int32_t	flag;
-} __fop_write_args;
-
-#define	DB___fop_rename	146
-typedef struct ___fop_rename_args {
-	u_int32_t type;
-	DB_TXN *txnid;
-	DB_LSN prev_lsn;
-	DBT	oldname;
-	DBT	newname;
-	DBT	fileid;
-	u_int32_t	appname;
-} __fop_rename_args;
-
-#define	DB___fop_file_remove	141
-typedef struct ___fop_file_remove_args {
-	u_int32_t type;
-	DB_TXN *txnid;
-	DB_LSN prev_lsn;
-	DBT	real_fid;
-	DBT	tmp_fid;
-	DBT	name;
-	u_int32_t	appname;
-	u_int32_t	child;
-} __fop_file_remove_args;
-
-#endif
diff --git a/bdb/dbinc_auto/fileops_ext.h b/bdb/dbinc_auto/fileops_ext.h
deleted file mode 100644
index 66d80e60ad91dc03e6eeb4d5f315227a9c765d19..0000000000000000000000000000000000000000
--- a/bdb/dbinc_auto/fileops_ext.h
+++ /dev/null
@@ -1,52 +0,0 @@
-/* DO NOT EDIT: automatically built by dist/s_include. */
-#ifndef	_fileops_ext_h_
-#define	_fileops_ext_h_
-
-#if defined(__cplusplus)
-extern "C" {
-#endif
-
-int __fop_create_log __P((DB_ENV *, DB_TXN *, DB_LSN *, u_int32_t, const DBT *, u_int32_t, u_int32_t));
-int __fop_create_getpgnos __P((DB_ENV *, DBT *, DB_LSN *, db_recops, void *));
-int __fop_create_print __P((DB_ENV *, DBT *, DB_LSN *, db_recops, void *));
-int __fop_create_read __P((DB_ENV *, void *, __fop_create_args **));
-int __fop_remove_log __P((DB_ENV *, DB_TXN *, DB_LSN *, u_int32_t, const DBT *, const DBT *, u_int32_t));
-int __fop_remove_getpgnos __P((DB_ENV *, DBT *, DB_LSN *, db_recops, void *));
-int __fop_remove_print __P((DB_ENV *, DBT *, DB_LSN *, db_recops, void *));
-int __fop_remove_read __P((DB_ENV *, void *, __fop_remove_args **));
-int __fop_write_log __P((DB_ENV *, DB_TXN *, DB_LSN *, u_int32_t, const DBT *, u_int32_t, u_int32_t, const DBT *, u_int32_t));
-int __fop_write_getpgnos __P((DB_ENV *, DBT *, DB_LSN *, db_recops, void *));
-int __fop_write_print __P((DB_ENV *, DBT *, DB_LSN *, db_recops, void *));
-int __fop_write_read __P((DB_ENV *, void *, __fop_write_args **));
-int __fop_rename_log __P((DB_ENV *, DB_TXN *, DB_LSN *, u_int32_t, const DBT *, const DBT *, const DBT *, u_int32_t));
-int __fop_rename_getpgnos __P((DB_ENV *, DBT *, DB_LSN *, db_recops, void *));
-int __fop_rename_print __P((DB_ENV *, DBT *, DB_LSN *, db_recops, void *));
-int __fop_rename_read __P((DB_ENV *, void *, __fop_rename_args **));
-int __fop_file_remove_log __P((DB_ENV *, DB_TXN *, DB_LSN *, u_int32_t, const DBT *, const DBT *, const DBT *, u_int32_t, u_int32_t));
-int __fop_file_remove_getpgnos __P((DB_ENV *, DBT *, DB_LSN *, db_recops, void *));
-int __fop_file_remove_print __P((DB_ENV *, DBT *, DB_LSN *, db_recops, void *));
-int __fop_file_remove_read __P((DB_ENV *, void *, __fop_file_remove_args **));
-int __fop_init_print __P((DB_ENV *, int (***)(DB_ENV *, DBT *, DB_LSN *, db_recops, void *), size_t *));
-int __fop_init_getpgnos __P((DB_ENV *, int (***)(DB_ENV *, DBT *, DB_LSN *, db_recops, void *), size_t *));
-int __fop_init_recover __P((DB_ENV *, int (***)(DB_ENV *, DBT *, DB_LSN *, db_recops, void *), size_t *));
-int __fop_create __P((DB_ENV *, DB_TXN *, DB_FH *, const char *, APPNAME, int));
-int __fop_remove __P((DB_ENV *, DB_TXN *, u_int8_t *, const char *, APPNAME));
-int __fop_write __P((DB_ENV *, DB_TXN *, const char *, APPNAME, DB_FH *, u_int32_t, u_int8_t *, u_int32_t, u_int32_t));
-int __fop_rename __P((DB_ENV *, DB_TXN *, const char *, const char *, u_int8_t *, APPNAME));
-int __fop_create_recover __P((DB_ENV *, DBT *, DB_LSN *, db_recops, void *));
-int __fop_remove_recover __P((DB_ENV *, DBT *, DB_LSN *, db_recops, void *));
-int __fop_write_recover __P((DB_ENV *, DBT *, DB_LSN *, db_recops, void *));
-int __fop_rename_recover __P((DB_ENV *, DBT *, DB_LSN *, db_recops, void *));
-int __fop_file_remove_recover __P((DB_ENV *, DBT *, DB_LSN *, db_recops, void *));
-int __fop_lock_handle __P((DB_ENV *, DB *, u_int32_t, db_lockmode_t, DB_LOCK *, u_int32_t));
-int __fop_file_setup __P((DB *, DB_TXN *, const char *, int, u_int32_t, u_int32_t *));
-int __fop_subdb_setup __P((DB *, DB_TXN *, const char *, const char *, int, u_int32_t));
-int __fop_remove_setup __P((DB *, DB_TXN *, const char *, u_int32_t));
-int __fop_read_meta __P((DB_ENV *, const char *, u_int8_t *, size_t, DB_FH *, int, u_int32_t));
-int __fop_dummy __P((DB *, DB_TXN *, const char *, const char *, u_int32_t));
-int __fop_dbrename __P((DB *, const char *, const char *));
-
-#if defined(__cplusplus)
-}
-#endif
-#endif /* !_fileops_ext_h_ */
diff --git a/bdb/dbinc_auto/hash_auto.h b/bdb/dbinc_auto/hash_auto.h
deleted file mode 100644
index 7ec3fb7ef08f770fbe47dfc7aeeb5009dfe7755f..0000000000000000000000000000000000000000
--- a/bdb/dbinc_auto/hash_auto.h
+++ /dev/null
@@ -1,132 +0,0 @@
-/* Do not edit: automatically built by gen_rec.awk. */
-
-#ifndef	__ham_AUTO_H
-#define	__ham_AUTO_H
-#define	DB___ham_insdel	21
-typedef struct ___ham_insdel_args {
-	u_int32_t type;
-	DB_TXN *txnid;
-	DB_LSN prev_lsn;
-	u_int32_t	opcode;
-	int32_t	fileid;
-	db_pgno_t	pgno;
-	u_int32_t	ndx;
-	DB_LSN	pagelsn;
-	DBT	key;
-	DBT	data;
-} __ham_insdel_args;
-
-#define	DB___ham_newpage	22
-typedef struct ___ham_newpage_args {
-	u_int32_t type;
-	DB_TXN *txnid;
-	DB_LSN prev_lsn;
-	u_int32_t	opcode;
-	int32_t	fileid;
-	db_pgno_t	prev_pgno;
-	DB_LSN	prevlsn;
-	db_pgno_t	new_pgno;
-	DB_LSN	pagelsn;
-	db_pgno_t	next_pgno;
-	DB_LSN	nextlsn;
-} __ham_newpage_args;
-
-#define	DB___ham_splitdata	24
-typedef struct ___ham_splitdata_args {
-	u_int32_t type;
-	DB_TXN *txnid;
-	DB_LSN prev_lsn;
-	int32_t	fileid;
-	u_int32_t	opcode;
-	db_pgno_t	pgno;
-	DBT	pageimage;
-	DB_LSN	pagelsn;
-} __ham_splitdata_args;
-
-#define	DB___ham_replace	25
-typedef struct ___ham_replace_args {
-	u_int32_t type;
-	DB_TXN *txnid;
-	DB_LSN prev_lsn;
-	int32_t	fileid;
-	db_pgno_t	pgno;
-	u_int32_t	ndx;
-	DB_LSN	pagelsn;
-	int32_t	off;
-	DBT	olditem;
-	DBT	newitem;
-	u_int32_t	makedup;
-} __ham_replace_args;
-
-#define	DB___ham_copypage	28
-typedef struct ___ham_copypage_args {
-	u_int32_t type;
-	DB_TXN *txnid;
-	DB_LSN prev_lsn;
-	int32_t	fileid;
-	db_pgno_t	pgno;
-	DB_LSN	pagelsn;
-	db_pgno_t	next_pgno;
-	DB_LSN	nextlsn;
-	db_pgno_t	nnext_pgno;
-	DB_LSN	nnextlsn;
-	DBT	page;
-} __ham_copypage_args;
-
-#define	DB___ham_metagroup	29
-typedef struct ___ham_metagroup_args {
-	u_int32_t type;
-	DB_TXN *txnid;
-	DB_LSN prev_lsn;
-	int32_t	fileid;
-	u_int32_t	bucket;
-	db_pgno_t	mmpgno;
-	DB_LSN	mmetalsn;
-	db_pgno_t	mpgno;
-	DB_LSN	metalsn;
-	db_pgno_t	pgno;
-	DB_LSN	pagelsn;
-	u_int32_t	newalloc;
-} __ham_metagroup_args;
-
-#define	DB___ham_groupalloc	32
-typedef struct ___ham_groupalloc_args {
-	u_int32_t type;
-	DB_TXN *txnid;
-	DB_LSN prev_lsn;
-	int32_t	fileid;
-	DB_LSN	meta_lsn;
-	db_pgno_t	start_pgno;
-	u_int32_t	num;
-	db_pgno_t	free;
-} __ham_groupalloc_args;
-
-#define	DB___ham_curadj	33
-typedef struct ___ham_curadj_args {
-	u_int32_t type;
-	DB_TXN *txnid;
-	DB_LSN prev_lsn;
-	int32_t	fileid;
-	db_pgno_t	pgno;
-	u_int32_t	indx;
-	u_int32_t	len;
-	u_int32_t	dup_off;
-	int	add;
-	int	is_dup;
-	u_int32_t	order;
-} __ham_curadj_args;
-
-#define	DB___ham_chgpg	34
-typedef struct ___ham_chgpg_args {
-	u_int32_t type;
-	DB_TXN *txnid;
-	DB_LSN prev_lsn;
-	int32_t	fileid;
-	db_ham_mode	mode;
-	db_pgno_t	old_pgno;
-	db_pgno_t	new_pgno;
-	u_int32_t	old_indx;
-	u_int32_t	new_indx;
-} __ham_chgpg_args;
-
-#endif
diff --git a/bdb/dbinc_auto/hash_ext.h b/bdb/dbinc_auto/hash_ext.h
deleted file mode 100644
index 1ee2398706fe6253b84616604cdc74f21be5ec6b..0000000000000000000000000000000000000000
--- a/bdb/dbinc_auto/hash_ext.h
+++ /dev/null
@@ -1,125 +0,0 @@
-/* DO NOT EDIT: automatically built by dist/s_include. */
-#ifndef	_hash_ext_h_
-#define	_hash_ext_h_
-
-#if defined(__cplusplus)
-extern "C" {
-#endif
-
-int __ham_quick_delete __P((DBC *));
-int __ham_c_init __P((DBC *));
-int __ham_c_count __P((DBC *, db_recno_t *));
-int __ham_c_dup __P((DBC *, DBC *));
-u_int32_t __ham_call_hash __P((DBC *, u_int8_t *, int32_t));
-int __ham_init_dbt __P((DB_ENV *, DBT *, u_int32_t, void **, u_int32_t *));
-int __ham_c_update __P((DBC *, u_int32_t, int, int));
-int __ham_get_clist __P((DB *, db_pgno_t, u_int32_t, DBC ***));
-int __ham_insdel_log __P((DB *, DB_TXN *, DB_LSN *, u_int32_t, u_int32_t, db_pgno_t, u_int32_t, DB_LSN *, const DBT *, const DBT *));
-int __ham_insdel_getpgnos __P((DB_ENV *, DBT *, DB_LSN *, db_recops, void *));
-int __ham_insdel_print __P((DB_ENV *, DBT *, DB_LSN *, db_recops, void *));
-int __ham_insdel_read __P((DB_ENV *, void *, __ham_insdel_args **));
-int __ham_newpage_log __P((DB *, DB_TXN *, DB_LSN *, u_int32_t, u_int32_t, db_pgno_t, DB_LSN *, db_pgno_t, DB_LSN *, db_pgno_t, DB_LSN *));
-int __ham_newpage_getpgnos __P((DB_ENV *, DBT *, DB_LSN *, db_recops, void *));
-int __ham_newpage_print __P((DB_ENV *, DBT *, DB_LSN *, db_recops, void *));
-int __ham_newpage_read __P((DB_ENV *, void *, __ham_newpage_args **));
-int __ham_splitdata_log __P((DB *, DB_TXN *, DB_LSN *, u_int32_t, u_int32_t, db_pgno_t, const DBT *, DB_LSN *));
-int __ham_splitdata_getpgnos __P((DB_ENV *, DBT *, DB_LSN *, db_recops, void *));
-int __ham_splitdata_print __P((DB_ENV *, DBT *, DB_LSN *, db_recops, void *));
-int __ham_splitdata_read __P((DB_ENV *, void *, __ham_splitdata_args **));
-int __ham_replace_log __P((DB *, DB_TXN *, DB_LSN *, u_int32_t, db_pgno_t, u_int32_t, DB_LSN *, int32_t, const DBT *, const DBT *, u_int32_t));
-int __ham_replace_getpgnos __P((DB_ENV *, DBT *, DB_LSN *, db_recops, void *));
-int __ham_replace_print __P((DB_ENV *, DBT *, DB_LSN *, db_recops, void *));
-int __ham_replace_read __P((DB_ENV *, void *, __ham_replace_args **));
-int __ham_copypage_log __P((DB *, DB_TXN *, DB_LSN *, u_int32_t, db_pgno_t, DB_LSN *, db_pgno_t, DB_LSN *, db_pgno_t, DB_LSN *, const DBT *));
-int __ham_copypage_getpgnos __P((DB_ENV *, DBT *, DB_LSN *, db_recops, void *));
-int __ham_copypage_print __P((DB_ENV *, DBT *, DB_LSN *, db_recops, void *));
-int __ham_copypage_read __P((DB_ENV *, void *, __ham_copypage_args **));
-int __ham_metagroup_log __P((DB *, DB_TXN *, DB_LSN *, u_int32_t, u_int32_t, db_pgno_t, DB_LSN *, db_pgno_t, DB_LSN *, db_pgno_t, DB_LSN *, u_int32_t));
-int __ham_metagroup_getpgnos __P((DB_ENV *, DBT *, DB_LSN *, db_recops, void *));
-int __ham_metagroup_print __P((DB_ENV *, DBT *, DB_LSN *, db_recops, void *));
-int __ham_metagroup_read __P((DB_ENV *, void *, __ham_metagroup_args **));
-int __ham_groupalloc_log __P((DB *, DB_TXN *, DB_LSN *, u_int32_t, DB_LSN *, db_pgno_t, u_int32_t, db_pgno_t));
-int __ham_groupalloc_getpgnos __P((DB_ENV *, DBT *, DB_LSN *, db_recops, void *));
-int __ham_groupalloc_print __P((DB_ENV *, DBT *, DB_LSN *, db_recops, void *));
-int __ham_groupalloc_read __P((DB_ENV *, void *, __ham_groupalloc_args **));
-int __ham_curadj_log __P((DB *, DB_TXN *, DB_LSN *, u_int32_t, db_pgno_t, u_int32_t, u_int32_t, u_int32_t, int, int, u_int32_t));
-int __ham_curadj_getpgnos __P((DB_ENV *, DBT *, DB_LSN *, db_recops, void *));
-int __ham_curadj_print __P((DB_ENV *, DBT *, DB_LSN *, db_recops, void *));
-int __ham_curadj_read __P((DB_ENV *, void *, __ham_curadj_args **));
-int __ham_chgpg_log __P((DB *, DB_TXN *, DB_LSN *, u_int32_t, db_ham_mode, db_pgno_t, db_pgno_t, u_int32_t, u_int32_t));
-int __ham_chgpg_getpgnos __P((DB_ENV *, DBT *, DB_LSN *, db_recops, void *));
-int __ham_chgpg_print __P((DB_ENV *, DBT *, DB_LSN *, db_recops, void *));
-int __ham_chgpg_read __P((DB_ENV *, void *, __ham_chgpg_args **));
-int __ham_init_print __P((DB_ENV *, int (***)(DB_ENV *, DBT *, DB_LSN *, db_recops, void *), size_t *));
-int __ham_init_getpgnos __P((DB_ENV *, int (***)(DB_ENV *, DBT *, DB_LSN *, db_recops, void *), size_t *));
-int __ham_init_recover __P((DB_ENV *, int (***)(DB_ENV *, DBT *, DB_LSN *, db_recops, void *), size_t *));
-int __ham_pgin __P((DB_ENV *, DB *, db_pgno_t, void *, DBT *));
-int __ham_pgout __P((DB_ENV *, DB *, db_pgno_t, void *, DBT *));
-int __ham_mswap __P((void *));
-int __ham_add_dup __P((DBC *, DBT *, u_int32_t, db_pgno_t *));
-int __ham_dup_convert __P((DBC *));
-int __ham_make_dup __P((DB_ENV *, const DBT *, DBT *d, void **, u_int32_t *));
-void __ham_dsearch __P((DBC *, DBT *, u_int32_t *, int *, u_int32_t));
-void __ham_cprint __P((DBC *));
-u_int32_t __ham_func2 __P((DB *, const void *, u_int32_t));
-u_int32_t __ham_func3 __P((DB *, const void *, u_int32_t));
-u_int32_t __ham_func4 __P((DB *, const void *, u_int32_t));
-u_int32_t __ham_func5 __P((DB *, const void *, u_int32_t));
-u_int32_t __ham_test __P((DB *, const void *, u_int32_t));
-int __ham_get_meta __P((DBC *));
-int __ham_release_meta __P((DBC *));
-int __ham_dirty_meta __P((DBC *));
-int __ham_db_create __P((DB *));
-int __ham_db_close __P((DB *));
-int __ham_open __P((DB *, DB_TXN *, const char * name, db_pgno_t, u_int32_t));
-int __ham_metachk __P((DB *, const char *, HMETA *));
-int __ham_new_file __P((DB *, DB_TXN *, DB_FH *, const char *));
-int __ham_new_subdb __P((DB *, DB *, DB_TXN *));
-int __ham_item __P((DBC *, db_lockmode_t, db_pgno_t *));
-int __ham_item_reset __P((DBC *));
-void __ham_item_init __P((DBC *));
-int __ham_item_last __P((DBC *, db_lockmode_t, db_pgno_t *));
-int __ham_item_first __P((DBC *, db_lockmode_t, db_pgno_t *));
-int __ham_item_prev __P((DBC *, db_lockmode_t, db_pgno_t *));
-int __ham_item_next __P((DBC *, db_lockmode_t, db_pgno_t *));
-void __ham_putitem __P((DB *, PAGE *p, const DBT *, int));
-void __ham_reputpair  __P((DB *, PAGE *, u_int32_t, const DBT *, const DBT *));
-int __ham_del_pair __P((DBC *, int));
-int __ham_replpair __P((DBC *, DBT *, u_int32_t));
-void __ham_onpage_replace __P((DB *, PAGE *, u_int32_t, int32_t, int32_t,  DBT *));
-int __ham_split_page __P((DBC *, u_int32_t, u_int32_t));
-int __ham_add_el __P((DBC *, const DBT *, const DBT *, int));
-void __ham_copy_item __P((DB *, PAGE *, u_int32_t, PAGE *));
-int __ham_add_ovflpage __P((DBC *, PAGE *, int, PAGE **));
-int __ham_get_cpage __P((DBC *, db_lockmode_t));
-int __ham_next_cpage __P((DBC *, db_pgno_t, int));
-int __ham_lock_bucket __P((DBC *, db_lockmode_t));
-void __ham_dpair __P((DB *, PAGE *, u_int32_t));
-int __ham_insdel_recover __P((DB_ENV *, DBT *, DB_LSN *, db_recops, void *));
-int __ham_newpage_recover __P((DB_ENV *, DBT *, DB_LSN *, db_recops, void *));
-int __ham_replace_recover __P((DB_ENV *, DBT *, DB_LSN *, db_recops, void *));
-int __ham_splitdata_recover __P((DB_ENV *, DBT *, DB_LSN *, db_recops, void *));
-int __ham_copypage_recover __P((DB_ENV *, DBT *, DB_LSN *, db_recops, void *));
-int __ham_metagroup_recover __P((DB_ENV *, DBT *, DB_LSN *, db_recops, void *));
-int __ham_groupalloc_recover __P((DB_ENV *, DBT *, DB_LSN *, db_recops, void *));
-int __ham_curadj_recover __P((DB_ENV *, DBT *, DB_LSN *, db_recops, void *));
-int __ham_chgpg_recover __P((DB_ENV *, DBT *, DB_LSN *, db_recops, void *));
-int __ham_reclaim __P((DB *, DB_TXN *txn));
-int __ham_truncate __P((DB *, DB_TXN *txn, u_int32_t *));
-int __ham_stat __P((DB *, void *, u_int32_t));
-int __ham_traverse __P((DBC *, db_lockmode_t, int (*)(DB *, PAGE *, void *, int *), void *, int));
-int __ham_30_hashmeta __P((DB *, char *, u_int8_t *));
-int __ham_30_sizefix __P((DB *, DB_FH *, char *, u_int8_t *));
-int __ham_31_hashmeta __P((DB *, char *, u_int32_t, DB_FH *, PAGE *, int *));
-int __ham_31_hash __P((DB *, char *, u_int32_t, DB_FH *, PAGE *, int *));
-int __ham_vrfy_meta __P((DB *, VRFY_DBINFO *, HMETA *, db_pgno_t, u_int32_t));
-int __ham_vrfy __P((DB *, VRFY_DBINFO *, PAGE *, db_pgno_t, u_int32_t));
-int __ham_vrfy_structure __P((DB *, VRFY_DBINFO *, db_pgno_t, u_int32_t));
-int __ham_vrfy_hashing __P((DB *, u_int32_t, HMETA *, u_int32_t, db_pgno_t, u_int32_t, u_int32_t (*) __P((DB *, const void *, u_int32_t))));
-int __ham_salvage __P((DB *, VRFY_DBINFO *, db_pgno_t, PAGE *, void *, int (*)(void *, const void *), u_int32_t));
-int __ham_meta2pgset __P((DB *, VRFY_DBINFO *, HMETA *, u_int32_t, DB *));
-
-#if defined(__cplusplus)
-}
-#endif
-#endif /* !_hash_ext_h_ */
diff --git a/bdb/dbinc_auto/hmac_ext.h b/bdb/dbinc_auto/hmac_ext.h
deleted file mode 100644
index d161a7291f4d82ec7434f283206d984d050d6c95..0000000000000000000000000000000000000000
--- a/bdb/dbinc_auto/hmac_ext.h
+++ /dev/null
@@ -1,20 +0,0 @@
-/* DO NOT EDIT: automatically built by dist/s_include. */
-#ifndef	_hmac_ext_h_
-#define	_hmac_ext_h_
-
-#if defined(__cplusplus)
-extern "C" {
-#endif
-
-void __db_chksum __P((u_int8_t *, size_t, u_int8_t *, u_int8_t *));
-void __db_derive_mac __P((u_int8_t *, size_t, u_int8_t *));
-int __db_check_chksum __P((DB_ENV *, DB_CIPHER *, u_int8_t *, void *, size_t, int));
-void __db_SHA1Transform __P((u_int32_t *, unsigned char *));
-void __db_SHA1Init __P((SHA1_CTX *));
-void __db_SHA1Update __P((SHA1_CTX *, unsigned char *, size_t));
-void __db_SHA1Final __P((unsigned char *, SHA1_CTX *));
-
-#if defined(__cplusplus)
-}
-#endif
-#endif /* !_hmac_ext_h_ */
diff --git a/bdb/dbinc_auto/lock_ext.h b/bdb/dbinc_auto/lock_ext.h
deleted file mode 100644
index be6b1d06d1e9c9aba0c14a92b9832622ca37f3a6..0000000000000000000000000000000000000000
--- a/bdb/dbinc_auto/lock_ext.h
+++ /dev/null
@@ -1,41 +0,0 @@
-/* DO NOT EDIT: automatically built by dist/s_include. */
-#ifndef	_lock_ext_h_
-#define	_lock_ext_h_
-
-#if defined(__cplusplus)
-extern "C" {
-#endif
-
-int __lock_id __P((DB_ENV *, u_int32_t *));
-int __lock_id_free __P((DB_ENV *, u_int32_t));
-int __lock_vec __P((DB_ENV *, u_int32_t, u_int32_t, DB_LOCKREQ *, int, DB_LOCKREQ **));
-int __lock_get __P((DB_ENV *, u_int32_t, u_int32_t, const DBT *, db_lockmode_t, DB_LOCK *));
-int  __lock_put __P((DB_ENV *, DB_LOCK *));
-int __lock_downgrade __P((DB_ENV *, DB_LOCK *, db_lockmode_t, u_int32_t));
-int __lock_addfamilylocker __P((DB_ENV *, u_int32_t, u_int32_t));
-int __lock_freefamilylocker  __P((DB_LOCKTAB *, u_int32_t));
-int __lock_set_timeout __P(( DB_ENV *, u_int32_t, db_timeout_t, u_int32_t));
-int __lock_inherit_timeout __P(( DB_ENV *, u_int32_t, u_int32_t));
-int __lock_getlocker __P((DB_LOCKTAB *, u_int32_t, u_int32_t, int, DB_LOCKER **));
-int __lock_promote __P((DB_LOCKTAB *, DB_LOCKOBJ *, u_int32_t));
-int __lock_expired __P((DB_ENV *, db_timeval_t *, db_timeval_t *));
-int __lock_detect __P((DB_ENV *, u_int32_t, u_int32_t, int *));
-void __lock_dbenv_create __P((DB_ENV *));
-void __lock_dbenv_close __P((DB_ENV *));
-int __lock_open __P((DB_ENV *));
-int __lock_dbenv_refresh __P((DB_ENV *));
-void __lock_region_destroy __P((DB_ENV *, REGINFO *));
-int __lock_id_set __P((DB_ENV *, u_int32_t, u_int32_t));
-int __lock_stat __P((DB_ENV *, DB_LOCK_STAT **, u_int32_t));
-int __lock_dump_region __P((DB_ENV *, char *, FILE *));
-void __lock_printlock __P((DB_LOCKTAB *, struct __db_lock *, int));
-int __lock_cmp __P((const DBT *, DB_LOCKOBJ *));
-int __lock_locker_cmp __P((u_int32_t, DB_LOCKER *));
-u_int32_t __lock_ohash __P((const DBT *));
-u_int32_t __lock_lhash __P((DB_LOCKOBJ *));
-u_int32_t __lock_locker_hash __P((u_int32_t));
-
-#if defined(__cplusplus)
-}
-#endif
-#endif /* !_lock_ext_h_ */
diff --git a/bdb/dbinc_auto/log_ext.h b/bdb/dbinc_auto/log_ext.h
deleted file mode 100644
index 6fc69afd2b4f98951ffea54fa263fd3e03813b41..0000000000000000000000000000000000000000
--- a/bdb/dbinc_auto/log_ext.h
+++ /dev/null
@@ -1,32 +0,0 @@
-/* DO NOT EDIT: automatically built by dist/s_include. */
-#ifndef	_log_ext_h_
-#define	_log_ext_h_
-
-#if defined(__cplusplus)
-extern "C" {
-#endif
-
-int __log_open __P((DB_ENV *));
-int __log_find __P((DB_LOG *, int, u_int32_t *, logfile_validity *));
-int __log_valid __P((DB_LOG *, u_int32_t, int, logfile_validity *));
-int __log_dbenv_refresh __P((DB_ENV *));
-int __log_stat __P((DB_ENV *, DB_LOG_STAT **, u_int32_t));
-void __log_get_cached_ckp_lsn __P((DB_ENV *, DB_LSN *));
-void __log_region_destroy __P((DB_ENV *, REGINFO *));
-int __log_vtruncate __P((DB_ENV *, DB_LSN *, DB_LSN *));
-int __log_is_outdated __P((DB_ENV *dbenv, u_int32_t fnum, int *outdatedp));
-int __log_archive __P((DB_ENV *, char **[], u_int32_t));
-int __log_cursor __P((DB_ENV *, DB_LOGC **, u_int32_t));
-void __log_dbenv_create __P((DB_ENV *));
-int __log_put __P((DB_ENV *, DB_LSN *, const DBT *, u_int32_t));
-void __log_txn_lsn __P((DB_ENV *, DB_LSN *, u_int32_t *, u_int32_t *));
-int __log_newfile __P((DB_LOG *, DB_LSN *));
-int __log_flush __P((DB_ENV *, const DB_LSN *));
-int __log_file __P((DB_ENV *, const DB_LSN *, char *, size_t));
-int __log_name __P((DB_LOG *, u_int32_t, char **, DB_FH *, u_int32_t));
-int __log_rep_put __P((DB_ENV *, DB_LSN *, const DBT *));
-
-#if defined(__cplusplus)
-}
-#endif
-#endif /* !_log_ext_h_ */
diff --git a/bdb/dbinc_auto/mp_ext.h b/bdb/dbinc_auto/mp_ext.h
deleted file mode 100644
index ceadb3d9adca38b4c4a1ec9ffbe0dec09d9d03ba..0000000000000000000000000000000000000000
--- a/bdb/dbinc_auto/mp_ext.h
+++ /dev/null
@@ -1,44 +0,0 @@
-/* DO NOT EDIT: automatically built by dist/s_include. */
-#ifndef	_mp_ext_h_
-#define	_mp_ext_h_
-
-#if defined(__cplusplus)
-extern "C" {
-#endif
-
-int __memp_alloc __P((DB_MPOOL *, REGINFO *, MPOOLFILE *, size_t, roff_t *, void *));
-#ifdef DIAGNOSTIC
-void __memp_check_order __P((DB_MPOOL_HASH *));
-#endif
-int __memp_bhwrite __P((DB_MPOOL *, DB_MPOOL_HASH *, MPOOLFILE *, BH *, int));
-int __memp_pgread __P((DB_MPOOLFILE *, DB_MUTEX *, BH *, int));
-int __memp_pg __P((DB_MPOOLFILE *, BH *, int));
-void __memp_bhfree __P((DB_MPOOL *, DB_MPOOL_HASH *, BH *, int));
-int __memp_fget __P((DB_MPOOLFILE *, db_pgno_t *, u_int32_t, void *));
-int __memp_fcreate __P((DB_ENV *, DB_MPOOLFILE **, u_int32_t));
-int __memp_fopen_int __P((DB_MPOOLFILE *, MPOOLFILE *, const char *, u_int32_t, int, size_t));
-int __memp_fclose_int __P((DB_MPOOLFILE *, u_int32_t));
-int __memp_mf_discard __P((DB_MPOOL *, MPOOLFILE *));
-char * __memp_fn __P((DB_MPOOLFILE *));
-char * __memp_fns __P((DB_MPOOL *, MPOOLFILE *));
-int __memp_fput __P((DB_MPOOLFILE *, void *, u_int32_t));
-int __memp_fset __P((DB_MPOOLFILE *, void *, u_int32_t));
-void __memp_dbenv_create __P((DB_ENV *));
-int __memp_open __P((DB_ENV *));
-int __memp_dbenv_refresh __P((DB_ENV *));
-void __mpool_region_destroy __P((DB_ENV *, REGINFO *));
-int  __memp_nameop __P((DB_ENV *, u_int8_t *, const char *, const char *, const char *));
-int __memp_register __P((DB_ENV *, int, int (*)(DB_ENV *, db_pgno_t, void *, DBT *), int (*)(DB_ENV *, db_pgno_t, void *, DBT *)));
-int __memp_stat __P((DB_ENV *, DB_MPOOL_STAT **, DB_MPOOL_FSTAT ***, u_int32_t));
-int __memp_dump_region __P((DB_ENV *, char *, FILE *));
-void __memp_stat_hash __P((REGINFO *, MPOOL *, u_int32_t *));
-int __memp_sync __P((DB_ENV *, DB_LSN *));
-int __memp_fsync __P((DB_MPOOLFILE *));
-int __mp_xxx_fh __P((DB_MPOOLFILE *, DB_FH **));
-int __memp_sync_int __P((DB_ENV *, DB_MPOOLFILE *, int, db_sync_op, int *));
-int __memp_trickle __P((DB_ENV *, int, int *));
-
-#if defined(__cplusplus)
-}
-#endif
-#endif /* !_mp_ext_h_ */
diff --git a/bdb/dbinc_auto/mutex_ext.h b/bdb/dbinc_auto/mutex_ext.h
deleted file mode 100644
index a40f04d55786a7b6b321ea3a4480cdbf2288065d..0000000000000000000000000000000000000000
--- a/bdb/dbinc_auto/mutex_ext.h
+++ /dev/null
@@ -1,35 +0,0 @@
-/* DO NOT EDIT: automatically built by dist/s_include. */
-#ifndef	_mutex_ext_h_
-#define	_mutex_ext_h_
-
-#if defined(__cplusplus)
-extern "C" {
-#endif
-
-int __db_fcntl_mutex_init __P((DB_ENV *, DB_MUTEX *, u_int32_t));
-int __db_fcntl_mutex_lock __P((DB_ENV *, DB_MUTEX *));
-int __db_fcntl_mutex_unlock __P((DB_ENV *, DB_MUTEX *));
-int __db_fcntl_mutex_destroy __P((DB_MUTEX *));
-int __db_pthread_mutex_init __P((DB_ENV *, DB_MUTEX *, u_int32_t));
-int __db_pthread_mutex_lock __P((DB_ENV *, DB_MUTEX *));
-int __db_pthread_mutex_unlock __P((DB_ENV *, DB_MUTEX *));
-int __db_pthread_mutex_destroy __P((DB_MUTEX *));
-int __db_tas_mutex_init __P((DB_ENV *, DB_MUTEX *, u_int32_t));
-int __db_tas_mutex_lock __P((DB_ENV *, DB_MUTEX *));
-int __db_tas_mutex_unlock __P((DB_ENV *, DB_MUTEX *));
-int __db_tas_mutex_destroy __P((DB_MUTEX *));
-int __db_win32_mutex_init __P((DB_ENV *, DB_MUTEX *, u_int32_t));
-int __db_win32_mutex_lock __P((DB_ENV *, DB_MUTEX *));
-int __db_win32_mutex_unlock __P((DB_ENV *, DB_MUTEX *));
-int __db_win32_mutex_destroy __P((DB_MUTEX *));
-int __db_mutex_setup __P((DB_ENV *, REGINFO *, void *, u_int32_t));
-void __db_mutex_free __P((DB_ENV *, REGINFO *, DB_MUTEX *));
-void __db_shreg_locks_clear __P((DB_MUTEX *, REGINFO *, REGMAINT *));
-void __db_shreg_locks_destroy __P((REGINFO *, REGMAINT *));
-int __db_shreg_mutex_init __P((DB_ENV *, DB_MUTEX *, u_int32_t, u_int32_t, REGINFO *, REGMAINT *));
-void __db_shreg_maintinit __P((REGINFO *, void *addr, size_t));
-
-#if defined(__cplusplus)
-}
-#endif
-#endif /* !_mutex_ext_h_ */
diff --git a/bdb/dbinc_auto/os_ext.h b/bdb/dbinc_auto/os_ext.h
deleted file mode 100644
index 0a2e5ab2054b4f0027fd5b3dd05c93d7a4c252da..0000000000000000000000000000000000000000
--- a/bdb/dbinc_auto/os_ext.h
+++ /dev/null
@@ -1,74 +0,0 @@
-/* DO NOT EDIT: automatically built by dist/s_include. */
-#ifndef	_os_ext_h_
-#define	_os_ext_h_
-
-#if defined(__cplusplus)
-extern "C" {
-#endif
-
-int __os_abspath __P((const char *));
-int __os_umalloc __P((DB_ENV *, size_t, void *));
-int __os_urealloc __P((DB_ENV *, size_t, void *));
-int __os_ufree __P((DB_ENV *, void *));
-int __os_strdup __P((DB_ENV *, const char *, void *));
-int __os_calloc __P((DB_ENV *, size_t, size_t, void *));
-int __os_malloc __P((DB_ENV *, size_t, void *));
-int __os_realloc __P((DB_ENV *, size_t, void *));
-void __os_free __P((DB_ENV *, void *));
-void *__ua_memcpy __P((void *, const void *, size_t));
-int __os_clock __P((DB_ENV *, u_int32_t *, u_int32_t *));
-int __os_fs_notzero __P((void));
-int __os_dirlist __P((DB_ENV *, const char *, char ***, int *));
-void __os_dirfree __P((DB_ENV *, char **, int));
-int __os_get_errno_ret_zero __P((void));
-int __os_get_errno __P((void));
-void __os_set_errno __P((int));
-int __os_fileid __P((DB_ENV *, const char *, int, u_int8_t *));
-int __os_fsync __P((DB_ENV *, DB_FH *));
-int __os_openhandle __P((DB_ENV *, const char *, int, int, DB_FH *));
-int __os_closehandle __P((DB_ENV *, DB_FH *));
-void __os_id __P((u_int32_t *));
-int __os_r_sysattach __P((DB_ENV *, REGINFO *, REGION *));
-int __os_r_sysdetach __P((DB_ENV *, REGINFO *, int));
-int __os_mapfile __P((DB_ENV *, char *, DB_FH *, size_t, int, void **));
-int __os_unmapfile __P((DB_ENV *, void *, size_t));
-u_int32_t __db_oflags __P((int));
-int __db_omode __P((const char *));
-int __os_open __P((DB_ENV *, const char *, u_int32_t, int, DB_FH *));
-#ifdef HAVE_QNX
-int __os_shmname __P((DB_ENV *, const char *, char **));
-#endif
-int __os_r_attach __P((DB_ENV *, REGINFO *, REGION *));
-int __os_r_detach __P((DB_ENV *, REGINFO *, int));
-int __os_rename __P((DB_ENV *, const char *, const char *, u_int32_t));
-int __os_isroot __P((void));
-char *__db_rpath __P((const char *));
-int __os_io __P((DB_ENV *, DB_IO *, int, size_t *));
-int __os_read __P((DB_ENV *, DB_FH *, void *, size_t, size_t *));
-int __os_write __P((DB_ENV *, DB_FH *, void *, size_t, size_t *));
-int __os_seek __P((DB_ENV *, DB_FH *, size_t, db_pgno_t, u_int32_t, int, DB_OS_SEEK));
-int __os_sleep __P((DB_ENV *, u_long, u_long));
-int __os_spin __P((DB_ENV *));
-void __os_yield __P((DB_ENV*, u_long));
-int __os_exists __P((const char *, int *));
-int __os_ioinfo __P((DB_ENV *, const char *, DB_FH *, u_int32_t *, u_int32_t *, u_int32_t *));
-int __os_tmpdir __P((DB_ENV *, u_int32_t));
-int __os_region_unlink __P((DB_ENV *, const char *));
-int __os_unlink __P((DB_ENV *, const char *));
-#if defined(DB_WIN32)
-int __os_win32_errno __P((void));
-#endif
-int __os_fsync __P((DB_ENV *, DB_FH *));
-int __os_openhandle __P((DB_ENV *, const char *, int, int, DB_FH *));
-int __os_closehandle __P((DB_ENV *, DB_FH *));
-int __os_io __P((DB_ENV *, DB_IO *, int, size_t *));
-int __os_read __P((DB_ENV *, DB_FH *, void *, size_t, size_t *));
-int __os_write __P((DB_ENV *, DB_FH *, void *, size_t, size_t *));
-int __os_exists __P((const char *, int *));
-int __os_ioinfo __P((DB_ENV *, const char *, DB_FH *, u_int32_t *, u_int32_t *, u_int32_t *));
-int __os_is_winnt __P((void));
-
-#if defined(__cplusplus)
-}
-#endif
-#endif /* !_os_ext_h_ */
diff --git a/bdb/dbinc_auto/qam_auto.h b/bdb/dbinc_auto/qam_auto.h
deleted file mode 100644
index 655c6d0280fd9b22f786b8c8482e79b1ff9ae8ca..0000000000000000000000000000000000000000
--- a/bdb/dbinc_auto/qam_auto.h
+++ /dev/null
@@ -1,70 +0,0 @@
-/* Do not edit: automatically built by gen_rec.awk. */
-
-#ifndef	__qam_AUTO_H
-#define	__qam_AUTO_H
-#define	DB___qam_incfirst	84
-typedef struct ___qam_incfirst_args {
-	u_int32_t type;
-	DB_TXN *txnid;
-	DB_LSN prev_lsn;
-	int32_t	fileid;
-	db_recno_t	recno;
-	db_pgno_t	meta_pgno;
-} __qam_incfirst_args;
-
-#define	DB___qam_mvptr	85
-typedef struct ___qam_mvptr_args {
-	u_int32_t type;
-	DB_TXN *txnid;
-	DB_LSN prev_lsn;
-	u_int32_t	opcode;
-	int32_t	fileid;
-	db_recno_t	old_first;
-	db_recno_t	new_first;
-	db_recno_t	old_cur;
-	db_recno_t	new_cur;
-	DB_LSN	metalsn;
-	db_pgno_t	meta_pgno;
-} __qam_mvptr_args;
-
-#define	DB___qam_del	79
-typedef struct ___qam_del_args {
-	u_int32_t type;
-	DB_TXN *txnid;
-	DB_LSN prev_lsn;
-	int32_t	fileid;
-	DB_LSN	lsn;
-	db_pgno_t	pgno;
-	u_int32_t	indx;
-	db_recno_t	recno;
-} __qam_del_args;
-
-#define	DB___qam_add	80
-typedef struct ___qam_add_args {
-	u_int32_t type;
-	DB_TXN *txnid;
-	DB_LSN prev_lsn;
-	int32_t	fileid;
-	DB_LSN	lsn;
-	db_pgno_t	pgno;
-	u_int32_t	indx;
-	db_recno_t	recno;
-	DBT	data;
-	u_int32_t	vflag;
-	DBT	olddata;
-} __qam_add_args;
-
-#define	DB___qam_delext	83
-typedef struct ___qam_delext_args {
-	u_int32_t type;
-	DB_TXN *txnid;
-	DB_LSN prev_lsn;
-	int32_t	fileid;
-	DB_LSN	lsn;
-	db_pgno_t	pgno;
-	u_int32_t	indx;
-	db_recno_t	recno;
-	DBT	data;
-} __qam_delext_args;
-
-#endif
diff --git a/bdb/dbinc_auto/qam_ext.h b/bdb/dbinc_auto/qam_ext.h
deleted file mode 100644
index 16dbea79e4c0b3ee98295bd565acbc07d286f4cc..0000000000000000000000000000000000000000
--- a/bdb/dbinc_auto/qam_ext.h
+++ /dev/null
@@ -1,70 +0,0 @@
-/* DO NOT EDIT: automatically built by dist/s_include. */
-#ifndef	_qam_ext_h_
-#define	_qam_ext_h_
-
-#if defined(__cplusplus)
-extern "C" {
-#endif
-
-int __qam_position __P((DBC *, db_recno_t *, qam_position_mode, int *));
-int __qam_pitem __P((DBC *,  QPAGE *, u_int32_t, db_recno_t, DBT *));
-int __qam_append __P((DBC *, DBT *, DBT *));
-int __qam_c_dup __P((DBC *, DBC *));
-int __qam_c_init __P((DBC *));
-int __qam_truncate __P((DB *, DB_TXN *, u_int32_t *));
-int __qam_incfirst_log __P((DB *, DB_TXN *, DB_LSN *, u_int32_t, db_recno_t, db_pgno_t));
-int __qam_incfirst_getpgnos __P((DB_ENV *, DBT *, DB_LSN *, db_recops, void *));
-int __qam_incfirst_print __P((DB_ENV *, DBT *, DB_LSN *, db_recops, void *));
-int __qam_incfirst_read __P((DB_ENV *, void *, __qam_incfirst_args **));
-int __qam_mvptr_log __P((DB *, DB_TXN *, DB_LSN *, u_int32_t, u_int32_t, db_recno_t, db_recno_t, db_recno_t, db_recno_t, DB_LSN *, db_pgno_t));
-int __qam_mvptr_getpgnos __P((DB_ENV *, DBT *, DB_LSN *, db_recops, void *));
-int __qam_mvptr_print __P((DB_ENV *, DBT *, DB_LSN *, db_recops, void *));
-int __qam_mvptr_read __P((DB_ENV *, void *, __qam_mvptr_args **));
-int __qam_del_log __P((DB *, DB_TXN *, DB_LSN *, u_int32_t, DB_LSN *, db_pgno_t, u_int32_t, db_recno_t));
-int __qam_del_getpgnos __P((DB_ENV *, DBT *, DB_LSN *, db_recops, void *));
-int __qam_del_print __P((DB_ENV *, DBT *, DB_LSN *, db_recops, void *));
-int __qam_del_read __P((DB_ENV *, void *, __qam_del_args **));
-int __qam_add_log __P((DB *, DB_TXN *, DB_LSN *, u_int32_t, DB_LSN *, db_pgno_t, u_int32_t, db_recno_t, const DBT *, u_int32_t, const DBT *));
-int __qam_add_getpgnos __P((DB_ENV *, DBT *, DB_LSN *, db_recops, void *));
-int __qam_add_print __P((DB_ENV *, DBT *, DB_LSN *, db_recops, void *));
-int __qam_add_read __P((DB_ENV *, void *, __qam_add_args **));
-int __qam_delext_log __P((DB *, DB_TXN *, DB_LSN *, u_int32_t, DB_LSN *, db_pgno_t, u_int32_t, db_recno_t, const DBT *));
-int __qam_delext_getpgnos __P((DB_ENV *, DBT *, DB_LSN *, db_recops, void *));
-int __qam_delext_print __P((DB_ENV *, DBT *, DB_LSN *, db_recops, void *));
-int __qam_delext_read __P((DB_ENV *, void *, __qam_delext_args **));
-int __qam_init_print __P((DB_ENV *, int (***)(DB_ENV *, DBT *, DB_LSN *, db_recops, void *), size_t *));
-int __qam_init_getpgnos __P((DB_ENV *, int (***)(DB_ENV *, DBT *, DB_LSN *, db_recops, void *), size_t *));
-int __qam_init_recover __P((DB_ENV *, int (***)(DB_ENV *, DBT *, DB_LSN *, db_recops, void *), size_t *));
-int __qam_mswap __P((PAGE *));
-int __qam_pgin_out __P((DB_ENV *, db_pgno_t, void *, DBT *));
-int __qam_fprobe __P((DB *, db_pgno_t, void *, qam_probe_mode, u_int32_t));
-int __qam_fclose __P((DB *, db_pgno_t));
-int __qam_fremove __P((DB *, db_pgno_t));
-int __qam_sync __P((DB *, u_int32_t));
-int __qam_gen_filelist __P(( DB *, QUEUE_FILELIST **));
-int __qam_extent_names __P((DB_ENV *, char *, char ***));
-void __qam_exid __P((DB *, u_int8_t *, u_int32_t));
-int __qam_db_create __P((DB *));
-int __qam_db_close __P((DB *));
-int __db_prqueue __P((DB *, FILE *, u_int32_t));
-int __qam_remove __P((DB *, DB_TXN *, const char *, const char *, DB_LSN *));
-int __qam_rename __P((DB *, DB_TXN *, const char *, const char *, const char *));
-int __qam_open __P((DB *, DB_TXN *, const char *, db_pgno_t, int, u_int32_t));
-int __qam_metachk __P((DB *, const char *, QMETA *));
-int __qam_new_file __P((DB *, DB_TXN *, DB_FH *, const char *));
-int __qam_incfirst_recover __P((DB_ENV *, DBT *, DB_LSN *, db_recops, void *));
-int __qam_mvptr_recover __P((DB_ENV *, DBT *, DB_LSN *, db_recops, void *));
-int __qam_del_recover __P((DB_ENV *, DBT *, DB_LSN *, db_recops, void *));
-int __qam_delext_recover __P((DB_ENV *, DBT *, DB_LSN *, db_recops, void *));
-int __qam_add_recover __P((DB_ENV *, DBT *, DB_LSN *, db_recops, void *));
-int __qam_stat __P((DB *, void *, u_int32_t));
-int __qam_31_qammeta __P((DB *, char *, u_int8_t *));
-int __qam_32_qammeta __P((DB *, char *, u_int8_t *));
-int __qam_vrfy_meta __P((DB *, VRFY_DBINFO *, QMETA *, db_pgno_t, u_int32_t));
-int __qam_vrfy_data __P((DB *, VRFY_DBINFO *, QPAGE *, db_pgno_t, u_int32_t));
-int __qam_vrfy_structure __P((DB *, VRFY_DBINFO *, u_int32_t));
-
-#if defined(__cplusplus)
-}
-#endif
-#endif /* !_qam_ext_h_ */
diff --git a/bdb/dbinc_auto/rep_ext.h b/bdb/dbinc_auto/rep_ext.h
deleted file mode 100644
index 22e2d254fe84a8ed041af6e4feb3415608605bed..0000000000000000000000000000000000000000
--- a/bdb/dbinc_auto/rep_ext.h
+++ /dev/null
@@ -1,30 +0,0 @@
-/* DO NOT EDIT: automatically built by dist/s_include. */
-#ifndef	_rep_ext_h_
-#define	_rep_ext_h_
-
-#if defined(__cplusplus)
-extern "C" {
-#endif
-
-int __rep_dbenv_create __P((DB_ENV *));
-int __rep_process_message __P((DB_ENV *, DBT *, DBT *, int *));
-int __rep_process_txn __P((DB_ENV *, DBT *));
-int __rep_region_init __P((DB_ENV *));
-int __rep_region_destroy __P((DB_ENV *));
-int __rep_dbenv_close __P((DB_ENV *));
-int __rep_preclose __P((DB_ENV *, int));
-int __rep_check_alloc __P((DB_ENV *, TXN_RECS *, int));
-int __rep_send_message __P((DB_ENV *, int, u_int32_t, DB_LSN *, const DBT *, u_int32_t));
-int __rep_new_master __P((DB_ENV *, REP_CONTROL *, int));
-int __rep_lockpgno_init __P((DB_ENV *, int (***)(DB_ENV *, DBT *, DB_LSN *, db_recops, void *), size_t *));
-int __rep_unlockpages __P((DB_ENV *, u_int32_t));
-int __rep_lockpages __P((DB_ENV *, int (**)(DB_ENV *, DBT *, DB_LSN *, db_recops, void *), size_t, DB_LSN *, DB_LSN *, TXN_RECS *, u_int32_t));
-int __rep_is_client __P((DB_ENV *));
-int __rep_send_vote __P((DB_ENV *, DB_LSN *, int, int, int));
-int __rep_grow_sites __P((DB_ENV *dbenv, int nsites));
-void __rep_print_message __P((DB_ENV *, int, REP_CONTROL *, char *));
-
-#if defined(__cplusplus)
-}
-#endif
-#endif /* !_rep_ext_h_ */
diff --git a/bdb/dbinc_auto/rpc_client_ext.h b/bdb/dbinc_auto/rpc_client_ext.h
deleted file mode 100644
index 9634b34abefc322ba55212d5d93017b69463dc63..0000000000000000000000000000000000000000
--- a/bdb/dbinc_auto/rpc_client_ext.h
+++ /dev/null
@@ -1,167 +0,0 @@
-/* DO NOT EDIT: automatically built by dist/s_include. */
-#ifndef	_rpc_client_ext_h_
-#define	_rpc_client_ext_h_
-
-#if defined(__cplusplus)
-extern "C" {
-#endif
-
-int __dbcl_envrpcserver __P((DB_ENV *, void *, const char *, long, long, u_int32_t));
-int __dbcl_env_open_wrap __P((DB_ENV *, const char *, u_int32_t, int));
-int __dbcl_db_open_wrap __P((DB *, DB_TXN *, const char *, const char *, DBTYPE, u_int32_t, int));
-int __dbcl_refresh __P((DB_ENV *));
-int __dbcl_retcopy __P((DB_ENV *, DBT *, void *, u_int32_t, void **, u_int32_t *));
-void __dbcl_txn_end __P((DB_TXN *));
-void __dbcl_txn_setup __P((DB_ENV *, DB_TXN *, DB_TXN *, u_int32_t));
-void __dbcl_c_refresh __P((DBC *));
-int __dbcl_c_setup __P((long, DB *, DBC **));
-int __dbcl_dbclose_common __P((DB *));
-int __dbcl_env_alloc __P((DB_ENV *, void *(*)(size_t), void *(*)(void *, size_t), void (*)(void *)));
-int __dbcl_set_app_dispatch __P((DB_ENV *, int (*)(DB_ENV *, DBT *, DB_LSN *, db_recops)));
-int __dbcl_env_cachesize __P((DB_ENV *, u_int32_t, u_int32_t, int));
-int __dbcl_env_close __P((DB_ENV *, u_int32_t));
-int __dbcl_env_create __P((DB_ENV *, long));
-int __dbcl_set_data_dir __P((DB_ENV *, const char *));
-int __dbcl_env_dbremove __P((DB_ENV *, DB_TXN *, const char *, const char *, u_int32_t));
-int __dbcl_env_dbrename __P((DB_ENV *, DB_TXN *, const char *, const char *, const char *, u_int32_t));
-int __dbcl_env_encrypt __P((DB_ENV *, const char *, u_int32_t));
-int __dbcl_env_set_feedback __P((DB_ENV *, void (*)(DB_ENV *, int, int)));
-int __dbcl_env_flags __P((DB_ENV *, u_int32_t, int));
-int __dbcl_set_lg_bsize __P((DB_ENV *, u_int32_t));
-int __dbcl_set_lg_dir __P((DB_ENV *, const char *));
-int __dbcl_set_lg_max __P((DB_ENV *, u_int32_t));
-int __dbcl_set_lg_regionmax __P((DB_ENV *, u_int32_t));
-int __dbcl_set_lk_conflict __P((DB_ENV *, u_int8_t *, int));
-int __dbcl_set_lk_detect __P((DB_ENV *, u_int32_t));
-int __dbcl_set_lk_max __P((DB_ENV *, u_int32_t));
-int __dbcl_set_lk_max_locks __P((DB_ENV *, u_int32_t));
-int __dbcl_set_lk_max_lockers __P((DB_ENV *, u_int32_t));
-int __dbcl_set_lk_max_objects __P((DB_ENV *, u_int32_t));
-int __dbcl_set_mp_mmapsize __P((DB_ENV *, size_t));
-int __dbcl_env_open __P((DB_ENV *, const char *, u_int32_t, int));
-int __dbcl_env_paniccall __P((DB_ENV *, void (*)(DB_ENV *, int)));
-int __dbcl_env_remove __P((DB_ENV *, const char *, u_int32_t));
-int __dbcl_set_shm_key __P((DB_ENV *, long));
-int __dbcl_set_tas_spins __P((DB_ENV *, u_int32_t));
-int __dbcl_set_timeout __P((DB_ENV *, u_int32_t, u_int32_t));
-int __dbcl_set_tmp_dir __P((DB_ENV *, const char *));
-int __dbcl_set_tx_max __P((DB_ENV *, u_int32_t));
-int __dbcl_set_tx_timestamp __P((DB_ENV *, time_t *));
-int __dbcl_set_verbose __P((DB_ENV *, u_int32_t, int));
-int __dbcl_txn_abort __P((DB_TXN *));
-int __dbcl_txn_begin __P((DB_ENV *, DB_TXN *, DB_TXN **, u_int32_t));
-int __dbcl_txn_checkpoint __P((DB_ENV *, u_int32_t, u_int32_t, u_int32_t));
-int __dbcl_txn_commit __P((DB_TXN *, u_int32_t));
-int __dbcl_txn_discard __P((DB_TXN *, u_int32_t));
-int __dbcl_txn_prepare __P((DB_TXN *, u_int8_t *));
-int __dbcl_txn_recover __P((DB_ENV *, DB_PREPLIST *, long, long *, u_int32_t));
-int __dbcl_txn_stat __P((DB_ENV *, DB_TXN_STAT **, u_int32_t));
-int __dbcl_txn_timeout __P((DB_TXN *, u_int32_t, u_int32_t));
-int __dbcl_rep_elect __P((DB_ENV *, int, int, u_int32_t, int *));
-int __dbcl_rep_flush __P((DB_ENV *));
-int __dbcl_rep_process_message __P((DB_ENV *, DBT *, DBT *, int *));
-int __dbcl_rep_set_limit __P((DB_ENV *, u_int32_t, u_int32_t));
-int __dbcl_rep_set_request __P((DB_ENV *, u_int32_t, u_int32_t));
-int __dbcl_rep_set_rep_transport __P((DB_ENV *, int, int (*)(DB_ENV *, const DBT *, const DBT *, int, u_int32_t)));
-int __dbcl_rep_start __P((DB_ENV *, DBT *, u_int32_t));
-int __dbcl_rep_stat __P((DB_ENV *, DB_REP_STAT **, u_int32_t));
-int __dbcl_db_alloc __P((DB *, void *(*)(size_t), void *(*)(void *, size_t), void (*)(void *)));
-int __dbcl_db_associate __P((DB *, DB_TXN *, DB *, int (*)(DB *, const DBT *, const DBT *, DBT *), u_int32_t));
-int __dbcl_db_bt_compare __P((DB *, int (*)(DB *, const DBT *, const DBT *)));
-int __dbcl_db_bt_maxkey __P((DB *, u_int32_t));
-int __dbcl_db_bt_minkey __P((DB *, u_int32_t));
-int __dbcl_db_bt_prefix __P((DB *, size_t(*)(DB *, const DBT *, const DBT *)));
-int __dbcl_db_set_append_recno __P((DB *, int (*)(DB *, DBT *, db_recno_t)));
-int __dbcl_db_cache_priority __P((DB *, DB_CACHE_PRIORITY));
-int __dbcl_db_cachesize __P((DB *, u_int32_t, u_int32_t, int));
-int __dbcl_db_close __P((DB *, u_int32_t));
-int __dbcl_db_create __P((DB *, DB_ENV *, u_int32_t));
-int __dbcl_db_del __P((DB *, DB_TXN *, DBT *, u_int32_t));
-int __dbcl_db_dup_compare __P((DB *, int (*)(DB *, const DBT *, const DBT *)));
-int __dbcl_db_encrypt __P((DB *, const char *, u_int32_t));
-int __dbcl_db_extentsize __P((DB *, u_int32_t));
-int __dbcl_db_fd __P((DB *, int *));
-int __dbcl_db_feedback __P((DB *, void (*)(DB *, int, int)));
-int __dbcl_db_flags __P((DB *, u_int32_t));
-int __dbcl_db_get __P((DB *, DB_TXN *, DBT *, DBT *, u_int32_t));
-int __dbcl_db_h_ffactor __P((DB *, u_int32_t));
-int __dbcl_db_h_hash __P((DB *, u_int32_t(*)(DB *, const void *, u_int32_t)));
-int __dbcl_db_h_nelem __P((DB *, u_int32_t));
-int __dbcl_db_key_range __P((DB *, DB_TXN *, DBT *, DB_KEY_RANGE *, u_int32_t));
-int __dbcl_db_lorder __P((DB *, int));
-int __dbcl_db_open __P((DB *, DB_TXN *, const char *, const char *, DBTYPE, u_int32_t, int));
-int __dbcl_db_pagesize __P((DB *, u_int32_t));
-int __dbcl_db_panic __P((DB *, void (*)(DB_ENV *, int)));
-int __dbcl_db_pget __P((DB *, DB_TXN *, DBT *, DBT *, DBT *, u_int32_t));
-int __dbcl_db_put __P((DB *, DB_TXN *, DBT *, DBT *, u_int32_t));
-int __dbcl_db_re_delim __P((DB *, int));
-int __dbcl_db_re_len __P((DB *, u_int32_t));
-int __dbcl_db_re_pad __P((DB *, int));
-int __dbcl_db_re_source __P((DB *, const char *));
-int __dbcl_db_remove __P((DB *, const char *, const char *, u_int32_t));
-int __dbcl_db_rename __P((DB *, const char *, const char *, const char *, u_int32_t));
-int __dbcl_db_stat __P((DB *, void *, u_int32_t));
-int __dbcl_db_sync __P((DB *, u_int32_t));
-int __dbcl_db_truncate __P((DB *, DB_TXN *, u_int32_t  *, u_int32_t));
-int __dbcl_db_upgrade __P((DB *, const char *, u_int32_t));
-int __dbcl_db_verify __P((DB *, const char *, const char *, FILE *, u_int32_t));
-int __dbcl_db_cursor __P((DB *, DB_TXN *, DBC **, u_int32_t));
-int __dbcl_db_join __P((DB *, DBC **, DBC **, u_int32_t));
-int __dbcl_dbc_close __P((DBC *));
-int __dbcl_dbc_count __P((DBC *, db_recno_t *, u_int32_t));
-int __dbcl_dbc_del __P((DBC *, u_int32_t));
-int __dbcl_dbc_dup __P((DBC *, DBC **, u_int32_t));
-int __dbcl_dbc_get __P((DBC *, DBT *, DBT *, u_int32_t));
-int __dbcl_dbc_pget __P((DBC *, DBT *, DBT *, DBT *, u_int32_t));
-int __dbcl_dbc_put __P((DBC *, DBT *, DBT *, u_int32_t));
-int __dbcl_lock_detect __P((DB_ENV *, u_int32_t, u_int32_t, int *));
-int __dbcl_lock_get __P((DB_ENV *, u_int32_t, u_int32_t, const DBT *, db_lockmode_t, DB_LOCK *));
-int __dbcl_lock_id __P((DB_ENV *, u_int32_t *));
-int __dbcl_lock_id_free __P((DB_ENV *, u_int32_t));
-int __dbcl_lock_put __P((DB_ENV *, DB_LOCK *));
-int __dbcl_lock_stat __P((DB_ENV *, DB_LOCK_STAT **, u_int32_t));
-int __dbcl_lock_vec __P((DB_ENV *, u_int32_t, u_int32_t, DB_LOCKREQ *, int, DB_LOCKREQ **));
-int __dbcl_log_archive __P((DB_ENV *, char ***, u_int32_t));
-int __dbcl_log_cursor __P((DB_ENV *, DB_LOGC **, u_int32_t));
-int __dbcl_log_file __P((DB_ENV *, const DB_LSN *, char *, size_t));
-int __dbcl_log_flush __P((DB_ENV *, const DB_LSN *));
-int __dbcl_log_put __P((DB_ENV *, DB_LSN *, const DBT *, u_int32_t));
-int __dbcl_log_stat __P((DB_ENV *, DB_LOG_STAT **, u_int32_t));
-int __dbcl_memp_fcreate __P((DB_ENV *, DB_MPOOLFILE **, u_int32_t));
-int __dbcl_memp_register __P((DB_ENV *, int, int (*)(DB_ENV *, db_pgno_t, void *, DBT *), int (*)(DB_ENV *, db_pgno_t, void *, DBT *)));
-int __dbcl_memp_stat __P((DB_ENV *, DB_MPOOL_STAT **, DB_MPOOL_FSTAT ***, u_int32_t));
-int __dbcl_memp_sync __P((DB_ENV *, DB_LSN *));
-int __dbcl_memp_trickle __P((DB_ENV *, int, int *));
-int __dbcl_env_close_ret __P((DB_ENV *, u_int32_t, __env_close_reply *));
-int __dbcl_env_create_ret __P((DB_ENV *, long, __env_create_reply *));
-int __dbcl_env_open_ret __P((DB_ENV *, const char *, u_int32_t, int, __env_open_reply *));
-int __dbcl_env_remove_ret __P((DB_ENV *, const char *, u_int32_t, __env_remove_reply *));
-int __dbcl_txn_abort_ret __P((DB_TXN *, __txn_abort_reply *));
-int __dbcl_txn_begin_ret __P((DB_ENV *, DB_TXN *, DB_TXN **, u_int32_t, __txn_begin_reply *));
-int __dbcl_txn_commit_ret __P((DB_TXN *, u_int32_t, __txn_commit_reply *));
-int __dbcl_txn_discard_ret __P((DB_TXN *, u_int32_t, __txn_discard_reply *));
-int __dbcl_txn_recover_ret __P((DB_ENV *, DB_PREPLIST *, long, long *, u_int32_t, __txn_recover_reply *));
-int __dbcl_db_close_ret __P((DB *, u_int32_t, __db_close_reply *));
-int __dbcl_db_create_ret __P((DB *, DB_ENV *, u_int32_t, __db_create_reply *));
-int __dbcl_db_get_ret __P((DB *, DB_TXN *, DBT *, DBT *, u_int32_t, __db_get_reply *));
-int __dbcl_db_key_range_ret __P((DB *, DB_TXN *, DBT *, DB_KEY_RANGE *, u_int32_t, __db_key_range_reply *));
-int __dbcl_db_open_ret __P((DB *, DB_TXN *, const char *, const char *, DBTYPE, u_int32_t, int, __db_open_reply *));
-int __dbcl_db_pget_ret __P((DB *, DB_TXN *, DBT *, DBT *, DBT *, u_int32_t, __db_pget_reply *));
-int __dbcl_db_put_ret __P((DB *, DB_TXN *, DBT *, DBT *, u_int32_t, __db_put_reply *));
-int __dbcl_db_remove_ret __P((DB *, const char *, const char *, u_int32_t, __db_remove_reply *));
-int __dbcl_db_rename_ret __P((DB *, const char *, const char *, const char *, u_int32_t, __db_rename_reply *));
-int __dbcl_db_stat_ret __P((DB *, void *, u_int32_t, __db_stat_reply *));
-int __dbcl_db_truncate_ret __P((DB *, DB_TXN *, u_int32_t  *, u_int32_t, __db_truncate_reply *));
-int __dbcl_db_cursor_ret __P((DB *, DB_TXN *, DBC **, u_int32_t, __db_cursor_reply *));
-int __dbcl_db_join_ret __P((DB *, DBC **, DBC **, u_int32_t, __db_join_reply *));
-int __dbcl_dbc_close_ret __P((DBC *, __dbc_close_reply *));
-int __dbcl_dbc_count_ret __P((DBC *, db_recno_t *, u_int32_t, __dbc_count_reply *));
-int __dbcl_dbc_dup_ret __P((DBC *, DBC **, u_int32_t, __dbc_dup_reply *));
-int __dbcl_dbc_get_ret __P((DBC *, DBT *, DBT *, u_int32_t, __dbc_get_reply *));
-int __dbcl_dbc_pget_ret __P((DBC *, DBT *, DBT *, DBT *, u_int32_t, __dbc_pget_reply *));
-int __dbcl_dbc_put_ret __P((DBC *, DBT *, DBT *, u_int32_t, __dbc_put_reply *));
-
-#if defined(__cplusplus)
-}
-#endif
-#endif /* !_rpc_client_ext_h_ */
diff --git a/bdb/dbinc_auto/rpc_defs.in b/bdb/dbinc_auto/rpc_defs.in
deleted file mode 100644
index cae76f5606d756b80dfa2464f9f11368dc2755cb..0000000000000000000000000000000000000000
--- a/bdb/dbinc_auto/rpc_defs.in
+++ /dev/null
@@ -1,4 +0,0 @@
-
-/* DO NOT EDIT: automatically built by dist/s_rpc. */
-#define	DB_RPC_SERVERPROG ((unsigned long)(351457))
-#define	DB_RPC_SERVERVERS ((unsigned long)(4001))
diff --git a/bdb/dbinc_auto/rpc_server_ext.h b/bdb/dbinc_auto/rpc_server_ext.h
deleted file mode 100644
index c0c706881c7891d34521c4dd93dacced5d1b73ad..0000000000000000000000000000000000000000
--- a/bdb/dbinc_auto/rpc_server_ext.h
+++ /dev/null
@@ -1,126 +0,0 @@
-/* DO NOT EDIT: automatically built by dist/s_include. */
-#ifndef	_rpc_server_ext_h_
-#define	_rpc_server_ext_h_
-
-#if defined(__cplusplus)
-extern "C" {
-#endif
-
-void __env_cachesize_proc __P((long, u_int32_t, u_int32_t, u_int32_t, __env_cachesize_reply *));
-void __env_close_proc __P((long, u_int32_t, __env_close_reply *));
-void __env_create_proc __P((u_int32_t, __env_create_reply *));
-void __env_dbremove_proc __P((long, long, char *, char *, u_int32_t, __env_dbremove_reply *));
-void __env_dbrename_proc __P((long, long, char *, char *, char *, u_int32_t, __env_dbrename_reply *));
-void __env_encrypt_proc __P((long, char *, u_int32_t, __env_encrypt_reply *));
-void __env_flags_proc __P((long, u_int32_t, u_int32_t, __env_flags_reply *));
-void __env_open_proc __P((long, char *, u_int32_t, u_int32_t, __env_open_reply *));
-void __env_remove_proc __P((long, char *, u_int32_t, __env_remove_reply *));
-void __txn_abort_proc __P((long, __txn_abort_reply *));
-void __txn_begin_proc __P((long, long, u_int32_t, __txn_begin_reply *));
-void __txn_commit_proc __P((long, u_int32_t, __txn_commit_reply *));
-void __txn_discard_proc __P((long, u_int32_t, __txn_discard_reply *));
-void __txn_prepare_proc __P((long, u_int8_t *, __txn_prepare_reply *));
-void __txn_recover_proc __P((long, u_int32_t, u_int32_t, __txn_recover_reply *, int *));
-void __db_bt_maxkey_proc __P((long, u_int32_t, __db_bt_maxkey_reply *));
-void __db_associate_proc __P((long, long, long, u_int32_t, __db_associate_reply *));
-void __db_bt_minkey_proc __P((long, u_int32_t, __db_bt_minkey_reply *));
-void __db_close_proc __P((long, u_int32_t, __db_close_reply *));
-void __db_create_proc __P((long, u_int32_t, __db_create_reply *));
-void __db_del_proc __P((long, long, u_int32_t, u_int32_t, u_int32_t, u_int32_t, void *, u_int32_t, u_int32_t, __db_del_reply *));
-void __db_encrypt_proc __P((long, char *, u_int32_t, __db_encrypt_reply *));
-void __db_extentsize_proc __P((long, u_int32_t, __db_extentsize_reply *));
-void __db_flags_proc __P((long, u_int32_t, __db_flags_reply *));
-void __db_get_proc __P((long, long, u_int32_t, u_int32_t, u_int32_t, u_int32_t, void *, u_int32_t, u_int32_t, u_int32_t, u_int32_t, u_int32_t, void *, u_int32_t, u_int32_t, __db_get_reply *, int *));
-void __db_h_ffactor_proc __P((long, u_int32_t, __db_h_ffactor_reply *));
-void __db_h_nelem_proc __P((long, u_int32_t, __db_h_nelem_reply *));
-void __db_key_range_proc __P((long, long, u_int32_t, u_int32_t, u_int32_t, u_int32_t, void *, u_int32_t, u_int32_t, __db_key_range_reply *));
-void __db_lorder_proc __P((long, u_int32_t, __db_lorder_reply *));
-void __db_open_proc __P((long, long, char *, char *, u_int32_t, u_int32_t, u_int32_t, __db_open_reply *));
-void __db_pagesize_proc __P((long, u_int32_t, __db_pagesize_reply *));
-void __db_pget_proc __P((long, long, u_int32_t, u_int32_t, u_int32_t, u_int32_t, void *, u_int32_t, u_int32_t, u_int32_t, u_int32_t, u_int32_t, void *, u_int32_t, u_int32_t, u_int32_t, u_int32_t, u_int32_t, void *, u_int32_t, u_int32_t, __db_pget_reply *, int *));
-void __db_put_proc __P((long, long, u_int32_t, u_int32_t, u_int32_t, u_int32_t, void *, u_int32_t, u_int32_t, u_int32_t, u_int32_t, u_int32_t, void *, u_int32_t, u_int32_t, __db_put_reply *, int *));
-void __db_re_delim_proc __P((long, u_int32_t, __db_re_delim_reply *));
-void __db_re_len_proc __P((long, u_int32_t, __db_re_len_reply *));
-void __db_re_pad_proc __P((long, u_int32_t, __db_re_pad_reply *));
-void __db_remove_proc __P((long, char *, char *, u_int32_t, __db_remove_reply *));
-void __db_rename_proc __P((long, char *, char *, char *, u_int32_t, __db_rename_reply *));
-void __db_stat_proc __P((long, u_int32_t, __db_stat_reply *, int *));
-void __db_sync_proc __P((long, u_int32_t, __db_sync_reply *));
-void __db_truncate_proc __P((long, long, u_int32_t, __db_truncate_reply *));
-void __db_cursor_proc __P((long, long, u_int32_t, __db_cursor_reply *));
-void __db_join_proc __P((long, u_int32_t *, u_int32_t, u_int32_t, __db_join_reply *));
-void __dbc_close_proc __P((long, __dbc_close_reply *));
-void __dbc_count_proc __P((long, u_int32_t, __dbc_count_reply *));
-void __dbc_del_proc __P((long, u_int32_t, __dbc_del_reply *));
-void __dbc_dup_proc __P((long, u_int32_t, __dbc_dup_reply *));
-void __dbc_get_proc __P((long, u_int32_t, u_int32_t, u_int32_t, u_int32_t, void *, u_int32_t, u_int32_t, u_int32_t, u_int32_t, u_int32_t, void *, u_int32_t, u_int32_t, __dbc_get_reply *, int *));
-void __dbc_pget_proc __P((long, u_int32_t, u_int32_t, u_int32_t, u_int32_t, void *, u_int32_t, u_int32_t, u_int32_t, u_int32_t, u_int32_t, void *, u_int32_t, u_int32_t, u_int32_t, u_int32_t, u_int32_t, void *, u_int32_t, u_int32_t, __dbc_pget_reply *, int *));
-void __dbc_put_proc __P((long, u_int32_t, u_int32_t, u_int32_t, u_int32_t, void *, u_int32_t, u_int32_t, u_int32_t, u_int32_t, u_int32_t, void *, u_int32_t, u_int32_t, __dbc_put_reply *, int *));
-void __dbsrv_settimeout __P((ct_entry *, u_int32_t));
-void __dbsrv_timeout __P((int));
-void __dbclear_ctp __P((ct_entry *));
-void __dbdel_ctp __P((ct_entry *));
-ct_entry *new_ct_ent __P((int *));
-ct_entry *get_tableent __P((long));
-ct_entry *__dbsrv_sharedb __P((ct_entry *, const char *, const char *, DBTYPE, u_int32_t));
-ct_entry *__dbsrv_shareenv __P((ct_entry *, home_entry *, u_int32_t));
-void __dbsrv_active __P((ct_entry *));
-int __db_close_int __P((long, u_int32_t));
-int __dbc_close_int __P((ct_entry *));
-int __dbenv_close_int __P((long, u_int32_t, int));
-home_entry *get_home __P((char *));
-__env_cachesize_reply *__db_env_cachesize_4001  __P((__env_cachesize_msg *, struct svc_req *));
-__env_close_reply *__db_env_close_4001 __P((__env_close_msg *, struct svc_req *));
-__env_create_reply *__db_env_create_4001 __P((__env_create_msg *, struct svc_req *));
-__env_dbremove_reply *__db_env_dbremove_4001  __P((__env_dbremove_msg *, struct svc_req *));
-__env_dbrename_reply *__db_env_dbrename_4001  __P((__env_dbrename_msg *, struct svc_req *));
-__env_encrypt_reply *__db_env_encrypt_4001  __P((__env_encrypt_msg *, struct svc_req *));
-__env_flags_reply *__db_env_flags_4001 __P((__env_flags_msg *, struct svc_req *));
-__env_open_reply *__db_env_open_4001 __P((__env_open_msg *, struct svc_req *));
-__env_remove_reply *__db_env_remove_4001 __P((__env_remove_msg *, struct svc_req *));
-__txn_abort_reply *__db_txn_abort_4001 __P((__txn_abort_msg *, struct svc_req *));
-__txn_begin_reply *__db_txn_begin_4001 __P((__txn_begin_msg *, struct svc_req *));
-__txn_commit_reply *__db_txn_commit_4001 __P((__txn_commit_msg *, struct svc_req *));
-__txn_discard_reply *__db_txn_discard_4001  __P((__txn_discard_msg *, struct svc_req *));
-__txn_prepare_reply *__db_txn_prepare_4001  __P((__txn_prepare_msg *, struct svc_req *));
-__txn_recover_reply *__db_txn_recover_4001  __P((__txn_recover_msg *, struct svc_req *));
-__db_associate_reply *__db_db_associate_4001  __P((__db_associate_msg *, struct svc_req *));
-__db_bt_maxkey_reply *__db_db_bt_maxkey_4001  __P((__db_bt_maxkey_msg *, struct svc_req *));
-__db_bt_minkey_reply *__db_db_bt_minkey_4001  __P((__db_bt_minkey_msg *, struct svc_req *));
-__db_close_reply *__db_db_close_4001 __P((__db_close_msg *, struct svc_req *));
-__db_create_reply *__db_db_create_4001 __P((__db_create_msg *, struct svc_req *));
-__db_del_reply *__db_db_del_4001 __P((__db_del_msg *, struct svc_req *));
-__db_encrypt_reply *__db_db_encrypt_4001 __P((__db_encrypt_msg *, struct svc_req *));
-__db_extentsize_reply *__db_db_extentsize_4001  __P((__db_extentsize_msg *, struct svc_req *));
-__db_flags_reply *__db_db_flags_4001 __P((__db_flags_msg *, struct svc_req *));
-__db_get_reply *__db_db_get_4001 __P((__db_get_msg *, struct svc_req *));
-__db_h_ffactor_reply *__db_db_h_ffactor_4001  __P((__db_h_ffactor_msg *, struct svc_req *));
-__db_h_nelem_reply *__db_db_h_nelem_4001 __P((__db_h_nelem_msg *, struct svc_req *));
-__db_key_range_reply *__db_db_key_range_4001  __P((__db_key_range_msg *, struct svc_req *));
-__db_lorder_reply *__db_db_lorder_4001 __P((__db_lorder_msg *, struct svc_req *));
-__db_open_reply *__db_db_open_4001 __P((__db_open_msg *, struct svc_req *));
-__db_pagesize_reply *__db_db_pagesize_4001  __P((__db_pagesize_msg *, struct svc_req *));
-__db_pget_reply *__db_db_pget_4001 __P((__db_pget_msg *, struct svc_req *));
-__db_put_reply *__db_db_put_4001 __P((__db_put_msg *, struct svc_req *));
-__db_re_delim_reply *__db_db_re_delim_4001  __P((__db_re_delim_msg *, struct svc_req *));
-__db_re_len_reply *__db_db_re_len_4001 __P((__db_re_len_msg *, struct svc_req *));
-__db_re_pad_reply *__db_db_re_pad_4001 __P((__db_re_pad_msg *, struct svc_req *));
-__db_remove_reply *__db_db_remove_4001 __P((__db_remove_msg *, struct svc_req *));
-__db_rename_reply *__db_db_rename_4001 __P((__db_rename_msg *, struct svc_req *));
-__db_stat_reply *__db_db_stat_4001 __P((__db_stat_msg *, struct svc_req *));
-__db_sync_reply *__db_db_sync_4001 __P((__db_sync_msg *, struct svc_req *));
-__db_truncate_reply *__db_db_truncate_4001  __P((__db_truncate_msg *, struct svc_req *));
-__db_cursor_reply *__db_db_cursor_4001 __P((__db_cursor_msg *, struct svc_req *));
-__db_join_reply *__db_db_join_4001 __P((__db_join_msg *, struct svc_req *));
-__dbc_close_reply *__db_dbc_close_4001 __P((__dbc_close_msg *, struct svc_req *));
-__dbc_count_reply *__db_dbc_count_4001 __P((__dbc_count_msg *, struct svc_req *));
-__dbc_del_reply *__db_dbc_del_4001 __P((__dbc_del_msg *, struct svc_req *));
-__dbc_dup_reply *__db_dbc_dup_4001 __P((__dbc_dup_msg *, struct svc_req *));
-__dbc_get_reply *__db_dbc_get_4001 __P((__dbc_get_msg *, struct svc_req *));
-__dbc_pget_reply *__db_dbc_pget_4001 __P((__dbc_pget_msg *, struct svc_req *));
-__dbc_put_reply *__db_dbc_put_4001 __P((__dbc_put_msg *, struct svc_req *));
-
-#if defined(__cplusplus)
-}
-#endif
-#endif /* !_rpc_server_ext_h_ */
diff --git a/bdb/dbinc_auto/tcl_ext.h b/bdb/dbinc_auto/tcl_ext.h
deleted file mode 100644
index 619ea4a9dfccd3a745c5c3b12a760650c3a82675..0000000000000000000000000000000000000000
--- a/bdb/dbinc_auto/tcl_ext.h
+++ /dev/null
@@ -1,82 +0,0 @@
-/* DO NOT EDIT: automatically built by dist/s_include. */
-#ifndef	_tcl_ext_h_
-#define	_tcl_ext_h_
-
-#if defined(__cplusplus)
-extern "C" {
-#endif
-
-int bdb_HCommand __P((Tcl_Interp *, int, Tcl_Obj * CONST*));
-#if DB_DBM_HSEARCH != 0
-int bdb_NdbmOpen __P((Tcl_Interp *, int, Tcl_Obj * CONST*, DBM **));
-#endif
-#if DB_DBM_HSEARCH != 0
-int bdb_DbmCommand __P((Tcl_Interp *, int, Tcl_Obj * CONST*, int, DBM *));
-#endif
-int ndbm_Cmd __P((ClientData, Tcl_Interp *, int, Tcl_Obj * CONST*));
-void _DbInfoDelete __P((Tcl_Interp *, DBTCL_INFO *));
-int db_Cmd __P((ClientData, Tcl_Interp *, int, Tcl_Obj * CONST*));
-int dbc_Cmd __P((ClientData, Tcl_Interp *, int, Tcl_Obj * CONST*));
-int env_Cmd __P((ClientData, Tcl_Interp *, int, Tcl_Obj * CONST*));
-int tcl_EnvRemove __P((Tcl_Interp *, int, Tcl_Obj * CONST*, DB_ENV *, DBTCL_INFO *));
-int tcl_EnvVerbose __P((Tcl_Interp *, DB_ENV *, Tcl_Obj *, Tcl_Obj *));
-int tcl_EnvAttr __P((Tcl_Interp *, int, Tcl_Obj * CONST*, DB_ENV *));
-int tcl_EnvTest __P((Tcl_Interp *, int, Tcl_Obj * CONST*, DB_ENV *));
-DBTCL_INFO *_NewInfo __P((Tcl_Interp *, void *, char *, enum INFOTYPE));
-void *_NameToPtr __P((CONST char *));
-DBTCL_INFO *_PtrToInfo __P((CONST void *));
-DBTCL_INFO *_NameToInfo __P((CONST char *));
-void  _SetInfoData __P((DBTCL_INFO *, void *));
-void  _DeleteInfo __P((DBTCL_INFO *));
-int _SetListElem __P((Tcl_Interp *, Tcl_Obj *, void *, int, void *, int));
-int _SetListElemInt __P((Tcl_Interp *, Tcl_Obj *, void *, int));
-int _SetListRecnoElem __P((Tcl_Interp *, Tcl_Obj *, db_recno_t, u_char *, int));
-int _Set3DBTList __P((Tcl_Interp *, Tcl_Obj *, DBT *, int, DBT *, int, DBT *));
-int _SetMultiList __P((Tcl_Interp *, Tcl_Obj *, DBT *, DBT*, int, int));
-int _GetGlobPrefix __P((char *, char **));
-int _ReturnSetup __P((Tcl_Interp *, int, int, char *));
-int _ErrorSetup __P((Tcl_Interp *, int, char *));
-void _ErrorFunc __P((CONST char *, char *));
-int _GetLsn __P((Tcl_Interp *, Tcl_Obj *, DB_LSN *));
-int _GetUInt32 __P((Tcl_Interp *, Tcl_Obj *, u_int32_t *));
-Tcl_Obj *_GetFlagsList __P((Tcl_Interp *, u_int32_t, void (*)(u_int32_t, void *, void (*)(u_int32_t, const FN *, void *))));
-void _debug_check  __P((void));
-int _CopyObjBytes  __P((Tcl_Interp *, Tcl_Obj *obj, void **, u_int32_t *, int *));
-int tcl_LockDetect __P((Tcl_Interp *, int, Tcl_Obj * CONST*, DB_ENV *));
-int tcl_LockGet __P((Tcl_Interp *, int, Tcl_Obj * CONST*, DB_ENV *));
-int tcl_LockStat __P((Tcl_Interp *, int, Tcl_Obj * CONST*, DB_ENV *));
-int tcl_LockTimeout __P((Tcl_Interp *, int, Tcl_Obj * CONST*, DB_ENV *));
-int tcl_LockVec __P((Tcl_Interp *, int, Tcl_Obj * CONST*, DB_ENV *));
-int tcl_LogArchive __P((Tcl_Interp *, int, Tcl_Obj * CONST*, DB_ENV *));
-int tcl_LogCompare __P((Tcl_Interp *, int, Tcl_Obj * CONST*));
-int tcl_LogFile __P((Tcl_Interp *, int, Tcl_Obj * CONST*, DB_ENV *));
-int tcl_LogFlush __P((Tcl_Interp *, int, Tcl_Obj * CONST*, DB_ENV *));
-int tcl_LogGet __P((Tcl_Interp *, int, Tcl_Obj * CONST*, DB_ENV *));
-int tcl_LogPut __P((Tcl_Interp *, int, Tcl_Obj * CONST*, DB_ENV *));
-int tcl_LogStat __P((Tcl_Interp *, int, Tcl_Obj * CONST*, DB_ENV *));
-int logc_Cmd __P((ClientData, Tcl_Interp *, int, Tcl_Obj * CONST*));
-void _MpInfoDelete __P((Tcl_Interp *, DBTCL_INFO *));
-int tcl_MpSync __P((Tcl_Interp *, int, Tcl_Obj * CONST*, DB_ENV *));
-int tcl_MpTrickle __P((Tcl_Interp *, int, Tcl_Obj * CONST*, DB_ENV *));
-int tcl_Mp __P((Tcl_Interp *, int, Tcl_Obj * CONST*, DB_ENV *, DBTCL_INFO *));
-int tcl_MpStat __P((Tcl_Interp *, int, Tcl_Obj * CONST*, DB_ENV *));
-int tcl_RepElect __P((Tcl_Interp *, int, Tcl_Obj * CONST *, DB_ENV *));
-int tcl_RepFlush __P((Tcl_Interp *, int, Tcl_Obj * CONST *, DB_ENV *));
-int tcl_RepLimit __P((Tcl_Interp *, int, Tcl_Obj * CONST *, DB_ENV *));
-int tcl_RepRequest __P((Tcl_Interp *, int, Tcl_Obj * CONST *, DB_ENV *));
-int tcl_RepStart __P((Tcl_Interp *, int, Tcl_Obj * CONST *, DB_ENV *));
-int tcl_RepProcessMessage __P((Tcl_Interp *, int, Tcl_Obj * CONST *, DB_ENV *));
-int tcl_RepStat __P((Tcl_Interp *, int, Tcl_Obj * CONST *, DB_ENV *));
-void _TxnInfoDelete __P((Tcl_Interp *, DBTCL_INFO *));
-int tcl_TxnCheckpoint __P((Tcl_Interp *, int, Tcl_Obj * CONST*, DB_ENV *));
-int tcl_Txn __P((Tcl_Interp *, int, Tcl_Obj * CONST*, DB_ENV *, DBTCL_INFO *));
-int tcl_TxnStat __P((Tcl_Interp *, int, Tcl_Obj * CONST*, DB_ENV *));
-int tcl_TxnTimeout __P((Tcl_Interp *, int, Tcl_Obj * CONST*, DB_ENV *));
-int tcl_TxnRecover __P((Tcl_Interp *, int, Tcl_Obj * CONST*, DB_ENV *, DBTCL_INFO *));
-int bdb_RandCommand __P((Tcl_Interp *, int, Tcl_Obj * CONST*));
-int tcl_Mutex __P((Tcl_Interp *, int, Tcl_Obj * CONST*, DB_ENV *, DBTCL_INFO *));
-
-#if defined(__cplusplus)
-}
-#endif
-#endif /* !_tcl_ext_h_ */
diff --git a/bdb/dbinc_auto/txn_auto.h b/bdb/dbinc_auto/txn_auto.h
deleted file mode 100644
index ac841ba5bc30e22aa1bc1f46b995be615385caa2..0000000000000000000000000000000000000000
--- a/bdb/dbinc_auto/txn_auto.h
+++ /dev/null
@@ -1,55 +0,0 @@
-/* Do not edit: automatically built by gen_rec.awk. */
-
-#ifndef	__txn_AUTO_H
-#define	__txn_AUTO_H
-#define	DB___txn_regop	10
-typedef struct ___txn_regop_args {
-	u_int32_t type;
-	DB_TXN *txnid;
-	DB_LSN prev_lsn;
-	u_int32_t	opcode;
-	int32_t	timestamp;
-} __txn_regop_args;
-
-#define	DB___txn_ckp	11
-typedef struct ___txn_ckp_args {
-	u_int32_t type;
-	DB_TXN *txnid;
-	DB_LSN prev_lsn;
-	DB_LSN	ckp_lsn;
-	DB_LSN	last_ckp;
-	int32_t	timestamp;
-} __txn_ckp_args;
-
-#define	DB___txn_child	12
-typedef struct ___txn_child_args {
-	u_int32_t type;
-	DB_TXN *txnid;
-	DB_LSN prev_lsn;
-	u_int32_t	child;
-	DB_LSN	c_lsn;
-} __txn_child_args;
-
-#define	DB___txn_xa_regop	13
-typedef struct ___txn_xa_regop_args {
-	u_int32_t type;
-	DB_TXN *txnid;
-	DB_LSN prev_lsn;
-	u_int32_t	opcode;
-	DBT	xid;
-	int32_t	formatID;
-	u_int32_t	gtrid;
-	u_int32_t	bqual;
-	DB_LSN	begin_lsn;
-} __txn_xa_regop_args;
-
-#define	DB___txn_recycle	14
-typedef struct ___txn_recycle_args {
-	u_int32_t type;
-	DB_TXN *txnid;
-	DB_LSN prev_lsn;
-	u_int32_t	min;
-	u_int32_t	max;
-} __txn_recycle_args;
-
-#endif
diff --git a/bdb/dbinc_auto/txn_ext.h b/bdb/dbinc_auto/txn_ext.h
deleted file mode 100644
index 5a4381ed890d9573af0559af0a38c0a991737a8c..0000000000000000000000000000000000000000
--- a/bdb/dbinc_auto/txn_ext.h
+++ /dev/null
@@ -1,70 +0,0 @@
-/* DO NOT EDIT: automatically built by dist/s_include. */
-#ifndef	_txn_ext_h_
-#define	_txn_ext_h_
-
-#if defined(__cplusplus)
-extern "C" {
-#endif
-
-int __txn_begin __P((DB_ENV *, DB_TXN *, DB_TXN **, u_int32_t));
-int __txn_xa_begin __P((DB_ENV *, DB_TXN *));
-int __txn_compensate_begin __P((DB_ENV *, DB_TXN **txnp));
-int __txn_commit __P((DB_TXN *, u_int32_t));
-int __txn_abort __P((DB_TXN *));
-int __txn_discard __P((DB_TXN *, u_int32_t flags));
-int __txn_prepare __P((DB_TXN *, u_int8_t *));
-u_int32_t __txn_id __P((DB_TXN *));
-int __txn_checkpoint __P((DB_ENV *, u_int32_t, u_int32_t, u_int32_t));
-int __txn_getckp __P((DB_ENV *, DB_LSN *));
-int __txn_activekids __P((DB_ENV *, u_int32_t, DB_TXN *));
-int __txn_force_abort __P((DB_ENV *, u_int8_t *));
-int __txn_preclose __P((DB_ENV *));
-int __txn_reset __P((DB_ENV *));
-int __txn_regop_log __P((DB_ENV *, DB_TXN *, DB_LSN *, u_int32_t, u_int32_t, int32_t));
-int __txn_regop_getpgnos __P((DB_ENV *, DBT *, DB_LSN *, db_recops, void *));
-int __txn_regop_print __P((DB_ENV *, DBT *, DB_LSN *, db_recops, void *));
-int __txn_regop_read __P((DB_ENV *, void *, __txn_regop_args **));
-int __txn_ckp_log __P((DB_ENV *, DB_TXN *, DB_LSN *, u_int32_t, DB_LSN *, DB_LSN *, int32_t));
-int __txn_ckp_getpgnos __P((DB_ENV *, DBT *, DB_LSN *, db_recops, void *));
-int __txn_ckp_print __P((DB_ENV *, DBT *, DB_LSN *, db_recops, void *));
-int __txn_ckp_read __P((DB_ENV *, void *, __txn_ckp_args **));
-int __txn_child_log __P((DB_ENV *, DB_TXN *, DB_LSN *, u_int32_t, u_int32_t, DB_LSN *));
-int __txn_child_getpgnos __P((DB_ENV *, DBT *, DB_LSN *, db_recops, void *));
-int __txn_child_print __P((DB_ENV *, DBT *, DB_LSN *, db_recops, void *));
-int __txn_child_read __P((DB_ENV *, void *, __txn_child_args **));
-int __txn_xa_regop_log __P((DB_ENV *, DB_TXN *, DB_LSN *, u_int32_t, u_int32_t, const DBT *, int32_t, u_int32_t, u_int32_t, DB_LSN *));
-int __txn_xa_regop_getpgnos __P((DB_ENV *, DBT *, DB_LSN *, db_recops, void *));
-int __txn_xa_regop_print __P((DB_ENV *, DBT *, DB_LSN *, db_recops, void *));
-int __txn_xa_regop_read __P((DB_ENV *, void *, __txn_xa_regop_args **));
-int __txn_recycle_log __P((DB_ENV *, DB_TXN *, DB_LSN *, u_int32_t, u_int32_t, u_int32_t));
-int __txn_recycle_getpgnos __P((DB_ENV *, DBT *, DB_LSN *, db_recops, void *));
-int __txn_recycle_print __P((DB_ENV *, DBT *, DB_LSN *, db_recops, void *));
-int __txn_recycle_read __P((DB_ENV *, void *, __txn_recycle_args **));
-int __txn_init_print __P((DB_ENV *, int (***)(DB_ENV *, DBT *, DB_LSN *, db_recops, void *), size_t *));
-int __txn_init_getpgnos __P((DB_ENV *, int (***)(DB_ENV *, DBT *, DB_LSN *, db_recops, void *), size_t *));
-int __txn_init_recover __P((DB_ENV *, int (***)(DB_ENV *, DBT *, DB_LSN *, db_recops, void *), size_t *));
-void __txn_dbenv_create __P((DB_ENV *));
-int __txn_regop_recover __P((DB_ENV *, DBT *, DB_LSN *, db_recops, void *));
-int __txn_xa_regop_recover __P((DB_ENV *, DBT *, DB_LSN *, db_recops, void *));
-int __txn_ckp_recover __P((DB_ENV *, DBT *, DB_LSN *, db_recops, void *));
-int __txn_child_recover __P((DB_ENV *, DBT *, DB_LSN *, db_recops, void *));
-int __txn_restore_txn __P((DB_ENV *, DB_LSN *, __txn_xa_regop_args *));
-int __txn_recycle_recover __P((DB_ENV *, DBT *, DB_LSN *, db_recops, void *));
-void __txn_continue __P((DB_ENV *, DB_TXN *, TXN_DETAIL *, size_t));
-int __txn_map_gid __P((DB_ENV *, u_int8_t *, TXN_DETAIL **, size_t *));
-int __txn_recover __P((DB_ENV *, DB_PREPLIST *, long, long *, u_int32_t));
-int __txn_get_prepared __P((DB_ENV *, XID *, DB_PREPLIST *, long, long *, u_int32_t));
-int __txn_open __P((DB_ENV *));
-int __txn_dbenv_refresh __P((DB_ENV *));
-void __txn_region_destroy __P((DB_ENV *, REGINFO *));
-int __txn_id_set __P((DB_ENV *, u_int32_t, u_int32_t));
-int __txn_stat __P((DB_ENV *, DB_TXN_STAT **, u_int32_t));
-int __txn_remevent __P((DB_ENV *, DB_TXN *, const char *, u_int8_t*));
-int __txn_lockevent __P((DB_ENV *, DB_TXN *, DB *, DB_LOCK *, u_int32_t));
-void __txn_remlock __P((DB_ENV *, DB_TXN *, DB_LOCK *, u_int32_t));
-int __txn_doevents __P((DB_ENV *, DB_TXN *, int, int));
-
-#if defined(__cplusplus)
-}
-#endif
-#endif /* !_txn_ext_h_ */
diff --git a/bdb/dbinc_auto/xa_ext.h b/bdb/dbinc_auto/xa_ext.h
deleted file mode 100644
index e4fc9895e18fc26b84e3521c98ad56d72df244c9..0000000000000000000000000000000000000000
--- a/bdb/dbinc_auto/xa_ext.h
+++ /dev/null
@@ -1,20 +0,0 @@
-/* DO NOT EDIT: automatically built by dist/s_include. */
-#ifndef	_xa_ext_h_
-#define	_xa_ext_h_
-
-#if defined(__cplusplus)
-extern "C" {
-#endif
-
-int __db_xa_create __P((DB *));
-int __db_rmid_to_env __P((int rmid, DB_ENV **envp));
-int __db_xid_to_txn __P((DB_ENV *, XID *, size_t *));
-int __db_map_rmid __P((int, DB_ENV *));
-int __db_unmap_rmid __P((int));
-int __db_map_xid __P((DB_ENV *, XID *, size_t));
-void __db_unmap_xid __P((DB_ENV *, XID *, size_t));
-
-#if defined(__cplusplus)
-}
-#endif
-#endif /* !_xa_ext_h_ */
diff --git a/bdb/dbreg/dbreg_auto.c b/bdb/dbreg/dbreg_auto.c
deleted file mode 100644
index 91eace3f4bf4b4ca80308e6eb9618e838ade6ccd..0000000000000000000000000000000000000000
--- a/bdb/dbreg/dbreg_auto.c
+++ /dev/null
@@ -1,358 +0,0 @@
-/* Do not edit: automatically built by gen_rec.awk. */
-#include "db_config.h"
-
-#ifndef NO_SYSTEM_INCLUDES
-#include <sys/types.h>
-
-#include <ctype.h>
-#include <string.h>
-#endif
-
-#include "db_int.h"
-#include "dbinc/crypto.h"
-#include "dbinc/db_page.h"
-#include "dbinc/db_dispatch.h"
-#include "dbinc/db_am.h"
-#include "dbinc/log.h"
-#include "dbinc/rep.h"
-#include "dbinc/txn.h"
-
-/*
- * PUBLIC: int __dbreg_register_log __P((DB_ENV *, DB_TXN *,
- * PUBLIC:     DB_LSN *, u_int32_t, u_int32_t, const DBT *, const DBT *,
- * PUBLIC:     int32_t, DBTYPE, db_pgno_t, u_int32_t));
- */
-int
-__dbreg_register_log(dbenv, txnid, ret_lsnp, flags,
-    opcode, name, uid, fileid, ftype, meta_pgno,
-    id)
-	DB_ENV *dbenv;
-	DB_TXN *txnid;
-	DB_LSN *ret_lsnp;
-	u_int32_t flags;
-	u_int32_t opcode;
-	const DBT *name;
-	const DBT *uid;
-	int32_t fileid;
-	DBTYPE ftype;
-	db_pgno_t meta_pgno;
-	u_int32_t id;
-{
-	DBT logrec;
-	DB_LSN *lsnp, null_lsn;
-	u_int32_t zero;
-	u_int32_t uinttmp;
-	u_int32_t npad, rectype, txn_num;
-	int ret;
-	u_int8_t *bp;
-
-	rectype = DB___dbreg_register;
-	npad = 0;
-
-	if (txnid == NULL) {
-		txn_num = 0;
-		null_lsn.file = 0;
-		null_lsn.offset = 0;
-		lsnp = &null_lsn;
-	} else {
-		if (TAILQ_FIRST(&txnid->kids) != NULL &&
-		    (ret = __txn_activekids(dbenv, rectype, txnid)) != 0)
-			return (ret);
-		txn_num = txnid->txnid;
-		lsnp = &txnid->last_lsn;
-	}
-
-	logrec.size = sizeof(rectype) + sizeof(txn_num) + sizeof(DB_LSN)
-	    + sizeof(u_int32_t)
-	    + sizeof(u_int32_t) + (name == NULL ? 0 : name->size)
-	    + sizeof(u_int32_t) + (uid == NULL ? 0 : uid->size)
-	    + sizeof(u_int32_t)
-	    + sizeof(u_int32_t)
-	    + sizeof(u_int32_t)
-	    + sizeof(u_int32_t);
-	if (CRYPTO_ON(dbenv)) {
-		npad =
-		    ((DB_CIPHER *)dbenv->crypto_handle)->adj_size(logrec.size);
-		logrec.size += npad;
-	}
-
-	if ((ret = __os_malloc(dbenv,
-	    logrec.size, &logrec.data)) != 0)
-		return (ret);
-
-	if (npad > 0)
-		memset((u_int8_t *)logrec.data + logrec.size - npad, 0, npad);
-
-	bp = logrec.data;
-
-	memcpy(bp, &rectype, sizeof(rectype));
-	bp += sizeof(rectype);
-
-	memcpy(bp, &txn_num, sizeof(txn_num));
-	bp += sizeof(txn_num);
-
-	memcpy(bp, lsnp, sizeof(DB_LSN));
-	bp += sizeof(DB_LSN);
-
-	uinttmp = (u_int32_t)opcode;
-	memcpy(bp, &uinttmp, sizeof(uinttmp));
-	bp += sizeof(uinttmp);
-
-	if (name == NULL) {
-		zero = 0;
-		memcpy(bp, &zero, sizeof(u_int32_t));
-		bp += sizeof(u_int32_t);
-	} else {
-		memcpy(bp, &name->size, sizeof(name->size));
-		bp += sizeof(name->size);
-		memcpy(bp, name->data, name->size);
-		bp += name->size;
-	}
-
-	if (uid == NULL) {
-		zero = 0;
-		memcpy(bp, &zero, sizeof(u_int32_t));
-		bp += sizeof(u_int32_t);
-	} else {
-		memcpy(bp, &uid->size, sizeof(uid->size));
-		bp += sizeof(uid->size);
-		memcpy(bp, uid->data, uid->size);
-		bp += uid->size;
-	}
-
-	uinttmp = (u_int32_t)fileid;
-	memcpy(bp, &uinttmp, sizeof(uinttmp));
-	bp += sizeof(uinttmp);
-
-	uinttmp = (u_int32_t)ftype;
-	memcpy(bp, &uinttmp, sizeof(uinttmp));
-	bp += sizeof(uinttmp);
-
-	uinttmp = (u_int32_t)meta_pgno;
-	memcpy(bp, &uinttmp, sizeof(uinttmp));
-	bp += sizeof(uinttmp);
-
-	uinttmp = (u_int32_t)id;
-	memcpy(bp, &uinttmp, sizeof(uinttmp));
-	bp += sizeof(uinttmp);
-
-	DB_ASSERT((u_int32_t)(bp - (u_int8_t *)logrec.data) <= logrec.size);
-	ret = dbenv->log_put(dbenv,
-	   ret_lsnp, (DBT *)&logrec, flags | DB_NOCOPY);
-	if (txnid != NULL && ret == 0)
-		txnid->last_lsn = *ret_lsnp;
-#ifdef LOG_DIAGNOSTIC
-	if (ret != 0)
-		(void)__dbreg_register_print(dbenv,
-		    (DBT *)&logrec, ret_lsnp, NULL, NULL);
-#endif
-	__os_free(dbenv, logrec.data);
-	return (ret);
-}
-
-/*
- * PUBLIC: int __dbreg_register_getpgnos __P((DB_ENV *, DBT *,
- * PUBLIC:     DB_LSN *, db_recops, void *));
- */
-int
-__dbreg_register_getpgnos(dbenv, rec, lsnp, notused1, summary)
-	DB_ENV *dbenv;
-	DBT *rec;
-	DB_LSN *lsnp;
-	db_recops notused1;
-	void *summary;
-{
-	TXN_RECS *t;
-	int ret;
-	COMPQUIET(rec, NULL);
-	COMPQUIET(notused1, DB_TXN_ABORT);
-
-	t = (TXN_RECS *)summary;
-
-	if ((ret = __rep_check_alloc(dbenv, t, 1)) != 0)
-		return (ret);
-
-	t->array[t->npages].flags = LSN_PAGE_NOLOCK;
-	t->array[t->npages].lsn = *lsnp;
-	t->array[t->npages].fid = DB_LOGFILEID_INVALID;
-	memset(&t->array[t->npages].pgdesc, 0,
-	    sizeof(t->array[t->npages].pgdesc));
-
-	t->npages++;
-
-	return (0);
-}
-
-/*
- * PUBLIC: int __dbreg_register_print __P((DB_ENV *, DBT *, DB_LSN *,
- * PUBLIC:     db_recops, void *));
- */
-int
-__dbreg_register_print(dbenv, dbtp, lsnp, notused2, notused3)
-	DB_ENV *dbenv;
-	DBT *dbtp;
-	DB_LSN *lsnp;
-	db_recops notused2;
-	void *notused3;
-{
-	__dbreg_register_args *argp;
-	u_int32_t i;
-	int ch;
-	int ret;
-
-	notused2 = DB_TXN_ABORT;
-	notused3 = NULL;
-
-	if ((ret = __dbreg_register_read(dbenv, dbtp->data, &argp)) != 0)
-		return (ret);
-	(void)printf(
-	    "[%lu][%lu]__dbreg_register: rec: %lu txnid %lx prevlsn [%lu][%lu]\n",
-	    (u_long)lsnp->file,
-	    (u_long)lsnp->offset,
-	    (u_long)argp->type,
-	    (u_long)argp->txnid->txnid,
-	    (u_long)argp->prev_lsn.file,
-	    (u_long)argp->prev_lsn.offset);
-	(void)printf("\topcode: %lu\n", (u_long)argp->opcode);
-	(void)printf("\tname: ");
-	for (i = 0; i < argp->name.size; i++) {
-		ch = ((u_int8_t *)argp->name.data)[i];
-		printf(isprint(ch) || ch == 0x0a ? "%c" : "%#x ", ch);
-	}
-	(void)printf("\n");
-	(void)printf("\tuid: ");
-	for (i = 0; i < argp->uid.size; i++) {
-		ch = ((u_int8_t *)argp->uid.data)[i];
-		printf(isprint(ch) || ch == 0x0a ? "%c" : "%#x ", ch);
-	}
-	(void)printf("\n");
-	(void)printf("\tfileid: %ld\n", (long)argp->fileid);
-	(void)printf("\tftype: 0x%lx\n", (u_long)argp->ftype);
-	(void)printf("\tmeta_pgno: %lu\n", (u_long)argp->meta_pgno);
-	(void)printf("\tid: 0x%lx\n", (u_long)argp->id);
-	(void)printf("\n");
-	__os_free(dbenv, argp);
-	return (0);
-}
-
-/*
- * PUBLIC: int __dbreg_register_read __P((DB_ENV *, void *,
- * PUBLIC:     __dbreg_register_args **));
- */
-int
-__dbreg_register_read(dbenv, recbuf, argpp)
-	DB_ENV *dbenv;
-	void *recbuf;
-	__dbreg_register_args **argpp;
-{
-	__dbreg_register_args *argp;
-	u_int32_t uinttmp;
-	u_int8_t *bp;
-	int ret;
-
-	if ((ret = __os_malloc(dbenv,
-	    sizeof(__dbreg_register_args) + sizeof(DB_TXN), &argp)) != 0)
-		return (ret);
-
-	argp->txnid = (DB_TXN *)&argp[1];
-
-	bp = recbuf;
-	memcpy(&argp->type, bp, sizeof(argp->type));
-	bp += sizeof(argp->type);
-
-	memcpy(&argp->txnid->txnid,  bp, sizeof(argp->txnid->txnid));
-	bp += sizeof(argp->txnid->txnid);
-
-	memcpy(&argp->prev_lsn, bp, sizeof(DB_LSN));
-	bp += sizeof(DB_LSN);
-
-	memcpy(&uinttmp, bp, sizeof(uinttmp));
-	argp->opcode = (u_int32_t)uinttmp;
-	bp += sizeof(uinttmp);
-
-	memset(&argp->name, 0, sizeof(argp->name));
-	memcpy(&argp->name.size, bp, sizeof(u_int32_t));
-	bp += sizeof(u_int32_t);
-	argp->name.data = bp;
-	bp += argp->name.size;
-
-	memset(&argp->uid, 0, sizeof(argp->uid));
-	memcpy(&argp->uid.size, bp, sizeof(u_int32_t));
-	bp += sizeof(u_int32_t);
-	argp->uid.data = bp;
-	bp += argp->uid.size;
-
-	memcpy(&uinttmp, bp, sizeof(uinttmp));
-	argp->fileid = (int32_t)uinttmp;
-	bp += sizeof(uinttmp);
-
-	memcpy(&uinttmp, bp, sizeof(uinttmp));
-	argp->ftype = (DBTYPE)uinttmp;
-	bp += sizeof(uinttmp);
-
-	memcpy(&uinttmp, bp, sizeof(uinttmp));
-	argp->meta_pgno = (db_pgno_t)uinttmp;
-	bp += sizeof(uinttmp);
-
-	memcpy(&uinttmp, bp, sizeof(uinttmp));
-	argp->id = (u_int32_t)uinttmp;
-	bp += sizeof(uinttmp);
-
-	*argpp = argp;
-	return (0);
-}
-
-/*
- * PUBLIC: int __dbreg_init_print __P((DB_ENV *, int (***)(DB_ENV *,
- * PUBLIC:     DBT *, DB_LSN *, db_recops, void *), size_t *));
- */
-int
-__dbreg_init_print(dbenv, dtabp, dtabsizep)
-	DB_ENV *dbenv;
-	int (***dtabp)__P((DB_ENV *, DBT *, DB_LSN *, db_recops, void *));
-	size_t *dtabsizep;
-{
-	int ret;
-
-	if ((ret = __db_add_recovery(dbenv, dtabp, dtabsizep,
-	    __dbreg_register_print, DB___dbreg_register)) != 0)
-		return (ret);
-	return (0);
-}
-
-/*
- * PUBLIC: int __dbreg_init_getpgnos __P((DB_ENV *,
- * PUBLIC:     int (***)(DB_ENV *, DBT *, DB_LSN *, db_recops, void *),
- * PUBLIC:     size_t *));
- */
-int
-__dbreg_init_getpgnos(dbenv, dtabp, dtabsizep)
-	DB_ENV *dbenv;
-	int (***dtabp)__P((DB_ENV *, DBT *, DB_LSN *, db_recops, void *));
-	size_t *dtabsizep;
-{
-	int ret;
-
-	if ((ret = __db_add_recovery(dbenv, dtabp, dtabsizep,
-	    __dbreg_register_getpgnos, DB___dbreg_register)) != 0)
-		return (ret);
-	return (0);
-}
-
-/*
- * PUBLIC: int __dbreg_init_recover __P((DB_ENV *, int (***)(DB_ENV *,
- * PUBLIC:     DBT *, DB_LSN *, db_recops, void *), size_t *));
- */
-int
-__dbreg_init_recover(dbenv, dtabp, dtabsizep)
-	DB_ENV *dbenv;
-	int (***dtabp)__P((DB_ENV *, DBT *, DB_LSN *, db_recops, void *));
-	size_t *dtabsizep;
-{
-	int ret;
-
-	if ((ret = __db_add_recovery(dbenv, dtabp, dtabsizep,
-	    __dbreg_register_recover, DB___dbreg_register)) != 0)
-		return (ret);
-	return (0);
-}
diff --git a/bdb/dist/RELEASE b/bdb/dist/RELEASE
index fe9b6667bbe213bf20c11a75e46527758d517e16..61151b8589c0953e7485b6a84d79a3e8fd0f5b92 100644
--- a/bdb/dist/RELEASE
+++ b/bdb/dist/RELEASE
@@ -9,3 +9,20 @@ DB_VERSION_UNIQUE_NAME=`printf "_%d%03d" $DB_VERSION_MAJOR $DB_VERSION_MINOR`
 
 DB_RELEASE_DATE=`date "+%B %e, %Y"`
 DB_VERSION_STRING="Sleepycat Software: Berkeley DB $DB_VERSION: ($DB_RELEASE_DATE)"
+
+# this file is included by all s_* scripts, so it's the way to apply
+# hacks :)
+
+# bitkeeper doesn't like somebody to mess with permissions!
+chmod()
+{
+  echo "chmod $1 $2" >/dev/null
+}
+
+# useful trick to find auto-generated files
+#cmp()
+#{
+#  echo "==>> CMP $1 $2" >/dev/tty
+#  /usr/bin/cmp "$1" "$2"
+#}
+
diff --git a/bdb/dist/s_all b/bdb/dist/s_all
index c0e3ac72f3a3703035427681b058c6bc0c55a45e..ee0041032d8cf7a996ad3a826c39c39d91e3bac1 100644
--- a/bdb/dist/s_all
+++ b/bdb/dist/s_all
@@ -1,7 +1,9 @@
 #!/bin/sh -
 #	$Id: s_all,v 1.10 2001/08/04 14:01:44 bostic Exp $
 
-sh s_perm		# permissions.
+sh s_dir
+
+#sh s_perm		# permissions.
 sh s_symlink		# symbolic links.
 sh s_readme		# db/README file.
 
@@ -15,7 +17,7 @@ sh s_include		# standard include files.
 
 sh s_win32		# Win32 include files.
 sh s_win32_dsp		# Win32 build environment.
-sh s_vxworks		# VxWorks include files.
-sh s_java		# Java support.
+#sh s_vxworks		# VxWorks include files.
+#sh s_java		# Java support.
 sh s_test		# Test suite support.
-sh s_tags		# Tags files.
+#sh s_tags		# Tags files.
diff --git a/bdb/dist/s_crypto b/bdb/dist/s_crypto
index be7e5de047448ef3f5e47397722d1432d6c8c669..f7947cb3e1045d6d8bc02f5206ef52085ae348e5 100644
--- a/bdb/dist/s_crypto
+++ b/bdb/dist/s_crypto
@@ -3,6 +3,8 @@
 
 # Remove crypto from the DB source tree.
 
+. ./RELEASE
+
 d=..
 
 t=/tmp/__db_a
diff --git a/bdb/dist/s_dir b/bdb/dist/s_dir
new file mode 100644
index 0000000000000000000000000000000000000000..58513a8321de3a5dcf2c63dc34fb2b1a0d0f8b11
--- /dev/null
+++ b/bdb/dist/s_dir
@@ -0,0 +1,42 @@
+#!/bin/sh -
+
+make_dir()
+{
+  if test ! -d $1; then
+    echo  "mkdir $1"
+    mkdir $1
+    status=$?
+    if test $status -ne 0 && test ! -d $1; then
+      echo "error: $status"
+    fi
+  fi
+}
+
+echo "Creating directories..."
+
+make_dir ../test_server
+make_dir ../dbinc_auto
+make_dir ../build_vxworks/BerkeleyDB
+make_dir ../build_vxworks/db_archive
+make_dir ../build_vxworks/db_archive/db_archive
+make_dir ../build_vxworks/db_checkpoint
+make_dir ../build_vxworks/db_checkpoint/db_checkpoint
+make_dir ../build_vxworks/db_deadlock
+make_dir ../build_vxworks/db_deadlock/db_deadlock
+make_dir ../build_vxworks/db_dump
+make_dir ../build_vxworks/db_dump/db_dump
+make_dir ../build_vxworks/db_load
+make_dir ../build_vxworks/db_load/db_load
+make_dir ../build_vxworks/db_printlog
+make_dir ../build_vxworks/db_printlog/db_printlog
+make_dir ../build_vxworks/db_recover
+make_dir ../build_vxworks/db_recover/db_recover
+make_dir ../build_vxworks/db_stat
+make_dir ../build_vxworks/db_stat/db_stat
+make_dir ../build_vxworks/db_upgrade
+make_dir ../build_vxworks/db_upgrade/db_upgrade
+make_dir ../build_vxworks/db_verify
+make_dir ../build_vxworks/db_verify/db_verify
+make_dir ../build_vxworks/dbdemo/dbdemo
+make_dir ../dbinc_auto
+
diff --git a/bdb/dist/s_java b/bdb/dist/s_java
index 2a65da60a738ae2787d673c2a2cd6ec6618b5d7a..f3c856d05327ce1bb73e10fb223e691741127ed7 100755
--- a/bdb/dist/s_java
+++ b/bdb/dist/s_java
@@ -38,7 +38,7 @@ cmp $t $f > /dev/null 2>&1 ||
     (echo "Building $f" && rm -f $f && cp $t $f && chmod 444 $f)
 
 # Build Db.java.
-f=../java/src/com/sleepycat/db/Db.java
+f=../java/src/com/sleepycat/db/Db.java.in
 sed '/BEGIN-JAVA-SPECIAL-CONSTANTS/q' < $f > $t
 (echo "    $msgjava" &&
  for i in `egrep '^DB_.*C$' pubdef.in | awk '{print $1}'`; do \
diff --git a/bdb/dist/s_perm b/bdb/dist/s_perm
index 03cc4a35a8a6a7a00371d32cbbc2ac36c5541f44..c35278b8c8388ede9ed5f1eaebec9ac64c64c0a1 100755
--- a/bdb/dist/s_perm
+++ b/bdb/dist/s_perm
@@ -4,6 +4,8 @@
 d=..
 echo 'Updating Berkeley DB source tree permissions...'
 
+. ./RELEASE
+
 run()
 {
 	echo "	$1 ($2)"
diff --git a/bdb/dist/s_recover b/bdb/dist/s_recover
index 331ae623d3fcc1c96be42a1a83bddad24f355815..869b5bfd363207c8c8d89264f97738de291318a2 100755
--- a/bdb/dist/s_recover
+++ b/bdb/dist/s_recover
@@ -3,6 +3,8 @@
 #
 # Build the automatically generated logging/recovery files.
 
+. ./RELEASE
+
 tmp=/tmp/__db_a
 loglist=/tmp/__db_b
 source=/tmp/__db_c
diff --git a/bdb/dist/s_rpc b/bdb/dist/s_rpc
index 302930068ca26a899a21ab84f6b9337b5cdba777..cdafa669d85b2e29abb5446c5395e02b20be1a9d 100644
--- a/bdb/dist/s_rpc
+++ b/bdb/dist/s_rpc
@@ -25,14 +25,12 @@ server_file=../rpc_server/c/gen_db_server.c
 stmpl_file=./template/db_server_proc
 xdr_file=../rpc_server/db_server.x
 
-#
-# NOTE: We do NOT want to remove proc_file.  It is what we apply $sed_file
-# to, but we do not want to remove it, it does not get built in place.
 rm -f   $client_file \
 	$ctmpl_file \
 	$header_file \
 	$rpcclnt_file \
 	$rpcsvc_file \
+	$proc_file \
 	$rpcxdr_file \
 	$sed_file \
 	$server_file \
@@ -92,8 +90,7 @@ ENDOFSEDTEXT
 sed -f $t $rpcsvc_file > ${rpcsvc_file}.new
 mv ${rpcsvc_file}.new $rpcsvc_file
 
-sed -f $sed_file $proc_file > ${proc_file}.new
-mv ${proc_file}.new $proc_file
+sed -f $sed_file ${proc_file}.in > ${proc_file}
 
 # Run rpcgen files through sed to add HAVE_RPC ifdef and appropriate
 # includes.
diff --git a/bdb/dist/s_symlink b/bdb/dist/s_symlink
index e69bb57dc46d1049e07911d6b722a572e40eb838..ee80a220a830d0c2e22ea63e99682c27e52794ee 100755
--- a/bdb/dist/s_symlink
+++ b/bdb/dist/s_symlink
@@ -2,6 +2,7 @@
 #	$Id: s_symlink,v 1.28 2002/08/18 21:15:45 bostic Exp $
 
 echo 'Creating Berkeley DB source tree symbolic links...'
+. ./RELEASE
 
 build()
 {
diff --git a/bdb/dist/s_tags b/bdb/dist/s_tags
index d50378964436af865599c2971ce7a968d294ac1c..18b6025aa862f6b7e162767b9566c1fe756d26cc 100755
--- a/bdb/dist/s_tags
+++ b/bdb/dist/s_tags
@@ -3,6 +3,8 @@
 #
 # Build tags files.
 
+. ./RELEASE
+
 files="../dbinc/*.h \
 	../dbinc/*.in \
 	../btree/*.[ch] \
diff --git a/bdb/dist/template/rec_dbreg b/bdb/dist/template/rec_dbreg
deleted file mode 100644
index bbdf19d5ffcd4996e8877e2c79f5b6fee7224e14..0000000000000000000000000000000000000000
--- a/bdb/dist/template/rec_dbreg
+++ /dev/null
@@ -1,75 +0,0 @@
-#include "db_config.h"
-
-#ifndef NO_SYSTEM_INCLUDES
-#include <sys/types.h>
-
-#include <string.h>
-#endif
-
-#include "db_int.h"
-#include "dbinc/db_page.h"
-#include "dbinc/__dbreg.h"
-#include "dbinc/log.h"
-
-/*
- * __dbreg_register_recover --
- *	Recovery function for register.
- *
- * PUBLIC: int __dbreg_register_recover
- * PUBLIC:   __P((DB_ENV *, DBT *, DB_LSN *, db_recops, void *));
- */
-int
-__dbreg_register_recover(dbenv, dbtp, lsnp, op, info)
-	DB_ENV *dbenv;
-	DBT *dbtp;
-	DB_LSN *lsnp;
-	db_recops op;
-	void *info;
-{
-	__dbreg_register_args *argp;
-	DB *file_dbp;
-	DBC *dbc;
-	DB_MPOOLFILE *mpf;
-	PAGE *pagep;
-	int cmp_n, cmp_p, modified, ret;
-
-	REC_PRINT(__dbreg_register_print);
-	REC_INTRO(__dbreg_register_read, 1);
-
-	if ((ret = mpf->get(mpf, &argp->pgno, 0, &pagep)) != 0)
-		if (DB_REDO(op)) {
-			if ((ret = mpf->get(mpf,
-			    &argp->pgno, DB_MPOOL_CREATE, &pagep)) != 0)
-				goto out;
-		} else {
-			*lsnp = argp->prev_lsn;
-			ret = 0;
-			goto out;
-		}
-
-	modified = 0;
-	cmp_n = log_compare(lsnp, &LSN(pagep));
-
-	/*
-	 * Use this when there is something like "pagelsn" in the argp
-	 * structure.  Sometimes, you might need to compare meta-data
-	 * lsn's instead.
-	 *
-	 * cmp_p = log_compare(&LSN(pagep), argp->pagelsn);
-	 */
-	if (cmp_p == 0 && DB_REDO(op)) {
-		/* Need to redo update described. */
-		modified = 1;
-	} else if (cmp_n == 0 && !DB_REDO(op)) {
-		/* Need to undo update described. */
-		modified = 1;
-	}
-	if (ret = mpf->put(mpf, pagep, modified ? DB_MPOOL_DIRTY : 0))
-		goto out;
-
-	*lsnp = argp->prev_lsn;
-	ret = 0;
-
-out:	REC_CLOSE;
-}
-
diff --git a/bdb/dist/template/rec_fileops b/bdb/dist/template/rec_fileops
deleted file mode 100644
index c1487835ea9c9377e4bca3865c4038caed1ae193..0000000000000000000000000000000000000000
--- a/bdb/dist/template/rec_fileops
+++ /dev/null
@@ -1,323 +0,0 @@
-#include "db_config.h"
-
-#ifndef NO_SYSTEM_INCLUDES
-#include <sys/types.h>
-
-#include <string.h>
-#endif
-
-#include "db_int.h"
-#include "dbinc/db_page.h"
-#include "dbinc/__fop.h"
-#include "dbinc/log.h"
-
-/*
- * __fop_create_recover --
- *	Recovery function for create.
- *
- * PUBLIC: int __fop_create_recover
- * PUBLIC:   __P((DB_ENV *, DBT *, DB_LSN *, db_recops, void *));
- */
-int
-__fop_create_recover(dbenv, dbtp, lsnp, op, info)
-	DB_ENV *dbenv;
-	DBT *dbtp;
-	DB_LSN *lsnp;
-	db_recops op;
-	void *info;
-{
-	__fop_create_args *argp;
-	DB *file_dbp;
-	DBC *dbc;
-	DB_MPOOLFILE *mpf;
-	PAGE *pagep;
-	int cmp_n, cmp_p, modified, ret;
-
-	REC_PRINT(__fop_create_print);
-	REC_INTRO(__fop_create_read, 1);
-
-	if ((ret = mpf->get(mpf, &argp->pgno, 0, &pagep)) != 0)
-		if (DB_REDO(op)) {
-			if ((ret = mpf->get(mpf,
-			    &argp->pgno, DB_MPOOL_CREATE, &pagep)) != 0)
-				goto out;
-		} else {
-			*lsnp = argp->prev_lsn;
-			ret = 0;
-			goto out;
-		}
-
-	modified = 0;
-	cmp_n = log_compare(lsnp, &LSN(pagep));
-
-	/*
-	 * Use this when there is something like "pagelsn" in the argp
-	 * structure.  Sometimes, you might need to compare meta-data
-	 * lsn's instead.
-	 *
-	 * cmp_p = log_compare(&LSN(pagep), argp->pagelsn);
-	 */
-	if (cmp_p == 0 && DB_REDO(op)) {
-		/* Need to redo update described. */
-		modified = 1;
-	} else if (cmp_n == 0 && !DB_REDO(op)) {
-		/* Need to undo update described. */
-		modified = 1;
-	}
-	if (ret = mpf->put(mpf, pagep, modified ? DB_MPOOL_DIRTY : 0))
-		goto out;
-
-	*lsnp = argp->prev_lsn;
-	ret = 0;
-
-out:	REC_CLOSE;
-}
-
-/*
- * __fop_remove_recover --
- *	Recovery function for remove.
- *
- * PUBLIC: int __fop_remove_recover
- * PUBLIC:   __P((DB_ENV *, DBT *, DB_LSN *, db_recops, void *));
- */
-int
-__fop_remove_recover(dbenv, dbtp, lsnp, op, info)
-	DB_ENV *dbenv;
-	DBT *dbtp;
-	DB_LSN *lsnp;
-	db_recops op;
-	void *info;
-{
-	__fop_remove_args *argp;
-	DB *file_dbp;
-	DBC *dbc;
-	DB_MPOOLFILE *mpf;
-	PAGE *pagep;
-	int cmp_n, cmp_p, modified, ret;
-
-	REC_PRINT(__fop_remove_print);
-	REC_INTRO(__fop_remove_read, 1);
-
-	if ((ret = mpf->get(mpf, &argp->pgno, 0, &pagep)) != 0)
-		if (DB_REDO(op)) {
-			if ((ret = mpf->get(mpf,
-			    &argp->pgno, DB_MPOOL_CREATE, &pagep)) != 0)
-				goto out;
-		} else {
-			*lsnp = argp->prev_lsn;
-			ret = 0;
-			goto out;
-		}
-
-	modified = 0;
-	cmp_n = log_compare(lsnp, &LSN(pagep));
-
-	/*
-	 * Use this when there is something like "pagelsn" in the argp
-	 * structure.  Sometimes, you might need to compare meta-data
-	 * lsn's instead.
-	 *
-	 * cmp_p = log_compare(&LSN(pagep), argp->pagelsn);
-	 */
-	if (cmp_p == 0 && DB_REDO(op)) {
-		/* Need to redo update described. */
-		modified = 1;
-	} else if (cmp_n == 0 && !DB_REDO(op)) {
-		/* Need to undo update described. */
-		modified = 1;
-	}
-	if (ret = mpf->put(mpf, pagep, modified ? DB_MPOOL_DIRTY : 0))
-		goto out;
-
-	*lsnp = argp->prev_lsn;
-	ret = 0;
-
-out:	REC_CLOSE;
-}
-
-/*
- * __fop_write_recover --
- *	Recovery function for write.
- *
- * PUBLIC: int __fop_write_recover
- * PUBLIC:   __P((DB_ENV *, DBT *, DB_LSN *, db_recops, void *));
- */
-int
-__fop_write_recover(dbenv, dbtp, lsnp, op, info)
-	DB_ENV *dbenv;
-	DBT *dbtp;
-	DB_LSN *lsnp;
-	db_recops op;
-	void *info;
-{
-	__fop_write_args *argp;
-	DB *file_dbp;
-	DBC *dbc;
-	DB_MPOOLFILE *mpf;
-	PAGE *pagep;
-	int cmp_n, cmp_p, modified, ret;
-
-	REC_PRINT(__fop_write_print);
-	REC_INTRO(__fop_write_read, 1);
-
-	if ((ret = mpf->get(mpf, &argp->pgno, 0, &pagep)) != 0)
-		if (DB_REDO(op)) {
-			if ((ret = mpf->get(mpf,
-			    &argp->pgno, DB_MPOOL_CREATE, &pagep)) != 0)
-				goto out;
-		} else {
-			*lsnp = argp->prev_lsn;
-			ret = 0;
-			goto out;
-		}
-
-	modified = 0;
-	cmp_n = log_compare(lsnp, &LSN(pagep));
-
-	/*
-	 * Use this when there is something like "pagelsn" in the argp
-	 * structure.  Sometimes, you might need to compare meta-data
-	 * lsn's instead.
-	 *
-	 * cmp_p = log_compare(&LSN(pagep), argp->pagelsn);
-	 */
-	if (cmp_p == 0 && DB_REDO(op)) {
-		/* Need to redo update described. */
-		modified = 1;
-	} else if (cmp_n == 0 && !DB_REDO(op)) {
-		/* Need to undo update described. */
-		modified = 1;
-	}
-	if (ret = mpf->put(mpf, pagep, modified ? DB_MPOOL_DIRTY : 0))
-		goto out;
-
-	*lsnp = argp->prev_lsn;
-	ret = 0;
-
-out:	REC_CLOSE;
-}
-
-/*
- * __fop_rename_recover --
- *	Recovery function for rename.
- *
- * PUBLIC: int __fop_rename_recover
- * PUBLIC:   __P((DB_ENV *, DBT *, DB_LSN *, db_recops, void *));
- */
-int
-__fop_rename_recover(dbenv, dbtp, lsnp, op, info)
-	DB_ENV *dbenv;
-	DBT *dbtp;
-	DB_LSN *lsnp;
-	db_recops op;
-	void *info;
-{
-	__fop_rename_args *argp;
-	DB *file_dbp;
-	DBC *dbc;
-	DB_MPOOLFILE *mpf;
-	PAGE *pagep;
-	int cmp_n, cmp_p, modified, ret;
-
-	REC_PRINT(__fop_rename_print);
-	REC_INTRO(__fop_rename_read, 1);
-
-	if ((ret = mpf->get(mpf, &argp->pgno, 0, &pagep)) != 0)
-		if (DB_REDO(op)) {
-			if ((ret = mpf->get(mpf,
-			    &argp->pgno, DB_MPOOL_CREATE, &pagep)) != 0)
-				goto out;
-		} else {
-			*lsnp = argp->prev_lsn;
-			ret = 0;
-			goto out;
-		}
-
-	modified = 0;
-	cmp_n = log_compare(lsnp, &LSN(pagep));
-
-	/*
-	 * Use this when there is something like "pagelsn" in the argp
-	 * structure.  Sometimes, you might need to compare meta-data
-	 * lsn's instead.
-	 *
-	 * cmp_p = log_compare(&LSN(pagep), argp->pagelsn);
-	 */
-	if (cmp_p == 0 && DB_REDO(op)) {
-		/* Need to redo update described. */
-		modified = 1;
-	} else if (cmp_n == 0 && !DB_REDO(op)) {
-		/* Need to undo update described. */
-		modified = 1;
-	}
-	if (ret = mpf->put(mpf, pagep, modified ? DB_MPOOL_DIRTY : 0))
-		goto out;
-
-	*lsnp = argp->prev_lsn;
-	ret = 0;
-
-out:	REC_CLOSE;
-}
-
-/*
- * __fop_file_remove_recover --
- *	Recovery function for file_remove.
- *
- * PUBLIC: int __fop_file_remove_recover
- * PUBLIC:   __P((DB_ENV *, DBT *, DB_LSN *, db_recops, void *));
- */
-int
-__fop_file_remove_recover(dbenv, dbtp, lsnp, op, info)
-	DB_ENV *dbenv;
-	DBT *dbtp;
-	DB_LSN *lsnp;
-	db_recops op;
-	void *info;
-{
-	__fop_file_remove_args *argp;
-	DB *file_dbp;
-	DBC *dbc;
-	DB_MPOOLFILE *mpf;
-	PAGE *pagep;
-	int cmp_n, cmp_p, modified, ret;
-
-	REC_PRINT(__fop_file_remove_print);
-	REC_INTRO(__fop_file_remove_read, 1);
-
-	if ((ret = mpf->get(mpf, &argp->pgno, 0, &pagep)) != 0)
-		if (DB_REDO(op)) {
-			if ((ret = mpf->get(mpf,
-			    &argp->pgno, DB_MPOOL_CREATE, &pagep)) != 0)
-				goto out;
-		} else {
-			*lsnp = argp->prev_lsn;
-			ret = 0;
-			goto out;
-		}
-
-	modified = 0;
-	cmp_n = log_compare(lsnp, &LSN(pagep));
-
-	/*
-	 * Use this when there is something like "pagelsn" in the argp
-	 * structure.  Sometimes, you might need to compare meta-data
-	 * lsn's instead.
-	 *
-	 * cmp_p = log_compare(&LSN(pagep), argp->pagelsn);
-	 */
-	if (cmp_p == 0 && DB_REDO(op)) {
-		/* Need to redo update described. */
-		modified = 1;
-	} else if (cmp_n == 0 && !DB_REDO(op)) {
-		/* Need to undo update described. */
-		modified = 1;
-	}
-	if (ret = mpf->put(mpf, pagep, modified ? DB_MPOOL_DIRTY : 0))
-		goto out;
-
-	*lsnp = argp->prev_lsn;
-	ret = 0;
-
-out:	REC_CLOSE;
-}
-
diff --git a/bdb/examples_c/ex_apprec/ex_apprec_auto.c b/bdb/examples_c/ex_apprec/ex_apprec_auto.c
deleted file mode 100644
index d8c27e762c76aa89ef99e478c501b691ab3fef98..0000000000000000000000000000000000000000
--- a/bdb/examples_c/ex_apprec/ex_apprec_auto.c
+++ /dev/null
@@ -1,188 +0,0 @@
-/* Do not edit: automatically built by gen_rec.awk. */
-#include <ctype.h>
-#include <errno.h>
-#include <stdlib.h>
-#include <string.h>
-
-#include <db.h>
-
-#include "ex_apprec.h"
-/*
- * PUBLIC: int ex_apprec_mkdir_log __P((DB_ENV *, DB_TXN *, DB_LSN *,
- * PUBLIC:     u_int32_t, const DBT *));
- */
-int
-ex_apprec_mkdir_log(dbenv, txnid, ret_lsnp, flags,
-    dirname)
-	DB_ENV *dbenv;
-	DB_TXN *txnid;
-	DB_LSN *ret_lsnp;
-	u_int32_t flags;
-	const DBT *dirname;
-{
-	DBT logrec;
-	DB_LSN *lsnp, null_lsn;
-	u_int32_t zero;
-	u_int32_t npad, rectype, txn_num;
-	int ret;
-	u_int8_t *bp;
-
-	rectype = DB_ex_apprec_mkdir;
-	npad = 0;
-
-	if (txnid == NULL) {
-		txn_num = 0;
-		null_lsn.file = 0;
-		null_lsn.offset = 0;
-		lsnp = &null_lsn;
-	} else {
-		txn_num = txnid->txnid;
-		lsnp = &txnid->last_lsn;
-	}
-
-	logrec.size = sizeof(rectype) + sizeof(txn_num) + sizeof(DB_LSN)
-	    + sizeof(u_int32_t) + (dirname == NULL ? 0 : dirname->size);
-	if ((logrec.data = malloc(logrec.size)) == NULL)
-		return (ENOMEM);
-
-	if (npad > 0)
-		memset((u_int8_t *)logrec.data + logrec.size - npad, 0, npad);
-
-	bp = logrec.data;
-
-	memcpy(bp, &rectype, sizeof(rectype));
-	bp += sizeof(rectype);
-
-	memcpy(bp, &txn_num, sizeof(txn_num));
-	bp += sizeof(txn_num);
-
-	memcpy(bp, lsnp, sizeof(DB_LSN));
-	bp += sizeof(DB_LSN);
-
-	if (dirname == NULL) {
-		zero = 0;
-		memcpy(bp, &zero, sizeof(u_int32_t));
-		bp += sizeof(u_int32_t);
-	} else {
-		memcpy(bp, &dirname->size, sizeof(dirname->size));
-		bp += sizeof(dirname->size);
-		memcpy(bp, dirname->data, dirname->size);
-		bp += dirname->size;
-	}
-
-	ret = dbenv->log_put(dbenv,
-	   ret_lsnp, (DBT *)&logrec, flags);
-	if (txnid != NULL && ret == 0)
-		txnid->last_lsn = *ret_lsnp;
-#ifdef LOG_DIAGNOSTIC
-	if (ret != 0)
-		(void)ex_apprec_mkdir_print(dbenv,
-		    (DBT *)&logrec, ret_lsnp, NULL, NULL);
-#endif
-	free(logrec.data);
-	return (ret);
-}
-
-/*
- * PUBLIC: int ex_apprec_mkdir_print __P((DB_ENV *, DBT *, DB_LSN *,
- * PUBLIC:     db_recops, void *));
- */
-int
-ex_apprec_mkdir_print(dbenv, dbtp, lsnp, notused2, notused3)
-	DB_ENV *dbenv;
-	DBT *dbtp;
-	DB_LSN *lsnp;
-	db_recops notused2;
-	void *notused3;
-{
-	ex_apprec_mkdir_args *argp;
-	u_int32_t i;
-	int ch;
-	int ret;
-
-	notused2 = DB_TXN_ABORT;
-	notused3 = NULL;
-
-	if ((ret = ex_apprec_mkdir_read(dbenv, dbtp->data, &argp)) != 0)
-		return (ret);
-	(void)printf(
-	    "[%lu][%lu]ex_apprec_mkdir: rec: %lu txnid %lx prevlsn [%lu][%lu]\n",
-	    (u_long)lsnp->file,
-	    (u_long)lsnp->offset,
-	    (u_long)argp->type,
-	    (u_long)argp->txnid->txnid,
-	    (u_long)argp->prev_lsn.file,
-	    (u_long)argp->prev_lsn.offset);
-	(void)printf("\tdirname: ");
-	for (i = 0; i < argp->dirname.size; i++) {
-		ch = ((u_int8_t *)argp->dirname.data)[i];
-		printf(isprint(ch) || ch == 0x0a ? "%c" : "%#x ", ch);
-	}
-	(void)printf("\n");
-	(void)printf("\n");
-	free(argp);
-	return (0);
-}
-
-/*
- * PUBLIC: int ex_apprec_mkdir_read __P((DB_ENV *, void *,
- * PUBLIC:     ex_apprec_mkdir_args **));
- */
-int
-ex_apprec_mkdir_read(dbenv, recbuf, argpp)
-	DB_ENV *dbenv;
-	void *recbuf;
-	ex_apprec_mkdir_args **argpp;
-{
-	ex_apprec_mkdir_args *argp;
-	u_int8_t *bp;
-	/* Keep the compiler quiet. */
-
-	dbenv = NULL;
-	if ((argp = malloc(sizeof(ex_apprec_mkdir_args) + sizeof(DB_TXN))) == NULL)
-		return (ENOMEM);
-
-	argp->txnid = (DB_TXN *)&argp[1];
-
-	bp = recbuf;
-	memcpy(&argp->type, bp, sizeof(argp->type));
-	bp += sizeof(argp->type);
-
-	memcpy(&argp->txnid->txnid,  bp, sizeof(argp->txnid->txnid));
-	bp += sizeof(argp->txnid->txnid);
-
-	memcpy(&argp->prev_lsn, bp, sizeof(DB_LSN));
-	bp += sizeof(DB_LSN);
-
-	memset(&argp->dirname, 0, sizeof(argp->dirname));
-	memcpy(&argp->dirname.size, bp, sizeof(u_int32_t));
-	bp += sizeof(u_int32_t);
-	argp->dirname.data = bp;
-	bp += argp->dirname.size;
-
-	*argpp = argp;
-	return (0);
-}
-
-/*
- * PUBLIC: int ex_apprec_init_print __P((DB_ENV *, int (***)(DB_ENV *,
- * PUBLIC:     DBT *, DB_LSN *, db_recops, void *), size_t *));
- */
-int
-ex_apprec_init_print(dbenv, dtabp, dtabsizep)
-	DB_ENV *dbenv;
-	int (***dtabp)__P((DB_ENV *, DBT *, DB_LSN *, db_recops, void *));
-	size_t *dtabsizep;
-{
-	int __db_add_recovery __P((DB_ENV *,
-	    int (***)(DB_ENV *, DBT *, DB_LSN *, db_recops, void *),
-	    size_t *,
-	    int (*)(DB_ENV *, DBT *, DB_LSN *, db_recops, void *), u_int32_t));
-	int ret;
-
-	if ((ret = __db_add_recovery(dbenv, dtabp, dtabsizep,
-	    ex_apprec_mkdir_print, DB_ex_apprec_mkdir)) != 0)
-		return (ret);
-	return (0);
-}
-
diff --git a/bdb/examples_c/ex_apprec/ex_apprec_auto.h b/bdb/examples_c/ex_apprec/ex_apprec_auto.h
deleted file mode 100644
index 358b1a9f0918b24bf3a7413898f1832febedb793..0000000000000000000000000000000000000000
--- a/bdb/examples_c/ex_apprec/ex_apprec_auto.h
+++ /dev/null
@@ -1,13 +0,0 @@
-/* Do not edit: automatically built by gen_rec.awk. */
-
-#ifndef	ex_apprec_AUTO_H
-#define	ex_apprec_AUTO_H
-#define	DB_ex_apprec_mkdir	10000
-typedef struct _ex_apprec_mkdir_args {
-	u_int32_t type;
-	DB_TXN *txnid;
-	DB_LSN prev_lsn;
-	DBT	dirname;
-} ex_apprec_mkdir_args;
-
-#endif
diff --git a/bdb/examples_c/ex_apprec/ex_apprec_template b/bdb/examples_c/ex_apprec/ex_apprec_template
deleted file mode 100644
index e67ccb6d8c3e9fe2c64b5c7b37dfa8eec8696f4f..0000000000000000000000000000000000000000
--- a/bdb/examples_c/ex_apprec/ex_apprec_template
+++ /dev/null
@@ -1,75 +0,0 @@
-#include "db_config.h"
-
-#ifndef NO_SYSTEM_INCLUDES
-#include <sys/types.h>
-
-#include <string.h>
-#endif
-
-#include "db_int.h"
-#include "dbinc/db_page.h"
-#include "dbinc/ex_apprec.h"
-#include "dbinc/log.h"
-
-/*
- * ex_apprec_mkdir_recover --
- *	Recovery function for mkdir.
- *
- * PUBLIC: int ex_apprec_mkdir_recover
- * PUBLIC:   __P((DB_ENV *, DBT *, DB_LSN *, db_recops, void *));
- */
-int
-ex_apprec_mkdir_recover(dbenv, dbtp, lsnp, op, info)
-	DB_ENV *dbenv;
-	DBT *dbtp;
-	DB_LSN *lsnp;
-	db_recops op;
-	void *info;
-{
-	ex_apprec_mkdir_args *argp;
-	DB *file_dbp;
-	DBC *dbc;
-	DB_MPOOLFILE *mpf;
-	PAGE *pagep;
-	int cmp_n, cmp_p, modified, ret;
-
-	REC_PRINT(ex_apprec_mkdir_print);
-	REC_INTRO(ex_apprec_mkdir_read, 1);
-
-	if ((ret = mpf->get(mpf, &argp->pgno, 0, &pagep)) != 0)
-		if (DB_REDO(op)) {
-			if ((ret = mpf->get(mpf,
-			    &argp->pgno, DB_MPOOL_CREATE, &pagep)) != 0)
-				goto out;
-		} else {
-			*lsnp = argp->prev_lsn;
-			ret = 0;
-			goto out;
-		}
-
-	modified = 0;
-	cmp_n = log_compare(lsnp, &LSN(pagep));
-
-	/*
-	 * Use this when there is something like "pagelsn" in the argp
-	 * structure.  Sometimes, you might need to compare meta-data
-	 * lsn's instead.
-	 *
-	 * cmp_p = log_compare(&LSN(pagep), argp->pagelsn);
-	 */
-	if (cmp_p == 0 && DB_REDO(op)) {
-		/* Need to redo update described. */
-		modified = 1;
-	} else if (cmp_n == 0 && !DB_REDO(op)) {
-		/* Need to undo update described. */
-		modified = 1;
-	}
-	if (ret = mpf->put(mpf, pagep, modified ? DB_MPOOL_DIRTY : 0))
-		goto out;
-
-	*lsnp = argp->prev_lsn;
-	ret = 0;
-
-out:	REC_CLOSE;
-}
-
diff --git a/bdb/fileops/fileops_auto.c b/bdb/fileops/fileops_auto.c
deleted file mode 100644
index f38640b7480ff5526ec3f3b50ae2d7624701905f..0000000000000000000000000000000000000000
--- a/bdb/fileops/fileops_auto.c
+++ /dev/null
@@ -1,1371 +0,0 @@
-/* Do not edit: automatically built by gen_rec.awk. */
-#include "db_config.h"
-
-#ifndef NO_SYSTEM_INCLUDES
-#include <sys/types.h>
-
-#include <ctype.h>
-#include <string.h>
-#endif
-
-#include "db_int.h"
-#include "dbinc/crypto.h"
-#include "dbinc/db_page.h"
-#include "dbinc/db_dispatch.h"
-#include "dbinc/db_am.h"
-#include "dbinc/log.h"
-#include "dbinc/rep.h"
-#include "dbinc/txn.h"
-#include "dbinc/fop.h"
-
-/*
- * PUBLIC: int __fop_create_log __P((DB_ENV *, DB_TXN *, DB_LSN *,
- * PUBLIC:     u_int32_t, const DBT *, u_int32_t, u_int32_t));
- */
-int
-__fop_create_log(dbenv, txnid, ret_lsnp, flags,
-    name, appname, mode)
-	DB_ENV *dbenv;
-	DB_TXN *txnid;
-	DB_LSN *ret_lsnp;
-	u_int32_t flags;
-	const DBT *name;
-	u_int32_t appname;
-	u_int32_t mode;
-{
-	DBT logrec;
-	DB_LSN *lsnp, null_lsn;
-	u_int32_t zero;
-	u_int32_t uinttmp;
-	u_int32_t npad, rectype, txn_num;
-	int ret;
-	u_int8_t *bp;
-
-	rectype = DB___fop_create;
-	npad = 0;
-
-	if (txnid == NULL) {
-		txn_num = 0;
-		null_lsn.file = 0;
-		null_lsn.offset = 0;
-		lsnp = &null_lsn;
-	} else {
-		if (TAILQ_FIRST(&txnid->kids) != NULL &&
-		    (ret = __txn_activekids(dbenv, rectype, txnid)) != 0)
-			return (ret);
-		txn_num = txnid->txnid;
-		lsnp = &txnid->last_lsn;
-	}
-
-	logrec.size = sizeof(rectype) + sizeof(txn_num) + sizeof(DB_LSN)
-	    + sizeof(u_int32_t) + (name == NULL ? 0 : name->size)
-	    + sizeof(u_int32_t)
-	    + sizeof(u_int32_t);
-	if (CRYPTO_ON(dbenv)) {
-		npad =
-		    ((DB_CIPHER *)dbenv->crypto_handle)->adj_size(logrec.size);
-		logrec.size += npad;
-	}
-
-	if ((ret = __os_malloc(dbenv,
-	    logrec.size, &logrec.data)) != 0)
-		return (ret);
-
-	if (npad > 0)
-		memset((u_int8_t *)logrec.data + logrec.size - npad, 0, npad);
-
-	bp = logrec.data;
-
-	memcpy(bp, &rectype, sizeof(rectype));
-	bp += sizeof(rectype);
-
-	memcpy(bp, &txn_num, sizeof(txn_num));
-	bp += sizeof(txn_num);
-
-	memcpy(bp, lsnp, sizeof(DB_LSN));
-	bp += sizeof(DB_LSN);
-
-	if (name == NULL) {
-		zero = 0;
-		memcpy(bp, &zero, sizeof(u_int32_t));
-		bp += sizeof(u_int32_t);
-	} else {
-		memcpy(bp, &name->size, sizeof(name->size));
-		bp += sizeof(name->size);
-		memcpy(bp, name->data, name->size);
-		bp += name->size;
-	}
-
-	uinttmp = (u_int32_t)appname;
-	memcpy(bp, &uinttmp, sizeof(uinttmp));
-	bp += sizeof(uinttmp);
-
-	uinttmp = (u_int32_t)mode;
-	memcpy(bp, &uinttmp, sizeof(uinttmp));
-	bp += sizeof(uinttmp);
-
-	DB_ASSERT((u_int32_t)(bp - (u_int8_t *)logrec.data) <= logrec.size);
-	ret = dbenv->log_put(dbenv,
-	   ret_lsnp, (DBT *)&logrec, flags | DB_NOCOPY);
-	if (txnid != NULL && ret == 0)
-		txnid->last_lsn = *ret_lsnp;
-#ifdef LOG_DIAGNOSTIC
-	if (ret != 0)
-		(void)__fop_create_print(dbenv,
-		    (DBT *)&logrec, ret_lsnp, NULL, NULL);
-#endif
-	__os_free(dbenv, logrec.data);
-	return (ret);
-}
-
-/*
- * PUBLIC: int __fop_create_getpgnos __P((DB_ENV *, DBT *, DB_LSN *,
- * PUBLIC:     db_recops, void *));
- */
-int
-__fop_create_getpgnos(dbenv, rec, lsnp, notused1, summary)
-	DB_ENV *dbenv;
-	DBT *rec;
-	DB_LSN *lsnp;
-	db_recops notused1;
-	void *summary;
-{
-	TXN_RECS *t;
-	int ret;
-	COMPQUIET(rec, NULL);
-	COMPQUIET(notused1, DB_TXN_ABORT);
-
-	t = (TXN_RECS *)summary;
-
-	if ((ret = __rep_check_alloc(dbenv, t, 1)) != 0)
-		return (ret);
-
-	t->array[t->npages].flags = LSN_PAGE_NOLOCK;
-	t->array[t->npages].lsn = *lsnp;
-	t->array[t->npages].fid = DB_LOGFILEID_INVALID;
-	memset(&t->array[t->npages].pgdesc, 0,
-	    sizeof(t->array[t->npages].pgdesc));
-
-	t->npages++;
-
-	return (0);
-}
-
-/*
- * PUBLIC: int __fop_create_print __P((DB_ENV *, DBT *, DB_LSN *,
- * PUBLIC:     db_recops, void *));
- */
-int
-__fop_create_print(dbenv, dbtp, lsnp, notused2, notused3)
-	DB_ENV *dbenv;
-	DBT *dbtp;
-	DB_LSN *lsnp;
-	db_recops notused2;
-	void *notused3;
-{
-	__fop_create_args *argp;
-	u_int32_t i;
-	int ch;
-	int ret;
-
-	notused2 = DB_TXN_ABORT;
-	notused3 = NULL;
-
-	if ((ret = __fop_create_read(dbenv, dbtp->data, &argp)) != 0)
-		return (ret);
-	(void)printf(
-	    "[%lu][%lu]__fop_create: rec: %lu txnid %lx prevlsn [%lu][%lu]\n",
-	    (u_long)lsnp->file,
-	    (u_long)lsnp->offset,
-	    (u_long)argp->type,
-	    (u_long)argp->txnid->txnid,
-	    (u_long)argp->prev_lsn.file,
-	    (u_long)argp->prev_lsn.offset);
-	(void)printf("\tname: ");
-	for (i = 0; i < argp->name.size; i++) {
-		ch = ((u_int8_t *)argp->name.data)[i];
-		printf(isprint(ch) || ch == 0x0a ? "%c" : "%#x ", ch);
-	}
-	(void)printf("\n");
-	(void)printf("\tappname: %lu\n", (u_long)argp->appname);
-	(void)printf("\tmode: %o\n", argp->mode);
-	(void)printf("\n");
-	__os_free(dbenv, argp);
-	return (0);
-}
-
-/*
- * PUBLIC: int __fop_create_read __P((DB_ENV *, void *, __fop_create_args **));
- */
-int
-__fop_create_read(dbenv, recbuf, argpp)
-	DB_ENV *dbenv;
-	void *recbuf;
-	__fop_create_args **argpp;
-{
-	__fop_create_args *argp;
-	u_int32_t uinttmp;
-	u_int8_t *bp;
-	int ret;
-
-	if ((ret = __os_malloc(dbenv,
-	    sizeof(__fop_create_args) + sizeof(DB_TXN), &argp)) != 0)
-		return (ret);
-
-	argp->txnid = (DB_TXN *)&argp[1];
-
-	bp = recbuf;
-	memcpy(&argp->type, bp, sizeof(argp->type));
-	bp += sizeof(argp->type);
-
-	memcpy(&argp->txnid->txnid,  bp, sizeof(argp->txnid->txnid));
-	bp += sizeof(argp->txnid->txnid);
-
-	memcpy(&argp->prev_lsn, bp, sizeof(DB_LSN));
-	bp += sizeof(DB_LSN);
-
-	memset(&argp->name, 0, sizeof(argp->name));
-	memcpy(&argp->name.size, bp, sizeof(u_int32_t));
-	bp += sizeof(u_int32_t);
-	argp->name.data = bp;
-	bp += argp->name.size;
-
-	memcpy(&uinttmp, bp, sizeof(uinttmp));
-	argp->appname = (u_int32_t)uinttmp;
-	bp += sizeof(uinttmp);
-
-	memcpy(&uinttmp, bp, sizeof(uinttmp));
-	argp->mode = (u_int32_t)uinttmp;
-	bp += sizeof(uinttmp);
-
-	*argpp = argp;
-	return (0);
-}
-
-/*
- * PUBLIC: int __fop_remove_log __P((DB_ENV *, DB_TXN *, DB_LSN *,
- * PUBLIC:     u_int32_t, const DBT *, const DBT *, u_int32_t));
- */
-int
-__fop_remove_log(dbenv, txnid, ret_lsnp, flags,
-    name, fid, appname)
-	DB_ENV *dbenv;
-	DB_TXN *txnid;
-	DB_LSN *ret_lsnp;
-	u_int32_t flags;
-	const DBT *name;
-	const DBT *fid;
-	u_int32_t appname;
-{
-	DBT logrec;
-	DB_LSN *lsnp, null_lsn;
-	u_int32_t zero;
-	u_int32_t uinttmp;
-	u_int32_t npad, rectype, txn_num;
-	int ret;
-	u_int8_t *bp;
-
-	rectype = DB___fop_remove;
-	npad = 0;
-
-	if (txnid == NULL) {
-		txn_num = 0;
-		null_lsn.file = 0;
-		null_lsn.offset = 0;
-		lsnp = &null_lsn;
-	} else {
-		if (TAILQ_FIRST(&txnid->kids) != NULL &&
-		    (ret = __txn_activekids(dbenv, rectype, txnid)) != 0)
-			return (ret);
-		txn_num = txnid->txnid;
-		lsnp = &txnid->last_lsn;
-	}
-
-	logrec.size = sizeof(rectype) + sizeof(txn_num) + sizeof(DB_LSN)
-	    + sizeof(u_int32_t) + (name == NULL ? 0 : name->size)
-	    + sizeof(u_int32_t) + (fid == NULL ? 0 : fid->size)
-	    + sizeof(u_int32_t);
-	if (CRYPTO_ON(dbenv)) {
-		npad =
-		    ((DB_CIPHER *)dbenv->crypto_handle)->adj_size(logrec.size);
-		logrec.size += npad;
-	}
-
-	if ((ret = __os_malloc(dbenv,
-	    logrec.size, &logrec.data)) != 0)
-		return (ret);
-
-	if (npad > 0)
-		memset((u_int8_t *)logrec.data + logrec.size - npad, 0, npad);
-
-	bp = logrec.data;
-
-	memcpy(bp, &rectype, sizeof(rectype));
-	bp += sizeof(rectype);
-
-	memcpy(bp, &txn_num, sizeof(txn_num));
-	bp += sizeof(txn_num);
-
-	memcpy(bp, lsnp, sizeof(DB_LSN));
-	bp += sizeof(DB_LSN);
-
-	if (name == NULL) {
-		zero = 0;
-		memcpy(bp, &zero, sizeof(u_int32_t));
-		bp += sizeof(u_int32_t);
-	} else {
-		memcpy(bp, &name->size, sizeof(name->size));
-		bp += sizeof(name->size);
-		memcpy(bp, name->data, name->size);
-		bp += name->size;
-	}
-
-	if (fid == NULL) {
-		zero = 0;
-		memcpy(bp, &zero, sizeof(u_int32_t));
-		bp += sizeof(u_int32_t);
-	} else {
-		memcpy(bp, &fid->size, sizeof(fid->size));
-		bp += sizeof(fid->size);
-		memcpy(bp, fid->data, fid->size);
-		bp += fid->size;
-	}
-
-	uinttmp = (u_int32_t)appname;
-	memcpy(bp, &uinttmp, sizeof(uinttmp));
-	bp += sizeof(uinttmp);
-
-	DB_ASSERT((u_int32_t)(bp - (u_int8_t *)logrec.data) <= logrec.size);
-	ret = dbenv->log_put(dbenv,
-	   ret_lsnp, (DBT *)&logrec, flags | DB_NOCOPY);
-	if (txnid != NULL && ret == 0)
-		txnid->last_lsn = *ret_lsnp;
-#ifdef LOG_DIAGNOSTIC
-	if (ret != 0)
-		(void)__fop_remove_print(dbenv,
-		    (DBT *)&logrec, ret_lsnp, NULL, NULL);
-#endif
-	__os_free(dbenv, logrec.data);
-	return (ret);
-}
-
-/*
- * PUBLIC: int __fop_remove_getpgnos __P((DB_ENV *, DBT *, DB_LSN *,
- * PUBLIC:     db_recops, void *));
- */
-int
-__fop_remove_getpgnos(dbenv, rec, lsnp, notused1, summary)
-	DB_ENV *dbenv;
-	DBT *rec;
-	DB_LSN *lsnp;
-	db_recops notused1;
-	void *summary;
-{
-	TXN_RECS *t;
-	int ret;
-	COMPQUIET(rec, NULL);
-	COMPQUIET(notused1, DB_TXN_ABORT);
-
-	t = (TXN_RECS *)summary;
-
-	if ((ret = __rep_check_alloc(dbenv, t, 1)) != 0)
-		return (ret);
-
-	t->array[t->npages].flags = LSN_PAGE_NOLOCK;
-	t->array[t->npages].lsn = *lsnp;
-	t->array[t->npages].fid = DB_LOGFILEID_INVALID;
-	memset(&t->array[t->npages].pgdesc, 0,
-	    sizeof(t->array[t->npages].pgdesc));
-
-	t->npages++;
-
-	return (0);
-}
-
-/*
- * PUBLIC: int __fop_remove_print __P((DB_ENV *, DBT *, DB_LSN *,
- * PUBLIC:     db_recops, void *));
- */
-int
-__fop_remove_print(dbenv, dbtp, lsnp, notused2, notused3)
-	DB_ENV *dbenv;
-	DBT *dbtp;
-	DB_LSN *lsnp;
-	db_recops notused2;
-	void *notused3;
-{
-	__fop_remove_args *argp;
-	u_int32_t i;
-	int ch;
-	int ret;
-
-	notused2 = DB_TXN_ABORT;
-	notused3 = NULL;
-
-	if ((ret = __fop_remove_read(dbenv, dbtp->data, &argp)) != 0)
-		return (ret);
-	(void)printf(
-	    "[%lu][%lu]__fop_remove: rec: %lu txnid %lx prevlsn [%lu][%lu]\n",
-	    (u_long)lsnp->file,
-	    (u_long)lsnp->offset,
-	    (u_long)argp->type,
-	    (u_long)argp->txnid->txnid,
-	    (u_long)argp->prev_lsn.file,
-	    (u_long)argp->prev_lsn.offset);
-	(void)printf("\tname: ");
-	for (i = 0; i < argp->name.size; i++) {
-		ch = ((u_int8_t *)argp->name.data)[i];
-		printf(isprint(ch) || ch == 0x0a ? "%c" : "%#x ", ch);
-	}
-	(void)printf("\n");
-	(void)printf("\tfid: ");
-	for (i = 0; i < argp->fid.size; i++) {
-		ch = ((u_int8_t *)argp->fid.data)[i];
-		printf(isprint(ch) || ch == 0x0a ? "%c" : "%#x ", ch);
-	}
-	(void)printf("\n");
-	(void)printf("\tappname: %lu\n", (u_long)argp->appname);
-	(void)printf("\n");
-	__os_free(dbenv, argp);
-	return (0);
-}
-
-/*
- * PUBLIC: int __fop_remove_read __P((DB_ENV *, void *, __fop_remove_args **));
- */
-int
-__fop_remove_read(dbenv, recbuf, argpp)
-	DB_ENV *dbenv;
-	void *recbuf;
-	__fop_remove_args **argpp;
-{
-	__fop_remove_args *argp;
-	u_int32_t uinttmp;
-	u_int8_t *bp;
-	int ret;
-
-	if ((ret = __os_malloc(dbenv,
-	    sizeof(__fop_remove_args) + sizeof(DB_TXN), &argp)) != 0)
-		return (ret);
-
-	argp->txnid = (DB_TXN *)&argp[1];
-
-	bp = recbuf;
-	memcpy(&argp->type, bp, sizeof(argp->type));
-	bp += sizeof(argp->type);
-
-	memcpy(&argp->txnid->txnid,  bp, sizeof(argp->txnid->txnid));
-	bp += sizeof(argp->txnid->txnid);
-
-	memcpy(&argp->prev_lsn, bp, sizeof(DB_LSN));
-	bp += sizeof(DB_LSN);
-
-	memset(&argp->name, 0, sizeof(argp->name));
-	memcpy(&argp->name.size, bp, sizeof(u_int32_t));
-	bp += sizeof(u_int32_t);
-	argp->name.data = bp;
-	bp += argp->name.size;
-
-	memset(&argp->fid, 0, sizeof(argp->fid));
-	memcpy(&argp->fid.size, bp, sizeof(u_int32_t));
-	bp += sizeof(u_int32_t);
-	argp->fid.data = bp;
-	bp += argp->fid.size;
-
-	memcpy(&uinttmp, bp, sizeof(uinttmp));
-	argp->appname = (u_int32_t)uinttmp;
-	bp += sizeof(uinttmp);
-
-	*argpp = argp;
-	return (0);
-}
-
-/*
- * PUBLIC: int __fop_write_log __P((DB_ENV *, DB_TXN *, DB_LSN *,
- * PUBLIC:     u_int32_t, const DBT *, u_int32_t, u_int32_t, const DBT *,
- * PUBLIC:     u_int32_t));
- */
-int
-__fop_write_log(dbenv, txnid, ret_lsnp, flags,
-    name, appname, offset, page, flag)
-	DB_ENV *dbenv;
-	DB_TXN *txnid;
-	DB_LSN *ret_lsnp;
-	u_int32_t flags;
-	const DBT *name;
-	u_int32_t appname;
-	u_int32_t offset;
-	const DBT *page;
-	u_int32_t flag;
-{
-	DBT logrec;
-	DB_LSN *lsnp, null_lsn;
-	u_int32_t zero;
-	u_int32_t uinttmp;
-	u_int32_t npad, rectype, txn_num;
-	int ret;
-	u_int8_t *bp;
-
-	rectype = DB___fop_write;
-	npad = 0;
-
-	if (txnid == NULL) {
-		txn_num = 0;
-		null_lsn.file = 0;
-		null_lsn.offset = 0;
-		lsnp = &null_lsn;
-	} else {
-		if (TAILQ_FIRST(&txnid->kids) != NULL &&
-		    (ret = __txn_activekids(dbenv, rectype, txnid)) != 0)
-			return (ret);
-		txn_num = txnid->txnid;
-		lsnp = &txnid->last_lsn;
-	}
-
-	logrec.size = sizeof(rectype) + sizeof(txn_num) + sizeof(DB_LSN)
-	    + sizeof(u_int32_t) + (name == NULL ? 0 : name->size)
-	    + sizeof(u_int32_t)
-	    + sizeof(u_int32_t)
-	    + sizeof(u_int32_t) + (page == NULL ? 0 : page->size)
-	    + sizeof(u_int32_t);
-	if (CRYPTO_ON(dbenv)) {
-		npad =
-		    ((DB_CIPHER *)dbenv->crypto_handle)->adj_size(logrec.size);
-		logrec.size += npad;
-	}
-
-	if ((ret = __os_malloc(dbenv,
-	    logrec.size, &logrec.data)) != 0)
-		return (ret);
-
-	if (npad > 0)
-		memset((u_int8_t *)logrec.data + logrec.size - npad, 0, npad);
-
-	bp = logrec.data;
-
-	memcpy(bp, &rectype, sizeof(rectype));
-	bp += sizeof(rectype);
-
-	memcpy(bp, &txn_num, sizeof(txn_num));
-	bp += sizeof(txn_num);
-
-	memcpy(bp, lsnp, sizeof(DB_LSN));
-	bp += sizeof(DB_LSN);
-
-	if (name == NULL) {
-		zero = 0;
-		memcpy(bp, &zero, sizeof(u_int32_t));
-		bp += sizeof(u_int32_t);
-	} else {
-		memcpy(bp, &name->size, sizeof(name->size));
-		bp += sizeof(name->size);
-		memcpy(bp, name->data, name->size);
-		bp += name->size;
-	}
-
-	uinttmp = (u_int32_t)appname;
-	memcpy(bp, &uinttmp, sizeof(uinttmp));
-	bp += sizeof(uinttmp);
-
-	uinttmp = (u_int32_t)offset;
-	memcpy(bp, &uinttmp, sizeof(uinttmp));
-	bp += sizeof(uinttmp);
-
-	if (page == NULL) {
-		zero = 0;
-		memcpy(bp, &zero, sizeof(u_int32_t));
-		bp += sizeof(u_int32_t);
-	} else {
-		memcpy(bp, &page->size, sizeof(page->size));
-		bp += sizeof(page->size);
-		memcpy(bp, page->data, page->size);
-		bp += page->size;
-	}
-
-	uinttmp = (u_int32_t)flag;
-	memcpy(bp, &uinttmp, sizeof(uinttmp));
-	bp += sizeof(uinttmp);
-
-	DB_ASSERT((u_int32_t)(bp - (u_int8_t *)logrec.data) <= logrec.size);
-	ret = dbenv->log_put(dbenv,
-	   ret_lsnp, (DBT *)&logrec, flags | DB_NOCOPY);
-	if (txnid != NULL && ret == 0)
-		txnid->last_lsn = *ret_lsnp;
-#ifdef LOG_DIAGNOSTIC
-	if (ret != 0)
-		(void)__fop_write_print(dbenv,
-		    (DBT *)&logrec, ret_lsnp, NULL, NULL);
-#endif
-	__os_free(dbenv, logrec.data);
-	return (ret);
-}
-
-/*
- * PUBLIC: int __fop_write_getpgnos __P((DB_ENV *, DBT *, DB_LSN *,
- * PUBLIC:     db_recops, void *));
- */
-int
-__fop_write_getpgnos(dbenv, rec, lsnp, notused1, summary)
-	DB_ENV *dbenv;
-	DBT *rec;
-	DB_LSN *lsnp;
-	db_recops notused1;
-	void *summary;
-{
-	TXN_RECS *t;
-	int ret;
-	COMPQUIET(rec, NULL);
-	COMPQUIET(notused1, DB_TXN_ABORT);
-
-	t = (TXN_RECS *)summary;
-
-	if ((ret = __rep_check_alloc(dbenv, t, 1)) != 0)
-		return (ret);
-
-	t->array[t->npages].flags = LSN_PAGE_NOLOCK;
-	t->array[t->npages].lsn = *lsnp;
-	t->array[t->npages].fid = DB_LOGFILEID_INVALID;
-	memset(&t->array[t->npages].pgdesc, 0,
-	    sizeof(t->array[t->npages].pgdesc));
-
-	t->npages++;
-
-	return (0);
-}
-
-/*
- * PUBLIC: int __fop_write_print __P((DB_ENV *, DBT *, DB_LSN *,
- * PUBLIC:     db_recops, void *));
- */
-int
-__fop_write_print(dbenv, dbtp, lsnp, notused2, notused3)
-	DB_ENV *dbenv;
-	DBT *dbtp;
-	DB_LSN *lsnp;
-	db_recops notused2;
-	void *notused3;
-{
-	__fop_write_args *argp;
-	u_int32_t i;
-	int ch;
-	int ret;
-
-	notused2 = DB_TXN_ABORT;
-	notused3 = NULL;
-
-	if ((ret = __fop_write_read(dbenv, dbtp->data, &argp)) != 0)
-		return (ret);
-	(void)printf(
-	    "[%lu][%lu]__fop_write: rec: %lu txnid %lx prevlsn [%lu][%lu]\n",
-	    (u_long)lsnp->file,
-	    (u_long)lsnp->offset,
-	    (u_long)argp->type,
-	    (u_long)argp->txnid->txnid,
-	    (u_long)argp->prev_lsn.file,
-	    (u_long)argp->prev_lsn.offset);
-	(void)printf("\tname: ");
-	for (i = 0; i < argp->name.size; i++) {
-		ch = ((u_int8_t *)argp->name.data)[i];
-		printf(isprint(ch) || ch == 0x0a ? "%c" : "%#x ", ch);
-	}
-	(void)printf("\n");
-	(void)printf("\tappname: %lu\n", (u_long)argp->appname);
-	(void)printf("\toffset: %lu\n", (u_long)argp->offset);
-	(void)printf("\tpage: ");
-	for (i = 0; i < argp->page.size; i++) {
-		ch = ((u_int8_t *)argp->page.data)[i];
-		printf(isprint(ch) || ch == 0x0a ? "%c" : "%#x ", ch);
-	}
-	(void)printf("\n");
-	(void)printf("\tflag: %lu\n", (u_long)argp->flag);
-	(void)printf("\n");
-	__os_free(dbenv, argp);
-	return (0);
-}
-
-/*
- * PUBLIC: int __fop_write_read __P((DB_ENV *, void *, __fop_write_args **));
- */
-int
-__fop_write_read(dbenv, recbuf, argpp)
-	DB_ENV *dbenv;
-	void *recbuf;
-	__fop_write_args **argpp;
-{
-	__fop_write_args *argp;
-	u_int32_t uinttmp;
-	u_int8_t *bp;
-	int ret;
-
-	if ((ret = __os_malloc(dbenv,
-	    sizeof(__fop_write_args) + sizeof(DB_TXN), &argp)) != 0)
-		return (ret);
-
-	argp->txnid = (DB_TXN *)&argp[1];
-
-	bp = recbuf;
-	memcpy(&argp->type, bp, sizeof(argp->type));
-	bp += sizeof(argp->type);
-
-	memcpy(&argp->txnid->txnid,  bp, sizeof(argp->txnid->txnid));
-	bp += sizeof(argp->txnid->txnid);
-
-	memcpy(&argp->prev_lsn, bp, sizeof(DB_LSN));
-	bp += sizeof(DB_LSN);
-
-	memset(&argp->name, 0, sizeof(argp->name));
-	memcpy(&argp->name.size, bp, sizeof(u_int32_t));
-	bp += sizeof(u_int32_t);
-	argp->name.data = bp;
-	bp += argp->name.size;
-
-	memcpy(&uinttmp, bp, sizeof(uinttmp));
-	argp->appname = (u_int32_t)uinttmp;
-	bp += sizeof(uinttmp);
-
-	memcpy(&uinttmp, bp, sizeof(uinttmp));
-	argp->offset = (u_int32_t)uinttmp;
-	bp += sizeof(uinttmp);
-
-	memset(&argp->page, 0, sizeof(argp->page));
-	memcpy(&argp->page.size, bp, sizeof(u_int32_t));
-	bp += sizeof(u_int32_t);
-	argp->page.data = bp;
-	bp += argp->page.size;
-
-	memcpy(&uinttmp, bp, sizeof(uinttmp));
-	argp->flag = (u_int32_t)uinttmp;
-	bp += sizeof(uinttmp);
-
-	*argpp = argp;
-	return (0);
-}
-
-/*
- * PUBLIC: int __fop_rename_log __P((DB_ENV *, DB_TXN *, DB_LSN *,
- * PUBLIC:     u_int32_t, const DBT *, const DBT *, const DBT *, u_int32_t));
- */
-int
-__fop_rename_log(dbenv, txnid, ret_lsnp, flags,
-    oldname, newname, fileid, appname)
-	DB_ENV *dbenv;
-	DB_TXN *txnid;
-	DB_LSN *ret_lsnp;
-	u_int32_t flags;
-	const DBT *oldname;
-	const DBT *newname;
-	const DBT *fileid;
-	u_int32_t appname;
-{
-	DBT logrec;
-	DB_LSN *lsnp, null_lsn;
-	u_int32_t zero;
-	u_int32_t uinttmp;
-	u_int32_t npad, rectype, txn_num;
-	int ret;
-	u_int8_t *bp;
-
-	rectype = DB___fop_rename;
-	npad = 0;
-
-	if (txnid == NULL) {
-		txn_num = 0;
-		null_lsn.file = 0;
-		null_lsn.offset = 0;
-		lsnp = &null_lsn;
-	} else {
-		if (TAILQ_FIRST(&txnid->kids) != NULL &&
-		    (ret = __txn_activekids(dbenv, rectype, txnid)) != 0)
-			return (ret);
-		txn_num = txnid->txnid;
-		lsnp = &txnid->last_lsn;
-	}
-
-	logrec.size = sizeof(rectype) + sizeof(txn_num) + sizeof(DB_LSN)
-	    + sizeof(u_int32_t) + (oldname == NULL ? 0 : oldname->size)
-	    + sizeof(u_int32_t) + (newname == NULL ? 0 : newname->size)
-	    + sizeof(u_int32_t) + (fileid == NULL ? 0 : fileid->size)
-	    + sizeof(u_int32_t);
-	if (CRYPTO_ON(dbenv)) {
-		npad =
-		    ((DB_CIPHER *)dbenv->crypto_handle)->adj_size(logrec.size);
-		logrec.size += npad;
-	}
-
-	if ((ret = __os_malloc(dbenv,
-	    logrec.size, &logrec.data)) != 0)
-		return (ret);
-
-	if (npad > 0)
-		memset((u_int8_t *)logrec.data + logrec.size - npad, 0, npad);
-
-	bp = logrec.data;
-
-	memcpy(bp, &rectype, sizeof(rectype));
-	bp += sizeof(rectype);
-
-	memcpy(bp, &txn_num, sizeof(txn_num));
-	bp += sizeof(txn_num);
-
-	memcpy(bp, lsnp, sizeof(DB_LSN));
-	bp += sizeof(DB_LSN);
-
-	if (oldname == NULL) {
-		zero = 0;
-		memcpy(bp, &zero, sizeof(u_int32_t));
-		bp += sizeof(u_int32_t);
-	} else {
-		memcpy(bp, &oldname->size, sizeof(oldname->size));
-		bp += sizeof(oldname->size);
-		memcpy(bp, oldname->data, oldname->size);
-		bp += oldname->size;
-	}
-
-	if (newname == NULL) {
-		zero = 0;
-		memcpy(bp, &zero, sizeof(u_int32_t));
-		bp += sizeof(u_int32_t);
-	} else {
-		memcpy(bp, &newname->size, sizeof(newname->size));
-		bp += sizeof(newname->size);
-		memcpy(bp, newname->data, newname->size);
-		bp += newname->size;
-	}
-
-	if (fileid == NULL) {
-		zero = 0;
-		memcpy(bp, &zero, sizeof(u_int32_t));
-		bp += sizeof(u_int32_t);
-	} else {
-		memcpy(bp, &fileid->size, sizeof(fileid->size));
-		bp += sizeof(fileid->size);
-		memcpy(bp, fileid->data, fileid->size);
-		bp += fileid->size;
-	}
-
-	uinttmp = (u_int32_t)appname;
-	memcpy(bp, &uinttmp, sizeof(uinttmp));
-	bp += sizeof(uinttmp);
-
-	DB_ASSERT((u_int32_t)(bp - (u_int8_t *)logrec.data) <= logrec.size);
-	ret = dbenv->log_put(dbenv,
-	   ret_lsnp, (DBT *)&logrec, flags | DB_NOCOPY);
-	if (txnid != NULL && ret == 0)
-		txnid->last_lsn = *ret_lsnp;
-#ifdef LOG_DIAGNOSTIC
-	if (ret != 0)
-		(void)__fop_rename_print(dbenv,
-		    (DBT *)&logrec, ret_lsnp, NULL, NULL);
-#endif
-	__os_free(dbenv, logrec.data);
-	return (ret);
-}
-
-/*
- * PUBLIC: int __fop_rename_getpgnos __P((DB_ENV *, DBT *, DB_LSN *,
- * PUBLIC:     db_recops, void *));
- */
-int
-__fop_rename_getpgnos(dbenv, rec, lsnp, notused1, summary)
-	DB_ENV *dbenv;
-	DBT *rec;
-	DB_LSN *lsnp;
-	db_recops notused1;
-	void *summary;
-{
-	TXN_RECS *t;
-	int ret;
-	COMPQUIET(rec, NULL);
-	COMPQUIET(notused1, DB_TXN_ABORT);
-
-	t = (TXN_RECS *)summary;
-
-	if ((ret = __rep_check_alloc(dbenv, t, 1)) != 0)
-		return (ret);
-
-	t->array[t->npages].flags = LSN_PAGE_NOLOCK;
-	t->array[t->npages].lsn = *lsnp;
-	t->array[t->npages].fid = DB_LOGFILEID_INVALID;
-	memset(&t->array[t->npages].pgdesc, 0,
-	    sizeof(t->array[t->npages].pgdesc));
-
-	t->npages++;
-
-	return (0);
-}
-
-/*
- * PUBLIC: int __fop_rename_print __P((DB_ENV *, DBT *, DB_LSN *,
- * PUBLIC:     db_recops, void *));
- */
-int
-__fop_rename_print(dbenv, dbtp, lsnp, notused2, notused3)
-	DB_ENV *dbenv;
-	DBT *dbtp;
-	DB_LSN *lsnp;
-	db_recops notused2;
-	void *notused3;
-{
-	__fop_rename_args *argp;
-	u_int32_t i;
-	int ch;
-	int ret;
-
-	notused2 = DB_TXN_ABORT;
-	notused3 = NULL;
-
-	if ((ret = __fop_rename_read(dbenv, dbtp->data, &argp)) != 0)
-		return (ret);
-	(void)printf(
-	    "[%lu][%lu]__fop_rename: rec: %lu txnid %lx prevlsn [%lu][%lu]\n",
-	    (u_long)lsnp->file,
-	    (u_long)lsnp->offset,
-	    (u_long)argp->type,
-	    (u_long)argp->txnid->txnid,
-	    (u_long)argp->prev_lsn.file,
-	    (u_long)argp->prev_lsn.offset);
-	(void)printf("\toldname: ");
-	for (i = 0; i < argp->oldname.size; i++) {
-		ch = ((u_int8_t *)argp->oldname.data)[i];
-		printf(isprint(ch) || ch == 0x0a ? "%c" : "%#x ", ch);
-	}
-	(void)printf("\n");
-	(void)printf("\tnewname: ");
-	for (i = 0; i < argp->newname.size; i++) {
-		ch = ((u_int8_t *)argp->newname.data)[i];
-		printf(isprint(ch) || ch == 0x0a ? "%c" : "%#x ", ch);
-	}
-	(void)printf("\n");
-	(void)printf("\tfileid: ");
-	for (i = 0; i < argp->fileid.size; i++) {
-		ch = ((u_int8_t *)argp->fileid.data)[i];
-		printf(isprint(ch) || ch == 0x0a ? "%c" : "%#x ", ch);
-	}
-	(void)printf("\n");
-	(void)printf("\tappname: %lu\n", (u_long)argp->appname);
-	(void)printf("\n");
-	__os_free(dbenv, argp);
-	return (0);
-}
-
-/*
- * PUBLIC: int __fop_rename_read __P((DB_ENV *, void *, __fop_rename_args **));
- */
-int
-__fop_rename_read(dbenv, recbuf, argpp)
-	DB_ENV *dbenv;
-	void *recbuf;
-	__fop_rename_args **argpp;
-{
-	__fop_rename_args *argp;
-	u_int32_t uinttmp;
-	u_int8_t *bp;
-	int ret;
-
-	if ((ret = __os_malloc(dbenv,
-	    sizeof(__fop_rename_args) + sizeof(DB_TXN), &argp)) != 0)
-		return (ret);
-
-	argp->txnid = (DB_TXN *)&argp[1];
-
-	bp = recbuf;
-	memcpy(&argp->type, bp, sizeof(argp->type));
-	bp += sizeof(argp->type);
-
-	memcpy(&argp->txnid->txnid,  bp, sizeof(argp->txnid->txnid));
-	bp += sizeof(argp->txnid->txnid);
-
-	memcpy(&argp->prev_lsn, bp, sizeof(DB_LSN));
-	bp += sizeof(DB_LSN);
-
-	memset(&argp->oldname, 0, sizeof(argp->oldname));
-	memcpy(&argp->oldname.size, bp, sizeof(u_int32_t));
-	bp += sizeof(u_int32_t);
-	argp->oldname.data = bp;
-	bp += argp->oldname.size;
-
-	memset(&argp->newname, 0, sizeof(argp->newname));
-	memcpy(&argp->newname.size, bp, sizeof(u_int32_t));
-	bp += sizeof(u_int32_t);
-	argp->newname.data = bp;
-	bp += argp->newname.size;
-
-	memset(&argp->fileid, 0, sizeof(argp->fileid));
-	memcpy(&argp->fileid.size, bp, sizeof(u_int32_t));
-	bp += sizeof(u_int32_t);
-	argp->fileid.data = bp;
-	bp += argp->fileid.size;
-
-	memcpy(&uinttmp, bp, sizeof(uinttmp));
-	argp->appname = (u_int32_t)uinttmp;
-	bp += sizeof(uinttmp);
-
-	*argpp = argp;
-	return (0);
-}
-
-/*
- * PUBLIC: int __fop_file_remove_log __P((DB_ENV *, DB_TXN *,
- * PUBLIC:     DB_LSN *, u_int32_t, const DBT *, const DBT *, const DBT *,
- * PUBLIC:     u_int32_t, u_int32_t));
- */
-int
-__fop_file_remove_log(dbenv, txnid, ret_lsnp, flags,
-    real_fid, tmp_fid, name, appname, child)
-	DB_ENV *dbenv;
-	DB_TXN *txnid;
-	DB_LSN *ret_lsnp;
-	u_int32_t flags;
-	const DBT *real_fid;
-	const DBT *tmp_fid;
-	const DBT *name;
-	u_int32_t appname;
-	u_int32_t child;
-{
-	DBT logrec;
-	DB_LSN *lsnp, null_lsn;
-	u_int32_t zero;
-	u_int32_t uinttmp;
-	u_int32_t npad, rectype, txn_num;
-	int ret;
-	u_int8_t *bp;
-
-	rectype = DB___fop_file_remove;
-	npad = 0;
-
-	if (txnid == NULL) {
-		txn_num = 0;
-		null_lsn.file = 0;
-		null_lsn.offset = 0;
-		lsnp = &null_lsn;
-	} else {
-		if (TAILQ_FIRST(&txnid->kids) != NULL &&
-		    (ret = __txn_activekids(dbenv, rectype, txnid)) != 0)
-			return (ret);
-		txn_num = txnid->txnid;
-		lsnp = &txnid->last_lsn;
-	}
-
-	logrec.size = sizeof(rectype) + sizeof(txn_num) + sizeof(DB_LSN)
-	    + sizeof(u_int32_t) + (real_fid == NULL ? 0 : real_fid->size)
-	    + sizeof(u_int32_t) + (tmp_fid == NULL ? 0 : tmp_fid->size)
-	    + sizeof(u_int32_t) + (name == NULL ? 0 : name->size)
-	    + sizeof(u_int32_t)
-	    + sizeof(u_int32_t);
-	if (CRYPTO_ON(dbenv)) {
-		npad =
-		    ((DB_CIPHER *)dbenv->crypto_handle)->adj_size(logrec.size);
-		logrec.size += npad;
-	}
-
-	if ((ret = __os_malloc(dbenv,
-	    logrec.size, &logrec.data)) != 0)
-		return (ret);
-
-	if (npad > 0)
-		memset((u_int8_t *)logrec.data + logrec.size - npad, 0, npad);
-
-	bp = logrec.data;
-
-	memcpy(bp, &rectype, sizeof(rectype));
-	bp += sizeof(rectype);
-
-	memcpy(bp, &txn_num, sizeof(txn_num));
-	bp += sizeof(txn_num);
-
-	memcpy(bp, lsnp, sizeof(DB_LSN));
-	bp += sizeof(DB_LSN);
-
-	if (real_fid == NULL) {
-		zero = 0;
-		memcpy(bp, &zero, sizeof(u_int32_t));
-		bp += sizeof(u_int32_t);
-	} else {
-		memcpy(bp, &real_fid->size, sizeof(real_fid->size));
-		bp += sizeof(real_fid->size);
-		memcpy(bp, real_fid->data, real_fid->size);
-		bp += real_fid->size;
-	}
-
-	if (tmp_fid == NULL) {
-		zero = 0;
-		memcpy(bp, &zero, sizeof(u_int32_t));
-		bp += sizeof(u_int32_t);
-	} else {
-		memcpy(bp, &tmp_fid->size, sizeof(tmp_fid->size));
-		bp += sizeof(tmp_fid->size);
-		memcpy(bp, tmp_fid->data, tmp_fid->size);
-		bp += tmp_fid->size;
-	}
-
-	if (name == NULL) {
-		zero = 0;
-		memcpy(bp, &zero, sizeof(u_int32_t));
-		bp += sizeof(u_int32_t);
-	} else {
-		memcpy(bp, &name->size, sizeof(name->size));
-		bp += sizeof(name->size);
-		memcpy(bp, name->data, name->size);
-		bp += name->size;
-	}
-
-	uinttmp = (u_int32_t)appname;
-	memcpy(bp, &uinttmp, sizeof(uinttmp));
-	bp += sizeof(uinttmp);
-
-	uinttmp = (u_int32_t)child;
-	memcpy(bp, &uinttmp, sizeof(uinttmp));
-	bp += sizeof(uinttmp);
-
-	DB_ASSERT((u_int32_t)(bp - (u_int8_t *)logrec.data) <= logrec.size);
-	ret = dbenv->log_put(dbenv,
-	   ret_lsnp, (DBT *)&logrec, flags | DB_NOCOPY);
-	if (txnid != NULL && ret == 0)
-		txnid->last_lsn = *ret_lsnp;
-#ifdef LOG_DIAGNOSTIC
-	if (ret != 0)
-		(void)__fop_file_remove_print(dbenv,
-		    (DBT *)&logrec, ret_lsnp, NULL, NULL);
-#endif
-	__os_free(dbenv, logrec.data);
-	return (ret);
-}
-
-/*
- * PUBLIC: int __fop_file_remove_getpgnos __P((DB_ENV *, DBT *,
- * PUBLIC:     DB_LSN *, db_recops, void *));
- */
-int
-__fop_file_remove_getpgnos(dbenv, rec, lsnp, notused1, summary)
-	DB_ENV *dbenv;
-	DBT *rec;
-	DB_LSN *lsnp;
-	db_recops notused1;
-	void *summary;
-{
-	TXN_RECS *t;
-	int ret;
-	COMPQUIET(rec, NULL);
-	COMPQUIET(notused1, DB_TXN_ABORT);
-
-	t = (TXN_RECS *)summary;
-
-	if ((ret = __rep_check_alloc(dbenv, t, 1)) != 0)
-		return (ret);
-
-	t->array[t->npages].flags = LSN_PAGE_NOLOCK;
-	t->array[t->npages].lsn = *lsnp;
-	t->array[t->npages].fid = DB_LOGFILEID_INVALID;
-	memset(&t->array[t->npages].pgdesc, 0,
-	    sizeof(t->array[t->npages].pgdesc));
-
-	t->npages++;
-
-	return (0);
-}
-
-/*
- * PUBLIC: int __fop_file_remove_print __P((DB_ENV *, DBT *,
- * PUBLIC:     DB_LSN *, db_recops, void *));
- */
-int
-__fop_file_remove_print(dbenv, dbtp, lsnp, notused2, notused3)
-	DB_ENV *dbenv;
-	DBT *dbtp;
-	DB_LSN *lsnp;
-	db_recops notused2;
-	void *notused3;
-{
-	__fop_file_remove_args *argp;
-	u_int32_t i;
-	int ch;
-	int ret;
-
-	notused2 = DB_TXN_ABORT;
-	notused3 = NULL;
-
-	if ((ret = __fop_file_remove_read(dbenv, dbtp->data, &argp)) != 0)
-		return (ret);
-	(void)printf(
-	    "[%lu][%lu]__fop_file_remove: rec: %lu txnid %lx prevlsn [%lu][%lu]\n",
-	    (u_long)lsnp->file,
-	    (u_long)lsnp->offset,
-	    (u_long)argp->type,
-	    (u_long)argp->txnid->txnid,
-	    (u_long)argp->prev_lsn.file,
-	    (u_long)argp->prev_lsn.offset);
-	(void)printf("\treal_fid: ");
-	for (i = 0; i < argp->real_fid.size; i++) {
-		ch = ((u_int8_t *)argp->real_fid.data)[i];
-		printf(isprint(ch) || ch == 0x0a ? "%c" : "%#x ", ch);
-	}
-	(void)printf("\n");
-	(void)printf("\ttmp_fid: ");
-	for (i = 0; i < argp->tmp_fid.size; i++) {
-		ch = ((u_int8_t *)argp->tmp_fid.data)[i];
-		printf(isprint(ch) || ch == 0x0a ? "%c" : "%#x ", ch);
-	}
-	(void)printf("\n");
-	(void)printf("\tname: ");
-	for (i = 0; i < argp->name.size; i++) {
-		ch = ((u_int8_t *)argp->name.data)[i];
-		printf(isprint(ch) || ch == 0x0a ? "%c" : "%#x ", ch);
-	}
-	(void)printf("\n");
-	(void)printf("\tappname: %lu\n", (u_long)argp->appname);
-	(void)printf("\tchild: 0x%lx\n", (u_long)argp->child);
-	(void)printf("\n");
-	__os_free(dbenv, argp);
-	return (0);
-}
-
-/*
- * PUBLIC: int __fop_file_remove_read __P((DB_ENV *, void *,
- * PUBLIC:     __fop_file_remove_args **));
- */
-int
-__fop_file_remove_read(dbenv, recbuf, argpp)
-	DB_ENV *dbenv;
-	void *recbuf;
-	__fop_file_remove_args **argpp;
-{
-	__fop_file_remove_args *argp;
-	u_int32_t uinttmp;
-	u_int8_t *bp;
-	int ret;
-
-	if ((ret = __os_malloc(dbenv,
-	    sizeof(__fop_file_remove_args) + sizeof(DB_TXN), &argp)) != 0)
-		return (ret);
-
-	argp->txnid = (DB_TXN *)&argp[1];
-
-	bp = recbuf;
-	memcpy(&argp->type, bp, sizeof(argp->type));
-	bp += sizeof(argp->type);
-
-	memcpy(&argp->txnid->txnid,  bp, sizeof(argp->txnid->txnid));
-	bp += sizeof(argp->txnid->txnid);
-
-	memcpy(&argp->prev_lsn, bp, sizeof(DB_LSN));
-	bp += sizeof(DB_LSN);
-
-	memset(&argp->real_fid, 0, sizeof(argp->real_fid));
-	memcpy(&argp->real_fid.size, bp, sizeof(u_int32_t));
-	bp += sizeof(u_int32_t);
-	argp->real_fid.data = bp;
-	bp += argp->real_fid.size;
-
-	memset(&argp->tmp_fid, 0, sizeof(argp->tmp_fid));
-	memcpy(&argp->tmp_fid.size, bp, sizeof(u_int32_t));
-	bp += sizeof(u_int32_t);
-	argp->tmp_fid.data = bp;
-	bp += argp->tmp_fid.size;
-
-	memset(&argp->name, 0, sizeof(argp->name));
-	memcpy(&argp->name.size, bp, sizeof(u_int32_t));
-	bp += sizeof(u_int32_t);
-	argp->name.data = bp;
-	bp += argp->name.size;
-
-	memcpy(&uinttmp, bp, sizeof(uinttmp));
-	argp->appname = (u_int32_t)uinttmp;
-	bp += sizeof(uinttmp);
-
-	memcpy(&uinttmp, bp, sizeof(uinttmp));
-	argp->child = (u_int32_t)uinttmp;
-	bp += sizeof(uinttmp);
-
-	*argpp = argp;
-	return (0);
-}
-
-/*
- * PUBLIC: int __fop_init_print __P((DB_ENV *, int (***)(DB_ENV *,
- * PUBLIC:     DBT *, DB_LSN *, db_recops, void *), size_t *));
- */
-int
-__fop_init_print(dbenv, dtabp, dtabsizep)
-	DB_ENV *dbenv;
-	int (***dtabp)__P((DB_ENV *, DBT *, DB_LSN *, db_recops, void *));
-	size_t *dtabsizep;
-{
-	int ret;
-
-	if ((ret = __db_add_recovery(dbenv, dtabp, dtabsizep,
-	    __fop_create_print, DB___fop_create)) != 0)
-		return (ret);
-	if ((ret = __db_add_recovery(dbenv, dtabp, dtabsizep,
-	    __fop_remove_print, DB___fop_remove)) != 0)
-		return (ret);
-	if ((ret = __db_add_recovery(dbenv, dtabp, dtabsizep,
-	    __fop_write_print, DB___fop_write)) != 0)
-		return (ret);
-	if ((ret = __db_add_recovery(dbenv, dtabp, dtabsizep,
-	    __fop_rename_print, DB___fop_rename)) != 0)
-		return (ret);
-	if ((ret = __db_add_recovery(dbenv, dtabp, dtabsizep,
-	    __fop_file_remove_print, DB___fop_file_remove)) != 0)
-		return (ret);
-	return (0);
-}
-
-/*
- * PUBLIC: int __fop_init_getpgnos __P((DB_ENV *, int (***)(DB_ENV *,
- * PUBLIC:     DBT *, DB_LSN *, db_recops, void *), size_t *));
- */
-int
-__fop_init_getpgnos(dbenv, dtabp, dtabsizep)
-	DB_ENV *dbenv;
-	int (***dtabp)__P((DB_ENV *, DBT *, DB_LSN *, db_recops, void *));
-	size_t *dtabsizep;
-{
-	int ret;
-
-	if ((ret = __db_add_recovery(dbenv, dtabp, dtabsizep,
-	    __fop_create_getpgnos, DB___fop_create)) != 0)
-		return (ret);
-	if ((ret = __db_add_recovery(dbenv, dtabp, dtabsizep,
-	    __fop_remove_getpgnos, DB___fop_remove)) != 0)
-		return (ret);
-	if ((ret = __db_add_recovery(dbenv, dtabp, dtabsizep,
-	    __fop_write_getpgnos, DB___fop_write)) != 0)
-		return (ret);
-	if ((ret = __db_add_recovery(dbenv, dtabp, dtabsizep,
-	    __fop_rename_getpgnos, DB___fop_rename)) != 0)
-		return (ret);
-	if ((ret = __db_add_recovery(dbenv, dtabp, dtabsizep,
-	    __fop_file_remove_getpgnos, DB___fop_file_remove)) != 0)
-		return (ret);
-	return (0);
-}
-
-/*
- * PUBLIC: int __fop_init_recover __P((DB_ENV *, int (***)(DB_ENV *,
- * PUBLIC:     DBT *, DB_LSN *, db_recops, void *), size_t *));
- */
-int
-__fop_init_recover(dbenv, dtabp, dtabsizep)
-	DB_ENV *dbenv;
-	int (***dtabp)__P((DB_ENV *, DBT *, DB_LSN *, db_recops, void *));
-	size_t *dtabsizep;
-{
-	int ret;
-
-	if ((ret = __db_add_recovery(dbenv, dtabp, dtabsizep,
-	    __fop_create_recover, DB___fop_create)) != 0)
-		return (ret);
-	if ((ret = __db_add_recovery(dbenv, dtabp, dtabsizep,
-	    __fop_remove_recover, DB___fop_remove)) != 0)
-		return (ret);
-	if ((ret = __db_add_recovery(dbenv, dtabp, dtabsizep,
-	    __fop_write_recover, DB___fop_write)) != 0)
-		return (ret);
-	if ((ret = __db_add_recovery(dbenv, dtabp, dtabsizep,
-	    __fop_rename_recover, DB___fop_rename)) != 0)
-		return (ret);
-	if ((ret = __db_add_recovery(dbenv, dtabp, dtabsizep,
-	    __fop_file_remove_recover, DB___fop_file_remove)) != 0)
-		return (ret);
-	return (0);
-}
diff --git a/bdb/java/src/com/sleepycat/db/Db.java b/bdb/java/src/com/sleepycat/db/Db.java.in
similarity index 100%
rename from bdb/java/src/com/sleepycat/db/Db.java
rename to bdb/java/src/com/sleepycat/db/Db.java.in
diff --git a/bdb/java/src/com/sleepycat/db/DbBtreeStat.java b/bdb/java/src/com/sleepycat/db/DbBtreeStat.java
deleted file mode 100644
index 669afcffc8814542381efd6564d9ff156a3f39f5..0000000000000000000000000000000000000000
--- a/bdb/java/src/com/sleepycat/db/DbBtreeStat.java
+++ /dev/null
@@ -1,28 +0,0 @@
-/* DO NOT EDIT: automatically built by dist/s_java. */
-
-package com.sleepycat.db;
-
-public class DbBtreeStat
-{
-    public int bt_magic;
-    public int bt_version;
-    public int bt_metaflags;
-    public int bt_nkeys;
-    public int bt_ndata;
-    public int bt_pagesize;
-    public int bt_maxkey;
-    public int bt_minkey;
-    public int bt_re_len;
-    public int bt_re_pad;
-    public int bt_levels;
-    public int bt_int_pg;
-    public int bt_leaf_pg;
-    public int bt_dup_pg;
-    public int bt_over_pg;
-    public int bt_free;
-    public int bt_int_pgfree;
-    public int bt_leaf_pgfree;
-    public int bt_dup_pgfree;
-    public int bt_over_pgfree;
-}
-// end of DbBtreeStat.java
diff --git a/bdb/java/src/com/sleepycat/db/DbHashStat.java b/bdb/java/src/com/sleepycat/db/DbHashStat.java
deleted file mode 100644
index 97de6127af690c7a4da1f88df3802950e324fb9d..0000000000000000000000000000000000000000
--- a/bdb/java/src/com/sleepycat/db/DbHashStat.java
+++ /dev/null
@@ -1,24 +0,0 @@
-/* DO NOT EDIT: automatically built by dist/s_java. */
-
-package com.sleepycat.db;
-
-public class DbHashStat
-{
-    public int hash_magic;
-    public int hash_version;
-    public int hash_metaflags;
-    public int hash_nkeys;
-    public int hash_ndata;
-    public int hash_pagesize;
-    public int hash_ffactor;
-    public int hash_buckets;
-    public int hash_free;
-    public int hash_bfree;
-    public int hash_bigpages;
-    public int hash_big_bfree;
-    public int hash_overflows;
-    public int hash_ovfl_free;
-    public int hash_dup;
-    public int hash_dup_free;
-}
-// end of DbHashStat.java
diff --git a/bdb/java/src/com/sleepycat/db/DbLockStat.java b/bdb/java/src/com/sleepycat/db/DbLockStat.java
deleted file mode 100644
index f0903f061d2e965c22a1c3bfa2f039cb36077b8a..0000000000000000000000000000000000000000
--- a/bdb/java/src/com/sleepycat/db/DbLockStat.java
+++ /dev/null
@@ -1,32 +0,0 @@
-/* DO NOT EDIT: automatically built by dist/s_java. */
-
-package com.sleepycat.db;
-
-public class DbLockStat
-{
-    public int st_id;
-    public int st_cur_maxid;
-    public int st_maxlocks;
-    public int st_maxlockers;
-    public int st_maxobjects;
-    public int st_nmodes;
-    public int st_nlocks;
-    public int st_maxnlocks;
-    public int st_nlockers;
-    public int st_maxnlockers;
-    public int st_nobjects;
-    public int st_maxnobjects;
-    public int st_nconflicts;
-    public int st_nrequests;
-    public int st_nreleases;
-    public int st_nnowaits;
-    public int st_ndeadlocks;
-    public int st_locktimeout;
-    public int st_nlocktimeouts;
-    public int st_txntimeout;
-    public int st_ntxntimeouts;
-    public int st_region_wait;
-    public int st_region_nowait;
-    public int st_regsize;
-}
-// end of DbLockStat.java
diff --git a/bdb/java/src/com/sleepycat/db/DbLogStat.java b/bdb/java/src/com/sleepycat/db/DbLogStat.java
deleted file mode 100644
index 19e5be25ce38e92492d555344674879aa695dd10..0000000000000000000000000000000000000000
--- a/bdb/java/src/com/sleepycat/db/DbLogStat.java
+++ /dev/null
@@ -1,29 +0,0 @@
-/* DO NOT EDIT: automatically built by dist/s_java. */
-
-package com.sleepycat.db;
-
-public class DbLogStat
-{
-    public int st_magic;
-    public int st_version;
-    public int st_mode;
-    public int st_lg_bsize;
-    public int st_lg_size;
-    public int st_w_bytes;
-    public int st_w_mbytes;
-    public int st_wc_bytes;
-    public int st_wc_mbytes;
-    public int st_wcount;
-    public int st_wcount_fill;
-    public int st_scount;
-    public int st_region_wait;
-    public int st_region_nowait;
-    public int st_cur_file;
-    public int st_cur_offset;
-    public int st_disk_file;
-    public int st_disk_offset;
-    public int st_regsize;
-    public int st_maxcommitperflush;
-    public int st_mincommitperflush;
-}
-// end of DbLogStat.java
diff --git a/bdb/java/src/com/sleepycat/db/DbMpoolFStat.java b/bdb/java/src/com/sleepycat/db/DbMpoolFStat.java
deleted file mode 100644
index cc03b568fc39453f61d7ac4088c82206c7435541..0000000000000000000000000000000000000000
--- a/bdb/java/src/com/sleepycat/db/DbMpoolFStat.java
+++ /dev/null
@@ -1,16 +0,0 @@
-/* DO NOT EDIT: automatically built by dist/s_java. */
-
-package com.sleepycat.db;
-
-public class DbMpoolFStat
-{
-    public String file_name;
-    public int st_pagesize;
-    public int st_map;
-    public int st_cache_hit;
-    public int st_cache_miss;
-    public int st_page_create;
-    public int st_page_in;
-    public int st_page_out;
-}
-// end of DbMpoolFStat.java
diff --git a/bdb/java/src/com/sleepycat/db/DbQueueStat.java b/bdb/java/src/com/sleepycat/db/DbQueueStat.java
deleted file mode 100644
index 67d229ab8405453d9e8ad701b2753e0f6eec2234..0000000000000000000000000000000000000000
--- a/bdb/java/src/com/sleepycat/db/DbQueueStat.java
+++ /dev/null
@@ -1,21 +0,0 @@
-/* DO NOT EDIT: automatically built by dist/s_java. */
-
-package com.sleepycat.db;
-
-public class DbQueueStat
-{
-    public int qs_magic;
-    public int qs_version;
-    public int qs_metaflags;
-    public int qs_nkeys;
-    public int qs_ndata;
-    public int qs_pagesize;
-    public int qs_extentsize;
-    public int qs_pages;
-    public int qs_re_len;
-    public int qs_re_pad;
-    public int qs_pgfree;
-    public int qs_first_recno;
-    public int qs_cur_recno;
-}
-// end of DbQueueStat.java
diff --git a/bdb/java/src/com/sleepycat/db/DbRepStat.java b/bdb/java/src/com/sleepycat/db/DbRepStat.java
deleted file mode 100644
index 953d10eddd16d87d8b62b4cd076148ed18e9e14b..0000000000000000000000000000000000000000
--- a/bdb/java/src/com/sleepycat/db/DbRepStat.java
+++ /dev/null
@@ -1,43 +0,0 @@
-/* DO NOT EDIT: automatically built by dist/s_java. */
-
-package com.sleepycat.db;
-
-public class DbRepStat
-{
-    public int st_status;
-    public DbLsn st_next_lsn;
-    public DbLsn st_waiting_lsn;
-    public int st_dupmasters;
-    public int st_env_id;
-    public int st_env_priority;
-    public int st_gen;
-    public int st_log_duplicated;
-    public int st_log_queued;
-    public int st_log_queued_max;
-    public int st_log_queued_total;
-    public int st_log_records;
-    public int st_log_requested;
-    public int st_master;
-    public int st_master_changes;
-    public int st_msgs_badgen;
-    public int st_msgs_processed;
-    public int st_msgs_recover;
-    public int st_msgs_send_failures;
-    public int st_msgs_sent;
-    public int st_newsites;
-    public int st_nsites;
-    public int st_nthrottles;
-    public int st_outdated;
-    public int st_txns_applied;
-    public int st_elections;
-    public int st_elections_won;
-    public int st_election_cur_winner;
-    public int st_election_gen;
-    public DbLsn st_election_lsn;
-    public int st_election_nsites;
-    public int st_election_priority;
-    public int st_election_status;
-    public int st_election_tiebreaker;
-    public int st_election_votes;
-}
-// end of DbRepStat.java
diff --git a/bdb/java/src/com/sleepycat/db/DbTxnStat.java b/bdb/java/src/com/sleepycat/db/DbTxnStat.java
deleted file mode 100644
index 78794aea5044e482309708a77433b18d8d3c79c6..0000000000000000000000000000000000000000
--- a/bdb/java/src/com/sleepycat/db/DbTxnStat.java
+++ /dev/null
@@ -1,27 +0,0 @@
-/* DO NOT EDIT: automatically built by dist/s_java. */
-
-package com.sleepycat.db;
-
-public class DbTxnStat
-{
-    public static class Active {
-        public int txnid;
-        public int parentid;
-        public DbLsn lsn;
-    };
-    public DbLsn st_last_ckp;
-    public long st_time_ckp;
-    public int st_last_txnid;
-    public int st_maxtxns;
-    public int st_naborts;
-    public int st_nbegins;
-    public int st_ncommits;
-    public int st_nactive;
-    public int st_nrestores;
-    public int st_maxnactive;
-    public Active st_txnarray[];
-    public int st_region_wait;
-    public int st_region_nowait;
-    public int st_regsize;
-}
-// end of DbTxnStat.java
diff --git a/bdb/libdb_java/java_stat_auto.c b/bdb/libdb_java/java_stat_auto.c
deleted file mode 100644
index c1412232e8501f36c20c350571347b67f8ec611e..0000000000000000000000000000000000000000
--- a/bdb/libdb_java/java_stat_auto.c
+++ /dev/null
@@ -1,207 +0,0 @@
-/* DO NOT EDIT: automatically built by dist/s_java. */
-#include "java_util.h"
-int __jv_fill_bt_stat(JNIEnv *jnienv, jclass cl,
-    jobject jobj, struct __db_bt_stat *statp) {
-	JAVADB_STAT_INT(jnienv, cl, jobj, statp, bt_magic);
-	JAVADB_STAT_INT(jnienv, cl, jobj, statp, bt_version);
-	JAVADB_STAT_INT(jnienv, cl, jobj, statp, bt_metaflags);
-	JAVADB_STAT_INT(jnienv, cl, jobj, statp, bt_nkeys);
-	JAVADB_STAT_INT(jnienv, cl, jobj, statp, bt_ndata);
-	JAVADB_STAT_INT(jnienv, cl, jobj, statp, bt_pagesize);
-	JAVADB_STAT_INT(jnienv, cl, jobj, statp, bt_maxkey);
-	JAVADB_STAT_INT(jnienv, cl, jobj, statp, bt_minkey);
-	JAVADB_STAT_INT(jnienv, cl, jobj, statp, bt_re_len);
-	JAVADB_STAT_INT(jnienv, cl, jobj, statp, bt_re_pad);
-	JAVADB_STAT_INT(jnienv, cl, jobj, statp, bt_levels);
-	JAVADB_STAT_INT(jnienv, cl, jobj, statp, bt_int_pg);
-	JAVADB_STAT_INT(jnienv, cl, jobj, statp, bt_leaf_pg);
-	JAVADB_STAT_INT(jnienv, cl, jobj, statp, bt_dup_pg);
-	JAVADB_STAT_INT(jnienv, cl, jobj, statp, bt_over_pg);
-	JAVADB_STAT_INT(jnienv, cl, jobj, statp, bt_free);
-	JAVADB_STAT_INT(jnienv, cl, jobj, statp, bt_int_pgfree);
-	JAVADB_STAT_INT(jnienv, cl, jobj, statp, bt_leaf_pgfree);
-	JAVADB_STAT_INT(jnienv, cl, jobj, statp, bt_dup_pgfree);
-	JAVADB_STAT_INT(jnienv, cl, jobj, statp, bt_over_pgfree);
-	return (0);
-}
-int __jv_fill_h_stat(JNIEnv *jnienv, jclass cl,
-    jobject jobj, struct __db_h_stat *statp) {
-	JAVADB_STAT_INT(jnienv, cl, jobj, statp, hash_magic);
-	JAVADB_STAT_INT(jnienv, cl, jobj, statp, hash_version);
-	JAVADB_STAT_INT(jnienv, cl, jobj, statp, hash_metaflags);
-	JAVADB_STAT_INT(jnienv, cl, jobj, statp, hash_nkeys);
-	JAVADB_STAT_INT(jnienv, cl, jobj, statp, hash_ndata);
-	JAVADB_STAT_INT(jnienv, cl, jobj, statp, hash_pagesize);
-	JAVADB_STAT_INT(jnienv, cl, jobj, statp, hash_ffactor);
-	JAVADB_STAT_INT(jnienv, cl, jobj, statp, hash_buckets);
-	JAVADB_STAT_INT(jnienv, cl, jobj, statp, hash_free);
-	JAVADB_STAT_INT(jnienv, cl, jobj, statp, hash_bfree);
-	JAVADB_STAT_INT(jnienv, cl, jobj, statp, hash_bigpages);
-	JAVADB_STAT_INT(jnienv, cl, jobj, statp, hash_big_bfree);
-	JAVADB_STAT_INT(jnienv, cl, jobj, statp, hash_overflows);
-	JAVADB_STAT_INT(jnienv, cl, jobj, statp, hash_ovfl_free);
-	JAVADB_STAT_INT(jnienv, cl, jobj, statp, hash_dup);
-	JAVADB_STAT_INT(jnienv, cl, jobj, statp, hash_dup_free);
-	return (0);
-}
-int __jv_fill_lock_stat(JNIEnv *jnienv, jclass cl,
-    jobject jobj, struct __db_lock_stat *statp) {
-	JAVADB_STAT_INT(jnienv, cl, jobj, statp, st_id);
-	JAVADB_STAT_INT(jnienv, cl, jobj, statp, st_cur_maxid);
-	JAVADB_STAT_INT(jnienv, cl, jobj, statp, st_maxlocks);
-	JAVADB_STAT_INT(jnienv, cl, jobj, statp, st_maxlockers);
-	JAVADB_STAT_INT(jnienv, cl, jobj, statp, st_maxobjects);
-	JAVADB_STAT_INT(jnienv, cl, jobj, statp, st_nmodes);
-	JAVADB_STAT_INT(jnienv, cl, jobj, statp, st_nlocks);
-	JAVADB_STAT_INT(jnienv, cl, jobj, statp, st_maxnlocks);
-	JAVADB_STAT_INT(jnienv, cl, jobj, statp, st_nlockers);
-	JAVADB_STAT_INT(jnienv, cl, jobj, statp, st_maxnlockers);
-	JAVADB_STAT_INT(jnienv, cl, jobj, statp, st_nobjects);
-	JAVADB_STAT_INT(jnienv, cl, jobj, statp, st_maxnobjects);
-	JAVADB_STAT_INT(jnienv, cl, jobj, statp, st_nconflicts);
-	JAVADB_STAT_INT(jnienv, cl, jobj, statp, st_nrequests);
-	JAVADB_STAT_INT(jnienv, cl, jobj, statp, st_nreleases);
-	JAVADB_STAT_INT(jnienv, cl, jobj, statp, st_nnowaits);
-	JAVADB_STAT_INT(jnienv, cl, jobj, statp, st_ndeadlocks);
-	JAVADB_STAT_INT(jnienv, cl, jobj, statp, st_locktimeout);
-	JAVADB_STAT_INT(jnienv, cl, jobj, statp, st_nlocktimeouts);
-	JAVADB_STAT_INT(jnienv, cl, jobj, statp, st_txntimeout);
-	JAVADB_STAT_INT(jnienv, cl, jobj, statp, st_ntxntimeouts);
-	JAVADB_STAT_INT(jnienv, cl, jobj, statp, st_region_wait);
-	JAVADB_STAT_INT(jnienv, cl, jobj, statp, st_region_nowait);
-	JAVADB_STAT_INT(jnienv, cl, jobj, statp, st_regsize);
-	return (0);
-}
-int __jv_fill_log_stat(JNIEnv *jnienv, jclass cl,
-    jobject jobj, struct __db_log_stat *statp) {
-	JAVADB_STAT_INT(jnienv, cl, jobj, statp, st_magic);
-	JAVADB_STAT_INT(jnienv, cl, jobj, statp, st_version);
-	JAVADB_STAT_INT(jnienv, cl, jobj, statp, st_mode);
-	JAVADB_STAT_INT(jnienv, cl, jobj, statp, st_lg_bsize);
-	JAVADB_STAT_INT(jnienv, cl, jobj, statp, st_lg_size);
-	JAVADB_STAT_INT(jnienv, cl, jobj, statp, st_w_bytes);
-	JAVADB_STAT_INT(jnienv, cl, jobj, statp, st_w_mbytes);
-	JAVADB_STAT_INT(jnienv, cl, jobj, statp, st_wc_bytes);
-	JAVADB_STAT_INT(jnienv, cl, jobj, statp, st_wc_mbytes);
-	JAVADB_STAT_INT(jnienv, cl, jobj, statp, st_wcount);
-	JAVADB_STAT_INT(jnienv, cl, jobj, statp, st_wcount_fill);
-	JAVADB_STAT_INT(jnienv, cl, jobj, statp, st_scount);
-	JAVADB_STAT_INT(jnienv, cl, jobj, statp, st_region_wait);
-	JAVADB_STAT_INT(jnienv, cl, jobj, statp, st_region_nowait);
-	JAVADB_STAT_INT(jnienv, cl, jobj, statp, st_cur_file);
-	JAVADB_STAT_INT(jnienv, cl, jobj, statp, st_cur_offset);
-	JAVADB_STAT_INT(jnienv, cl, jobj, statp, st_disk_file);
-	JAVADB_STAT_INT(jnienv, cl, jobj, statp, st_disk_offset);
-	JAVADB_STAT_INT(jnienv, cl, jobj, statp, st_regsize);
-	JAVADB_STAT_INT(jnienv, cl, jobj, statp, st_maxcommitperflush);
-	JAVADB_STAT_INT(jnienv, cl, jobj, statp, st_mincommitperflush);
-	return (0);
-}
-int __jv_fill_mpool_stat(JNIEnv *jnienv, jclass cl,
-    jobject jobj, struct __db_mpool_stat *statp) {
-	JAVADB_STAT_INT(jnienv, cl, jobj, statp, st_gbytes);
-	JAVADB_STAT_INT(jnienv, cl, jobj, statp, st_bytes);
-	JAVADB_STAT_INT(jnienv, cl, jobj, statp, st_ncache);
-	JAVADB_STAT_INT(jnienv, cl, jobj, statp, st_regsize);
-	JAVADB_STAT_INT(jnienv, cl, jobj, statp, st_map);
-	JAVADB_STAT_INT(jnienv, cl, jobj, statp, st_cache_hit);
-	JAVADB_STAT_INT(jnienv, cl, jobj, statp, st_cache_miss);
-	JAVADB_STAT_INT(jnienv, cl, jobj, statp, st_page_create);
-	JAVADB_STAT_INT(jnienv, cl, jobj, statp, st_page_in);
-	JAVADB_STAT_INT(jnienv, cl, jobj, statp, st_page_out);
-	JAVADB_STAT_INT(jnienv, cl, jobj, statp, st_ro_evict);
-	JAVADB_STAT_INT(jnienv, cl, jobj, statp, st_rw_evict);
-	JAVADB_STAT_INT(jnienv, cl, jobj, statp, st_page_trickle);
-	JAVADB_STAT_INT(jnienv, cl, jobj, statp, st_pages);
-	JAVADB_STAT_INT(jnienv, cl, jobj, statp, st_page_clean);
-	JAVADB_STAT_INT(jnienv, cl, jobj, statp, st_page_dirty);
-	JAVADB_STAT_INT(jnienv, cl, jobj, statp, st_hash_buckets);
-	JAVADB_STAT_INT(jnienv, cl, jobj, statp, st_hash_searches);
-	JAVADB_STAT_INT(jnienv, cl, jobj, statp, st_hash_longest);
-	JAVADB_STAT_INT(jnienv, cl, jobj, statp, st_hash_examined);
-	JAVADB_STAT_INT(jnienv, cl, jobj, statp, st_hash_nowait);
-	JAVADB_STAT_INT(jnienv, cl, jobj, statp, st_hash_wait);
-	JAVADB_STAT_INT(jnienv, cl, jobj, statp, st_hash_max_wait);
-	JAVADB_STAT_INT(jnienv, cl, jobj, statp, st_region_nowait);
-	JAVADB_STAT_INT(jnienv, cl, jobj, statp, st_region_wait);
-	JAVADB_STAT_INT(jnienv, cl, jobj, statp, st_alloc);
-	JAVADB_STAT_INT(jnienv, cl, jobj, statp, st_alloc_buckets);
-	JAVADB_STAT_INT(jnienv, cl, jobj, statp, st_alloc_max_buckets);
-	JAVADB_STAT_INT(jnienv, cl, jobj, statp, st_alloc_pages);
-	JAVADB_STAT_INT(jnienv, cl, jobj, statp, st_alloc_max_pages);
-	return (0);
-}
-int __jv_fill_qam_stat(JNIEnv *jnienv, jclass cl,
-    jobject jobj, struct __db_qam_stat *statp) {
-	JAVADB_STAT_INT(jnienv, cl, jobj, statp, qs_magic);
-	JAVADB_STAT_INT(jnienv, cl, jobj, statp, qs_version);
-	JAVADB_STAT_INT(jnienv, cl, jobj, statp, qs_metaflags);
-	JAVADB_STAT_INT(jnienv, cl, jobj, statp, qs_nkeys);
-	JAVADB_STAT_INT(jnienv, cl, jobj, statp, qs_ndata);
-	JAVADB_STAT_INT(jnienv, cl, jobj, statp, qs_pagesize);
-	JAVADB_STAT_INT(jnienv, cl, jobj, statp, qs_extentsize);
-	JAVADB_STAT_INT(jnienv, cl, jobj, statp, qs_pages);
-	JAVADB_STAT_INT(jnienv, cl, jobj, statp, qs_re_len);
-	JAVADB_STAT_INT(jnienv, cl, jobj, statp, qs_re_pad);
-	JAVADB_STAT_INT(jnienv, cl, jobj, statp, qs_pgfree);
-	JAVADB_STAT_INT(jnienv, cl, jobj, statp, qs_first_recno);
-	JAVADB_STAT_INT(jnienv, cl, jobj, statp, qs_cur_recno);
-	return (0);
-}
-int __jv_fill_rep_stat(JNIEnv *jnienv, jclass cl,
-    jobject jobj, struct __db_rep_stat *statp) {
-	JAVADB_STAT_INT(jnienv, cl, jobj, statp, st_status);
-	JAVADB_STAT_LSN(jnienv, cl, jobj, statp, st_next_lsn);
-	JAVADB_STAT_LSN(jnienv, cl, jobj, statp, st_waiting_lsn);
-	JAVADB_STAT_INT(jnienv, cl, jobj, statp, st_dupmasters);
-	JAVADB_STAT_INT(jnienv, cl, jobj, statp, st_env_id);
-	JAVADB_STAT_INT(jnienv, cl, jobj, statp, st_env_priority);
-	JAVADB_STAT_INT(jnienv, cl, jobj, statp, st_gen);
-	JAVADB_STAT_INT(jnienv, cl, jobj, statp, st_log_duplicated);
-	JAVADB_STAT_INT(jnienv, cl, jobj, statp, st_log_queued);
-	JAVADB_STAT_INT(jnienv, cl, jobj, statp, st_log_queued_max);
-	JAVADB_STAT_INT(jnienv, cl, jobj, statp, st_log_queued_total);
-	JAVADB_STAT_INT(jnienv, cl, jobj, statp, st_log_records);
-	JAVADB_STAT_INT(jnienv, cl, jobj, statp, st_log_requested);
-	JAVADB_STAT_INT(jnienv, cl, jobj, statp, st_master);
-	JAVADB_STAT_INT(jnienv, cl, jobj, statp, st_master_changes);
-	JAVADB_STAT_INT(jnienv, cl, jobj, statp, st_msgs_badgen);
-	JAVADB_STAT_INT(jnienv, cl, jobj, statp, st_msgs_processed);
-	JAVADB_STAT_INT(jnienv, cl, jobj, statp, st_msgs_recover);
-	JAVADB_STAT_INT(jnienv, cl, jobj, statp, st_msgs_send_failures);
-	JAVADB_STAT_INT(jnienv, cl, jobj, statp, st_msgs_sent);
-	JAVADB_STAT_INT(jnienv, cl, jobj, statp, st_newsites);
-	JAVADB_STAT_INT(jnienv, cl, jobj, statp, st_nsites);
-	JAVADB_STAT_INT(jnienv, cl, jobj, statp, st_nthrottles);
-	JAVADB_STAT_INT(jnienv, cl, jobj, statp, st_outdated);
-	JAVADB_STAT_INT(jnienv, cl, jobj, statp, st_txns_applied);
-	JAVADB_STAT_INT(jnienv, cl, jobj, statp, st_elections);
-	JAVADB_STAT_INT(jnienv, cl, jobj, statp, st_elections_won);
-	JAVADB_STAT_INT(jnienv, cl, jobj, statp, st_election_cur_winner);
-	JAVADB_STAT_INT(jnienv, cl, jobj, statp, st_election_gen);
-	JAVADB_STAT_LSN(jnienv, cl, jobj, statp, st_election_lsn);
-	JAVADB_STAT_INT(jnienv, cl, jobj, statp, st_election_nsites);
-	JAVADB_STAT_INT(jnienv, cl, jobj, statp, st_election_priority);
-	JAVADB_STAT_INT(jnienv, cl, jobj, statp, st_election_status);
-	JAVADB_STAT_INT(jnienv, cl, jobj, statp, st_election_tiebreaker);
-	JAVADB_STAT_INT(jnienv, cl, jobj, statp, st_election_votes);
-	return (0);
-}
-int __jv_fill_txn_stat(JNIEnv *jnienv, jclass cl,
-    jobject jobj, struct __db_txn_stat *statp) {
-	JAVADB_STAT_LSN(jnienv, cl, jobj, statp, st_last_ckp);
-	JAVADB_STAT_LONG(jnienv, cl, jobj, statp, st_time_ckp);
-	JAVADB_STAT_INT(jnienv, cl, jobj, statp, st_last_txnid);
-	JAVADB_STAT_INT(jnienv, cl, jobj, statp, st_maxtxns);
-	JAVADB_STAT_INT(jnienv, cl, jobj, statp, st_naborts);
-	JAVADB_STAT_INT(jnienv, cl, jobj, statp, st_nbegins);
-	JAVADB_STAT_INT(jnienv, cl, jobj, statp, st_ncommits);
-	JAVADB_STAT_INT(jnienv, cl, jobj, statp, st_nactive);
-	JAVADB_STAT_INT(jnienv, cl, jobj, statp, st_nrestores);
-	JAVADB_STAT_INT(jnienv, cl, jobj, statp, st_maxnactive);
-	JAVADB_STAT_ACTIVE(jnienv, cl, jobj, statp, st_txnarray);
-	JAVADB_STAT_INT(jnienv, cl, jobj, statp, st_region_wait);
-	JAVADB_STAT_INT(jnienv, cl, jobj, statp, st_region_nowait);
-	JAVADB_STAT_INT(jnienv, cl, jobj, statp, st_regsize);
-	return (0);
-}
diff --git a/bdb/libdb_java/java_stat_auto.h b/bdb/libdb_java/java_stat_auto.h
deleted file mode 100644
index 20eecf1e2124b997411ad322cf22a0ff8bc233e6..0000000000000000000000000000000000000000
--- a/bdb/libdb_java/java_stat_auto.h
+++ /dev/null
@@ -1,9 +0,0 @@
-/* DO NOT EDIT: automatically built by dist/s_java. */
-extern int __jv_fill_bt_stat(JNIEnv *jnienv, jclass cl, jobject jobj, struct __db_bt_stat *statp);
-extern int __jv_fill_h_stat(JNIEnv *jnienv, jclass cl, jobject jobj, struct __db_h_stat *statp);
-extern int __jv_fill_lock_stat(JNIEnv *jnienv, jclass cl, jobject jobj, struct __db_lock_stat *statp);
-extern int __jv_fill_log_stat(JNIEnv *jnienv, jclass cl, jobject jobj, struct __db_log_stat *statp);
-extern int __jv_fill_mpool_stat(JNIEnv *jnienv, jclass cl, jobject jobj, struct __db_mpool_stat *statp);
-extern int __jv_fill_qam_stat(JNIEnv *jnienv, jclass cl, jobject jobj, struct __db_qam_stat *statp);
-extern int __jv_fill_rep_stat(JNIEnv *jnienv, jclass cl, jobject jobj, struct __db_rep_stat *statp);
-extern int __jv_fill_txn_stat(JNIEnv *jnienv, jclass cl, jobject jobj, struct __db_txn_stat *statp);
diff --git a/bdb/rpc_server/c/db_server_proc.c b/bdb/rpc_server/c/db_server_proc.c.in
similarity index 100%
rename from bdb/rpc_server/c/db_server_proc.c
rename to bdb/rpc_server/c/db_server_proc.c.in
diff --git a/bdb/rpc_server/c/db_server_proc.sed b/bdb/rpc_server/c/db_server_proc.sed
deleted file mode 100644
index e11b2c33cfe874a76f84d7245acbf3aba9d4ef8e..0000000000000000000000000000000000000000
--- a/bdb/rpc_server/c/db_server_proc.sed
+++ /dev/null
@@ -1,772 +0,0 @@
-/^\/\* BEGIN __env_cachesize_proc/,/^\/\* END __env_cachesize_proc/c\
-/* BEGIN __env_cachesize_proc */\
-/*\
-\ * PUBLIC: void __env_cachesize_proc __P((long, u_int32_t, u_int32_t,\
-\ * PUBLIC:      u_int32_t, __env_cachesize_reply *));\
-\ */\
-void\
-__env_cachesize_proc(dbenvcl_id, gbytes, bytes,\
-\	\	ncache, replyp)\
-\	long dbenvcl_id;\
-\	u_int32_t gbytes;\
-\	u_int32_t bytes;\
-\	u_int32_t ncache;\
-\	__env_cachesize_reply *replyp;\
-/* END __env_cachesize_proc */
-/^\/\* BEGIN __env_close_proc/,/^\/\* END __env_close_proc/c\
-/* BEGIN __env_close_proc */\
-/*\
-\ * PUBLIC: void __env_close_proc __P((long, u_int32_t, __env_close_reply *));\
-\ */\
-void\
-__env_close_proc(dbenvcl_id, flags, replyp)\
-\	long dbenvcl_id;\
-\	u_int32_t flags;\
-\	__env_close_reply *replyp;\
-/* END __env_close_proc */
-/^\/\* BEGIN __env_create_proc/,/^\/\* END __env_create_proc/c\
-/* BEGIN __env_create_proc */\
-/*\
-\ * PUBLIC: void __env_create_proc __P((u_int32_t, __env_create_reply *));\
-\ */\
-void\
-__env_create_proc(timeout, replyp)\
-\	u_int32_t timeout;\
-\	__env_create_reply *replyp;\
-/* END __env_create_proc */
-/^\/\* BEGIN __env_dbremove_proc/,/^\/\* END __env_dbremove_proc/c\
-/* BEGIN __env_dbremove_proc */\
-/*\
-\ * PUBLIC: void __env_dbremove_proc __P((long, long, char *, char *, u_int32_t,\
-\ * PUBLIC:      __env_dbremove_reply *));\
-\ */\
-void\
-__env_dbremove_proc(dbenvcl_id, txnpcl_id, name,\
-\	\	subdb, flags, replyp)\
-\	long dbenvcl_id;\
-\	long txnpcl_id;\
-\	char *name;\
-\	char *subdb;\
-\	u_int32_t flags;\
-\	__env_dbremove_reply *replyp;\
-/* END __env_dbremove_proc */
-/^\/\* BEGIN __env_dbrename_proc/,/^\/\* END __env_dbrename_proc/c\
-/* BEGIN __env_dbrename_proc */\
-/*\
-\ * PUBLIC: void __env_dbrename_proc __P((long, long, char *, char *, char *,\
-\ * PUBLIC:      u_int32_t, __env_dbrename_reply *));\
-\ */\
-void\
-__env_dbrename_proc(dbenvcl_id, txnpcl_id, name,\
-\	\	subdb, newname, flags, replyp)\
-\	long dbenvcl_id;\
-\	long txnpcl_id;\
-\	char *name;\
-\	char *subdb;\
-\	char *newname;\
-\	u_int32_t flags;\
-\	__env_dbrename_reply *replyp;\
-/* END __env_dbrename_proc */
-/^\/\* BEGIN __env_encrypt_proc/,/^\/\* END __env_encrypt_proc/c\
-/* BEGIN __env_encrypt_proc */\
-/*\
-\ * PUBLIC: void __env_encrypt_proc __P((long, char *, u_int32_t,\
-\ * PUBLIC:      __env_encrypt_reply *));\
-\ */\
-void\
-__env_encrypt_proc(dbenvcl_id, passwd, flags, replyp)\
-\	long dbenvcl_id;\
-\	char *passwd;\
-\	u_int32_t flags;\
-\	__env_encrypt_reply *replyp;\
-/* END __env_encrypt_proc */
-/^\/\* BEGIN __env_flags_proc/,/^\/\* END __env_flags_proc/c\
-/* BEGIN __env_flags_proc */\
-/*\
-\ * PUBLIC: void __env_flags_proc __P((long, u_int32_t, u_int32_t,\
-\ * PUBLIC:      __env_flags_reply *));\
-\ */\
-void\
-__env_flags_proc(dbenvcl_id, flags, onoff, replyp)\
-\	long dbenvcl_id;\
-\	u_int32_t flags;\
-\	u_int32_t onoff;\
-\	__env_flags_reply *replyp;\
-/* END __env_flags_proc */
-/^\/\* BEGIN __env_open_proc/,/^\/\* END __env_open_proc/c\
-/* BEGIN __env_open_proc */\
-/*\
-\ * PUBLIC: void __env_open_proc __P((long, char *, u_int32_t, u_int32_t,\
-\ * PUBLIC:      __env_open_reply *));\
-\ */\
-void\
-__env_open_proc(dbenvcl_id, home, flags,\
-\	\	mode, replyp)\
-\	long dbenvcl_id;\
-\	char *home;\
-\	u_int32_t flags;\
-\	u_int32_t mode;\
-\	__env_open_reply *replyp;\
-/* END __env_open_proc */
-/^\/\* BEGIN __env_remove_proc/,/^\/\* END __env_remove_proc/c\
-/* BEGIN __env_remove_proc */\
-/*\
-\ * PUBLIC: void __env_remove_proc __P((long, char *, u_int32_t,\
-\ * PUBLIC:      __env_remove_reply *));\
-\ */\
-void\
-__env_remove_proc(dbenvcl_id, home, flags, replyp)\
-\	long dbenvcl_id;\
-\	char *home;\
-\	u_int32_t flags;\
-\	__env_remove_reply *replyp;\
-/* END __env_remove_proc */
-/^\/\* BEGIN __txn_abort_proc/,/^\/\* END __txn_abort_proc/c\
-/* BEGIN __txn_abort_proc */\
-/*\
-\ * PUBLIC: void __txn_abort_proc __P((long, __txn_abort_reply *));\
-\ */\
-void\
-__txn_abort_proc(txnpcl_id, replyp)\
-\	long txnpcl_id;\
-\	__txn_abort_reply *replyp;\
-/* END __txn_abort_proc */
-/^\/\* BEGIN __txn_begin_proc/,/^\/\* END __txn_begin_proc/c\
-/* BEGIN __txn_begin_proc */\
-/*\
-\ * PUBLIC: void __txn_begin_proc __P((long, long, u_int32_t,\
-\ * PUBLIC:      __txn_begin_reply *));\
-\ */\
-void\
-__txn_begin_proc(dbenvcl_id, parentcl_id,\
-\	\	flags, replyp)\
-\	long dbenvcl_id;\
-\	long parentcl_id;\
-\	u_int32_t flags;\
-\	__txn_begin_reply *replyp;\
-/* END __txn_begin_proc */
-/^\/\* BEGIN __txn_commit_proc/,/^\/\* END __txn_commit_proc/c\
-/* BEGIN __txn_commit_proc */\
-/*\
-\ * PUBLIC: void __txn_commit_proc __P((long, u_int32_t,\
-\ * PUBLIC:      __txn_commit_reply *));\
-\ */\
-void\
-__txn_commit_proc(txnpcl_id, flags, replyp)\
-\	long txnpcl_id;\
-\	u_int32_t flags;\
-\	__txn_commit_reply *replyp;\
-/* END __txn_commit_proc */
-/^\/\* BEGIN __txn_discard_proc/,/^\/\* END __txn_discard_proc/c\
-/* BEGIN __txn_discard_proc */\
-/*\
-\ * PUBLIC: void __txn_discard_proc __P((long, u_int32_t,\
-\ * PUBLIC:      __txn_discard_reply *));\
-\ */\
-void\
-__txn_discard_proc(txnpcl_id, flags, replyp)\
-\	long txnpcl_id;\
-\	u_int32_t flags;\
-\	__txn_discard_reply *replyp;\
-/* END __txn_discard_proc */
-/^\/\* BEGIN __txn_prepare_proc/,/^\/\* END __txn_prepare_proc/c\
-/* BEGIN __txn_prepare_proc */\
-/*\
-\ * PUBLIC: void __txn_prepare_proc __P((long, u_int8_t *,\
-\ * PUBLIC:      __txn_prepare_reply *));\
-\ */\
-void\
-__txn_prepare_proc(txnpcl_id, gid, replyp)\
-\	long txnpcl_id;\
-\	u_int8_t *gid;\
-\	__txn_prepare_reply *replyp;\
-/* END __txn_prepare_proc */
-/^\/\* BEGIN __txn_recover_proc/,/^\/\* END __txn_recover_proc/c\
-/* BEGIN __txn_recover_proc */\
-/*\
-\ * PUBLIC: void __txn_recover_proc __P((long, u_int32_t, u_int32_t,\
-\ * PUBLIC:      __txn_recover_reply *, int *));\
-\ */\
-void\
-__txn_recover_proc(dbenvcl_id, count,\
-\	\	flags, replyp, freep)\
-\	long dbenvcl_id;\
-\	u_int32_t count;\
-\	u_int32_t flags;\
-\	__txn_recover_reply *replyp;\
-\	int * freep;\
-/* END __txn_recover_proc */
-/^\/\* BEGIN __db_associate_proc/,/^\/\* END __db_associate_proc/c\
-/* BEGIN __db_associate_proc */\
-/*\
-\ * PUBLIC: void __db_associate_proc __P((long, long, long, u_int32_t,\
-\ * PUBLIC:      __db_associate_reply *));\
-\ */\
-void\
-__db_associate_proc(dbpcl_id, txnpcl_id, sdbpcl_id,\
-\	\	flags, replyp)\
-\	long dbpcl_id;\
-\	long txnpcl_id;\
-\	long sdbpcl_id;\
-\	u_int32_t flags;\
-\	__db_associate_reply *replyp;\
-/* END __db_associate_proc */
-/^\/\* BEGIN __db_bt_maxkey_proc/,/^\/\* END __db_bt_maxkey_proc/c\
-/* BEGIN __db_bt_maxkey_proc */\
-/*\
-\ * PUBLIC: void __db_bt_maxkey_proc __P((long, u_int32_t,\
-\ * PUBLIC:      __db_bt_maxkey_reply *));\
-\ */\
-void\
-__db_bt_maxkey_proc(dbpcl_id, maxkey, replyp)\
-\	long dbpcl_id;\
-\	u_int32_t maxkey;\
-\	__db_bt_maxkey_reply *replyp;\
-/* END __db_bt_maxkey_proc */
-/^\/\* BEGIN __db_bt_minkey_proc/,/^\/\* END __db_bt_minkey_proc/c\
-/* BEGIN __db_bt_minkey_proc */\
-/*\
-\ * PUBLIC: void __db_bt_minkey_proc __P((long, u_int32_t,\
-\ * PUBLIC:      __db_bt_minkey_reply *));\
-\ */\
-void\
-__db_bt_minkey_proc(dbpcl_id, minkey, replyp)\
-\	long dbpcl_id;\
-\	u_int32_t minkey;\
-\	__db_bt_minkey_reply *replyp;\
-/* END __db_bt_minkey_proc */
-/^\/\* BEGIN __db_close_proc/,/^\/\* END __db_close_proc/c\
-/* BEGIN __db_close_proc */\
-/*\
-\ * PUBLIC: void __db_close_proc __P((long, u_int32_t, __db_close_reply *));\
-\ */\
-void\
-__db_close_proc(dbpcl_id, flags, replyp)\
-\	long dbpcl_id;\
-\	u_int32_t flags;\
-\	__db_close_reply *replyp;\
-/* END __db_close_proc */
-/^\/\* BEGIN __db_create_proc/,/^\/\* END __db_create_proc/c\
-/* BEGIN __db_create_proc */\
-/*\
-\ * PUBLIC: void __db_create_proc __P((long, u_int32_t, __db_create_reply *));\
-\ */\
-void\
-__db_create_proc(dbenvcl_id, flags, replyp)\
-\	long dbenvcl_id;\
-\	u_int32_t flags;\
-\	__db_create_reply *replyp;\
-/* END __db_create_proc */
-/^\/\* BEGIN __db_del_proc/,/^\/\* END __db_del_proc/c\
-/* BEGIN __db_del_proc */\
-/*\
-\ * PUBLIC: void __db_del_proc __P((long, long, u_int32_t, u_int32_t, u_int32_t,\
-\ * PUBLIC:      u_int32_t, void *, u_int32_t, u_int32_t, __db_del_reply *));\
-\ */\
-void\
-__db_del_proc(dbpcl_id, txnpcl_id, keydlen,\
-\	\	keydoff, keyulen, keyflags, keydata,\
-\	\	keysize, flags, replyp)\
-\	long dbpcl_id;\
-\	long txnpcl_id;\
-\	u_int32_t keydlen;\
-\	u_int32_t keydoff;\
-\	u_int32_t keyulen;\
-\	u_int32_t keyflags;\
-\	void *keydata;\
-\	u_int32_t keysize;\
-\	u_int32_t flags;\
-\	__db_del_reply *replyp;\
-/* END __db_del_proc */
-/^\/\* BEGIN __db_encrypt_proc/,/^\/\* END __db_encrypt_proc/c\
-/* BEGIN __db_encrypt_proc */\
-/*\
-\ * PUBLIC: void __db_encrypt_proc __P((long, char *, u_int32_t,\
-\ * PUBLIC:      __db_encrypt_reply *));\
-\ */\
-void\
-__db_encrypt_proc(dbpcl_id, passwd, flags, replyp)\
-\	long dbpcl_id;\
-\	char *passwd;\
-\	u_int32_t flags;\
-\	__db_encrypt_reply *replyp;\
-/* END __db_encrypt_proc */
-/^\/\* BEGIN __db_extentsize_proc/,/^\/\* END __db_extentsize_proc/c\
-/* BEGIN __db_extentsize_proc */\
-/*\
-\ * PUBLIC: void __db_extentsize_proc __P((long, u_int32_t,\
-\ * PUBLIC:      __db_extentsize_reply *));\
-\ */\
-void\
-__db_extentsize_proc(dbpcl_id, extentsize, replyp)\
-\	long dbpcl_id;\
-\	u_int32_t extentsize;\
-\	__db_extentsize_reply *replyp;\
-/* END __db_extentsize_proc */
-/^\/\* BEGIN __db_flags_proc/,/^\/\* END __db_flags_proc/c\
-/* BEGIN __db_flags_proc */\
-/*\
-\ * PUBLIC: void __db_flags_proc __P((long, u_int32_t, __db_flags_reply *));\
-\ */\
-void\
-__db_flags_proc(dbpcl_id, flags, replyp)\
-\	long dbpcl_id;\
-\	u_int32_t flags;\
-\	__db_flags_reply *replyp;\
-/* END __db_flags_proc */
-/^\/\* BEGIN __db_get_proc/,/^\/\* END __db_get_proc/c\
-/* BEGIN __db_get_proc */\
-/*\
-\ * PUBLIC: void __db_get_proc __P((long, long, u_int32_t, u_int32_t, u_int32_t,\
-\ * PUBLIC:      u_int32_t, void *, u_int32_t, u_int32_t, u_int32_t, u_int32_t, u_int32_t, void *,\
-\ * PUBLIC:      u_int32_t, u_int32_t, __db_get_reply *, int *));\
-\ */\
-void\
-__db_get_proc(dbpcl_id, txnpcl_id, keydlen,\
-\	\	keydoff, keyulen, keyflags, keydata,\
-\	\	keysize, datadlen, datadoff, dataulen,\
-\	\	dataflags, datadata, datasize, flags, replyp, freep)\
-\	long dbpcl_id;\
-\	long txnpcl_id;\
-\	u_int32_t keydlen;\
-\	u_int32_t keydoff;\
-\	u_int32_t keyulen;\
-\	u_int32_t keyflags;\
-\	void *keydata;\
-\	u_int32_t keysize;\
-\	u_int32_t datadlen;\
-\	u_int32_t datadoff;\
-\	u_int32_t dataulen;\
-\	u_int32_t dataflags;\
-\	void *datadata;\
-\	u_int32_t datasize;\
-\	u_int32_t flags;\
-\	__db_get_reply *replyp;\
-\	int * freep;\
-/* END __db_get_proc */
-/^\/\* BEGIN __db_h_ffactor_proc/,/^\/\* END __db_h_ffactor_proc/c\
-/* BEGIN __db_h_ffactor_proc */\
-/*\
-\ * PUBLIC: void __db_h_ffactor_proc __P((long, u_int32_t,\
-\ * PUBLIC:      __db_h_ffactor_reply *));\
-\ */\
-void\
-__db_h_ffactor_proc(dbpcl_id, ffactor, replyp)\
-\	long dbpcl_id;\
-\	u_int32_t ffactor;\
-\	__db_h_ffactor_reply *replyp;\
-/* END __db_h_ffactor_proc */
-/^\/\* BEGIN __db_h_nelem_proc/,/^\/\* END __db_h_nelem_proc/c\
-/* BEGIN __db_h_nelem_proc */\
-/*\
-\ * PUBLIC: void __db_h_nelem_proc __P((long, u_int32_t,\
-\ * PUBLIC:      __db_h_nelem_reply *));\
-\ */\
-void\
-__db_h_nelem_proc(dbpcl_id, nelem, replyp)\
-\	long dbpcl_id;\
-\	u_int32_t nelem;\
-\	__db_h_nelem_reply *replyp;\
-/* END __db_h_nelem_proc */
-/^\/\* BEGIN __db_key_range_proc/,/^\/\* END __db_key_range_proc/c\
-/* BEGIN __db_key_range_proc */\
-/*\
-\ * PUBLIC: void __db_key_range_proc __P((long, long, u_int32_t, u_int32_t,\
-\ * PUBLIC:      u_int32_t, u_int32_t, void *, u_int32_t, u_int32_t, __db_key_range_reply *));\
-\ */\
-void\
-__db_key_range_proc(dbpcl_id, txnpcl_id, keydlen,\
-\	\	keydoff, keyulen, keyflags, keydata,\
-\	\	keysize, flags, replyp)\
-\	long dbpcl_id;\
-\	long txnpcl_id;\
-\	u_int32_t keydlen;\
-\	u_int32_t keydoff;\
-\	u_int32_t keyulen;\
-\	u_int32_t keyflags;\
-\	void *keydata;\
-\	u_int32_t keysize;\
-\	u_int32_t flags;\
-\	__db_key_range_reply *replyp;\
-/* END __db_key_range_proc */
-/^\/\* BEGIN __db_lorder_proc/,/^\/\* END __db_lorder_proc/c\
-/* BEGIN __db_lorder_proc */\
-/*\
-\ * PUBLIC: void __db_lorder_proc __P((long, u_int32_t, __db_lorder_reply *));\
-\ */\
-void\
-__db_lorder_proc(dbpcl_id, lorder, replyp)\
-\	long dbpcl_id;\
-\	u_int32_t lorder;\
-\	__db_lorder_reply *replyp;\
-/* END __db_lorder_proc */
-/^\/\* BEGIN __db_open_proc/,/^\/\* END __db_open_proc/c\
-/* BEGIN __db_open_proc */\
-/*\
-\ * PUBLIC: void __db_open_proc __P((long, long, char *, char *, u_int32_t,\
-\ * PUBLIC:      u_int32_t, u_int32_t, __db_open_reply *));\
-\ */\
-void\
-__db_open_proc(dbpcl_id, txnpcl_id, name,\
-\	\	subdb, type, flags, mode, replyp)\
-\	long dbpcl_id;\
-\	long txnpcl_id;\
-\	char *name;\
-\	char *subdb;\
-\	u_int32_t type;\
-\	u_int32_t flags;\
-\	u_int32_t mode;\
-\	__db_open_reply *replyp;\
-/* END __db_open_proc */
-/^\/\* BEGIN __db_pagesize_proc/,/^\/\* END __db_pagesize_proc/c\
-/* BEGIN __db_pagesize_proc */\
-/*\
-\ * PUBLIC: void __db_pagesize_proc __P((long, u_int32_t,\
-\ * PUBLIC:      __db_pagesize_reply *));\
-\ */\
-void\
-__db_pagesize_proc(dbpcl_id, pagesize, replyp)\
-\	long dbpcl_id;\
-\	u_int32_t pagesize;\
-\	__db_pagesize_reply *replyp;\
-/* END __db_pagesize_proc */
-/^\/\* BEGIN __db_pget_proc/,/^\/\* END __db_pget_proc/c\
-/* BEGIN __db_pget_proc */\
-/*\
-\ * PUBLIC: void __db_pget_proc __P((long, long, u_int32_t, u_int32_t,\
-\ * PUBLIC:      u_int32_t, u_int32_t, void *, u_int32_t, u_int32_t, u_int32_t, u_int32_t,\
-\ * PUBLIC:      u_int32_t, void *, u_int32_t, u_int32_t, u_int32_t, u_int32_t, u_int32_t, void *,\
-\ * PUBLIC:      u_int32_t, u_int32_t, __db_pget_reply *, int *));\
-\ */\
-void\
-__db_pget_proc(dbpcl_id, txnpcl_id, skeydlen,\
-\	\	skeydoff, skeyulen, skeyflags, skeydata,\
-\	\	skeysize, pkeydlen, pkeydoff, pkeyulen,\
-\	\	pkeyflags, pkeydata, pkeysize, datadlen,\
-\	\	datadoff, dataulen, dataflags, datadata,\
-\	\	datasize, flags, replyp, freep)\
-\	long dbpcl_id;\
-\	long txnpcl_id;\
-\	u_int32_t skeydlen;\
-\	u_int32_t skeydoff;\
-\	u_int32_t skeyulen;\
-\	u_int32_t skeyflags;\
-\	void *skeydata;\
-\	u_int32_t skeysize;\
-\	u_int32_t pkeydlen;\
-\	u_int32_t pkeydoff;\
-\	u_int32_t pkeyulen;\
-\	u_int32_t pkeyflags;\
-\	void *pkeydata;\
-\	u_int32_t pkeysize;\
-\	u_int32_t datadlen;\
-\	u_int32_t datadoff;\
-\	u_int32_t dataulen;\
-\	u_int32_t dataflags;\
-\	void *datadata;\
-\	u_int32_t datasize;\
-\	u_int32_t flags;\
-\	__db_pget_reply *replyp;\
-\	int * freep;\
-/* END __db_pget_proc */
-/^\/\* BEGIN __db_put_proc/,/^\/\* END __db_put_proc/c\
-/* BEGIN __db_put_proc */\
-/*\
-\ * PUBLIC: void __db_put_proc __P((long, long, u_int32_t, u_int32_t, u_int32_t,\
-\ * PUBLIC:      u_int32_t, void *, u_int32_t, u_int32_t, u_int32_t, u_int32_t, u_int32_t, void *,\
-\ * PUBLIC:      u_int32_t, u_int32_t, __db_put_reply *, int *));\
-\ */\
-void\
-__db_put_proc(dbpcl_id, txnpcl_id, keydlen,\
-\	\	keydoff, keyulen, keyflags, keydata,\
-\	\	keysize, datadlen, datadoff, dataulen,\
-\	\	dataflags, datadata, datasize, flags, replyp, freep)\
-\	long dbpcl_id;\
-\	long txnpcl_id;\
-\	u_int32_t keydlen;\
-\	u_int32_t keydoff;\
-\	u_int32_t keyulen;\
-\	u_int32_t keyflags;\
-\	void *keydata;\
-\	u_int32_t keysize;\
-\	u_int32_t datadlen;\
-\	u_int32_t datadoff;\
-\	u_int32_t dataulen;\
-\	u_int32_t dataflags;\
-\	void *datadata;\
-\	u_int32_t datasize;\
-\	u_int32_t flags;\
-\	__db_put_reply *replyp;\
-\	int * freep;\
-/* END __db_put_proc */
-/^\/\* BEGIN __db_re_delim_proc/,/^\/\* END __db_re_delim_proc/c\
-/* BEGIN __db_re_delim_proc */\
-/*\
-\ * PUBLIC: void __db_re_delim_proc __P((long, u_int32_t,\
-\ * PUBLIC:      __db_re_delim_reply *));\
-\ */\
-void\
-__db_re_delim_proc(dbpcl_id, delim, replyp)\
-\	long dbpcl_id;\
-\	u_int32_t delim;\
-\	__db_re_delim_reply *replyp;\
-/* END __db_re_delim_proc */
-/^\/\* BEGIN __db_re_len_proc/,/^\/\* END __db_re_len_proc/c\
-/* BEGIN __db_re_len_proc */\
-/*\
-\ * PUBLIC: void __db_re_len_proc __P((long, u_int32_t, __db_re_len_reply *));\
-\ */\
-void\
-__db_re_len_proc(dbpcl_id, len, replyp)\
-\	long dbpcl_id;\
-\	u_int32_t len;\
-\	__db_re_len_reply *replyp;\
-/* END __db_re_len_proc */
-/^\/\* BEGIN __db_re_pad_proc/,/^\/\* END __db_re_pad_proc/c\
-/* BEGIN __db_re_pad_proc */\
-/*\
-\ * PUBLIC: void __db_re_pad_proc __P((long, u_int32_t, __db_re_pad_reply *));\
-\ */\
-void\
-__db_re_pad_proc(dbpcl_id, pad, replyp)\
-\	long dbpcl_id;\
-\	u_int32_t pad;\
-\	__db_re_pad_reply *replyp;\
-/* END __db_re_pad_proc */
-/^\/\* BEGIN __db_remove_proc/,/^\/\* END __db_remove_proc/c\
-/* BEGIN __db_remove_proc */\
-/*\
-\ * PUBLIC: void __db_remove_proc __P((long, char *, char *, u_int32_t,\
-\ * PUBLIC:      __db_remove_reply *));\
-\ */\
-void\
-__db_remove_proc(dbpcl_id, name, subdb,\
-\	\	flags, replyp)\
-\	long dbpcl_id;\
-\	char *name;\
-\	char *subdb;\
-\	u_int32_t flags;\
-\	__db_remove_reply *replyp;\
-/* END __db_remove_proc */
-/^\/\* BEGIN __db_rename_proc/,/^\/\* END __db_rename_proc/c\
-/* BEGIN __db_rename_proc */\
-/*\
-\ * PUBLIC: void __db_rename_proc __P((long, char *, char *, char *, u_int32_t,\
-\ * PUBLIC:      __db_rename_reply *));\
-\ */\
-void\
-__db_rename_proc(dbpcl_id, name, subdb,\
-\	\	newname, flags, replyp)\
-\	long dbpcl_id;\
-\	char *name;\
-\	char *subdb;\
-\	char *newname;\
-\	u_int32_t flags;\
-\	__db_rename_reply *replyp;\
-/* END __db_rename_proc */
-/^\/\* BEGIN __db_stat_proc/,/^\/\* END __db_stat_proc/c\
-/* BEGIN __db_stat_proc */\
-/*\
-\ * PUBLIC: void __db_stat_proc __P((long, u_int32_t, __db_stat_reply *,\
-\ * PUBLIC:      int *));\
-\ */\
-void\
-__db_stat_proc(dbpcl_id, flags, replyp, freep)\
-\	long dbpcl_id;\
-\	u_int32_t flags;\
-\	__db_stat_reply *replyp;\
-\	int * freep;\
-/* END __db_stat_proc */
-/^\/\* BEGIN __db_sync_proc/,/^\/\* END __db_sync_proc/c\
-/* BEGIN __db_sync_proc */\
-/*\
-\ * PUBLIC: void __db_sync_proc __P((long, u_int32_t, __db_sync_reply *));\
-\ */\
-void\
-__db_sync_proc(dbpcl_id, flags, replyp)\
-\	long dbpcl_id;\
-\	u_int32_t flags;\
-\	__db_sync_reply *replyp;\
-/* END __db_sync_proc */
-/^\/\* BEGIN __db_truncate_proc/,/^\/\* END __db_truncate_proc/c\
-/* BEGIN __db_truncate_proc */\
-/*\
-\ * PUBLIC: void __db_truncate_proc __P((long, long, u_int32_t,\
-\ * PUBLIC:      __db_truncate_reply *));\
-\ */\
-void\
-__db_truncate_proc(dbpcl_id, txnpcl_id,\
-\	\	flags, replyp)\
-\	long dbpcl_id;\
-\	long txnpcl_id;\
-\	u_int32_t flags;\
-\	__db_truncate_reply *replyp;\
-/* END __db_truncate_proc */
-/^\/\* BEGIN __db_cursor_proc/,/^\/\* END __db_cursor_proc/c\
-/* BEGIN __db_cursor_proc */\
-/*\
-\ * PUBLIC: void __db_cursor_proc __P((long, long, u_int32_t,\
-\ * PUBLIC:      __db_cursor_reply *));\
-\ */\
-void\
-__db_cursor_proc(dbpcl_id, txnpcl_id,\
-\	\	flags, replyp)\
-\	long dbpcl_id;\
-\	long txnpcl_id;\
-\	u_int32_t flags;\
-\	__db_cursor_reply *replyp;\
-/* END __db_cursor_proc */
-/^\/\* BEGIN __db_join_proc/,/^\/\* END __db_join_proc/c\
-/* BEGIN __db_join_proc */\
-/*\
-\ * PUBLIC: void __db_join_proc __P((long, u_int32_t *, u_int32_t, u_int32_t,\
-\ * PUBLIC:      __db_join_reply *));\
-\ */\
-void\
-__db_join_proc(dbpcl_id, curs, curslen,\
-\	\	flags, replyp)\
-\	long dbpcl_id;\
-\	u_int32_t * curs;\
-\	u_int32_t curslen;\
-\	u_int32_t flags;\
-\	__db_join_reply *replyp;\
-/* END __db_join_proc */
-/^\/\* BEGIN __dbc_close_proc/,/^\/\* END __dbc_close_proc/c\
-/* BEGIN __dbc_close_proc */\
-/*\
-\ * PUBLIC: void __dbc_close_proc __P((long, __dbc_close_reply *));\
-\ */\
-void\
-__dbc_close_proc(dbccl_id, replyp)\
-\	long dbccl_id;\
-\	__dbc_close_reply *replyp;\
-/* END __dbc_close_proc */
-/^\/\* BEGIN __dbc_count_proc/,/^\/\* END __dbc_count_proc/c\
-/* BEGIN __dbc_count_proc */\
-/*\
-\ * PUBLIC: void __dbc_count_proc __P((long, u_int32_t, __dbc_count_reply *));\
-\ */\
-void\
-__dbc_count_proc(dbccl_id, flags, replyp)\
-\	long dbccl_id;\
-\	u_int32_t flags;\
-\	__dbc_count_reply *replyp;\
-/* END __dbc_count_proc */
-/^\/\* BEGIN __dbc_del_proc/,/^\/\* END __dbc_del_proc/c\
-/* BEGIN __dbc_del_proc */\
-/*\
-\ * PUBLIC: void __dbc_del_proc __P((long, u_int32_t, __dbc_del_reply *));\
-\ */\
-void\
-__dbc_del_proc(dbccl_id, flags, replyp)\
-\	long dbccl_id;\
-\	u_int32_t flags;\
-\	__dbc_del_reply *replyp;\
-/* END __dbc_del_proc */
-/^\/\* BEGIN __dbc_dup_proc/,/^\/\* END __dbc_dup_proc/c\
-/* BEGIN __dbc_dup_proc */\
-/*\
-\ * PUBLIC: void __dbc_dup_proc __P((long, u_int32_t, __dbc_dup_reply *));\
-\ */\
-void\
-__dbc_dup_proc(dbccl_id, flags, replyp)\
-\	long dbccl_id;\
-\	u_int32_t flags;\
-\	__dbc_dup_reply *replyp;\
-/* END __dbc_dup_proc */
-/^\/\* BEGIN __dbc_get_proc/,/^\/\* END __dbc_get_proc/c\
-/* BEGIN __dbc_get_proc */\
-/*\
-\ * PUBLIC: void __dbc_get_proc __P((long, u_int32_t, u_int32_t, u_int32_t,\
-\ * PUBLIC:      u_int32_t, void *, u_int32_t, u_int32_t, u_int32_t, u_int32_t, u_int32_t, void *,\
-\ * PUBLIC:      u_int32_t, u_int32_t, __dbc_get_reply *, int *));\
-\ */\
-void\
-__dbc_get_proc(dbccl_id, keydlen, keydoff,\
-\	\	keyulen, keyflags, keydata, keysize,\
-\	\	datadlen, datadoff, dataulen, dataflags,\
-\	\	datadata, datasize, flags, replyp, freep)\
-\	long dbccl_id;\
-\	u_int32_t keydlen;\
-\	u_int32_t keydoff;\
-\	u_int32_t keyulen;\
-\	u_int32_t keyflags;\
-\	void *keydata;\
-\	u_int32_t keysize;\
-\	u_int32_t datadlen;\
-\	u_int32_t datadoff;\
-\	u_int32_t dataulen;\
-\	u_int32_t dataflags;\
-\	void *datadata;\
-\	u_int32_t datasize;\
-\	u_int32_t flags;\
-\	__dbc_get_reply *replyp;\
-\	int * freep;\
-/* END __dbc_get_proc */
-/^\/\* BEGIN __dbc_pget_proc/,/^\/\* END __dbc_pget_proc/c\
-/* BEGIN __dbc_pget_proc */\
-/*\
-\ * PUBLIC: void __dbc_pget_proc __P((long, u_int32_t, u_int32_t, u_int32_t,\
-\ * PUBLIC:      u_int32_t, void *, u_int32_t, u_int32_t, u_int32_t, u_int32_t, u_int32_t, void *,\
-\ * PUBLIC:      u_int32_t, u_int32_t, u_int32_t, u_int32_t, u_int32_t, void *, u_int32_t,\
-\ * PUBLIC:      u_int32_t, __dbc_pget_reply *, int *));\
-\ */\
-void\
-__dbc_pget_proc(dbccl_id, skeydlen, skeydoff,\
-\	\	skeyulen, skeyflags, skeydata, skeysize,\
-\	\	pkeydlen, pkeydoff, pkeyulen, pkeyflags,\
-\	\	pkeydata, pkeysize, datadlen, datadoff,\
-\	\	dataulen, dataflags, datadata, datasize,\
-\	\	flags, replyp, freep)\
-\	long dbccl_id;\
-\	u_int32_t skeydlen;\
-\	u_int32_t skeydoff;\
-\	u_int32_t skeyulen;\
-\	u_int32_t skeyflags;\
-\	void *skeydata;\
-\	u_int32_t skeysize;\
-\	u_int32_t pkeydlen;\
-\	u_int32_t pkeydoff;\
-\	u_int32_t pkeyulen;\
-\	u_int32_t pkeyflags;\
-\	void *pkeydata;\
-\	u_int32_t pkeysize;\
-\	u_int32_t datadlen;\
-\	u_int32_t datadoff;\
-\	u_int32_t dataulen;\
-\	u_int32_t dataflags;\
-\	void *datadata;\
-\	u_int32_t datasize;\
-\	u_int32_t flags;\
-\	__dbc_pget_reply *replyp;\
-\	int * freep;\
-/* END __dbc_pget_proc */
-/^\/\* BEGIN __dbc_put_proc/,/^\/\* END __dbc_put_proc/c\
-/* BEGIN __dbc_put_proc */\
-/*\
-\ * PUBLIC: void __dbc_put_proc __P((long, u_int32_t, u_int32_t, u_int32_t,\
-\ * PUBLIC:      u_int32_t, void *, u_int32_t, u_int32_t, u_int32_t, u_int32_t, u_int32_t, void *,\
-\ * PUBLIC:      u_int32_t, u_int32_t, __dbc_put_reply *, int *));\
-\ */\
-void\
-__dbc_put_proc(dbccl_id, keydlen, keydoff,\
-\	\	keyulen, keyflags, keydata, keysize,\
-\	\	datadlen, datadoff, dataulen, dataflags,\
-\	\	datadata, datasize, flags, replyp, freep)\
-\	long dbccl_id;\
-\	u_int32_t keydlen;\
-\	u_int32_t keydoff;\
-\	u_int32_t keyulen;\
-\	u_int32_t keyflags;\
-\	void *keydata;\
-\	u_int32_t keysize;\
-\	u_int32_t datadlen;\
-\	u_int32_t datadoff;\
-\	u_int32_t dataulen;\
-\	u_int32_t dataflags;\
-\	void *datadata;\
-\	u_int32_t datasize;\
-\	u_int32_t flags;\
-\	__dbc_put_reply *replyp;\
-\	int * freep;\
-/* END __dbc_put_proc */
diff --git a/bdb/rpc_server/c/db_server_svc.c b/bdb/rpc_server/c/db_server_svc.c
deleted file mode 100644
index 96dd959ec8c9cc40665f019b56207719185995de..0000000000000000000000000000000000000000
--- a/bdb/rpc_server/c/db_server_svc.c
+++ /dev/null
@@ -1,435 +0,0 @@
-/*
- * Please do not edit this file.
- * It was generated using rpcgen.
- */
-
-#include "db_config.h"
-
-#ifndef NO_SYSTEM_INCLUDES
-#include <rpc/rpc.h>
-#include <rpc/pmap_clnt.h>
-#include <stdio.h>
-#include <stdlib.h> /* getenv, exit */
-#include <memory.h>
-#include <sys/socket.h>
-#include <netinet/in.h>
-#endif
-
-#include "db_int.h"
-#include "dbinc_auto/db_server.h"
-#include "dbinc/db_server_int.h"
-#include "dbinc_auto/rpc_server_ext.h"
-
-#ifdef DEBUG
-#define	RPC_SVC_FG
-#endif
-
-static void
-db_rpc_serverprog_4001(rqstp, transp)
-	struct svc_req *rqstp;
-	register SVCXPRT *transp;
-{
-	union {
-		__env_cachesize_msg __db_env_cachesize_4001_arg;
-		__env_close_msg __db_env_close_4001_arg;
-		__env_create_msg __db_env_create_4001_arg;
-		__env_dbremove_msg __db_env_dbremove_4001_arg;
-		__env_dbrename_msg __db_env_dbrename_4001_arg;
-		__env_encrypt_msg __db_env_encrypt_4001_arg;
-		__env_flags_msg __db_env_flags_4001_arg;
-		__env_open_msg __db_env_open_4001_arg;
-		__env_remove_msg __db_env_remove_4001_arg;
-		__txn_abort_msg __db_txn_abort_4001_arg;
-		__txn_begin_msg __db_txn_begin_4001_arg;
-		__txn_commit_msg __db_txn_commit_4001_arg;
-		__txn_discard_msg __db_txn_discard_4001_arg;
-		__txn_prepare_msg __db_txn_prepare_4001_arg;
-		__txn_recover_msg __db_txn_recover_4001_arg;
-		__db_associate_msg __db_db_associate_4001_arg;
-		__db_bt_maxkey_msg __db_db_bt_maxkey_4001_arg;
-		__db_bt_minkey_msg __db_db_bt_minkey_4001_arg;
-		__db_close_msg __db_db_close_4001_arg;
-		__db_create_msg __db_db_create_4001_arg;
-		__db_del_msg __db_db_del_4001_arg;
-		__db_encrypt_msg __db_db_encrypt_4001_arg;
-		__db_extentsize_msg __db_db_extentsize_4001_arg;
-		__db_flags_msg __db_db_flags_4001_arg;
-		__db_get_msg __db_db_get_4001_arg;
-		__db_h_ffactor_msg __db_db_h_ffactor_4001_arg;
-		__db_h_nelem_msg __db_db_h_nelem_4001_arg;
-		__db_key_range_msg __db_db_key_range_4001_arg;
-		__db_lorder_msg __db_db_lorder_4001_arg;
-		__db_open_msg __db_db_open_4001_arg;
-		__db_pagesize_msg __db_db_pagesize_4001_arg;
-		__db_pget_msg __db_db_pget_4001_arg;
-		__db_put_msg __db_db_put_4001_arg;
-		__db_re_delim_msg __db_db_re_delim_4001_arg;
-		__db_re_len_msg __db_db_re_len_4001_arg;
-		__db_re_pad_msg __db_db_re_pad_4001_arg;
-		__db_remove_msg __db_db_remove_4001_arg;
-		__db_rename_msg __db_db_rename_4001_arg;
-		__db_stat_msg __db_db_stat_4001_arg;
-		__db_sync_msg __db_db_sync_4001_arg;
-		__db_truncate_msg __db_db_truncate_4001_arg;
-		__db_cursor_msg __db_db_cursor_4001_arg;
-		__db_join_msg __db_db_join_4001_arg;
-		__dbc_close_msg __db_dbc_close_4001_arg;
-		__dbc_count_msg __db_dbc_count_4001_arg;
-		__dbc_del_msg __db_dbc_del_4001_arg;
-		__dbc_dup_msg __db_dbc_dup_4001_arg;
-		__dbc_get_msg __db_dbc_get_4001_arg;
-		__dbc_pget_msg __db_dbc_pget_4001_arg;
-		__dbc_put_msg __db_dbc_put_4001_arg;
-	} argument;
-	char *result;
-	bool_t (*xdr_argument)(), (*xdr_result)();
-	char *(*local)();
-
-	switch (rqstp->rq_proc) {
-	case NULLPROC:
-		(void) svc_sendreply(transp, (xdrproc_t)xdr_void,
-			(char *)NULL);
-		return;
-
-	case __DB_env_cachesize:
-		xdr_argument = xdr___env_cachesize_msg;
-		xdr_result = xdr___env_cachesize_reply;
-		local = (char *(*)()) __db_env_cachesize_4001;
-		break;
-
-	case __DB_env_close:
-		xdr_argument = xdr___env_close_msg;
-		xdr_result = xdr___env_close_reply;
-		local = (char *(*)()) __db_env_close_4001;
-		break;
-
-	case __DB_env_create:
-		xdr_argument = xdr___env_create_msg;
-		xdr_result = xdr___env_create_reply;
-		local = (char *(*)()) __db_env_create_4001;
-		break;
-
-	case __DB_env_dbremove:
-		xdr_argument = xdr___env_dbremove_msg;
-		xdr_result = xdr___env_dbremove_reply;
-		local = (char *(*)()) __db_env_dbremove_4001;
-		break;
-
-	case __DB_env_dbrename:
-		xdr_argument = xdr___env_dbrename_msg;
-		xdr_result = xdr___env_dbrename_reply;
-		local = (char *(*)()) __db_env_dbrename_4001;
-		break;
-
-	case __DB_env_encrypt:
-		xdr_argument = xdr___env_encrypt_msg;
-		xdr_result = xdr___env_encrypt_reply;
-		local = (char *(*)()) __db_env_encrypt_4001;
-		break;
-
-	case __DB_env_flags:
-		xdr_argument = xdr___env_flags_msg;
-		xdr_result = xdr___env_flags_reply;
-		local = (char *(*)()) __db_env_flags_4001;
-		break;
-
-	case __DB_env_open:
-		xdr_argument = xdr___env_open_msg;
-		xdr_result = xdr___env_open_reply;
-		local = (char *(*)()) __db_env_open_4001;
-		break;
-
-	case __DB_env_remove:
-		xdr_argument = xdr___env_remove_msg;
-		xdr_result = xdr___env_remove_reply;
-		local = (char *(*)()) __db_env_remove_4001;
-		break;
-
-	case __DB_txn_abort:
-		xdr_argument = xdr___txn_abort_msg;
-		xdr_result = xdr___txn_abort_reply;
-		local = (char *(*)()) __db_txn_abort_4001;
-		break;
-
-	case __DB_txn_begin:
-		xdr_argument = xdr___txn_begin_msg;
-		xdr_result = xdr___txn_begin_reply;
-		local = (char *(*)()) __db_txn_begin_4001;
-		break;
-
-	case __DB_txn_commit:
-		xdr_argument = xdr___txn_commit_msg;
-		xdr_result = xdr___txn_commit_reply;
-		local = (char *(*)()) __db_txn_commit_4001;
-		break;
-
-	case __DB_txn_discard:
-		xdr_argument = xdr___txn_discard_msg;
-		xdr_result = xdr___txn_discard_reply;
-		local = (char *(*)()) __db_txn_discard_4001;
-		break;
-
-	case __DB_txn_prepare:
-		xdr_argument = xdr___txn_prepare_msg;
-		xdr_result = xdr___txn_prepare_reply;
-		local = (char *(*)()) __db_txn_prepare_4001;
-		break;
-
-	case __DB_txn_recover:
-		xdr_argument = xdr___txn_recover_msg;
-		xdr_result = xdr___txn_recover_reply;
-		local = (char *(*)()) __db_txn_recover_4001;
-		break;
-
-	case __DB_db_associate:
-		xdr_argument = xdr___db_associate_msg;
-		xdr_result = xdr___db_associate_reply;
-		local = (char *(*)()) __db_db_associate_4001;
-		break;
-
-	case __DB_db_bt_maxkey:
-		xdr_argument = xdr___db_bt_maxkey_msg;
-		xdr_result = xdr___db_bt_maxkey_reply;
-		local = (char *(*)()) __db_db_bt_maxkey_4001;
-		break;
-
-	case __DB_db_bt_minkey:
-		xdr_argument = xdr___db_bt_minkey_msg;
-		xdr_result = xdr___db_bt_minkey_reply;
-		local = (char *(*)()) __db_db_bt_minkey_4001;
-		break;
-
-	case __DB_db_close:
-		xdr_argument = xdr___db_close_msg;
-		xdr_result = xdr___db_close_reply;
-		local = (char *(*)()) __db_db_close_4001;
-		break;
-
-	case __DB_db_create:
-		xdr_argument = xdr___db_create_msg;
-		xdr_result = xdr___db_create_reply;
-		local = (char *(*)()) __db_db_create_4001;
-		break;
-
-	case __DB_db_del:
-		xdr_argument = xdr___db_del_msg;
-		xdr_result = xdr___db_del_reply;
-		local = (char *(*)()) __db_db_del_4001;
-		break;
-
-	case __DB_db_encrypt:
-		xdr_argument = xdr___db_encrypt_msg;
-		xdr_result = xdr___db_encrypt_reply;
-		local = (char *(*)()) __db_db_encrypt_4001;
-		break;
-
-	case __DB_db_extentsize:
-		xdr_argument = xdr___db_extentsize_msg;
-		xdr_result = xdr___db_extentsize_reply;
-		local = (char *(*)()) __db_db_extentsize_4001;
-		break;
-
-	case __DB_db_flags:
-		xdr_argument = xdr___db_flags_msg;
-		xdr_result = xdr___db_flags_reply;
-		local = (char *(*)()) __db_db_flags_4001;
-		break;
-
-	case __DB_db_get:
-		xdr_argument = xdr___db_get_msg;
-		xdr_result = xdr___db_get_reply;
-		local = (char *(*)()) __db_db_get_4001;
-		break;
-
-	case __DB_db_h_ffactor:
-		xdr_argument = xdr___db_h_ffactor_msg;
-		xdr_result = xdr___db_h_ffactor_reply;
-		local = (char *(*)()) __db_db_h_ffactor_4001;
-		break;
-
-	case __DB_db_h_nelem:
-		xdr_argument = xdr___db_h_nelem_msg;
-		xdr_result = xdr___db_h_nelem_reply;
-		local = (char *(*)()) __db_db_h_nelem_4001;
-		break;
-
-	case __DB_db_key_range:
-		xdr_argument = xdr___db_key_range_msg;
-		xdr_result = xdr___db_key_range_reply;
-		local = (char *(*)()) __db_db_key_range_4001;
-		break;
-
-	case __DB_db_lorder:
-		xdr_argument = xdr___db_lorder_msg;
-		xdr_result = xdr___db_lorder_reply;
-		local = (char *(*)()) __db_db_lorder_4001;
-		break;
-
-	case __DB_db_open:
-		xdr_argument = xdr___db_open_msg;
-		xdr_result = xdr___db_open_reply;
-		local = (char *(*)()) __db_db_open_4001;
-		break;
-
-	case __DB_db_pagesize:
-		xdr_argument = xdr___db_pagesize_msg;
-		xdr_result = xdr___db_pagesize_reply;
-		local = (char *(*)()) __db_db_pagesize_4001;
-		break;
-
-	case __DB_db_pget:
-		xdr_argument = xdr___db_pget_msg;
-		xdr_result = xdr___db_pget_reply;
-		local = (char *(*)()) __db_db_pget_4001;
-		break;
-
-	case __DB_db_put:
-		xdr_argument = xdr___db_put_msg;
-		xdr_result = xdr___db_put_reply;
-		local = (char *(*)()) __db_db_put_4001;
-		break;
-
-	case __DB_db_re_delim:
-		xdr_argument = xdr___db_re_delim_msg;
-		xdr_result = xdr___db_re_delim_reply;
-		local = (char *(*)()) __db_db_re_delim_4001;
-		break;
-
-	case __DB_db_re_len:
-		xdr_argument = xdr___db_re_len_msg;
-		xdr_result = xdr___db_re_len_reply;
-		local = (char *(*)()) __db_db_re_len_4001;
-		break;
-
-	case __DB_db_re_pad:
-		xdr_argument = xdr___db_re_pad_msg;
-		xdr_result = xdr___db_re_pad_reply;
-		local = (char *(*)()) __db_db_re_pad_4001;
-		break;
-
-	case __DB_db_remove:
-		xdr_argument = xdr___db_remove_msg;
-		xdr_result = xdr___db_remove_reply;
-		local = (char *(*)()) __db_db_remove_4001;
-		break;
-
-	case __DB_db_rename:
-		xdr_argument = xdr___db_rename_msg;
-		xdr_result = xdr___db_rename_reply;
-		local = (char *(*)()) __db_db_rename_4001;
-		break;
-
-	case __DB_db_stat:
-		xdr_argument = xdr___db_stat_msg;
-		xdr_result = xdr___db_stat_reply;
-		local = (char *(*)()) __db_db_stat_4001;
-		break;
-
-	case __DB_db_sync:
-		xdr_argument = xdr___db_sync_msg;
-		xdr_result = xdr___db_sync_reply;
-		local = (char *(*)()) __db_db_sync_4001;
-		break;
-
-	case __DB_db_truncate:
-		xdr_argument = xdr___db_truncate_msg;
-		xdr_result = xdr___db_truncate_reply;
-		local = (char *(*)()) __db_db_truncate_4001;
-		break;
-
-	case __DB_db_cursor:
-		xdr_argument = xdr___db_cursor_msg;
-		xdr_result = xdr___db_cursor_reply;
-		local = (char *(*)()) __db_db_cursor_4001;
-		break;
-
-	case __DB_db_join:
-		xdr_argument = xdr___db_join_msg;
-		xdr_result = xdr___db_join_reply;
-		local = (char *(*)()) __db_db_join_4001;
-		break;
-
-	case __DB_dbc_close:
-		xdr_argument = xdr___dbc_close_msg;
-		xdr_result = xdr___dbc_close_reply;
-		local = (char *(*)()) __db_dbc_close_4001;
-		break;
-
-	case __DB_dbc_count:
-		xdr_argument = xdr___dbc_count_msg;
-		xdr_result = xdr___dbc_count_reply;
-		local = (char *(*)()) __db_dbc_count_4001;
-		break;
-
-	case __DB_dbc_del:
-		xdr_argument = xdr___dbc_del_msg;
-		xdr_result = xdr___dbc_del_reply;
-		local = (char *(*)()) __db_dbc_del_4001;
-		break;
-
-	case __DB_dbc_dup:
-		xdr_argument = xdr___dbc_dup_msg;
-		xdr_result = xdr___dbc_dup_reply;
-		local = (char *(*)()) __db_dbc_dup_4001;
-		break;
-
-	case __DB_dbc_get:
-		xdr_argument = xdr___dbc_get_msg;
-		xdr_result = xdr___dbc_get_reply;
-		local = (char *(*)()) __db_dbc_get_4001;
-		break;
-
-	case __DB_dbc_pget:
-		xdr_argument = xdr___dbc_pget_msg;
-		xdr_result = xdr___dbc_pget_reply;
-		local = (char *(*)()) __db_dbc_pget_4001;
-		break;
-
-	case __DB_dbc_put:
-		xdr_argument = xdr___dbc_put_msg;
-		xdr_result = xdr___dbc_put_reply;
-		local = (char *(*)()) __db_dbc_put_4001;
-		break;
-
-	default:
-		svcerr_noproc(transp);
-		return;
-	}
-	(void) memset((char *)&argument, 0, sizeof (argument));
-	if (!svc_getargs(transp, (xdrproc_t)xdr_argument, (char *)&argument)) {
-		svcerr_decode(transp);
-		return;
-	}
-	result = (*local)(&argument, rqstp);
-	if (result != NULL && !svc_sendreply(transp, (xdrproc_t)xdr_result, result)) {
-		svcerr_systemerr(transp);
-	}
-	if (!svc_freeargs(transp, (xdrproc_t)xdr_argument, (char *)&argument)) {
-		fprintf(stderr, "unable to free arguments");
-		exit(1);
-	}
-	__dbsrv_timeout(0);
-	return;
-}
-
-void __dbsrv_main()
-{
-	register SVCXPRT *transp;
-
-	(void) pmap_unset(DB_RPC_SERVERPROG, DB_RPC_SERVERVERS);
-
-	transp = svctcp_create(RPC_ANYSOCK, 0, 0);
-	if (transp == NULL) {
-		fprintf(stderr, "cannot create tcp service.");
-		exit(1);
-	}
-	if (!svc_register(transp, DB_RPC_SERVERPROG, DB_RPC_SERVERVERS, db_rpc_serverprog_4001, IPPROTO_TCP)) {
-		fprintf(stderr, "unable to register (DB_RPC_SERVERPROG, DB_RPC_SERVERVERS, tcp).");
-		exit(1);
-	}
-
-	svc_run();
-	fprintf(stderr, "svc_run returned");
-	exit(1);
-	/* NOTREACHED */
-}
diff --git a/bdb/rpc_server/c/db_server_xdr.c b/bdb/rpc_server/c/db_server_xdr.c
deleted file mode 100644
index bfe2b6c09c75a1679251661fabb1040a110e2c73..0000000000000000000000000000000000000000
--- a/bdb/rpc_server/c/db_server_xdr.c
+++ /dev/null
@@ -1,1512 +0,0 @@
-#include "db_config.h"
-
-#ifdef HAVE_RPC
-/*
- * Please do not edit this file.
- * It was generated using rpcgen.
- */
-
-#ifndef NO_SYSTEM_INCLUDES
-#include <rpc/rpc.h>
-
-#include <strings.h>
-#endif
-
-#include "db_int.h"
-#include "dbinc_auto/db_server.h"
-
-bool_t
-xdr___env_cachesize_msg(xdrs, objp)
-	register XDR *xdrs;
-	__env_cachesize_msg *objp;
-{
-
-	if (!xdr_u_int(xdrs, &objp->dbenvcl_id))
-		return (FALSE);
-	if (!xdr_u_int(xdrs, &objp->gbytes))
-		return (FALSE);
-	if (!xdr_u_int(xdrs, &objp->bytes))
-		return (FALSE);
-	if (!xdr_u_int(xdrs, &objp->ncache))
-		return (FALSE);
-	return (TRUE);
-}
-
-bool_t
-xdr___env_cachesize_reply(xdrs, objp)
-	register XDR *xdrs;
-	__env_cachesize_reply *objp;
-{
-
-	if (!xdr_int(xdrs, &objp->status))
-		return (FALSE);
-	return (TRUE);
-}
-
-bool_t
-xdr___env_close_msg(xdrs, objp)
-	register XDR *xdrs;
-	__env_close_msg *objp;
-{
-
-	if (!xdr_u_int(xdrs, &objp->dbenvcl_id))
-		return (FALSE);
-	if (!xdr_u_int(xdrs, &objp->flags))
-		return (FALSE);
-	return (TRUE);
-}
-
-bool_t
-xdr___env_close_reply(xdrs, objp)
-	register XDR *xdrs;
-	__env_close_reply *objp;
-{
-
-	if (!xdr_int(xdrs, &objp->status))
-		return (FALSE);
-	return (TRUE);
-}
-
-bool_t
-xdr___env_create_msg(xdrs, objp)
-	register XDR *xdrs;
-	__env_create_msg *objp;
-{
-
-	if (!xdr_u_int(xdrs, &objp->timeout))
-		return (FALSE);
-	return (TRUE);
-}
-
-bool_t
-xdr___env_create_reply(xdrs, objp)
-	register XDR *xdrs;
-	__env_create_reply *objp;
-{
-
-	if (!xdr_int(xdrs, &objp->status))
-		return (FALSE);
-	if (!xdr_u_int(xdrs, &objp->envcl_id))
-		return (FALSE);
-	return (TRUE);
-}
-
-bool_t
-xdr___env_dbremove_msg(xdrs, objp)
-	register XDR *xdrs;
-	__env_dbremove_msg *objp;
-{
-
-	if (!xdr_u_int(xdrs, &objp->dbenvcl_id))
-		return (FALSE);
-	if (!xdr_u_int(xdrs, &objp->txnpcl_id))
-		return (FALSE);
-	if (!xdr_string(xdrs, &objp->name, ~0))
-		return (FALSE);
-	if (!xdr_string(xdrs, &objp->subdb, ~0))
-		return (FALSE);
-	if (!xdr_u_int(xdrs, &objp->flags))
-		return (FALSE);
-	return (TRUE);
-}
-
-bool_t
-xdr___env_dbremove_reply(xdrs, objp)
-	register XDR *xdrs;
-	__env_dbremove_reply *objp;
-{
-
-	if (!xdr_int(xdrs, &objp->status))
-		return (FALSE);
-	return (TRUE);
-}
-
-bool_t
-xdr___env_dbrename_msg(xdrs, objp)
-	register XDR *xdrs;
-	__env_dbrename_msg *objp;
-{
-
-	if (!xdr_u_int(xdrs, &objp->dbenvcl_id))
-		return (FALSE);
-	if (!xdr_u_int(xdrs, &objp->txnpcl_id))
-		return (FALSE);
-	if (!xdr_string(xdrs, &objp->name, ~0))
-		return (FALSE);
-	if (!xdr_string(xdrs, &objp->subdb, ~0))
-		return (FALSE);
-	if (!xdr_string(xdrs, &objp->newname, ~0))
-		return (FALSE);
-	if (!xdr_u_int(xdrs, &objp->flags))
-		return (FALSE);
-	return (TRUE);
-}
-
-bool_t
-xdr___env_dbrename_reply(xdrs, objp)
-	register XDR *xdrs;
-	__env_dbrename_reply *objp;
-{
-
-	if (!xdr_int(xdrs, &objp->status))
-		return (FALSE);
-	return (TRUE);
-}
-
-bool_t
-xdr___env_encrypt_msg(xdrs, objp)
-	register XDR *xdrs;
-	__env_encrypt_msg *objp;
-{
-
-	if (!xdr_u_int(xdrs, &objp->dbenvcl_id))
-		return (FALSE);
-	if (!xdr_string(xdrs, &objp->passwd, ~0))
-		return (FALSE);
-	if (!xdr_u_int(xdrs, &objp->flags))
-		return (FALSE);
-	return (TRUE);
-}
-
-bool_t
-xdr___env_encrypt_reply(xdrs, objp)
-	register XDR *xdrs;
-	__env_encrypt_reply *objp;
-{
-
-	if (!xdr_int(xdrs, &objp->status))
-		return (FALSE);
-	return (TRUE);
-}
-
-bool_t
-xdr___env_flags_msg(xdrs, objp)
-	register XDR *xdrs;
-	__env_flags_msg *objp;
-{
-
-	if (!xdr_u_int(xdrs, &objp->dbenvcl_id))
-		return (FALSE);
-	if (!xdr_u_int(xdrs, &objp->flags))
-		return (FALSE);
-	if (!xdr_u_int(xdrs, &objp->onoff))
-		return (FALSE);
-	return (TRUE);
-}
-
-bool_t
-xdr___env_flags_reply(xdrs, objp)
-	register XDR *xdrs;
-	__env_flags_reply *objp;
-{
-
-	if (!xdr_int(xdrs, &objp->status))
-		return (FALSE);
-	return (TRUE);
-}
-
-bool_t
-xdr___env_open_msg(xdrs, objp)
-	register XDR *xdrs;
-	__env_open_msg *objp;
-{
-
-	if (!xdr_u_int(xdrs, &objp->dbenvcl_id))
-		return (FALSE);
-	if (!xdr_string(xdrs, &objp->home, ~0))
-		return (FALSE);
-	if (!xdr_u_int(xdrs, &objp->flags))
-		return (FALSE);
-	if (!xdr_u_int(xdrs, &objp->mode))
-		return (FALSE);
-	return (TRUE);
-}
-
-bool_t
-xdr___env_open_reply(xdrs, objp)
-	register XDR *xdrs;
-	__env_open_reply *objp;
-{
-
-	if (!xdr_int(xdrs, &objp->status))
-		return (FALSE);
-	if (!xdr_u_int(xdrs, &objp->envcl_id))
-		return (FALSE);
-	return (TRUE);
-}
-
-bool_t
-xdr___env_remove_msg(xdrs, objp)
-	register XDR *xdrs;
-	__env_remove_msg *objp;
-{
-
-	if (!xdr_u_int(xdrs, &objp->dbenvcl_id))
-		return (FALSE);
-	if (!xdr_string(xdrs, &objp->home, ~0))
-		return (FALSE);
-	if (!xdr_u_int(xdrs, &objp->flags))
-		return (FALSE);
-	return (TRUE);
-}
-
-bool_t
-xdr___env_remove_reply(xdrs, objp)
-	register XDR *xdrs;
-	__env_remove_reply *objp;
-{
-
-	if (!xdr_int(xdrs, &objp->status))
-		return (FALSE);
-	return (TRUE);
-}
-
-bool_t
-xdr___txn_abort_msg(xdrs, objp)
-	register XDR *xdrs;
-	__txn_abort_msg *objp;
-{
-
-	if (!xdr_u_int(xdrs, &objp->txnpcl_id))
-		return (FALSE);
-	return (TRUE);
-}
-
-bool_t
-xdr___txn_abort_reply(xdrs, objp)
-	register XDR *xdrs;
-	__txn_abort_reply *objp;
-{
-
-	if (!xdr_int(xdrs, &objp->status))
-		return (FALSE);
-	return (TRUE);
-}
-
-bool_t
-xdr___txn_begin_msg(xdrs, objp)
-	register XDR *xdrs;
-	__txn_begin_msg *objp;
-{
-
-	if (!xdr_u_int(xdrs, &objp->dbenvcl_id))
-		return (FALSE);
-	if (!xdr_u_int(xdrs, &objp->parentcl_id))
-		return (FALSE);
-	if (!xdr_u_int(xdrs, &objp->flags))
-		return (FALSE);
-	return (TRUE);
-}
-
-bool_t
-xdr___txn_begin_reply(xdrs, objp)
-	register XDR *xdrs;
-	__txn_begin_reply *objp;
-{
-
-	if (!xdr_int(xdrs, &objp->status))
-		return (FALSE);
-	if (!xdr_u_int(xdrs, &objp->txnidcl_id))
-		return (FALSE);
-	return (TRUE);
-}
-
-bool_t
-xdr___txn_commit_msg(xdrs, objp)
-	register XDR *xdrs;
-	__txn_commit_msg *objp;
-{
-
-	if (!xdr_u_int(xdrs, &objp->txnpcl_id))
-		return (FALSE);
-	if (!xdr_u_int(xdrs, &objp->flags))
-		return (FALSE);
-	return (TRUE);
-}
-
-bool_t
-xdr___txn_commit_reply(xdrs, objp)
-	register XDR *xdrs;
-	__txn_commit_reply *objp;
-{
-
-	if (!xdr_int(xdrs, &objp->status))
-		return (FALSE);
-	return (TRUE);
-}
-
-bool_t
-xdr___txn_discard_msg(xdrs, objp)
-	register XDR *xdrs;
-	__txn_discard_msg *objp;
-{
-
-	if (!xdr_u_int(xdrs, &objp->txnpcl_id))
-		return (FALSE);
-	if (!xdr_u_int(xdrs, &objp->flags))
-		return (FALSE);
-	return (TRUE);
-}
-
-bool_t
-xdr___txn_discard_reply(xdrs, objp)
-	register XDR *xdrs;
-	__txn_discard_reply *objp;
-{
-
-	if (!xdr_int(xdrs, &objp->status))
-		return (FALSE);
-	return (TRUE);
-}
-
-bool_t
-xdr___txn_prepare_msg(xdrs, objp)
-	register XDR *xdrs;
-	__txn_prepare_msg *objp;
-{
-
-	if (!xdr_u_int(xdrs, &objp->txnpcl_id))
-		return (FALSE);
-	if (!xdr_opaque(xdrs, objp->gid, 128))
-		return (FALSE);
-	return (TRUE);
-}
-
-bool_t
-xdr___txn_prepare_reply(xdrs, objp)
-	register XDR *xdrs;
-	__txn_prepare_reply *objp;
-{
-
-	if (!xdr_int(xdrs, &objp->status))
-		return (FALSE);
-	return (TRUE);
-}
-
-bool_t
-xdr___txn_recover_msg(xdrs, objp)
-	register XDR *xdrs;
-	__txn_recover_msg *objp;
-{
-
-	if (!xdr_u_int(xdrs, &objp->dbenvcl_id))
-		return (FALSE);
-	if (!xdr_u_int(xdrs, &objp->count))
-		return (FALSE);
-	if (!xdr_u_int(xdrs, &objp->flags))
-		return (FALSE);
-	return (TRUE);
-}
-
-bool_t
-xdr___txn_recover_reply(xdrs, objp)
-	register XDR *xdrs;
-	__txn_recover_reply *objp;
-{
-
-	if (!xdr_int(xdrs, &objp->status))
-		return (FALSE);
-	if (!xdr_array(xdrs, (char **)&objp->txn.txn_val, (u_int *) &objp->txn.txn_len, ~0,
-		sizeof (u_int), (xdrproc_t) xdr_u_int))
-		return (FALSE);
-	if (!xdr_bytes(xdrs, (char **)&objp->gid.gid_val, (u_int *) &objp->gid.gid_len, ~0))
-		return (FALSE);
-	if (!xdr_u_int(xdrs, &objp->retcount))
-		return (FALSE);
-	return (TRUE);
-}
-
-bool_t
-xdr___db_associate_msg(xdrs, objp)
-	register XDR *xdrs;
-	__db_associate_msg *objp;
-{
-
-	if (!xdr_u_int(xdrs, &objp->dbpcl_id))
-		return (FALSE);
-	if (!xdr_u_int(xdrs, &objp->txnpcl_id))
-		return (FALSE);
-	if (!xdr_u_int(xdrs, &objp->sdbpcl_id))
-		return (FALSE);
-	if (!xdr_u_int(xdrs, &objp->flags))
-		return (FALSE);
-	return (TRUE);
-}
-
-bool_t
-xdr___db_associate_reply(xdrs, objp)
-	register XDR *xdrs;
-	__db_associate_reply *objp;
-{
-
-	if (!xdr_int(xdrs, &objp->status))
-		return (FALSE);
-	return (TRUE);
-}
-
-bool_t
-xdr___db_bt_maxkey_msg(xdrs, objp)
-	register XDR *xdrs;
-	__db_bt_maxkey_msg *objp;
-{
-
-	if (!xdr_u_int(xdrs, &objp->dbpcl_id))
-		return (FALSE);
-	if (!xdr_u_int(xdrs, &objp->maxkey))
-		return (FALSE);
-	return (TRUE);
-}
-
-bool_t
-xdr___db_bt_maxkey_reply(xdrs, objp)
-	register XDR *xdrs;
-	__db_bt_maxkey_reply *objp;
-{
-
-	if (!xdr_int(xdrs, &objp->status))
-		return (FALSE);
-	return (TRUE);
-}
-
-bool_t
-xdr___db_bt_minkey_msg(xdrs, objp)
-	register XDR *xdrs;
-	__db_bt_minkey_msg *objp;
-{
-
-	if (!xdr_u_int(xdrs, &objp->dbpcl_id))
-		return (FALSE);
-	if (!xdr_u_int(xdrs, &objp->minkey))
-		return (FALSE);
-	return (TRUE);
-}
-
-bool_t
-xdr___db_bt_minkey_reply(xdrs, objp)
-	register XDR *xdrs;
-	__db_bt_minkey_reply *objp;
-{
-
-	if (!xdr_int(xdrs, &objp->status))
-		return (FALSE);
-	return (TRUE);
-}
-
-bool_t
-xdr___db_close_msg(xdrs, objp)
-	register XDR *xdrs;
-	__db_close_msg *objp;
-{
-
-	if (!xdr_u_int(xdrs, &objp->dbpcl_id))
-		return (FALSE);
-	if (!xdr_u_int(xdrs, &objp->flags))
-		return (FALSE);
-	return (TRUE);
-}
-
-bool_t
-xdr___db_close_reply(xdrs, objp)
-	register XDR *xdrs;
-	__db_close_reply *objp;
-{
-
-	if (!xdr_int(xdrs, &objp->status))
-		return (FALSE);
-	return (TRUE);
-}
-
-bool_t
-xdr___db_create_msg(xdrs, objp)
-	register XDR *xdrs;
-	__db_create_msg *objp;
-{
-
-	if (!xdr_u_int(xdrs, &objp->dbenvcl_id))
-		return (FALSE);
-	if (!xdr_u_int(xdrs, &objp->flags))
-		return (FALSE);
-	return (TRUE);
-}
-
-bool_t
-xdr___db_create_reply(xdrs, objp)
-	register XDR *xdrs;
-	__db_create_reply *objp;
-{
-
-	if (!xdr_int(xdrs, &objp->status))
-		return (FALSE);
-	if (!xdr_u_int(xdrs, &objp->dbcl_id))
-		return (FALSE);
-	return (TRUE);
-}
-
-bool_t
-xdr___db_del_msg(xdrs, objp)
-	register XDR *xdrs;
-	__db_del_msg *objp;
-{
-
-	if (!xdr_u_int(xdrs, &objp->dbpcl_id))
-		return (FALSE);
-	if (!xdr_u_int(xdrs, &objp->txnpcl_id))
-		return (FALSE);
-	if (!xdr_u_int(xdrs, &objp->keydlen))
-		return (FALSE);
-	if (!xdr_u_int(xdrs, &objp->keydoff))
-		return (FALSE);
-	if (!xdr_u_int(xdrs, &objp->keyulen))
-		return (FALSE);
-	if (!xdr_u_int(xdrs, &objp->keyflags))
-		return (FALSE);
-	if (!xdr_bytes(xdrs, (char **)&objp->keydata.keydata_val, (u_int *) &objp->keydata.keydata_len, ~0))
-		return (FALSE);
-	if (!xdr_u_int(xdrs, &objp->flags))
-		return (FALSE);
-	return (TRUE);
-}
-
-bool_t
-xdr___db_del_reply(xdrs, objp)
-	register XDR *xdrs;
-	__db_del_reply *objp;
-{
-
-	if (!xdr_int(xdrs, &objp->status))
-		return (FALSE);
-	return (TRUE);
-}
-
-bool_t
-xdr___db_encrypt_msg(xdrs, objp)
-	register XDR *xdrs;
-	__db_encrypt_msg *objp;
-{
-
-	if (!xdr_u_int(xdrs, &objp->dbpcl_id))
-		return (FALSE);
-	if (!xdr_string(xdrs, &objp->passwd, ~0))
-		return (FALSE);
-	if (!xdr_u_int(xdrs, &objp->flags))
-		return (FALSE);
-	return (TRUE);
-}
-
-bool_t
-xdr___db_encrypt_reply(xdrs, objp)
-	register XDR *xdrs;
-	__db_encrypt_reply *objp;
-{
-
-	if (!xdr_int(xdrs, &objp->status))
-		return (FALSE);
-	return (TRUE);
-}
-
-bool_t
-xdr___db_extentsize_msg(xdrs, objp)
-	register XDR *xdrs;
-	__db_extentsize_msg *objp;
-{
-
-	if (!xdr_u_int(xdrs, &objp->dbpcl_id))
-		return (FALSE);
-	if (!xdr_u_int(xdrs, &objp->extentsize))
-		return (FALSE);
-	return (TRUE);
-}
-
-bool_t
-xdr___db_extentsize_reply(xdrs, objp)
-	register XDR *xdrs;
-	__db_extentsize_reply *objp;
-{
-
-	if (!xdr_int(xdrs, &objp->status))
-		return (FALSE);
-	return (TRUE);
-}
-
-bool_t
-xdr___db_flags_msg(xdrs, objp)
-	register XDR *xdrs;
-	__db_flags_msg *objp;
-{
-
-	if (!xdr_u_int(xdrs, &objp->dbpcl_id))
-		return (FALSE);
-	if (!xdr_u_int(xdrs, &objp->flags))
-		return (FALSE);
-	return (TRUE);
-}
-
-bool_t
-xdr___db_flags_reply(xdrs, objp)
-	register XDR *xdrs;
-	__db_flags_reply *objp;
-{
-
-	if (!xdr_int(xdrs, &objp->status))
-		return (FALSE);
-	return (TRUE);
-}
-
-bool_t
-xdr___db_get_msg(xdrs, objp)
-	register XDR *xdrs;
-	__db_get_msg *objp;
-{
-
-	if (!xdr_u_int(xdrs, &objp->dbpcl_id))
-		return (FALSE);
-	if (!xdr_u_int(xdrs, &objp->txnpcl_id))
-		return (FALSE);
-	if (!xdr_u_int(xdrs, &objp->keydlen))
-		return (FALSE);
-	if (!xdr_u_int(xdrs, &objp->keydoff))
-		return (FALSE);
-	if (!xdr_u_int(xdrs, &objp->keyulen))
-		return (FALSE);
-	if (!xdr_u_int(xdrs, &objp->keyflags))
-		return (FALSE);
-	if (!xdr_bytes(xdrs, (char **)&objp->keydata.keydata_val, (u_int *) &objp->keydata.keydata_len, ~0))
-		return (FALSE);
-	if (!xdr_u_int(xdrs, &objp->datadlen))
-		return (FALSE);
-	if (!xdr_u_int(xdrs, &objp->datadoff))
-		return (FALSE);
-	if (!xdr_u_int(xdrs, &objp->dataulen))
-		return (FALSE);
-	if (!xdr_u_int(xdrs, &objp->dataflags))
-		return (FALSE);
-	if (!xdr_bytes(xdrs, (char **)&objp->datadata.datadata_val, (u_int *) &objp->datadata.datadata_len, ~0))
-		return (FALSE);
-	if (!xdr_u_int(xdrs, &objp->flags))
-		return (FALSE);
-	return (TRUE);
-}
-
-bool_t
-xdr___db_get_reply(xdrs, objp)
-	register XDR *xdrs;
-	__db_get_reply *objp;
-{
-
-	if (!xdr_int(xdrs, &objp->status))
-		return (FALSE);
-	if (!xdr_bytes(xdrs, (char **)&objp->keydata.keydata_val, (u_int *) &objp->keydata.keydata_len, ~0))
-		return (FALSE);
-	if (!xdr_bytes(xdrs, (char **)&objp->datadata.datadata_val, (u_int *) &objp->datadata.datadata_len, ~0))
-		return (FALSE);
-	return (TRUE);
-}
-
-bool_t
-xdr___db_h_ffactor_msg(xdrs, objp)
-	register XDR *xdrs;
-	__db_h_ffactor_msg *objp;
-{
-
-	if (!xdr_u_int(xdrs, &objp->dbpcl_id))
-		return (FALSE);
-	if (!xdr_u_int(xdrs, &objp->ffactor))
-		return (FALSE);
-	return (TRUE);
-}
-
-bool_t
-xdr___db_h_ffactor_reply(xdrs, objp)
-	register XDR *xdrs;
-	__db_h_ffactor_reply *objp;
-{
-
-	if (!xdr_int(xdrs, &objp->status))
-		return (FALSE);
-	return (TRUE);
-}
-
-bool_t
-xdr___db_h_nelem_msg(xdrs, objp)
-	register XDR *xdrs;
-	__db_h_nelem_msg *objp;
-{
-
-	if (!xdr_u_int(xdrs, &objp->dbpcl_id))
-		return (FALSE);
-	if (!xdr_u_int(xdrs, &objp->nelem))
-		return (FALSE);
-	return (TRUE);
-}
-
-bool_t
-xdr___db_h_nelem_reply(xdrs, objp)
-	register XDR *xdrs;
-	__db_h_nelem_reply *objp;
-{
-
-	if (!xdr_int(xdrs, &objp->status))
-		return (FALSE);
-	return (TRUE);
-}
-
-bool_t
-xdr___db_key_range_msg(xdrs, objp)
-	register XDR *xdrs;
-	__db_key_range_msg *objp;
-{
-
-	if (!xdr_u_int(xdrs, &objp->dbpcl_id))
-		return (FALSE);
-	if (!xdr_u_int(xdrs, &objp->txnpcl_id))
-		return (FALSE);
-	if (!xdr_u_int(xdrs, &objp->keydlen))
-		return (FALSE);
-	if (!xdr_u_int(xdrs, &objp->keydoff))
-		return (FALSE);
-	if (!xdr_u_int(xdrs, &objp->keyulen))
-		return (FALSE);
-	if (!xdr_u_int(xdrs, &objp->keyflags))
-		return (FALSE);
-	if (!xdr_bytes(xdrs, (char **)&objp->keydata.keydata_val, (u_int *) &objp->keydata.keydata_len, ~0))
-		return (FALSE);
-	if (!xdr_u_int(xdrs, &objp->flags))
-		return (FALSE);
-	return (TRUE);
-}
-
-bool_t
-xdr___db_key_range_reply(xdrs, objp)
-	register XDR *xdrs;
-	__db_key_range_reply *objp;
-{
-
-	if (!xdr_int(xdrs, &objp->status))
-		return (FALSE);
-	if (!xdr_double(xdrs, &objp->less))
-		return (FALSE);
-	if (!xdr_double(xdrs, &objp->equal))
-		return (FALSE);
-	if (!xdr_double(xdrs, &objp->greater))
-		return (FALSE);
-	return (TRUE);
-}
-
-bool_t
-xdr___db_lorder_msg(xdrs, objp)
-	register XDR *xdrs;
-	__db_lorder_msg *objp;
-{
-
-	if (!xdr_u_int(xdrs, &objp->dbpcl_id))
-		return (FALSE);
-	if (!xdr_u_int(xdrs, &objp->lorder))
-		return (FALSE);
-	return (TRUE);
-}
-
-bool_t
-xdr___db_lorder_reply(xdrs, objp)
-	register XDR *xdrs;
-	__db_lorder_reply *objp;
-{
-
-	if (!xdr_int(xdrs, &objp->status))
-		return (FALSE);
-	return (TRUE);
-}
-
-bool_t
-xdr___db_open_msg(xdrs, objp)
-	register XDR *xdrs;
-	__db_open_msg *objp;
-{
-
-	if (!xdr_u_int(xdrs, &objp->dbpcl_id))
-		return (FALSE);
-	if (!xdr_u_int(xdrs, &objp->txnpcl_id))
-		return (FALSE);
-	if (!xdr_string(xdrs, &objp->name, ~0))
-		return (FALSE);
-	if (!xdr_string(xdrs, &objp->subdb, ~0))
-		return (FALSE);
-	if (!xdr_u_int(xdrs, &objp->type))
-		return (FALSE);
-	if (!xdr_u_int(xdrs, &objp->flags))
-		return (FALSE);
-	if (!xdr_u_int(xdrs, &objp->mode))
-		return (FALSE);
-	return (TRUE);
-}
-
-bool_t
-xdr___db_open_reply(xdrs, objp)
-	register XDR *xdrs;
-	__db_open_reply *objp;
-{
-
-	if (!xdr_int(xdrs, &objp->status))
-		return (FALSE);
-	if (!xdr_u_int(xdrs, &objp->dbcl_id))
-		return (FALSE);
-	if (!xdr_u_int(xdrs, &objp->type))
-		return (FALSE);
-	if (!xdr_u_int(xdrs, &objp->dbflags))
-		return (FALSE);
-	if (!xdr_u_int(xdrs, &objp->lorder))
-		return (FALSE);
-	return (TRUE);
-}
-
-bool_t
-xdr___db_pagesize_msg(xdrs, objp)
-	register XDR *xdrs;
-	__db_pagesize_msg *objp;
-{
-
-	if (!xdr_u_int(xdrs, &objp->dbpcl_id))
-		return (FALSE);
-	if (!xdr_u_int(xdrs, &objp->pagesize))
-		return (FALSE);
-	return (TRUE);
-}
-
-bool_t
-xdr___db_pagesize_reply(xdrs, objp)
-	register XDR *xdrs;
-	__db_pagesize_reply *objp;
-{
-
-	if (!xdr_int(xdrs, &objp->status))
-		return (FALSE);
-	return (TRUE);
-}
-
-bool_t
-xdr___db_pget_msg(xdrs, objp)
-	register XDR *xdrs;
-	__db_pget_msg *objp;
-{
-
-	if (!xdr_u_int(xdrs, &objp->dbpcl_id))
-		return (FALSE);
-	if (!xdr_u_int(xdrs, &objp->txnpcl_id))
-		return (FALSE);
-	if (!xdr_u_int(xdrs, &objp->skeydlen))
-		return (FALSE);
-	if (!xdr_u_int(xdrs, &objp->skeydoff))
-		return (FALSE);
-	if (!xdr_u_int(xdrs, &objp->skeyulen))
-		return (FALSE);
-	if (!xdr_u_int(xdrs, &objp->skeyflags))
-		return (FALSE);
-	if (!xdr_bytes(xdrs, (char **)&objp->skeydata.skeydata_val, (u_int *) &objp->skeydata.skeydata_len, ~0))
-		return (FALSE);
-	if (!xdr_u_int(xdrs, &objp->pkeydlen))
-		return (FALSE);
-	if (!xdr_u_int(xdrs, &objp->pkeydoff))
-		return (FALSE);
-	if (!xdr_u_int(xdrs, &objp->pkeyulen))
-		return (FALSE);
-	if (!xdr_u_int(xdrs, &objp->pkeyflags))
-		return (FALSE);
-	if (!xdr_bytes(xdrs, (char **)&objp->pkeydata.pkeydata_val, (u_int *) &objp->pkeydata.pkeydata_len, ~0))
-		return (FALSE);
-	if (!xdr_u_int(xdrs, &objp->datadlen))
-		return (FALSE);
-	if (!xdr_u_int(xdrs, &objp->datadoff))
-		return (FALSE);
-	if (!xdr_u_int(xdrs, &objp->dataulen))
-		return (FALSE);
-	if (!xdr_u_int(xdrs, &objp->dataflags))
-		return (FALSE);
-	if (!xdr_bytes(xdrs, (char **)&objp->datadata.datadata_val, (u_int *) &objp->datadata.datadata_len, ~0))
-		return (FALSE);
-	if (!xdr_u_int(xdrs, &objp->flags))
-		return (FALSE);
-	return (TRUE);
-}
-
-bool_t
-xdr___db_pget_reply(xdrs, objp)
-	register XDR *xdrs;
-	__db_pget_reply *objp;
-{
-
-	if (!xdr_int(xdrs, &objp->status))
-		return (FALSE);
-	if (!xdr_bytes(xdrs, (char **)&objp->skeydata.skeydata_val, (u_int *) &objp->skeydata.skeydata_len, ~0))
-		return (FALSE);
-	if (!xdr_bytes(xdrs, (char **)&objp->pkeydata.pkeydata_val, (u_int *) &objp->pkeydata.pkeydata_len, ~0))
-		return (FALSE);
-	if (!xdr_bytes(xdrs, (char **)&objp->datadata.datadata_val, (u_int *) &objp->datadata.datadata_len, ~0))
-		return (FALSE);
-	return (TRUE);
-}
-
-bool_t
-xdr___db_put_msg(xdrs, objp)
-	register XDR *xdrs;
-	__db_put_msg *objp;
-{
-
-	if (!xdr_u_int(xdrs, &objp->dbpcl_id))
-		return (FALSE);
-	if (!xdr_u_int(xdrs, &objp->txnpcl_id))
-		return (FALSE);
-	if (!xdr_u_int(xdrs, &objp->keydlen))
-		return (FALSE);
-	if (!xdr_u_int(xdrs, &objp->keydoff))
-		return (FALSE);
-	if (!xdr_u_int(xdrs, &objp->keyulen))
-		return (FALSE);
-	if (!xdr_u_int(xdrs, &objp->keyflags))
-		return (FALSE);
-	if (!xdr_bytes(xdrs, (char **)&objp->keydata.keydata_val, (u_int *) &objp->keydata.keydata_len, ~0))
-		return (FALSE);
-	if (!xdr_u_int(xdrs, &objp->datadlen))
-		return (FALSE);
-	if (!xdr_u_int(xdrs, &objp->datadoff))
-		return (FALSE);
-	if (!xdr_u_int(xdrs, &objp->dataulen))
-		return (FALSE);
-	if (!xdr_u_int(xdrs, &objp->dataflags))
-		return (FALSE);
-	if (!xdr_bytes(xdrs, (char **)&objp->datadata.datadata_val, (u_int *) &objp->datadata.datadata_len, ~0))
-		return (FALSE);
-	if (!xdr_u_int(xdrs, &objp->flags))
-		return (FALSE);
-	return (TRUE);
-}
-
-bool_t
-xdr___db_put_reply(xdrs, objp)
-	register XDR *xdrs;
-	__db_put_reply *objp;
-{
-
-	if (!xdr_int(xdrs, &objp->status))
-		return (FALSE);
-	if (!xdr_bytes(xdrs, (char **)&objp->keydata.keydata_val, (u_int *) &objp->keydata.keydata_len, ~0))
-		return (FALSE);
-	return (TRUE);
-}
-
-bool_t
-xdr___db_re_delim_msg(xdrs, objp)
-	register XDR *xdrs;
-	__db_re_delim_msg *objp;
-{
-
-	if (!xdr_u_int(xdrs, &objp->dbpcl_id))
-		return (FALSE);
-	if (!xdr_u_int(xdrs, &objp->delim))
-		return (FALSE);
-	return (TRUE);
-}
-
-bool_t
-xdr___db_re_delim_reply(xdrs, objp)
-	register XDR *xdrs;
-	__db_re_delim_reply *objp;
-{
-
-	if (!xdr_int(xdrs, &objp->status))
-		return (FALSE);
-	return (TRUE);
-}
-
-bool_t
-xdr___db_re_len_msg(xdrs, objp)
-	register XDR *xdrs;
-	__db_re_len_msg *objp;
-{
-
-	if (!xdr_u_int(xdrs, &objp->dbpcl_id))
-		return (FALSE);
-	if (!xdr_u_int(xdrs, &objp->len))
-		return (FALSE);
-	return (TRUE);
-}
-
-bool_t
-xdr___db_re_len_reply(xdrs, objp)
-	register XDR *xdrs;
-	__db_re_len_reply *objp;
-{
-
-	if (!xdr_int(xdrs, &objp->status))
-		return (FALSE);
-	return (TRUE);
-}
-
-bool_t
-xdr___db_re_pad_msg(xdrs, objp)
-	register XDR *xdrs;
-	__db_re_pad_msg *objp;
-{
-
-	if (!xdr_u_int(xdrs, &objp->dbpcl_id))
-		return (FALSE);
-	if (!xdr_u_int(xdrs, &objp->pad))
-		return (FALSE);
-	return (TRUE);
-}
-
-bool_t
-xdr___db_re_pad_reply(xdrs, objp)
-	register XDR *xdrs;
-	__db_re_pad_reply *objp;
-{
-
-	if (!xdr_int(xdrs, &objp->status))
-		return (FALSE);
-	return (TRUE);
-}
-
-bool_t
-xdr___db_remove_msg(xdrs, objp)
-	register XDR *xdrs;
-	__db_remove_msg *objp;
-{
-
-	if (!xdr_u_int(xdrs, &objp->dbpcl_id))
-		return (FALSE);
-	if (!xdr_string(xdrs, &objp->name, ~0))
-		return (FALSE);
-	if (!xdr_string(xdrs, &objp->subdb, ~0))
-		return (FALSE);
-	if (!xdr_u_int(xdrs, &objp->flags))
-		return (FALSE);
-	return (TRUE);
-}
-
-bool_t
-xdr___db_remove_reply(xdrs, objp)
-	register XDR *xdrs;
-	__db_remove_reply *objp;
-{
-
-	if (!xdr_int(xdrs, &objp->status))
-		return (FALSE);
-	return (TRUE);
-}
-
-bool_t
-xdr___db_rename_msg(xdrs, objp)
-	register XDR *xdrs;
-	__db_rename_msg *objp;
-{
-
-	if (!xdr_u_int(xdrs, &objp->dbpcl_id))
-		return (FALSE);
-	if (!xdr_string(xdrs, &objp->name, ~0))
-		return (FALSE);
-	if (!xdr_string(xdrs, &objp->subdb, ~0))
-		return (FALSE);
-	if (!xdr_string(xdrs, &objp->newname, ~0))
-		return (FALSE);
-	if (!xdr_u_int(xdrs, &objp->flags))
-		return (FALSE);
-	return (TRUE);
-}
-
-bool_t
-xdr___db_rename_reply(xdrs, objp)
-	register XDR *xdrs;
-	__db_rename_reply *objp;
-{
-
-	if (!xdr_int(xdrs, &objp->status))
-		return (FALSE);
-	return (TRUE);
-}
-
-bool_t
-xdr___db_stat_msg(xdrs, objp)
-	register XDR *xdrs;
-	__db_stat_msg *objp;
-{
-
-	if (!xdr_u_int(xdrs, &objp->dbpcl_id))
-		return (FALSE);
-	if (!xdr_u_int(xdrs, &objp->flags))
-		return (FALSE);
-	return (TRUE);
-}
-
-bool_t
-xdr___db_stat_reply(xdrs, objp)
-	register XDR *xdrs;
-	__db_stat_reply *objp;
-{
-
-	if (!xdr_int(xdrs, &objp->status))
-		return (FALSE);
-	if (!xdr_array(xdrs, (char **)&objp->stats.stats_val, (u_int *) &objp->stats.stats_len, ~0,
-		sizeof (u_int), (xdrproc_t) xdr_u_int))
-		return (FALSE);
-	return (TRUE);
-}
-
-bool_t
-xdr___db_sync_msg(xdrs, objp)
-	register XDR *xdrs;
-	__db_sync_msg *objp;
-{
-
-	if (!xdr_u_int(xdrs, &objp->dbpcl_id))
-		return (FALSE);
-	if (!xdr_u_int(xdrs, &objp->flags))
-		return (FALSE);
-	return (TRUE);
-}
-
-bool_t
-xdr___db_sync_reply(xdrs, objp)
-	register XDR *xdrs;
-	__db_sync_reply *objp;
-{
-
-	if (!xdr_int(xdrs, &objp->status))
-		return (FALSE);
-	return (TRUE);
-}
-
-bool_t
-xdr___db_truncate_msg(xdrs, objp)
-	register XDR *xdrs;
-	__db_truncate_msg *objp;
-{
-
-	if (!xdr_u_int(xdrs, &objp->dbpcl_id))
-		return (FALSE);
-	if (!xdr_u_int(xdrs, &objp->txnpcl_id))
-		return (FALSE);
-	if (!xdr_u_int(xdrs, &objp->flags))
-		return (FALSE);
-	return (TRUE);
-}
-
-bool_t
-xdr___db_truncate_reply(xdrs, objp)
-	register XDR *xdrs;
-	__db_truncate_reply *objp;
-{
-
-	if (!xdr_int(xdrs, &objp->status))
-		return (FALSE);
-	if (!xdr_u_int(xdrs, &objp->count))
-		return (FALSE);
-	return (TRUE);
-}
-
-bool_t
-xdr___db_cursor_msg(xdrs, objp)
-	register XDR *xdrs;
-	__db_cursor_msg *objp;
-{
-
-	if (!xdr_u_int(xdrs, &objp->dbpcl_id))
-		return (FALSE);
-	if (!xdr_u_int(xdrs, &objp->txnpcl_id))
-		return (FALSE);
-	if (!xdr_u_int(xdrs, &objp->flags))
-		return (FALSE);
-	return (TRUE);
-}
-
-bool_t
-xdr___db_cursor_reply(xdrs, objp)
-	register XDR *xdrs;
-	__db_cursor_reply *objp;
-{
-
-	if (!xdr_int(xdrs, &objp->status))
-		return (FALSE);
-	if (!xdr_u_int(xdrs, &objp->dbcidcl_id))
-		return (FALSE);
-	return (TRUE);
-}
-
-bool_t
-xdr___db_join_msg(xdrs, objp)
-	register XDR *xdrs;
-	__db_join_msg *objp;
-{
-
-	if (!xdr_u_int(xdrs, &objp->dbpcl_id))
-		return (FALSE);
-	if (!xdr_array(xdrs, (char **)&objp->curs.curs_val, (u_int *) &objp->curs.curs_len, ~0,
-		sizeof (u_int), (xdrproc_t) xdr_u_int))
-		return (FALSE);
-	if (!xdr_u_int(xdrs, &objp->flags))
-		return (FALSE);
-	return (TRUE);
-}
-
-bool_t
-xdr___db_join_reply(xdrs, objp)
-	register XDR *xdrs;
-	__db_join_reply *objp;
-{
-
-	if (!xdr_int(xdrs, &objp->status))
-		return (FALSE);
-	if (!xdr_u_int(xdrs, &objp->dbcidcl_id))
-		return (FALSE);
-	return (TRUE);
-}
-
-bool_t
-xdr___dbc_close_msg(xdrs, objp)
-	register XDR *xdrs;
-	__dbc_close_msg *objp;
-{
-
-	if (!xdr_u_int(xdrs, &objp->dbccl_id))
-		return (FALSE);
-	return (TRUE);
-}
-
-bool_t
-xdr___dbc_close_reply(xdrs, objp)
-	register XDR *xdrs;
-	__dbc_close_reply *objp;
-{
-
-	if (!xdr_int(xdrs, &objp->status))
-		return (FALSE);
-	return (TRUE);
-}
-
-bool_t
-xdr___dbc_count_msg(xdrs, objp)
-	register XDR *xdrs;
-	__dbc_count_msg *objp;
-{
-
-	if (!xdr_u_int(xdrs, &objp->dbccl_id))
-		return (FALSE);
-	if (!xdr_u_int(xdrs, &objp->flags))
-		return (FALSE);
-	return (TRUE);
-}
-
-bool_t
-xdr___dbc_count_reply(xdrs, objp)
-	register XDR *xdrs;
-	__dbc_count_reply *objp;
-{
-
-	if (!xdr_int(xdrs, &objp->status))
-		return (FALSE);
-	if (!xdr_u_int(xdrs, &objp->dupcount))
-		return (FALSE);
-	return (TRUE);
-}
-
-bool_t
-xdr___dbc_del_msg(xdrs, objp)
-	register XDR *xdrs;
-	__dbc_del_msg *objp;
-{
-
-	if (!xdr_u_int(xdrs, &objp->dbccl_id))
-		return (FALSE);
-	if (!xdr_u_int(xdrs, &objp->flags))
-		return (FALSE);
-	return (TRUE);
-}
-
-bool_t
-xdr___dbc_del_reply(xdrs, objp)
-	register XDR *xdrs;
-	__dbc_del_reply *objp;
-{
-
-	if (!xdr_int(xdrs, &objp->status))
-		return (FALSE);
-	return (TRUE);
-}
-
-bool_t
-xdr___dbc_dup_msg(xdrs, objp)
-	register XDR *xdrs;
-	__dbc_dup_msg *objp;
-{
-
-	if (!xdr_u_int(xdrs, &objp->dbccl_id))
-		return (FALSE);
-	if (!xdr_u_int(xdrs, &objp->flags))
-		return (FALSE);
-	return (TRUE);
-}
-
-bool_t
-xdr___dbc_dup_reply(xdrs, objp)
-	register XDR *xdrs;
-	__dbc_dup_reply *objp;
-{
-
-	if (!xdr_int(xdrs, &objp->status))
-		return (FALSE);
-	if (!xdr_u_int(xdrs, &objp->dbcidcl_id))
-		return (FALSE);
-	return (TRUE);
-}
-
-bool_t
-xdr___dbc_get_msg(xdrs, objp)
-	register XDR *xdrs;
-	__dbc_get_msg *objp;
-{
-
-	if (!xdr_u_int(xdrs, &objp->dbccl_id))
-		return (FALSE);
-	if (!xdr_u_int(xdrs, &objp->keydlen))
-		return (FALSE);
-	if (!xdr_u_int(xdrs, &objp->keydoff))
-		return (FALSE);
-	if (!xdr_u_int(xdrs, &objp->keyulen))
-		return (FALSE);
-	if (!xdr_u_int(xdrs, &objp->keyflags))
-		return (FALSE);
-	if (!xdr_bytes(xdrs, (char **)&objp->keydata.keydata_val, (u_int *) &objp->keydata.keydata_len, ~0))
-		return (FALSE);
-	if (!xdr_u_int(xdrs, &objp->datadlen))
-		return (FALSE);
-	if (!xdr_u_int(xdrs, &objp->datadoff))
-		return (FALSE);
-	if (!xdr_u_int(xdrs, &objp->dataulen))
-		return (FALSE);
-	if (!xdr_u_int(xdrs, &objp->dataflags))
-		return (FALSE);
-	if (!xdr_bytes(xdrs, (char **)&objp->datadata.datadata_val, (u_int *) &objp->datadata.datadata_len, ~0))
-		return (FALSE);
-	if (!xdr_u_int(xdrs, &objp->flags))
-		return (FALSE);
-	return (TRUE);
-}
-
-bool_t
-xdr___dbc_get_reply(xdrs, objp)
-	register XDR *xdrs;
-	__dbc_get_reply *objp;
-{
-
-	if (!xdr_int(xdrs, &objp->status))
-		return (FALSE);
-	if (!xdr_bytes(xdrs, (char **)&objp->keydata.keydata_val, (u_int *) &objp->keydata.keydata_len, ~0))
-		return (FALSE);
-	if (!xdr_bytes(xdrs, (char **)&objp->datadata.datadata_val, (u_int *) &objp->datadata.datadata_len, ~0))
-		return (FALSE);
-	return (TRUE);
-}
-
-bool_t
-xdr___dbc_pget_msg(xdrs, objp)
-	register XDR *xdrs;
-	__dbc_pget_msg *objp;
-{
-
-	if (!xdr_u_int(xdrs, &objp->dbccl_id))
-		return (FALSE);
-	if (!xdr_u_int(xdrs, &objp->skeydlen))
-		return (FALSE);
-	if (!xdr_u_int(xdrs, &objp->skeydoff))
-		return (FALSE);
-	if (!xdr_u_int(xdrs, &objp->skeyulen))
-		return (FALSE);
-	if (!xdr_u_int(xdrs, &objp->skeyflags))
-		return (FALSE);
-	if (!xdr_bytes(xdrs, (char **)&objp->skeydata.skeydata_val, (u_int *) &objp->skeydata.skeydata_len, ~0))
-		return (FALSE);
-	if (!xdr_u_int(xdrs, &objp->pkeydlen))
-		return (FALSE);
-	if (!xdr_u_int(xdrs, &objp->pkeydoff))
-		return (FALSE);
-	if (!xdr_u_int(xdrs, &objp->pkeyulen))
-		return (FALSE);
-	if (!xdr_u_int(xdrs, &objp->pkeyflags))
-		return (FALSE);
-	if (!xdr_bytes(xdrs, (char **)&objp->pkeydata.pkeydata_val, (u_int *) &objp->pkeydata.pkeydata_len, ~0))
-		return (FALSE);
-	if (!xdr_u_int(xdrs, &objp->datadlen))
-		return (FALSE);
-	if (!xdr_u_int(xdrs, &objp->datadoff))
-		return (FALSE);
-	if (!xdr_u_int(xdrs, &objp->dataulen))
-		return (FALSE);
-	if (!xdr_u_int(xdrs, &objp->dataflags))
-		return (FALSE);
-	if (!xdr_bytes(xdrs, (char **)&objp->datadata.datadata_val, (u_int *) &objp->datadata.datadata_len, ~0))
-		return (FALSE);
-	if (!xdr_u_int(xdrs, &objp->flags))
-		return (FALSE);
-	return (TRUE);
-}
-
-bool_t
-xdr___dbc_pget_reply(xdrs, objp)
-	register XDR *xdrs;
-	__dbc_pget_reply *objp;
-{
-
-	if (!xdr_int(xdrs, &objp->status))
-		return (FALSE);
-	if (!xdr_bytes(xdrs, (char **)&objp->skeydata.skeydata_val, (u_int *) &objp->skeydata.skeydata_len, ~0))
-		return (FALSE);
-	if (!xdr_bytes(xdrs, (char **)&objp->pkeydata.pkeydata_val, (u_int *) &objp->pkeydata.pkeydata_len, ~0))
-		return (FALSE);
-	if (!xdr_bytes(xdrs, (char **)&objp->datadata.datadata_val, (u_int *) &objp->datadata.datadata_len, ~0))
-		return (FALSE);
-	return (TRUE);
-}
-
-bool_t
-xdr___dbc_put_msg(xdrs, objp)
-	register XDR *xdrs;
-	__dbc_put_msg *objp;
-{
-
-	if (!xdr_u_int(xdrs, &objp->dbccl_id))
-		return (FALSE);
-	if (!xdr_u_int(xdrs, &objp->keydlen))
-		return (FALSE);
-	if (!xdr_u_int(xdrs, &objp->keydoff))
-		return (FALSE);
-	if (!xdr_u_int(xdrs, &objp->keyulen))
-		return (FALSE);
-	if (!xdr_u_int(xdrs, &objp->keyflags))
-		return (FALSE);
-	if (!xdr_bytes(xdrs, (char **)&objp->keydata.keydata_val, (u_int *) &objp->keydata.keydata_len, ~0))
-		return (FALSE);
-	if (!xdr_u_int(xdrs, &objp->datadlen))
-		return (FALSE);
-	if (!xdr_u_int(xdrs, &objp->datadoff))
-		return (FALSE);
-	if (!xdr_u_int(xdrs, &objp->dataulen))
-		return (FALSE);
-	if (!xdr_u_int(xdrs, &objp->dataflags))
-		return (FALSE);
-	if (!xdr_bytes(xdrs, (char **)&objp->datadata.datadata_val, (u_int *) &objp->datadata.datadata_len, ~0))
-		return (FALSE);
-	if (!xdr_u_int(xdrs, &objp->flags))
-		return (FALSE);
-	return (TRUE);
-}
-
-bool_t
-xdr___dbc_put_reply(xdrs, objp)
-	register XDR *xdrs;
-	__dbc_put_reply *objp;
-{
-
-	if (!xdr_int(xdrs, &objp->status))
-		return (FALSE);
-	if (!xdr_bytes(xdrs, (char **)&objp->keydata.keydata_val, (u_int *) &objp->keydata.keydata_len, ~0))
-		return (FALSE);
-	return (TRUE);
-}
-#endif /* HAVE_RPC */
diff --git a/bdb/rpc_server/c/gen_db_server.c b/bdb/rpc_server/c/gen_db_server.c
deleted file mode 100644
index 0181fb06dce73cab62b3b106daaa9544d95210e0..0000000000000000000000000000000000000000
--- a/bdb/rpc_server/c/gen_db_server.c
+++ /dev/null
@@ -1,1169 +0,0 @@
-/* Do not edit: automatically built by gen_rpc.awk. */
-#include "db_config.h"
-
-#ifndef NO_SYSTEM_INCLUDES
-#include <sys/types.h>
-
-#include <rpc/rpc.h>
-#include <rpc/xdr.h>
-
-#include <string.h>
-#endif
-
-#include "db_int.h"
-#include "dbinc_auto/db_server.h"
-#include "dbinc/db_server_int.h"
-#include "dbinc_auto/rpc_server_ext.h"
-
-/*
- * PUBLIC: __env_cachesize_reply *__db_env_cachesize_4001 
- * PUBLIC:     __P((__env_cachesize_msg *, struct svc_req *));
- */
-__env_cachesize_reply *
-__db_env_cachesize_4001(msg, req)
-	__env_cachesize_msg *msg;
-	struct svc_req *req;
-{
-	static __env_cachesize_reply reply; /* must be static */
-	COMPQUIET(req, NULL);
-
-	__env_cachesize_proc(msg->dbenvcl_id,
-	    msg->gbytes,
-	    msg->bytes,
-	    msg->ncache,
-	    &reply);
-
-	return (&reply);
-}
-
-/*
- * PUBLIC: __env_close_reply *__db_env_close_4001 __P((__env_close_msg *,
- * PUBLIC:      struct svc_req *));
- */
-__env_close_reply *
-__db_env_close_4001(msg, req)
-	__env_close_msg *msg;
-	struct svc_req *req;
-{
-	static __env_close_reply reply; /* must be static */
-	COMPQUIET(req, NULL);
-
-	__env_close_proc(msg->dbenvcl_id,
-	    msg->flags,
-	    &reply);
-
-	return (&reply);
-}
-
-/*
- * PUBLIC: __env_create_reply *__db_env_create_4001 __P((__env_create_msg *,
- * PUBLIC:      struct svc_req *));
- */
-__env_create_reply *
-__db_env_create_4001(msg, req)
-	__env_create_msg *msg;
-	struct svc_req *req;
-{
-	static __env_create_reply reply; /* must be static */
-	COMPQUIET(req, NULL);
-
-	__env_create_proc(msg->timeout,
-	    &reply);
-
-	return (&reply);
-}
-
-/*
- * PUBLIC: __env_dbremove_reply *__db_env_dbremove_4001 
- * PUBLIC:     __P((__env_dbremove_msg *, struct svc_req *));
- */
-__env_dbremove_reply *
-__db_env_dbremove_4001(msg, req)
-	__env_dbremove_msg *msg;
-	struct svc_req *req;
-{
-	static __env_dbremove_reply reply; /* must be static */
-	COMPQUIET(req, NULL);
-
-	__env_dbremove_proc(msg->dbenvcl_id,
-	    msg->txnpcl_id,
-	    (*msg->name == '\0') ? NULL : msg->name,
-	    (*msg->subdb == '\0') ? NULL : msg->subdb,
-	    msg->flags,
-	    &reply);
-
-	return (&reply);
-}
-
-/*
- * PUBLIC: __env_dbrename_reply *__db_env_dbrename_4001 
- * PUBLIC:     __P((__env_dbrename_msg *, struct svc_req *));
- */
-__env_dbrename_reply *
-__db_env_dbrename_4001(msg, req)
-	__env_dbrename_msg *msg;
-	struct svc_req *req;
-{
-	static __env_dbrename_reply reply; /* must be static */
-	COMPQUIET(req, NULL);
-
-	__env_dbrename_proc(msg->dbenvcl_id,
-	    msg->txnpcl_id,
-	    (*msg->name == '\0') ? NULL : msg->name,
-	    (*msg->subdb == '\0') ? NULL : msg->subdb,
-	    (*msg->newname == '\0') ? NULL : msg->newname,
-	    msg->flags,
-	    &reply);
-
-	return (&reply);
-}
-
-/*
- * PUBLIC: __env_encrypt_reply *__db_env_encrypt_4001 
- * PUBLIC:     __P((__env_encrypt_msg *, struct svc_req *));
- */
-__env_encrypt_reply *
-__db_env_encrypt_4001(msg, req)
-	__env_encrypt_msg *msg;
-	struct svc_req *req;
-{
-	static __env_encrypt_reply reply; /* must be static */
-	COMPQUIET(req, NULL);
-
-	__env_encrypt_proc(msg->dbenvcl_id,
-	    (*msg->passwd == '\0') ? NULL : msg->passwd,
-	    msg->flags,
-	    &reply);
-
-	return (&reply);
-}
-
-/*
- * PUBLIC: __env_flags_reply *__db_env_flags_4001 __P((__env_flags_msg *,
- * PUBLIC:      struct svc_req *));
- */
-__env_flags_reply *
-__db_env_flags_4001(msg, req)
-	__env_flags_msg *msg;
-	struct svc_req *req;
-{
-	static __env_flags_reply reply; /* must be static */
-	COMPQUIET(req, NULL);
-
-	__env_flags_proc(msg->dbenvcl_id,
-	    msg->flags,
-	    msg->onoff,
-	    &reply);
-
-	return (&reply);
-}
-
-/*
- * PUBLIC: __env_open_reply *__db_env_open_4001 __P((__env_open_msg *,
- * PUBLIC:      struct svc_req *));
- */
-__env_open_reply *
-__db_env_open_4001(msg, req)
-	__env_open_msg *msg;
-	struct svc_req *req;
-{
-	static __env_open_reply reply; /* must be static */
-	COMPQUIET(req, NULL);
-
-	__env_open_proc(msg->dbenvcl_id,
-	    (*msg->home == '\0') ? NULL : msg->home,
-	    msg->flags,
-	    msg->mode,
-	    &reply);
-
-	return (&reply);
-}
-
-/*
- * PUBLIC: __env_remove_reply *__db_env_remove_4001 __P((__env_remove_msg *,
- * PUBLIC:      struct svc_req *));
- */
-__env_remove_reply *
-__db_env_remove_4001(msg, req)
-	__env_remove_msg *msg;
-	struct svc_req *req;
-{
-	static __env_remove_reply reply; /* must be static */
-	COMPQUIET(req, NULL);
-
-	__env_remove_proc(msg->dbenvcl_id,
-	    (*msg->home == '\0') ? NULL : msg->home,
-	    msg->flags,
-	    &reply);
-
-	return (&reply);
-}
-
-/*
- * PUBLIC: __txn_abort_reply *__db_txn_abort_4001 __P((__txn_abort_msg *,
- * PUBLIC:      struct svc_req *));
- */
-__txn_abort_reply *
-__db_txn_abort_4001(msg, req)
-	__txn_abort_msg *msg;
-	struct svc_req *req;
-{
-	static __txn_abort_reply reply; /* must be static */
-	COMPQUIET(req, NULL);
-
-	__txn_abort_proc(msg->txnpcl_id,
-	    &reply);
-
-	return (&reply);
-}
-
-/*
- * PUBLIC: __txn_begin_reply *__db_txn_begin_4001 __P((__txn_begin_msg *,
- * PUBLIC:      struct svc_req *));
- */
-__txn_begin_reply *
-__db_txn_begin_4001(msg, req)
-	__txn_begin_msg *msg;
-	struct svc_req *req;
-{
-	static __txn_begin_reply reply; /* must be static */
-	COMPQUIET(req, NULL);
-
-	__txn_begin_proc(msg->dbenvcl_id,
-	    msg->parentcl_id,
-	    msg->flags,
-	    &reply);
-
-	return (&reply);
-}
-
-/*
- * PUBLIC: __txn_commit_reply *__db_txn_commit_4001 __P((__txn_commit_msg *,
- * PUBLIC:      struct svc_req *));
- */
-__txn_commit_reply *
-__db_txn_commit_4001(msg, req)
-	__txn_commit_msg *msg;
-	struct svc_req *req;
-{
-	static __txn_commit_reply reply; /* must be static */
-	COMPQUIET(req, NULL);
-
-	__txn_commit_proc(msg->txnpcl_id,
-	    msg->flags,
-	    &reply);
-
-	return (&reply);
-}
-
-/*
- * PUBLIC: __txn_discard_reply *__db_txn_discard_4001 
- * PUBLIC:     __P((__txn_discard_msg *, struct svc_req *));
- */
-__txn_discard_reply *
-__db_txn_discard_4001(msg, req)
-	__txn_discard_msg *msg;
-	struct svc_req *req;
-{
-	static __txn_discard_reply reply; /* must be static */
-	COMPQUIET(req, NULL);
-
-	__txn_discard_proc(msg->txnpcl_id,
-	    msg->flags,
-	    &reply);
-
-	return (&reply);
-}
-
-/*
- * PUBLIC: __txn_prepare_reply *__db_txn_prepare_4001 
- * PUBLIC:     __P((__txn_prepare_msg *, struct svc_req *));
- */
-__txn_prepare_reply *
-__db_txn_prepare_4001(msg, req)
-	__txn_prepare_msg *msg;
-	struct svc_req *req;
-{
-	static __txn_prepare_reply reply; /* must be static */
-	COMPQUIET(req, NULL);
-
-	__txn_prepare_proc(msg->txnpcl_id,
-	    msg->gid,
-	    &reply);
-
-	return (&reply);
-}
-
-/*
- * PUBLIC: __txn_recover_reply *__db_txn_recover_4001 
- * PUBLIC:     __P((__txn_recover_msg *, struct svc_req *));
- */
-__txn_recover_reply *
-__db_txn_recover_4001(msg, req)
-	__txn_recover_msg *msg;
-	struct svc_req *req;
-{
-	static __txn_recover_reply reply; /* must be static */
-	static int __txn_recover_free = 0; /* must be static */
-
-	COMPQUIET(req, NULL);
-	if (__txn_recover_free)
-		xdr_free((xdrproc_t)xdr___txn_recover_reply, (void *)&reply);
-	__txn_recover_free = 0;
-
-	/* Reinitialize allocated fields */
-	reply.txn.txn_val = NULL;
-	reply.gid.gid_val = NULL;
-
-	__txn_recover_proc(msg->dbenvcl_id,
-	    msg->count,
-	    msg->flags,
-	    &reply,
-	    &__txn_recover_free);
-	return (&reply);
-}
-
-/*
- * PUBLIC: __db_associate_reply *__db_db_associate_4001 
- * PUBLIC:     __P((__db_associate_msg *, struct svc_req *));
- */
-__db_associate_reply *
-__db_db_associate_4001(msg, req)
-	__db_associate_msg *msg;
-	struct svc_req *req;
-{
-	static __db_associate_reply reply; /* must be static */
-	COMPQUIET(req, NULL);
-
-	__db_associate_proc(msg->dbpcl_id,
-	    msg->txnpcl_id,
-	    msg->sdbpcl_id,
-	    msg->flags,
-	    &reply);
-
-	return (&reply);
-}
-
-/*
- * PUBLIC: __db_bt_maxkey_reply *__db_db_bt_maxkey_4001 
- * PUBLIC:     __P((__db_bt_maxkey_msg *, struct svc_req *));
- */
-__db_bt_maxkey_reply *
-__db_db_bt_maxkey_4001(msg, req)
-	__db_bt_maxkey_msg *msg;
-	struct svc_req *req;
-{
-	static __db_bt_maxkey_reply reply; /* must be static */
-	COMPQUIET(req, NULL);
-
-	__db_bt_maxkey_proc(msg->dbpcl_id,
-	    msg->maxkey,
-	    &reply);
-
-	return (&reply);
-}
-
-/*
- * PUBLIC: __db_bt_minkey_reply *__db_db_bt_minkey_4001 
- * PUBLIC:     __P((__db_bt_minkey_msg *, struct svc_req *));
- */
-__db_bt_minkey_reply *
-__db_db_bt_minkey_4001(msg, req)
-	__db_bt_minkey_msg *msg;
-	struct svc_req *req;
-{
-	static __db_bt_minkey_reply reply; /* must be static */
-	COMPQUIET(req, NULL);
-
-	__db_bt_minkey_proc(msg->dbpcl_id,
-	    msg->minkey,
-	    &reply);
-
-	return (&reply);
-}
-
-/*
- * PUBLIC: __db_close_reply *__db_db_close_4001 __P((__db_close_msg *,
- * PUBLIC:      struct svc_req *));
- */
-__db_close_reply *
-__db_db_close_4001(msg, req)
-	__db_close_msg *msg;
-	struct svc_req *req;
-{
-	static __db_close_reply reply; /* must be static */
-	COMPQUIET(req, NULL);
-
-	__db_close_proc(msg->dbpcl_id,
-	    msg->flags,
-	    &reply);
-
-	return (&reply);
-}
-
-/*
- * PUBLIC: __db_create_reply *__db_db_create_4001 __P((__db_create_msg *,
- * PUBLIC:      struct svc_req *));
- */
-__db_create_reply *
-__db_db_create_4001(msg, req)
-	__db_create_msg *msg;
-	struct svc_req *req;
-{
-	static __db_create_reply reply; /* must be static */
-	COMPQUIET(req, NULL);
-
-	__db_create_proc(msg->dbenvcl_id,
-	    msg->flags,
-	    &reply);
-
-	return (&reply);
-}
-
-/*
- * PUBLIC: __db_del_reply *__db_db_del_4001 __P((__db_del_msg *,
- * PUBLIC:      struct svc_req *));
- */
-__db_del_reply *
-__db_db_del_4001(msg, req)
-	__db_del_msg *msg;
-	struct svc_req *req;
-{
-	static __db_del_reply reply; /* must be static */
-	COMPQUIET(req, NULL);
-
-	__db_del_proc(msg->dbpcl_id,
-	    msg->txnpcl_id,
-	    msg->keydlen,
-	    msg->keydoff,
-	    msg->keyulen,
-	    msg->keyflags,
-	    msg->keydata.keydata_val,
-	    msg->keydata.keydata_len,
-	    msg->flags,
-	    &reply);
-
-	return (&reply);
-}
-
-/*
- * PUBLIC: __db_encrypt_reply *__db_db_encrypt_4001 __P((__db_encrypt_msg *,
- * PUBLIC:      struct svc_req *));
- */
-__db_encrypt_reply *
-__db_db_encrypt_4001(msg, req)
-	__db_encrypt_msg *msg;
-	struct svc_req *req;
-{
-	static __db_encrypt_reply reply; /* must be static */
-	COMPQUIET(req, NULL);
-
-	__db_encrypt_proc(msg->dbpcl_id,
-	    (*msg->passwd == '\0') ? NULL : msg->passwd,
-	    msg->flags,
-	    &reply);
-
-	return (&reply);
-}
-
-/*
- * PUBLIC: __db_extentsize_reply *__db_db_extentsize_4001 
- * PUBLIC:     __P((__db_extentsize_msg *, struct svc_req *));
- */
-__db_extentsize_reply *
-__db_db_extentsize_4001(msg, req)
-	__db_extentsize_msg *msg;
-	struct svc_req *req;
-{
-	static __db_extentsize_reply reply; /* must be static */
-	COMPQUIET(req, NULL);
-
-	__db_extentsize_proc(msg->dbpcl_id,
-	    msg->extentsize,
-	    &reply);
-
-	return (&reply);
-}
-
-/*
- * PUBLIC: __db_flags_reply *__db_db_flags_4001 __P((__db_flags_msg *,
- * PUBLIC:      struct svc_req *));
- */
-__db_flags_reply *
-__db_db_flags_4001(msg, req)
-	__db_flags_msg *msg;
-	struct svc_req *req;
-{
-	static __db_flags_reply reply; /* must be static */
-	COMPQUIET(req, NULL);
-
-	__db_flags_proc(msg->dbpcl_id,
-	    msg->flags,
-	    &reply);
-
-	return (&reply);
-}
-
-/*
- * PUBLIC: __db_get_reply *__db_db_get_4001 __P((__db_get_msg *,
- * PUBLIC:      struct svc_req *));
- */
-__db_get_reply *
-__db_db_get_4001(msg, req)
-	__db_get_msg *msg;
-	struct svc_req *req;
-{
-	static __db_get_reply reply; /* must be static */
-	static int __db_get_free = 0; /* must be static */
-
-	COMPQUIET(req, NULL);
-	if (__db_get_free)
-		xdr_free((xdrproc_t)xdr___db_get_reply, (void *)&reply);
-	__db_get_free = 0;
-
-	/* Reinitialize allocated fields */
-	reply.keydata.keydata_val = NULL;
-	reply.datadata.datadata_val = NULL;
-
-	__db_get_proc(msg->dbpcl_id,
-	    msg->txnpcl_id,
-	    msg->keydlen,
-	    msg->keydoff,
-	    msg->keyulen,
-	    msg->keyflags,
-	    msg->keydata.keydata_val,
-	    msg->keydata.keydata_len,
-	    msg->datadlen,
-	    msg->datadoff,
-	    msg->dataulen,
-	    msg->dataflags,
-	    msg->datadata.datadata_val,
-	    msg->datadata.datadata_len,
-	    msg->flags,
-	    &reply,
-	    &__db_get_free);
-	return (&reply);
-}
-
-/*
- * PUBLIC: __db_h_ffactor_reply *__db_db_h_ffactor_4001 
- * PUBLIC:     __P((__db_h_ffactor_msg *, struct svc_req *));
- */
-__db_h_ffactor_reply *
-__db_db_h_ffactor_4001(msg, req)
-	__db_h_ffactor_msg *msg;
-	struct svc_req *req;
-{
-	static __db_h_ffactor_reply reply; /* must be static */
-	COMPQUIET(req, NULL);
-
-	__db_h_ffactor_proc(msg->dbpcl_id,
-	    msg->ffactor,
-	    &reply);
-
-	return (&reply);
-}
-
-/*
- * PUBLIC: __db_h_nelem_reply *__db_db_h_nelem_4001 __P((__db_h_nelem_msg *,
- * PUBLIC:      struct svc_req *));
- */
-__db_h_nelem_reply *
-__db_db_h_nelem_4001(msg, req)
-	__db_h_nelem_msg *msg;
-	struct svc_req *req;
-{
-	static __db_h_nelem_reply reply; /* must be static */
-	COMPQUIET(req, NULL);
-
-	__db_h_nelem_proc(msg->dbpcl_id,
-	    msg->nelem,
-	    &reply);
-
-	return (&reply);
-}
-
-/*
- * PUBLIC: __db_key_range_reply *__db_db_key_range_4001 
- * PUBLIC:     __P((__db_key_range_msg *, struct svc_req *));
- */
-__db_key_range_reply *
-__db_db_key_range_4001(msg, req)
-	__db_key_range_msg *msg;
-	struct svc_req *req;
-{
-	static __db_key_range_reply reply; /* must be static */
-	COMPQUIET(req, NULL);
-
-	__db_key_range_proc(msg->dbpcl_id,
-	    msg->txnpcl_id,
-	    msg->keydlen,
-	    msg->keydoff,
-	    msg->keyulen,
-	    msg->keyflags,
-	    msg->keydata.keydata_val,
-	    msg->keydata.keydata_len,
-	    msg->flags,
-	    &reply);
-
-	return (&reply);
-}
-
-/*
- * PUBLIC: __db_lorder_reply *__db_db_lorder_4001 __P((__db_lorder_msg *,
- * PUBLIC:      struct svc_req *));
- */
-__db_lorder_reply *
-__db_db_lorder_4001(msg, req)
-	__db_lorder_msg *msg;
-	struct svc_req *req;
-{
-	static __db_lorder_reply reply; /* must be static */
-	COMPQUIET(req, NULL);
-
-	__db_lorder_proc(msg->dbpcl_id,
-	    msg->lorder,
-	    &reply);
-
-	return (&reply);
-}
-
-/*
- * PUBLIC: __db_open_reply *__db_db_open_4001 __P((__db_open_msg *,
- * PUBLIC:      struct svc_req *));
- */
-__db_open_reply *
-__db_db_open_4001(msg, req)
-	__db_open_msg *msg;
-	struct svc_req *req;
-{
-	static __db_open_reply reply; /* must be static */
-	COMPQUIET(req, NULL);
-
-	__db_open_proc(msg->dbpcl_id,
-	    msg->txnpcl_id,
-	    (*msg->name == '\0') ? NULL : msg->name,
-	    (*msg->subdb == '\0') ? NULL : msg->subdb,
-	    msg->type,
-	    msg->flags,
-	    msg->mode,
-	    &reply);
-
-	return (&reply);
-}
-
-/*
- * PUBLIC: __db_pagesize_reply *__db_db_pagesize_4001 
- * PUBLIC:     __P((__db_pagesize_msg *, struct svc_req *));
- */
-__db_pagesize_reply *
-__db_db_pagesize_4001(msg, req)
-	__db_pagesize_msg *msg;
-	struct svc_req *req;
-{
-	static __db_pagesize_reply reply; /* must be static */
-	COMPQUIET(req, NULL);
-
-	__db_pagesize_proc(msg->dbpcl_id,
-	    msg->pagesize,
-	    &reply);
-
-	return (&reply);
-}
-
-/*
- * PUBLIC: __db_pget_reply *__db_db_pget_4001 __P((__db_pget_msg *,
- * PUBLIC:      struct svc_req *));
- */
-__db_pget_reply *
-__db_db_pget_4001(msg, req)
-	__db_pget_msg *msg;
-	struct svc_req *req;
-{
-	static __db_pget_reply reply; /* must be static */
-	static int __db_pget_free = 0; /* must be static */
-
-	COMPQUIET(req, NULL);
-	if (__db_pget_free)
-		xdr_free((xdrproc_t)xdr___db_pget_reply, (void *)&reply);
-	__db_pget_free = 0;
-
-	/* Reinitialize allocated fields */
-	reply.skeydata.skeydata_val = NULL;
-	reply.pkeydata.pkeydata_val = NULL;
-	reply.datadata.datadata_val = NULL;
-
-	__db_pget_proc(msg->dbpcl_id,
-	    msg->txnpcl_id,
-	    msg->skeydlen,
-	    msg->skeydoff,
-	    msg->skeyulen,
-	    msg->skeyflags,
-	    msg->skeydata.skeydata_val,
-	    msg->skeydata.skeydata_len,
-	    msg->pkeydlen,
-	    msg->pkeydoff,
-	    msg->pkeyulen,
-	    msg->pkeyflags,
-	    msg->pkeydata.pkeydata_val,
-	    msg->pkeydata.pkeydata_len,
-	    msg->datadlen,
-	    msg->datadoff,
-	    msg->dataulen,
-	    msg->dataflags,
-	    msg->datadata.datadata_val,
-	    msg->datadata.datadata_len,
-	    msg->flags,
-	    &reply,
-	    &__db_pget_free);
-	return (&reply);
-}
-
-/*
- * PUBLIC: __db_put_reply *__db_db_put_4001 __P((__db_put_msg *,
- * PUBLIC:      struct svc_req *));
- */
-__db_put_reply *
-__db_db_put_4001(msg, req)
-	__db_put_msg *msg;
-	struct svc_req *req;
-{
-	static __db_put_reply reply; /* must be static */
-	static int __db_put_free = 0; /* must be static */
-
-	COMPQUIET(req, NULL);
-	if (__db_put_free)
-		xdr_free((xdrproc_t)xdr___db_put_reply, (void *)&reply);
-	__db_put_free = 0;
-
-	/* Reinitialize allocated fields */
-	reply.keydata.keydata_val = NULL;
-
-	__db_put_proc(msg->dbpcl_id,
-	    msg->txnpcl_id,
-	    msg->keydlen,
-	    msg->keydoff,
-	    msg->keyulen,
-	    msg->keyflags,
-	    msg->keydata.keydata_val,
-	    msg->keydata.keydata_len,
-	    msg->datadlen,
-	    msg->datadoff,
-	    msg->dataulen,
-	    msg->dataflags,
-	    msg->datadata.datadata_val,
-	    msg->datadata.datadata_len,
-	    msg->flags,
-	    &reply,
-	    &__db_put_free);
-	return (&reply);
-}
-
-/*
- * PUBLIC: __db_re_delim_reply *__db_db_re_delim_4001 
- * PUBLIC:     __P((__db_re_delim_msg *, struct svc_req *));
- */
-__db_re_delim_reply *
-__db_db_re_delim_4001(msg, req)
-	__db_re_delim_msg *msg;
-	struct svc_req *req;
-{
-	static __db_re_delim_reply reply; /* must be static */
-	COMPQUIET(req, NULL);
-
-	__db_re_delim_proc(msg->dbpcl_id,
-	    msg->delim,
-	    &reply);
-
-	return (&reply);
-}
-
-/*
- * PUBLIC: __db_re_len_reply *__db_db_re_len_4001 __P((__db_re_len_msg *,
- * PUBLIC:      struct svc_req *));
- */
-__db_re_len_reply *
-__db_db_re_len_4001(msg, req)
-	__db_re_len_msg *msg;
-	struct svc_req *req;
-{
-	static __db_re_len_reply reply; /* must be static */
-	COMPQUIET(req, NULL);
-
-	__db_re_len_proc(msg->dbpcl_id,
-	    msg->len,
-	    &reply);
-
-	return (&reply);
-}
-
-/*
- * PUBLIC: __db_re_pad_reply *__db_db_re_pad_4001 __P((__db_re_pad_msg *,
- * PUBLIC:      struct svc_req *));
- */
-__db_re_pad_reply *
-__db_db_re_pad_4001(msg, req)
-	__db_re_pad_msg *msg;
-	struct svc_req *req;
-{
-	static __db_re_pad_reply reply; /* must be static */
-	COMPQUIET(req, NULL);
-
-	__db_re_pad_proc(msg->dbpcl_id,
-	    msg->pad,
-	    &reply);
-
-	return (&reply);
-}
-
-/*
- * PUBLIC: __db_remove_reply *__db_db_remove_4001 __P((__db_remove_msg *,
- * PUBLIC:      struct svc_req *));
- */
-__db_remove_reply *
-__db_db_remove_4001(msg, req)
-	__db_remove_msg *msg;
-	struct svc_req *req;
-{
-	static __db_remove_reply reply; /* must be static */
-	COMPQUIET(req, NULL);
-
-	__db_remove_proc(msg->dbpcl_id,
-	    (*msg->name == '\0') ? NULL : msg->name,
-	    (*msg->subdb == '\0') ? NULL : msg->subdb,
-	    msg->flags,
-	    &reply);
-
-	return (&reply);
-}
-
-/*
- * PUBLIC: __db_rename_reply *__db_db_rename_4001 __P((__db_rename_msg *,
- * PUBLIC:      struct svc_req *));
- */
-__db_rename_reply *
-__db_db_rename_4001(msg, req)
-	__db_rename_msg *msg;
-	struct svc_req *req;
-{
-	static __db_rename_reply reply; /* must be static */
-	COMPQUIET(req, NULL);
-
-	__db_rename_proc(msg->dbpcl_id,
-	    (*msg->name == '\0') ? NULL : msg->name,
-	    (*msg->subdb == '\0') ? NULL : msg->subdb,
-	    (*msg->newname == '\0') ? NULL : msg->newname,
-	    msg->flags,
-	    &reply);
-
-	return (&reply);
-}
-
-/*
- * PUBLIC: __db_stat_reply *__db_db_stat_4001 __P((__db_stat_msg *,
- * PUBLIC:      struct svc_req *));
- */
-__db_stat_reply *
-__db_db_stat_4001(msg, req)
-	__db_stat_msg *msg;
-	struct svc_req *req;
-{
-	static __db_stat_reply reply; /* must be static */
-	static int __db_stat_free = 0; /* must be static */
-
-	COMPQUIET(req, NULL);
-	if (__db_stat_free)
-		xdr_free((xdrproc_t)xdr___db_stat_reply, (void *)&reply);
-	__db_stat_free = 0;
-
-	/* Reinitialize allocated fields */
-	reply.stats.stats_val = NULL;
-
-	__db_stat_proc(msg->dbpcl_id,
-	    msg->flags,
-	    &reply,
-	    &__db_stat_free);
-	return (&reply);
-}
-
-/*
- * PUBLIC: __db_sync_reply *__db_db_sync_4001 __P((__db_sync_msg *,
- * PUBLIC:      struct svc_req *));
- */
-__db_sync_reply *
-__db_db_sync_4001(msg, req)
-	__db_sync_msg *msg;
-	struct svc_req *req;
-{
-	static __db_sync_reply reply; /* must be static */
-	COMPQUIET(req, NULL);
-
-	__db_sync_proc(msg->dbpcl_id,
-	    msg->flags,
-	    &reply);
-
-	return (&reply);
-}
-
-/*
- * PUBLIC: __db_truncate_reply *__db_db_truncate_4001 
- * PUBLIC:     __P((__db_truncate_msg *, struct svc_req *));
- */
-__db_truncate_reply *
-__db_db_truncate_4001(msg, req)
-	__db_truncate_msg *msg;
-	struct svc_req *req;
-{
-	static __db_truncate_reply reply; /* must be static */
-	COMPQUIET(req, NULL);
-
-	__db_truncate_proc(msg->dbpcl_id,
-	    msg->txnpcl_id,
-	    msg->flags,
-	    &reply);
-
-	return (&reply);
-}
-
-/*
- * PUBLIC: __db_cursor_reply *__db_db_cursor_4001 __P((__db_cursor_msg *,
- * PUBLIC:      struct svc_req *));
- */
-__db_cursor_reply *
-__db_db_cursor_4001(msg, req)
-	__db_cursor_msg *msg;
-	struct svc_req *req;
-{
-	static __db_cursor_reply reply; /* must be static */
-	COMPQUIET(req, NULL);
-
-	__db_cursor_proc(msg->dbpcl_id,
-	    msg->txnpcl_id,
-	    msg->flags,
-	    &reply);
-
-	return (&reply);
-}
-
-/*
- * PUBLIC: __db_join_reply *__db_db_join_4001 __P((__db_join_msg *,
- * PUBLIC:      struct svc_req *));
- */
-__db_join_reply *
-__db_db_join_4001(msg, req)
-	__db_join_msg *msg;
-	struct svc_req *req;
-{
-	static __db_join_reply reply; /* must be static */
-	COMPQUIET(req, NULL);
-
-	__db_join_proc(msg->dbpcl_id,
-	    msg->curs.curs_val,
-	    msg->curs.curs_len,
-	    msg->flags,
-	    &reply);
-
-	return (&reply);
-}
-
-/*
- * PUBLIC: __dbc_close_reply *__db_dbc_close_4001 __P((__dbc_close_msg *,
- * PUBLIC:      struct svc_req *));
- */
-__dbc_close_reply *
-__db_dbc_close_4001(msg, req)
-	__dbc_close_msg *msg;
-	struct svc_req *req;
-{
-	static __dbc_close_reply reply; /* must be static */
-	COMPQUIET(req, NULL);
-
-	__dbc_close_proc(msg->dbccl_id,
-	    &reply);
-
-	return (&reply);
-}
-
-/*
- * PUBLIC: __dbc_count_reply *__db_dbc_count_4001 __P((__dbc_count_msg *,
- * PUBLIC:      struct svc_req *));
- */
-__dbc_count_reply *
-__db_dbc_count_4001(msg, req)
-	__dbc_count_msg *msg;
-	struct svc_req *req;
-{
-	static __dbc_count_reply reply; /* must be static */
-	COMPQUIET(req, NULL);
-
-	__dbc_count_proc(msg->dbccl_id,
-	    msg->flags,
-	    &reply);
-
-	return (&reply);
-}
-
-/*
- * PUBLIC: __dbc_del_reply *__db_dbc_del_4001 __P((__dbc_del_msg *,
- * PUBLIC:      struct svc_req *));
- */
-__dbc_del_reply *
-__db_dbc_del_4001(msg, req)
-	__dbc_del_msg *msg;
-	struct svc_req *req;
-{
-	static __dbc_del_reply reply; /* must be static */
-	COMPQUIET(req, NULL);
-
-	__dbc_del_proc(msg->dbccl_id,
-	    msg->flags,
-	    &reply);
-
-	return (&reply);
-}
-
-/*
- * PUBLIC: __dbc_dup_reply *__db_dbc_dup_4001 __P((__dbc_dup_msg *,
- * PUBLIC:      struct svc_req *));
- */
-__dbc_dup_reply *
-__db_dbc_dup_4001(msg, req)
-	__dbc_dup_msg *msg;
-	struct svc_req *req;
-{
-	static __dbc_dup_reply reply; /* must be static */
-	COMPQUIET(req, NULL);
-
-	__dbc_dup_proc(msg->dbccl_id,
-	    msg->flags,
-	    &reply);
-
-	return (&reply);
-}
-
-/*
- * PUBLIC: __dbc_get_reply *__db_dbc_get_4001 __P((__dbc_get_msg *,
- * PUBLIC:      struct svc_req *));
- */
-__dbc_get_reply *
-__db_dbc_get_4001(msg, req)
-	__dbc_get_msg *msg;
-	struct svc_req *req;
-{
-	static __dbc_get_reply reply; /* must be static */
-	static int __dbc_get_free = 0; /* must be static */
-
-	COMPQUIET(req, NULL);
-	if (__dbc_get_free)
-		xdr_free((xdrproc_t)xdr___dbc_get_reply, (void *)&reply);
-	__dbc_get_free = 0;
-
-	/* Reinitialize allocated fields */
-	reply.keydata.keydata_val = NULL;
-	reply.datadata.datadata_val = NULL;
-
-	__dbc_get_proc(msg->dbccl_id,
-	    msg->keydlen,
-	    msg->keydoff,
-	    msg->keyulen,
-	    msg->keyflags,
-	    msg->keydata.keydata_val,
-	    msg->keydata.keydata_len,
-	    msg->datadlen,
-	    msg->datadoff,
-	    msg->dataulen,
-	    msg->dataflags,
-	    msg->datadata.datadata_val,
-	    msg->datadata.datadata_len,
-	    msg->flags,
-	    &reply,
-	    &__dbc_get_free);
-	return (&reply);
-}
-
-/*
- * PUBLIC: __dbc_pget_reply *__db_dbc_pget_4001 __P((__dbc_pget_msg *,
- * PUBLIC:      struct svc_req *));
- */
-__dbc_pget_reply *
-__db_dbc_pget_4001(msg, req)
-	__dbc_pget_msg *msg;
-	struct svc_req *req;
-{
-	static __dbc_pget_reply reply; /* must be static */
-	static int __dbc_pget_free = 0; /* must be static */
-
-	COMPQUIET(req, NULL);
-	if (__dbc_pget_free)
-		xdr_free((xdrproc_t)xdr___dbc_pget_reply, (void *)&reply);
-	__dbc_pget_free = 0;
-
-	/* Reinitialize allocated fields */
-	reply.skeydata.skeydata_val = NULL;
-	reply.pkeydata.pkeydata_val = NULL;
-	reply.datadata.datadata_val = NULL;
-
-	__dbc_pget_proc(msg->dbccl_id,
-	    msg->skeydlen,
-	    msg->skeydoff,
-	    msg->skeyulen,
-	    msg->skeyflags,
-	    msg->skeydata.skeydata_val,
-	    msg->skeydata.skeydata_len,
-	    msg->pkeydlen,
-	    msg->pkeydoff,
-	    msg->pkeyulen,
-	    msg->pkeyflags,
-	    msg->pkeydata.pkeydata_val,
-	    msg->pkeydata.pkeydata_len,
-	    msg->datadlen,
-	    msg->datadoff,
-	    msg->dataulen,
-	    msg->dataflags,
-	    msg->datadata.datadata_val,
-	    msg->datadata.datadata_len,
-	    msg->flags,
-	    &reply,
-	    &__dbc_pget_free);
-	return (&reply);
-}
-
-/*
- * PUBLIC: __dbc_put_reply *__db_dbc_put_4001 __P((__dbc_put_msg *,
- * PUBLIC:      struct svc_req *));
- */
-__dbc_put_reply *
-__db_dbc_put_4001(msg, req)
-	__dbc_put_msg *msg;
-	struct svc_req *req;
-{
-	static __dbc_put_reply reply; /* must be static */
-	static int __dbc_put_free = 0; /* must be static */
-
-	COMPQUIET(req, NULL);
-	if (__dbc_put_free)
-		xdr_free((xdrproc_t)xdr___dbc_put_reply, (void *)&reply);
-	__dbc_put_free = 0;
-
-	/* Reinitialize allocated fields */
-	reply.keydata.keydata_val = NULL;
-
-	__dbc_put_proc(msg->dbccl_id,
-	    msg->keydlen,
-	    msg->keydoff,
-	    msg->keyulen,
-	    msg->keyflags,
-	    msg->keydata.keydata_val,
-	    msg->keydata.keydata_len,
-	    msg->datadlen,
-	    msg->datadoff,
-	    msg->dataulen,
-	    msg->dataflags,
-	    msg->datadata.datadata_val,
-	    msg->datadata.datadata_len,
-	    msg->flags,
-	    &reply,
-	    &__dbc_put_free);
-	return (&reply);
-}
-
diff --git a/client/Makefile.am b/client/Makefile.am
index 9c994814714d371a61bb3e2df030ca85de2a00d5..92c465192752dc7bf472055daaf56642d5e1eef2 100644
--- a/client/Makefile.am
+++ b/client/Makefile.am
@@ -16,9 +16,8 @@
 
 # This file is public domain and comes with NO WARRANTY of any kind
 
-INCLUDES =			-I$(srcdir)/../include \
-				-I../include -I$(srcdir)/.. -I$(top_srcdir) \
-				-I.. $(openssl_includes)
+#AUTOMAKE_OPTIONS =              nostdinc
+INCLUDES =			-I$(top_srcdir)/include $(openssl_includes)
 LIBS =				@CLIENT_LIBS@
 LDADD =				@CLIENT_EXTRA_LDFLAGS@ ../libmysql/libmysqlclient.la
 bin_PROGRAMS =			mysql mysqladmin mysqlcheck mysqlshow \
diff --git a/client/client_priv.h b/client/client_priv.h
index acf9455bf9c794cf4f12035d7f18550b7eebccf8..eb4473cb10f9db26e4e9ac5a6ce08eddf9d536aa 100644
--- a/client/client_priv.h
+++ b/client/client_priv.h
@@ -17,7 +17,7 @@
 /* Common defines for all clients */
 
 #include <my_global.h>
-#include <my_sys.h> 
+#include <my_sys.h>
 #include <m_string.h>
 #include <mysql.h>
 #include <mysql_embed.h>
@@ -37,4 +37,5 @@ enum options { OPT_CHARSETS_DIR=256, OPT_DEFAULT_CHARSET,
 	       OPT_SELECT_LIMIT, OPT_MAX_JOIN_SIZE, OPT_SSL_SSL,
                OPT_SSL_KEY, OPT_SSL_CERT, OPT_SSL_CA, OPT_SSL_CAPATH,
                OPT_SSL_CIPHER, OPT_SHUTDOWN_TIMEOUT, OPT_LOCAL_INFILE,
-               OPT_PROMPT, OPT_IGN_LINES,OPT_TRANSACTION };
+               OPT_PROMPT, OPT_IGN_LINES,OPT_TRANSACTION,OPT_MYSQL_PROTOCOL,
+               OPT_SHARED_MEMORY_BASE_NAME, OPT_FRM };
diff --git a/client/completion_hash.cc b/client/completion_hash.cc
index ff5d0b28e413270dbe0a810f6b8b84c967bfa56c..536e7f9373a4b0d3778f1eab9dd3b7f2867563e1 100644
--- a/client/completion_hash.cc
+++ b/client/completion_hash.cc
@@ -27,7 +27,7 @@
 #include <my_sys.h>
 #include "completion_hash.h"
 
-uint hashpjw(char *arKey, uint nKeyLength)
+uint hashpjw(const char *arKey, uint nKeyLength)
 {
   uint h = 0, g, i;
 
@@ -111,7 +111,7 @@ int completion_hash_update(HashTable *ht, char *arKey, uint nKeyLength,
   return SUCCESS;
 }
 
-static Bucket *completion_hash_find(HashTable *ht, char *arKey,
+static Bucket *completion_hash_find(HashTable *ht, const char *arKey,
 				    uint nKeyLength)
 {
   uint h, nIndex;
@@ -156,7 +156,7 @@ int completion_hash_exists(HashTable *ht, char *arKey, uint nKeyLength)
   return 0;
 }
 
-Bucket *find_all_matches(HashTable *ht, char *str, uint length,
+Bucket *find_all_matches(HashTable *ht, const char *str, uint length,
 			 uint *res_length)
 {
   Bucket *b;
diff --git a/client/completion_hash.h b/client/completion_hash.h
index c0853fddfe7d01ae039fe036a2c21ac90d793723..2595a445c9d8b5164189f4b1cfc3124c14e55d97 100644
--- a/client/completion_hash.h
+++ b/client/completion_hash.h
@@ -43,14 +43,14 @@ typedef struct hashtable {
   uint nTableSize;
   uint initialized;
   MEM_ROOT mem_root;
-  uint(*pHashFunction) (char *arKey, uint nKeyLength);
+  uint(*pHashFunction) (const char *arKey, uint nKeyLength);
   Bucket **arBuckets;
 } HashTable;
 
 extern int completion_hash_init(HashTable *ht, uint nSize);
 extern int completion_hash_update(HashTable *ht, char *arKey, uint nKeyLength, char *str);
 extern int hash_exists(HashTable *ht, char *arKey);
-extern Bucket *find_all_matches(HashTable *ht, char *str, uint length, uint *res_length);
+extern Bucket *find_all_matches(HashTable *ht, const char *str, uint length, uint *res_length);
 extern Bucket *find_longest_match(HashTable *ht, char *str, uint length, uint *res_length);
 extern void add_word(HashTable *ht,char *str);
 extern void completion_hash_clean(HashTable *ht);
diff --git a/client/insert_test.c b/client/insert_test.c
index 42691df68755f030878eed18dd152cc01914c85d..fb4890faf73bb3ad44ddf9776ef5c72eb28b5816 100644
--- a/client/insert_test.c
+++ b/client/insert_test.c
@@ -16,6 +16,7 @@
 
 #include <stdio.h>
 #include <stdlib.h>
+#include <my_global.h>
 #include "mysql.h"
 
 #define INSERT_QUERY "insert into test (name,num) values ('item %d', %d)"
diff --git a/client/mysql.cc b/client/mysql.cc
index fbd3b13ca839effa838dd8e342c2b72c2a7899ea..13943691fb45d31da79773a478f01fcac66064ab 100644
--- a/client/mysql.cc
+++ b/client/mysql.cc
@@ -152,6 +152,11 @@ static FILE *PAGER, *OUTFILE;
 static MEM_ROOT hash_mem_root;
 static uint prompt_counter;
 
+#ifdef HAVE_SMEM
+static char *shared_memory_base_name=0;
+#endif
+static uint opt_protocol=0;
+			   
 #include "sslopt-vars.h"
 
 #ifndef DBUG_OFF
@@ -425,6 +430,9 @@ sig_handler mysql_end(int sig)
   my_free(full_username,MYF(MY_ALLOW_ZERO_PTR));
   my_free(part_username,MYF(MY_ALLOW_ZERO_PTR));
   my_free(default_prompt,MYF(MY_ALLOW_ZERO_PTR));
+#ifdef HAVE_SMEM
+  my_free(shared_memory_base_name,MYF(MY_ALLOW_ZERO_PTR));
+#endif
   my_free(current_prompt,MYF(MY_ALLOW_ZERO_PTR));
   mysql_server_end();
   free_defaults(defaults_argv);
@@ -532,6 +540,8 @@ static struct my_option my_long_options[] =
   {"prompt", OPT_PROMPT, "Set the mysql prompt to this value.",
    (gptr*) &current_prompt, (gptr*) &current_prompt, 0, GET_STR_ALLOC,
    REQUIRED_ARG, 0, 0, 0, 0, 0, 0},
+  {"protocol", OPT_MYSQL_PROTOCOL, "The protocol of connection (tcp,socket,pipe,memory)",
+   0, 0, 0, GET_STR,  REQUIRED_ARG, 0, 0, 0, 0, 0, 0},
   {"quick", 'q',
    "Don't cache result, print it row by row. This may slow down the server if the output is suspended. Doesn't use history file. ",
    (gptr*) &quick, (gptr*) &quick, 0, GET_BOOL, NO_ARG, 0, 0, 0, 0, 0, 0},
@@ -540,6 +550,11 @@ static struct my_option my_long_options[] =
    0, 0, 0},
   {"silent", 's', "Be more silent.", 0, 0, 0, GET_NO_ARG, NO_ARG, 0, 0, 0, 0,
    0, 0},
+#ifdef HAVE_SMEM
+  {"shared_memory_base_name", OPT_SHARED_MEMORY_BASE_NAME,
+   "Base name of shared memory", (gptr*) &shared_memory_base_name, (gptr*) &shared_memory_base_name, 
+   0, GET_STR_ALLOC, REQUIRED_ARG, 0, 0, 0, 0, 0, 0},
+#endif
   {"socket", 'S', "Socket file to use for connection.",
    (gptr*) &opt_mysql_unix_port, (gptr*) &opt_mysql_unix_port, 0, GET_STR_ALLOC,
    REQUIRED_ARG, 0, 0, 0, 0, 0, 0},
@@ -644,6 +659,15 @@ get_one_option(int optid, const struct my_option *opt __attribute__((unused)),
   case OPT_NOPAGER:
     printf("WARNING: option deprecated; use --disable-pager instead.\n");
     opt_nopager= 1;
+  case OPT_MYSQL_PROTOCOL:
+  {
+    if ((opt_protocol = find_type(argument, &sql_protocol_typelib,0)) == ~(ulong) 0)
+    {
+      fprintf(stderr, "Unknown option to protocol: %s\n", argument);
+      exit(1);
+    }
+    break;
+  }
     break;
   case 'A':
     rehash= 0;
@@ -706,7 +730,7 @@ get_one_option(int optid, const struct my_option *opt __attribute__((unused)),
     break;
   case 'W':
 #ifdef __WIN__
-    opt_mysql_unix_port= my_strdup(MYSQL_NAMEDPIPE, MYF(0));
+    opt_protocol = MYSQL_PROTOCOL_PIPE;
 #endif
     break;
 #include <sslopt-case.h>
@@ -952,7 +976,7 @@ static bool add_line(String &buffer,char *line,char *in_string)
       }
       if ((com=find_command(NullS,(char) inchar)))
       {
-	const String tmp(line,(uint) (out-line));
+	const String tmp(line,(uint) (out-line), system_charset_info);
 	buffer.append(tmp);
 	if ((*com->func)(&buffer,pos-1) > 0)
 	  return 1;				// Quit
@@ -1025,8 +1049,8 @@ static bool add_line(String &buffer,char *line,char *in_string)
 
 #ifdef HAVE_READLINE
 
-static char *new_command_generator(char *text, int);
-static char **new_mysql_completion (char *text, int start, int end);
+static char *new_command_generator(const char *text, int);
+static char **new_mysql_completion (const char *text, int start, int end);
 
 /*
   Tell the GNU Readline library how to complete.  We want to try to complete
@@ -1034,8 +1058,8 @@ static char **new_mysql_completion (char *text, int start, int end);
   if not.
 */
 
-char **no_completion (char *text __attribute__ ((unused)),
-		      char *word __attribute__ ((unused)))
+char *no_completion (const char *text __attribute__ ((unused)),
+		      int )
 {
   return 0;					/* No filename completion */
 }
@@ -1046,9 +1070,13 @@ static void initialize_readline (char *name)
   rl_readline_name = name;
 
   /* Tell the completer that we want a crack first. */
-  /* rl_attempted_completion_function = (CPPFunction *)mysql_completion;*/
-  rl_attempted_completion_function = (CPPFunction *) new_mysql_completion;
-  rl_completion_entry_function=(Function *) no_completion;
+#if RL_READLINE_VERSION > 0x0400
+  rl_attempted_completion_function = &new_mysql_completion;
+  rl_completion_entry_function= &no_completion;
+#else
+  rl_attempted_completion_function =(CPPFunction *)new_mysql_completion;
+  rl_completion_entry_function= (Function *)no_completion;
+#endif
 }
 
 /*
@@ -1058,17 +1086,21 @@ static void initialize_readline (char *name)
   array of matches, or NULL if there aren't any.
 */
 
-static char **new_mysql_completion (char *text,
+static char **new_mysql_completion (const char *text,
 				    int start __attribute__((unused)),
 				    int end __attribute__((unused)))
 {
   if (!status.batch && !quick)
-    return completion_matches(text, (CPFunction*) new_command_generator);
+#if RL_READLINE_VERSION > 0x0400
+    return rl_completion_matches(text, new_command_generator);
+#else
+    return completion_matches((char *)text, (CPFunction *)new_command_generator);
+#endif
   else
     return (char**) 0;
 }
 
-static char *new_command_generator(char *text,int state)
+static char *new_command_generator(const char *text,int state)
 {
   static int textlen;
   char *ptr;
@@ -1709,7 +1741,7 @@ print_table_data(MYSQL_RES *result)
     print_field_types(result);
     mysql_field_seek(result,0);
   }
-  separator.copy("+",1);
+  separator.copy("+",1,system_charset_info);
   while ((field = mysql_fetch_field(result)))
   {
     uint length= column_names ? (uint) strlen(field->name) : 0;
@@ -2349,6 +2381,12 @@ sql_real_connect(char *host,char *database,char *user,char *password,
   if (opt_use_ssl)
     mysql_ssl_set(&mysql, opt_ssl_key, opt_ssl_cert, opt_ssl_ca,
 		  opt_ssl_capath, opt_ssl_cipher);
+#endif
+  if (opt_protocol)
+    mysql_options(&mysql,MYSQL_OPT_PROTOCOL,(char*)&opt_protocol);
+#ifdef HAVE_SMEM
+  if (shared_memory_base_name)
+    mysql_options(&mysql,MYSQL_SHARED_MEMORY_BASE_NAME,shared_memory_base_name);
 #endif
   if (safe_updates)
   {
diff --git a/client/mysqladmin.c b/client/mysqladmin.c
index 00af8c592ecaa1191dfd40e77acdf6f8491f23d3..289204a6d335c27ae04608f72b1e4287e1154973 100644
--- a/client/mysqladmin.c
+++ b/client/mysqladmin.c
@@ -23,6 +23,7 @@
 #include <my_pthread.h>				/* because of signal()	*/
 #endif
 #include <sys/stat.h>
+#include <mysql.h>
 
 #define ADMIN_VERSION "8.38"
 #define MAX_MYSQL_VAR 128
@@ -42,6 +43,11 @@ static uint tcp_port = 0, option_wait = 0, option_silent=0, nr_iterations,
 static ulong opt_connect_timeout, opt_shutdown_timeout;
 static my_string unix_port=0;
 
+#ifdef HAVE_SMEM
+static char *shared_memory_base_name=0;
+#endif
+static uint opt_protocol=0;
+
 /*
   When using extended-status relatively, ex_val_max_len is the estimated
   maximum length for any relative value printed by extended-status. The
@@ -135,6 +141,8 @@ static struct my_option my_long_options[] =
 #endif
   {"port", 'P', "Port number to use for connection.", (gptr*) &tcp_port,
    (gptr*) &tcp_port, 0, GET_UINT, REQUIRED_ARG, 0, 0, 0, 0, 0, 0},
+  {"protocol", OPT_MYSQL_PROTOCOL, "The protocol of connection (tcp,socket,pipe,memory)",
+    0, 0, 0, GET_STR,  REQUIRED_ARG, 0, 0, 0, 0, 0, 0},
   {"relative", 'r',
    "Show difference between current and previous values when used with -i. Currently works only with extended-status.",
    (gptr*) &opt_relative, (gptr*) &opt_relative, 0, GET_BOOL, NO_ARG, 0, 0, 0,
@@ -142,6 +150,11 @@ static struct my_option my_long_options[] =
   {"set-variable", 'O',
    "Change the value of a variable. Please note that this option is deprecated; you can set variables directly with --variable-name=value.",
    0, 0, 0, GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0},
+#ifdef HAVE_SMEM
+  {"shared_memory_base_name", OPT_SHARED_MEMORY_BASE_NAME,
+   "Base name of shared memory", (gptr*) &shared_memory_base_name, (gptr*) &shared_memory_base_name, 
+   0, GET_STR_ALLOC, REQUIRED_ARG, 0, 0, 0, 0, 0, 0},
+#endif
   {"silent", 's', "Silently exit if one can't connect to server",
    0, 0, 0, GET_NO_ARG, NO_ARG, 0, 0, 0, 0, 0, 0},
   {"socket", 'S', "Socket file to use for connection.",
@@ -205,7 +218,7 @@ get_one_option(int optid, const struct my_option *opt __attribute__((unused)),
     break;
   case 'W':
 #ifdef __WIN__
-    unix_port=MYSQL_NAMEDPIPE;
+    opt_protocol = MYSQL_PROTOCOL_PIPE;
 #endif
     break;
   case '#':
@@ -234,6 +247,15 @@ get_one_option(int optid, const struct my_option *opt __attribute__((unused)),
     charsets_dir = argument;
 #endif
     break;
+  case OPT_MYSQL_PROTOCOL:
+  {
+    if ((opt_protocol = find_type(argument, &sql_protocol_typelib,0)) == ~(ulong) 0)
+    {
+      fprintf(stderr, "Unknown option to protocol: %s\n", argument);
+      exit(1);
+    }
+    break;
+  }
   }
   if (error)
   {
@@ -284,6 +306,12 @@ int main(int argc,char *argv[])
     mysql_ssl_set(&mysql, opt_ssl_key, opt_ssl_cert, opt_ssl_ca,
 		  opt_ssl_capath, opt_ssl_cipher);
 #endif
+  if (opt_protocol)
+    mysql_options(&mysql,MYSQL_OPT_PROTOCOL,(char*)&opt_protocol);
+#ifdef HAVE_SMEM
+  if (shared_memory_base_name)
+    mysql_options(&mysql,MYSQL_SHARED_MEMORY_BASE_NAME,shared_memory_base_name);
+#endif    
   if (sql_connect(&mysql, option_wait))
     error = 1;
   else
@@ -326,6 +354,9 @@ int main(int argc,char *argv[])
   }
   my_free(opt_password,MYF(MY_ALLOW_ZERO_PTR));
   my_free(user,MYF(MY_ALLOW_ZERO_PTR));
+#ifdef HAVE_SMEM
+  my_free(shared_memory_base_name,MYF(MY_ALLOW_ZERO_PTR));
+#endif
   free_defaults(save_argv);
   my_end(0);
   exit(error ? 1 : 0);
diff --git a/client/mysqlbinlog.cc b/client/mysqlbinlog.cc
index b2100ac159677279d2ee4c7177b85adfe82f283b..4cf86eb31c7654407e0fabf3c1f121eca6e5e6fd 100644
--- a/client/mysqlbinlog.cc
+++ b/client/mysqlbinlog.cc
@@ -176,7 +176,7 @@ static void dump_remote_file(NET* net, const char* fname)
 }
 
 
-static my_bool
+extern "C" my_bool
 get_one_option(int optid, const struct my_option *opt __attribute__((unused)),
 	       char *argument)
 {
@@ -210,7 +210,6 @@ get_one_option(int optid, const struct my_option *opt __attribute__((unused)),
     print_version();
     exit(0);
   case '?':
-  default:
     usage();
     exit(0);
   }
diff --git a/client/mysqlcheck.c b/client/mysqlcheck.c
index 24b67a602558c593871e0ce8f581a6607dc8d0be..f9719f05bf322f3e4064a38bd9185853a68c7d29 100644
--- a/client/mysqlcheck.c
+++ b/client/mysqlcheck.c
@@ -34,13 +34,17 @@ static my_bool opt_alldbs = 0, opt_check_only_changed = 0, opt_extended = 0,
                opt_compress = 0, opt_databases = 0, opt_fast = 0,
                opt_medium_check = 0, opt_quick = 0, opt_all_in_1 = 0,
                opt_silent = 0, opt_auto_repair = 0, ignore_errors = 0,
-               tty_password = 0;
+               tty_password = 0, opt_frm = 0;
 static uint verbose = 0, opt_mysql_port=0;
 static my_string opt_mysql_unix_port = 0;
 static char *opt_password = 0, *current_user = 0, *default_charset = 0,
             *current_host = 0;
 static int first_error = 0;
 DYNAMIC_ARRAY tables4repair;
+#ifdef HAVE_SMEM
+static char *shared_memory_base_name=0;
+#endif
+static uint opt_protocol=0;
 
 enum operations {DO_CHECK, DO_REPAIR, DO_ANALYZE, DO_OPTIMIZE};
 
@@ -109,6 +113,8 @@ static struct my_option my_long_options[] =
   {"port", 'P', "Port number to use for connection.", (gptr*) &opt_mysql_port,
    (gptr*) &opt_mysql_port, 0, GET_UINT, REQUIRED_ARG, MYSQL_PORT, 0, 0, 0, 0,
    0},
+  {"protocol", OPT_MYSQL_PROTOCOL, "The protocol of connection (tcp,socket,pipe,memory)",
+   0, 0, 0, GET_STR,  REQUIRED_ARG, 0, 0, 0, 0, 0, 0},
   {"quick", 'q',
    "If you are using this option with CHECK TABLE, it prevents the check from scanning the rows to check for wrong links. This is the fastest check. If you are using this option with REPAIR TABLE, it will try to repair only the index tree. This is the fastest repair method for a table.",
    (gptr*) &opt_quick, (gptr*) &opt_quick, 0, GET_BOOL, NO_ARG, 0, 0, 0, 0, 0,
@@ -116,6 +122,11 @@ static struct my_option my_long_options[] =
   {"repair", 'r',
    "Can fix almost anything except unique keys that aren't unique.",
    0, 0, 0, GET_NO_ARG, NO_ARG, 0, 0, 0, 0, 0, 0},
+#ifdef HAVE_SMEM
+  {"shared_memory_base_name", OPT_SHARED_MEMORY_BASE_NAME,
+   "Base name of shared memory", (gptr*) &shared_memory_base_name, (gptr*) &shared_memory_base_name, 
+   0, GET_STR_ALLOC, REQUIRED_ARG, 0, 0, 0, 0, 0, 0},
+#endif
   {"silent", 's', "Print only error messages.", (gptr*) &opt_silent,
    (gptr*) &opt_silent, 0, GET_BOOL, NO_ARG, 0, 0, 0, 0, 0, 0},
   {"socket", 'S', "Socket file to use for connection.",
@@ -128,13 +139,17 @@ static struct my_option my_long_options[] =
   {"user", 'u', "User for login if not current user.", (gptr*) &current_user,
    (gptr*) &current_user, 0, GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0},
 #endif
+  {"use-frm", OPT_FRM,
+   "When used with REPAIR, get table structure from .frm file, so the table can be repaired even if .MYI header is corrupted.",
+   (gptr*) &opt_frm, (gptr*) &opt_frm, 0, GET_BOOL, NO_ARG, 0, 0, 0, 0, 0,
+   0},
   {"verbose", 'v', "Print info about the various stages.", 0, 0, 0, GET_NO_ARG,
    NO_ARG, 0, 0, 0, 0, 0, 0},
   {"version", 'V', "Output version information and exit.", 0, 0, 0, GET_NO_ARG,
    NO_ARG, 0, 0, 0, 0, 0, 0},
   {0, 0, 0, 0, 0, 0, GET_NO_ARG, NO_ARG, 0, 0, 0, 0, 0, 0}
 };
-  
+
 static const char *load_default_groups[] = { "mysqlcheck", "client", 0 };
 
 
@@ -223,7 +238,7 @@ get_one_option(int optid, const struct my_option *opt __attribute__((unused)),
       opt_password = my_strdup(argument, MYF(MY_FAE));
       while (*argument) *argument++= 'x';		/* Destroy argument */
       if (*start)
-	start[1] = 0;	         		/* Cut length of argument */
+	start[1] = 0;                             /* Cut length of argument */
     }
     else
       tty_password = 1;
@@ -233,7 +248,7 @@ get_one_option(int optid, const struct my_option *opt __attribute__((unused)),
     break;
   case 'W':
 #ifdef __WIN__
-    opt_mysql_unix_port = MYSQL_NAMEDPIPE;
+    opt_protocol = MYSQL_PROTOCOL_PIPE;
 #endif
     break;
   case '#':
@@ -247,6 +262,15 @@ get_one_option(int optid, const struct my_option *opt __attribute__((unused)),
     verbose++;
     break;
   case 'V': print_version(); exit(0);
+  case OPT_MYSQL_PROTOCOL:
+  {
+    if ((opt_protocol = find_type(argument, &sql_protocol_typelib,0)) == ~(ulong) 0)
+    {
+      fprintf(stderr, "Unknown option to protocol: %s\n", argument);
+      exit(1);
+    }
+    break;
+  }
   }
   return 0;
 }
@@ -348,21 +372,25 @@ static int process_selected_tables(char *db, char **table_names, int tables)
     return 1;
   if (opt_all_in_1)
   {
+    /* 
+      We need table list in form `a`, `b`, `c`
+      that's why we need 4 more chars added to to each table name
+      space is for more readable output in logs and in case of error
+    */	  
     char *table_names_comma_sep, *end;
     int i, tot_length = 0;
 
     for (i = 0; i < tables; i++)
-      tot_length += strlen(*(table_names + i)) + 1;
+      tot_length += strlen(*(table_names + i)) + 4;
 
     if (!(table_names_comma_sep = (char *)
-	  my_malloc((sizeof(char) * tot_length) + 1, MYF(MY_WME))))
+	  my_malloc((sizeof(char) * tot_length) + 4, MYF(MY_WME))))
       return 1;
 
     for (end = table_names_comma_sep + 1; tables > 0;
 	 tables--, table_names++)
     {
-      end = strmov(end, *table_names);
-      *end++= ',';
+      end = strxmov(end, " `", *table_names, "`,", NullS);
     }
     *--end = 0;
     handle_request_for_tables(table_names_comma_sep + 1, tot_length - 1);
@@ -389,22 +417,27 @@ static int process_all_tables_in_db(char *database)
 
   if (opt_all_in_1)
   {
+    /* 
+      We need table list in form `a`, `b`, `c`
+      that's why we need 4 more chars added to to each table name
+      space is for more readable output in logs and in case of error
+     */
+	  
     char *tables, *end;
     uint tot_length = 0;
 
     while ((row = mysql_fetch_row(res)))
-      tot_length += strlen(row[0]) + 1;
+      tot_length += strlen(row[0]) + 4;
     mysql_data_seek(res, 0);
 
-    if (!(tables=(char *) my_malloc(sizeof(char)*tot_length+1, MYF(MY_WME))))
+    if (!(tables=(char *) my_malloc(sizeof(char)*tot_length+4, MYF(MY_WME))))
     {
       mysql_free_result(res);
       return 1;
     }
     for (end = tables + 1; (row = mysql_fetch_row(res)) ;)
     {
-      end = strmov(end, row[0]);
-      *end++= ',';
+      end = strxmov(end, " `", row[0], "`,", NullS);	    
     }
     *--end = 0;
     if (tot_length)
@@ -452,6 +485,7 @@ static int handle_request_for_tables(char *tables, uint length)
     op = "REPAIR";
     if (opt_quick)              end = strmov(end, " QUICK");
     if (opt_extended)           end = strmov(end, " EXTENDED");
+    if (opt_frm)                end = strmov(end, " USE_FRM");
     break;
   case DO_ANALYZE:
     op = "ANALYZE";
@@ -463,10 +497,14 @@ static int handle_request_for_tables(char *tables, uint length)
 
   if (!(query =(char *) my_malloc((sizeof(char)*(length+110)), MYF(MY_WME))))
     return 1;
-  sprintf(query, "%s TABLE %s %s", op, tables, options);
+  if (opt_all_in_1)
+    /* No backticks here as we added them before */
+    sprintf(query, "%s TABLE %s %s", op, tables, options);
+  else
+    sprintf(query, "%s TABLE `%s` %s", op, tables, options);
   if (mysql_query(sock, query))
   {
-    sprintf(message, "when executing '%s TABLE `%s` %s", op, tables,options);
+    sprintf(message, "when executing '%s TABLE ... %s'", op, options);
     DBerror(sock, message);
     return 1;
   }
@@ -533,6 +571,12 @@ static int dbConnect(char *host, char *user, char *passwd)
   if (opt_use_ssl)
     mysql_ssl_set(&mysql_connection, opt_ssl_key, opt_ssl_cert, opt_ssl_ca,
 		  opt_ssl_capath, opt_ssl_cipher);
+#endif
+  if (opt_protocol)
+    mysql_options(&mysql_connection,MYSQL_OPT_PROTOCOL,(char*)&opt_protocol);
+#ifdef HAVE_SMEM
+  if (shared_memory_base_name)
+    mysql_options(&mysql_connection,MYSQL_SHARED_MEMORY_BASE_NAME,shared_memory_base_name);
 #endif
   if (!(sock = mysql_real_connect(&mysql_connection, host, user, passwd,
          NULL, opt_mysql_port, opt_mysql_unix_port, 0)))
@@ -621,6 +665,9 @@ int main(int argc, char **argv)
   if (opt_auto_repair)
     delete_dynamic(&tables4repair);
   my_free(opt_password, MYF(MY_ALLOW_ZERO_PTR));
+#ifdef HAVE_SMEM
+  my_free(shared_memory_base_name,MYF(MY_ALLOW_ZERO_PTR));
+#endif
   my_end(0);
   return(first_error!=0);
 } /* main */
diff --git a/client/mysqldump.c b/client/mysqldump.c
index 9470786705d93011aeefe87320b7a0ef74ce9baa..9534cc68ed4602ab1b62680ee47655bc3688fe8a 100644
--- a/client/mysqldump.c
+++ b/client/mysqldump.c
@@ -90,6 +90,10 @@ extern ulong net_buffer_length;
 static DYNAMIC_STRING extended_row;
 #include <sslopt-vars.h>
 FILE  *md_result_file;
+#ifdef HAVE_SMEM
+static char *shared_memory_base_name=0;
+#endif
+static uint opt_protocol=0;
 
 static struct my_option my_long_options[] =
 {
@@ -200,6 +204,8 @@ static struct my_option my_long_options[] =
   {"port", 'P', "Port number to use for connection.", (gptr*) &opt_mysql_port,
    (gptr*) &opt_mysql_port, 0, GET_UINT, REQUIRED_ARG, MYSQL_PORT, 0, 0, 0, 0,
    0},
+  {"protocol", OPT_MYSQL_PROTOCOL, "The protocol of connection (tcp,socket,pipe,memory)",
+   0, 0, 0, GET_STR,  REQUIRED_ARG, 0, 0, 0, 0, 0, 0},
   {"quick", 'q', "Don't buffer query, dump directly to stdout.",
    (gptr*) &quick, (gptr*) &quick, 0, GET_BOOL, NO_ARG, 0, 0, 0, 0, 0, 0},
   {"quote-names",'Q', "Quote table and column names with a `",
@@ -208,6 +214,11 @@ static struct my_option my_long_options[] =
   {"result-file", 'r',
    "Direct output to a given file. This option should be used in MSDOS, because it prevents new line '\\n' from being converted to '\\r\\n' (carriage return + line feed).",
    0, 0, 0, GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0},
+#ifdef HAVE_SMEM
+  {"shared_memory_base_name", OPT_SHARED_MEMORY_BASE_NAME,
+   "Base name of shared memory", (gptr*) &shared_memory_base_name, (gptr*) &shared_memory_base_name, 
+   0, GET_STR_ALLOC, REQUIRED_ARG, 0, 0, 0, 0, 0, 0},
+#endif
   {"socket", 'S', "Socket file to use for connection.",
    (gptr*) &opt_mysql_unix_port, (gptr*) &opt_mysql_unix_port, 0, GET_STR,
    REQUIRED_ARG, 0, 0, 0, 0, 0, 0},
@@ -294,7 +305,10 @@ static void short_usage(void)
 static void write_header(FILE *sql_file, char *db_name)
 {
   if (opt_xml)
+  {
     fprintf(sql_file,"<?xml version=\"1.0\"?>\n");
+    fprintf(sql_file,"<mysqldump>\n");
+  }
   else
   {
     fprintf(sql_file, "-- MySQL dump %s\n--\n", DUMP_VERSION);
@@ -308,6 +322,12 @@ static void write_header(FILE *sql_file, char *db_name)
   return;
 } /* write_header */
 
+static void write_footer(FILE *sql_file)
+{
+  if (opt_xml)
+    fprintf(sql_file,"</mysqldump>");
+  fputs("\n", sql_file);
+} /* write_footer */
 
 static my_bool
 get_one_option(int optid, const struct my_option *opt __attribute__((unused)),
@@ -338,7 +358,7 @@ get_one_option(int optid, const struct my_option *opt __attribute__((unused)),
     break;
   case 'W':
 #ifdef __WIN__
-    opt_mysql_unix_port=MYSQL_NAMEDPIPE;
+    opt_protocol = MYSQL_PROTOCOL_PIPE;
 #endif
     break;
   case 'T':
@@ -365,6 +385,15 @@ get_one_option(int optid, const struct my_option *opt __attribute__((unused)),
   case (int) OPT_TABLES:
     opt_databases=0;
     break;
+  case OPT_MYSQL_PROTOCOL:
+  {
+    if ((opt_protocol = find_type(argument, &sql_protocol_typelib,0)) == ~(ulong) 0)
+    {
+      fprintf(stderr, "Unknown option to protocol: %s\n", argument);
+      exit(1);
+    }
+   break;
+  }
   }
   return 0;
 }
@@ -473,6 +502,12 @@ static int dbConnect(char *host, char *user,char *passwd)
   if (opt_use_ssl)
     mysql_ssl_set(&mysql_connection, opt_ssl_key, opt_ssl_cert, opt_ssl_ca,
 		  opt_ssl_capath, opt_ssl_cipher);
+#endif
+  if (opt_protocol)
+    mysql_options(&mysql_connection,MYSQL_OPT_PROTOCOL,(char*)&opt_protocol);
+#ifdef HAVE_SMEM
+  if (shared_memory_base_name)
+    mysql_options(&mysql_connection,MYSQL_SHARED_MEMORY_BASE_NAME,shared_memory_base_name);
 #endif
   if (!(sock= mysql_real_connect(&mysql_connection,host,user,passwd,
          NULL,opt_mysql_port,opt_mysql_unix_port,
@@ -978,7 +1013,7 @@ static void dumpTable(uint numFields, char *table)
     rownr=0;
     init_length=(uint) strlen(insert_pat)+4;
     if (opt_xml)
-      fprintf(md_result_file, "\t<%s>\n", table);
+      fprintf(md_result_file, "\t<table name=\"%s\">\n", table);
 
     if (opt_autocommit)
       fprintf(md_result_file, "set autocommit=0;\n");
@@ -1068,9 +1103,9 @@ static void dumpTable(uint numFields, char *table)
 	      /* change any strings ("inf","nan",..) into NULL */
 	      char *ptr = row[i];
 	      if (opt_xml)
-		fprintf(md_result_file, "\t\t<%s>%s</%s>\n",
+		fprintf(md_result_file, "\t\t<field name=\"%s\">%s</field>\n",
 			field->name,
-			!my_isalpha(system_charset_info,*ptr) ?ptr: "NULL",field->name);
+			!my_isalpha(system_charset_info, *ptr) ? ptr: "NULL");
 	      else
 		fputs((!my_isalpha(system_charset_info,*ptr)) ? 
 		       ptr : "NULL", md_result_file);
@@ -1079,8 +1114,8 @@ static void dumpTable(uint numFields, char *table)
 	  else
 	  {
 	    if (opt_xml)
-	      fprintf(md_result_file, "\t\t<%s>%s</%s>\n",
-		      field->name, "NULL", field->name);
+	      fprintf(md_result_file, "\t\t<field name=\"%s\">%s</field>\n",
+		      field->name, "NULL");
 	    else
 	      fputs("NULL", md_result_file);
 	  }
@@ -1121,7 +1156,7 @@ static void dumpTable(uint numFields, char *table)
 
     /* XML - close table tag and supress regular output */
     if (opt_xml)
-	fprintf(md_result_file, "\t</%s>\n", table);
+	fprintf(md_result_file, "\t</table>\n");
     else if (extended_insert && row_break)
       fputs(";\n", md_result_file);		/* If not empty table */
     fflush(md_result_file);
@@ -1153,7 +1188,7 @@ static void print_quoted_xml(FILE *output, char *fname, char *str, uint len)
 {
   const char *end;
 
-  fprintf(output, "\t\t<%s>", fname);
+  fprintf(output, "\t\t<field name=\"%s\">", fname);
   for (end = str + len; str != end; str++)
   {
     if (*str == '<')
@@ -1167,7 +1202,7 @@ static void print_quoted_xml(FILE *output, char *fname, char *str, uint len)
     else
       fputc(*str, output);
   }
-  fprintf(output, "</%s>\n", fname);
+  fprintf(output, "</field>\n");
 }
 
 static char *getTableName(int reset)
@@ -1222,13 +1257,8 @@ static int dump_databases(char **db_names)
   int result=0;
   for ( ; *db_names ; db_names++)
   {
-    /* XML edit - add database element */
-    if (opt_xml)
-      fprintf(md_result_file, "<%s>\n", *db_names);
     if (dump_all_tables_in_db(*db_names))
       result=1;
-    if (opt_xml)
-      fprintf(md_result_file, "</%s>\n", *db_names);
   }
   return result;
 } /* dump_databases */
@@ -1241,7 +1271,7 @@ static int init_dumping(char *database)
     DBerror(sock, "when selecting the database");
     return 1;			/* If --force */
   }
-  if (!path)
+  if (!path && !opt_xml)
   {
     if (opt_databases || opt_alldbs)
     {
@@ -1252,7 +1282,7 @@ static int init_dumping(char *database)
         MYSQL_ROW row;
         MYSQL_RES *dbinfo;
 	
-        sprintf(qbuf,"SHOW CREATE DATABASE IF NOT EXISTS %s",database);
+        sprintf(qbuf,"SHOW CREATE DATABASE WITH IF NOT EXISTS %s",database);
         
         if (mysql_query(sock, qbuf) || !(dbinfo = mysql_store_result(sock)))
         {
@@ -1287,6 +1317,8 @@ static int dump_all_tables_in_db(char *database)
 
   if (init_dumping(database))
     return 1;
+  if (opt_xml)
+    fprintf(md_result_file, "<database name=\"%s\">\n", database);
   if (lock_tables)
   {
     DYNAMIC_STRING query;
@@ -1313,6 +1345,8 @@ static int dump_all_tables_in_db(char *database)
     if (!dFlag && numrows > 0)
       dumpTable(numrows,table);
   }
+  if (opt_xml)
+    fprintf(md_result_file, "</database>\n");
   if (lock_tables)
     mysql_query(sock,"UNLOCK_TABLES");
   return 0;
@@ -1349,12 +1383,16 @@ static int dump_selected_tables(char *db, char **table_names, int tables)
       DBerror(sock, "when doing refresh");
      /* We shall countinue here, if --force was given */
   }
+  if (opt_xml)
+    fprintf(md_result_file, "<database name=\"%s\">\n", db);
   for (; tables > 0 ; tables-- , table_names++)
   {
     numrows = getTableStructure(*table_names, db);
     if (!dFlag && numrows > 0)
       dumpTable(numrows, *table_names);
   }
+  if (opt_xml)
+    fprintf(md_result_file, "</database>\n");
   if (lock_tables)
     mysql_query(sock,"UNLOCK_TABLES");
   return 0;
@@ -1471,6 +1509,9 @@ int main(int argc, char **argv)
 		      MYF(0), mysql_error(sock));
   }
   else if (opt_single_transaction) /* Just to make it beautiful enough */
+#ifdef HAVE_SMEM
+  my_free(shared_memory_base_name,MYF(MY_ALLOW_ZERO_PTR));
+#endif
   {
     /*
       In case we were locking all tables, we did not start transaction
@@ -1485,7 +1526,7 @@ int main(int argc, char **argv)
     }		      
   }
   dbDisconnect(current_host);
-  fputs("\n", md_result_file);
+  write_footer(md_result_file);
   if (md_result_file != stdout)
     my_fclose(md_result_file, MYF(0));
   my_free(opt_password, MYF(MY_ALLOW_ZERO_PTR));
diff --git a/client/mysqlimport.c b/client/mysqlimport.c
index a11b738351714465f1524fc1cecb4914494e1e21..2de4a9b81b57253cfcb19fdfe7016cf874a3f9b5 100644
--- a/client/mysqlimport.c
+++ b/client/mysqlimport.c
@@ -49,6 +49,11 @@ static my_string opt_mysql_unix_port=0;
 static my_string opt_ignore_lines=0;
 #include <sslopt-vars.h>
 
+#ifdef HAVE_SMEM
+static char *shared_memory_base_name=0;
+#endif
+static uint opt_protocol=0;
+
 static struct my_option my_long_options[] =
 {
   {"character-sets-dir", OPT_CHARSETS_DIR,
@@ -112,8 +117,15 @@ static struct my_option my_long_options[] =
   {"port", 'P', "Port number to use for connection.", (gptr*) &opt_mysql_port,
    (gptr*) &opt_mysql_port, 0, GET_UINT, REQUIRED_ARG, MYSQL_PORT, 0, 0, 0, 0,
    0},
+  {"protocol", OPT_MYSQL_PROTOCOL,
"The protocol of connection (tcp,socket,pipe,memory)",
+   0, 0, 0, GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0},
   {"replace", 'r', "If duplicate unique key was found, replace old row.",
    (gptr*) &replace, (gptr*) &replace, 0, GET_BOOL, NO_ARG, 0, 0, 0, 0, 0, 0},
+#ifdef HAVE_SMEM
+  {"shared_memory_base_name", OPT_SHARED_MEMORY_BASE_NAME,
+   "Base name of shared memory", (gptr*) &shared_memory_base_name, (gptr*) &shared_memory_base_name, 
+   0, GET_STR_ALLOC, REQUIRED_ARG, 0, 0, 0, 0, 0, 0},
+#endif
   {"silent", 's', "Be more silent.", (gptr*) &silent, (gptr*) &silent, 0,
    GET_BOOL, NO_ARG, 0, 0, 0, 0, 0, 0},
   {"socket", 'S', "Socket file to use for connection.",
@@ -181,10 +193,19 @@ get_one_option(int optid, const struct my_option *opt __attribute__((unused)),
     break;
 #ifdef __WIN__
   case 'W':
-    opt_mysql_unix_port=MYSQL_NAMEDPIPE;
+    opt_protocol = MYSQL_PROTOCOL_PIPE;
     opt_local_file=1;
     break;
 #endif
+  case OPT_MYSQL_PROTOCOL:
+  {
+    if ((opt_protocol = find_type(argument, &sql_protocol_typelib,0)) == ~(ulong) 0)
+    {
+      fprintf(stderr, "Unknown option to protocol: %s\n", argument);
+      exit(1);
+    }
+    break;
+  }
   case '#':
     DBUG_PUSH(argument ? argument : "d:t:o");
     break;
@@ -351,6 +372,12 @@ static MYSQL *db_connect(char *host, char *database, char *user, char *passwd)
   if (opt_use_ssl)
     mysql_ssl_set(&mysql_connection, opt_ssl_key, opt_ssl_cert, opt_ssl_ca,
 		  opt_ssl_capath, opt_ssl_cipher);
+#endif
+  if (opt_protocol)
+    mysql_options(&mysql_connection,MYSQL_OPT_PROTOCOL,(char*)&opt_protocol);
+#ifdef HAVE_SMEM
+  if (shared_memory_base_name)
+    mysql_options(&mysql_connection,MYSQL_SHARED_MEMORY_BASE_NAME,shared_memory_base_name);
 #endif
   if (!(sock= mysql_real_connect(&mysql_connection,host,user,passwd,
 				 database,opt_mysql_port,opt_mysql_unix_port,
@@ -486,6 +513,9 @@ int main(int argc, char **argv)
 	exitcode = error;
   db_disconnect(current_host, sock);
   my_free(opt_password,MYF(MY_ALLOW_ZERO_PTR));
+#ifdef HAVE_SMEM
+  my_free(shared_memory_base_name,MYF(MY_ALLOW_ZERO_PTR));
+#endif
   free_defaults(argv_to_free);
   my_end(0);
   return(exitcode);
diff --git a/client/mysqlshow.c b/client/mysqlshow.c
index 5475fc7b5316444f425ee7ab8b50367ee7c99551..df624a02c55b54d7b4b034c77f281529255b07d8 100644
--- a/client/mysqlshow.c
+++ b/client/mysqlshow.c
@@ -31,6 +31,11 @@ static my_string host=0,opt_password=0,user=0;
 static my_bool opt_show_keys=0,opt_compress=0,opt_status=0, tty_password=0;
 static uint opt_verbose=0;
 
+#ifdef HAVE_SMEM 
+static char *shared_memory_base_name=0;
+#endif
+static uint opt_protocol=0;
+
 static void get_options(int *argc,char ***argv);
 static uint opt_mysql_port=0;
 static int list_dbs(MYSQL *mysql,const char *wild);
@@ -51,6 +56,7 @@ static my_string opt_mysql_unix_port=0;
 int main(int argc, char **argv)
 {
   int error;
+  my_bool first_argument_uses_wildcards=0;
   char *wild;
   MYSQL mysql;
   MY_INIT(argv[0]);
@@ -58,21 +64,37 @@ int main(int argc, char **argv)
   get_options(&argc,&argv);
 
   wild=0;
-  if (argc && strcont(argv[argc-1],"*?%_"))
+  if (argc)
   {
-    char *pos;
-
-    wild=argv[--argc];
-    for (pos=wild ; *pos ; pos++)
-    {					/* Unix wildcards to sql  */
-      if (*pos == '*')
-	*pos='%';
-      else if (*pos == '?')
-	*pos='_';
-    }
+    char *pos= argv[argc-1], *to;
+    for (to= pos ; *pos ; pos++, to++)
+    {
+      switch (*pos)
+      {
+      case '*':
+	*pos= '%';
+	first_argument_uses_wildcards= 1;
+	break;
+      case '?':
+	*pos= '_';
+	first_argument_uses_wildcards= 1;
+	break;
+      case '%':
+      case '_':
+	first_argument_uses_wildcards= 1;
+	break;
+      case '\\':
+	pos++;
+      default: break;
+      }
+      *to= *pos;
+    }    
+    *to= *pos; // just to copy a '\0'  if '\\' was used
   }
+  if (first_argument_uses_wildcards)
+    wild= argv[--argc];
   else if (argc == 3)			/* We only want one field */
-    wild=argv[--argc];
+    wild= argv[--argc];
 
   if (argc > 2)
   {
@@ -86,9 +108,15 @@ int main(int argc, char **argv)
   if (opt_use_ssl)
     mysql_ssl_set(&mysql, opt_ssl_key, opt_ssl_cert, opt_ssl_ca,
 		  opt_ssl_capath, opt_ssl_cipher);
+#endif
+  if (opt_protocol)
+    mysql_options(&mysql,MYSQL_OPT_PROTOCOL,(char*)&opt_protocol);
+#ifdef HAVE_SMEM
+  if (shared_memory_base_name)
+    mysql_options(&mysql,MYSQL_SHARED_MEMORY_BASE_NAME,shared_memory_base_name);
 #endif
   if (!(mysql_real_connect(&mysql,host,user,opt_password,
-			   argv[0],opt_mysql_port,opt_mysql_unix_port,
+			   (first_argument_uses_wildcards) ? "" : argv[0],opt_mysql_port,opt_mysql_unix_port,
 			   0)))
   {
     fprintf(stderr,"%s: %s\n",my_progname,mysql_error(&mysql));
@@ -114,6 +142,9 @@ int main(int argc, char **argv)
   mysql_close(&mysql);			/* Close & free connection */
   if (opt_password)
     my_free(opt_password,MYF(0));
+#ifdef HAVE_SMEM
+  my_free(shared_memory_base_name,MYF(MY_ALLOW_ZERO_PTR));
+#endif
   my_end(0);
   exit(error ? 1 : 0);
   return 0;				/* No compiler warnings */
@@ -147,6 +178,13 @@ static struct my_option my_long_options[] =
 #ifdef __WIN__
   {"pipe", 'W', "Use named pipes to connect to server.", 0, 0, 0, GET_NO_ARG,
    NO_ARG, 0, 0, 0, 0, 0, 0},
+#endif
+  {"protocol", OPT_MYSQL_PROTOCOL,
"The protocol of connection (tcp,socket,pipe,memory)",
+   0, 0, 0, GET_STR,  REQUIRED_ARG, 0, 0, 0, 0, 0, 0},
+#ifdef HAVE_SMEM
+  {"shared_memory_base_name", OPT_SHARED_MEMORY_BASE_NAME,
+   "Base name of shared memory", (gptr*) &shared_memory_base_name, (gptr*) &shared_memory_base_name, 
+   0, GET_STR_ALLOC, REQUIRED_ARG, 0, 0, 0, 0, 0, 0},
 #endif
   {"socket", 'S', "Socket file to use for connection.",
    (gptr*) &opt_mysql_unix_port, (gptr*) &opt_mysql_unix_port, 0, GET_STR,
@@ -213,9 +251,18 @@ get_one_option(int optid, const struct my_option *opt __attribute__((unused)),
     break;
   case 'W':
 #ifdef __WIN__
-    opt_mysql_unix_port=MYSQL_NAMEDPIPE;
+    opt_protocol = MYSQL_PROTOCOL_PIPE;
 #endif
     break;
+  case OPT_MYSQL_PROTOCOL:
+  {
+    if ((opt_protocol = find_type(argument, &sql_protocol_typelib,0)) == ~(ulong) 0)
+    {
+      fprintf(stderr, "Unknown option to protocol: %s\n", argument);
+      exit(1);
+    }
+    break;
+  }
   case '#':
     DBUG_PUSH(argument ? argument : "d:t:o");
     break;
diff --git a/client/mysqltest.c b/client/mysqltest.c
index 036130f2d805e0e6c27171882457bc6b370354c3..9d724404edcef11f3a8917fc007b56e194dde2d2 100644
--- a/client/mysqltest.c
+++ b/client/mysqltest.c
@@ -91,7 +91,7 @@
 
 
 enum {OPT_MANAGER_USER=256,OPT_MANAGER_HOST,OPT_MANAGER_PASSWD,
-      OPT_MANAGER_PORT,OPT_MANAGER_WAIT_TIMEOUT};
+      OPT_MANAGER_PORT,OPT_MANAGER_WAIT_TIMEOUT, OPT_SKIP_SAFEMALLOC};
 
 static int record = 0, opt_sleep=0;
 static char *db = 0, *pass=0;
@@ -1850,6 +1850,9 @@ static struct my_option my_long_options[] =
    0, 0, 0, GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0},
   {"silent", 's', "Suppress all normal output. Synonym for --quiet.",
    (gptr*) &silent, (gptr*) &silent, 0, GET_BOOL, NO_ARG, 0, 0, 0, 0, 0, 0},
+  {"skip-safemalloc", OPT_SKIP_SAFEMALLOC,
+   "Don't use the memory allocation checking", 0, 0, 0, GET_NO_ARG, NO_ARG,
+   0, 0, 0, 0, 0, 0},
   {"sleep", 'T', "Sleep always this many seconds on sleep commands",
    (gptr*) &opt_sleep, (gptr*) &opt_sleep, 0, GET_INT, REQUIRED_ARG, 0, 0, 0,
    0, 0, 0},
@@ -1949,6 +1952,11 @@ get_one_option(int optid, const struct my_option *opt __attribute__((unused)),
     if (read_server_arguments(argument))
       die(NullS);
     break;
+  case OPT_SKIP_SAFEMALLOC:
+#ifdef SAFEMALLOC
+    sf_malloc_quick=1;
+#endif
+    break;
   case 'V':
     print_version();
     exit(0);
@@ -2323,6 +2331,7 @@ static void var_from_env(const char* name, const char* def_val)
 static void init_var_hash()
 {
   VAR* v;
+  DBUG_ENTER("init_var_hash");
   if (hash_init(&var_hash, system_charset_info, 
                 1024, 0, 0, get_var_key, var_free, MYF(0)))
     die("Variable hash initialization failed");
@@ -2332,6 +2341,7 @@ static void init_var_hash()
   var_from_env("BIG_TEST", opt_big_test ? "1" : "0");
   v=var_init(0,"MAX_TABLES", 0, (sizeof(ulong) == 4) ? "31" : "63",0);
   hash_insert(&var_hash, (byte*)v);
+  DBUG_VOID_RETURN;
 }
 
 
diff --git a/client/select_test.c b/client/select_test.c
index ee2a91928655ba08798af896de034a979429163f..d7f18c0f1f0ebdb14479fd9fef8182cbfbdd7b8c 100644
--- a/client/select_test.c
+++ b/client/select_test.c
@@ -19,6 +19,7 @@
 #endif
 #include <stdio.h>
 #include <stdlib.h>
+#include "my_global.h"
 #include "mysql.h"
 
 #define SELECT_QUERY "select name from test where num = %d"
diff --git a/client/sql_string.cc b/client/sql_string.cc
index 65854ece0effe0e7adb300171c12f5209c13bd3e..5083fb1310596e35ee1557397a0441ecd8aabad4 100644
--- a/client/sql_string.cc
+++ b/client/sql_string.cc
@@ -40,19 +40,16 @@ extern void sql_element_free(void *ptr);
 bool String::real_alloc(uint32 arg_length)
 {
   arg_length=ALIGN_SIZE(arg_length+1);
+  str_length=0;
   if (Alloced_length < arg_length)
   {
     free();
     if (!(Ptr=(char*) my_malloc(arg_length,MYF(MY_WME))))
-    {
-      str_length=0;
       return TRUE;
-    }
     Alloced_length=arg_length;
     alloced=1;
   }
   Ptr[0]=0;
-  str_length=0;
   return FALSE;
 }
 
@@ -94,36 +91,58 @@ bool String::realloc(uint32 alloc_length)
   return FALSE;
 }
 
-bool String::set(longlong num)
+bool String::set(longlong num, CHARSET_INFO *cs)
 {
-  if (alloc(21))
+  uint l=20*cs->mbmaxlen+1;
+
+  if (alloc(l))
     return TRUE;
-  str_length=(uint32) (longlong10_to_str(num,Ptr,-10)-Ptr);
+  if (cs->snprintf == my_snprintf_8bit)
+  {
+    str_length=(uint32) (longlong10_to_str(num,Ptr,-10)-Ptr);
+  }
+  else
+  {
+    str_length=cs->snprintf(cs,Ptr,l,"%d",num);
+  }
+  str_charset=cs;
   return FALSE;
 }
 
-bool String::set(ulonglong num)
+bool String::set(ulonglong num, CHARSET_INFO *cs)
 {
-  if (alloc(21))
+  uint l=20*cs->mbmaxlen+1;
+
+  if (alloc(l))
     return TRUE;
-  str_length=(uint32) (longlong10_to_str(num,Ptr,10)-Ptr);
+  if (cs->snprintf == my_snprintf_8bit)
+  {
+    str_length=(uint32) (longlong10_to_str(num,Ptr,10)-Ptr);
+  }
+  else
+  {
+    str_length=cs->snprintf(cs,Ptr,l,"%d",num);
+  }
+  str_charset=cs;
   return FALSE;
 }
 
-bool String::set(double num,uint decimals)
+bool String::set(double num,uint decimals, CHARSET_INFO *cs)
 {
   char buff[331];
+
+  str_charset=cs;
   if (decimals >= NOT_FIXED_DEC)
   {
     sprintf(buff,"%.14g",num);			// Enough for a DATETIME
-    return copy(buff, (uint32) strlen(buff));
+    return copy(buff, (uint32) strlen(buff), my_charset_latin1, cs);
   }
 #ifdef HAVE_FCONVERT
   int decpt,sign;
   char *pos,*to;
 
   VOID(fconvert(num,(int) decimals,&decpt,&sign,buff+1));
-  if (!isdigit(buff[1]))
+  if (!my_isdigit(my_charset_latin1, buff[1]))
   {						// Nan or Inf
     pos=buff+1;
     if (sign)
@@ -131,7 +150,7 @@ bool String::set(double num,uint decimals)
       buff[0]='-';
       pos=buff;
     }
-    return copy(pos,(uint32) strlen(pos));
+    return copy(pos,(uint32) strlen(pos), my_charset_latin1, cs);
   }
   if (alloc((uint32) ((uint32) decpt+3+decimals)))
     return TRUE;
@@ -181,7 +200,7 @@ bool String::set(double num,uint decimals)
 #else
   sprintf(buff,"%.*f",(int) decimals,num);
 #endif
-  return copy(buff,(uint32) strlen(buff));
+  return copy(buff,(uint32) strlen(buff), my_charset_latin1, cs);
 #endif
 }
 
@@ -203,16 +222,67 @@ bool String::copy(const String &str)
   str_length=str.str_length;
   bmove(Ptr,str.Ptr,str_length);		// May be overlapping
   Ptr[str_length]=0;
+  str_charset=str.str_charset;
   return FALSE;
 }
 
-bool String::copy(const char *str,uint32 arg_length)
+bool String::copy(const char *str,uint32 arg_length, CHARSET_INFO *cs)
 {
   if (alloc(arg_length))
     return TRUE;
   if ((str_length=arg_length))
     memcpy(Ptr,str,arg_length);
   Ptr[arg_length]=0;
+  str_charset=cs;
+  return FALSE;
+}
+
+/* Copy with charset convertion */
+bool String::copy(const char *str,uint32 arg_length, CHARSET_INFO *from, CHARSET_INFO *to)
+{
+  uint32      new_length=to->mbmaxlen*arg_length;
+  int         cnvres;
+  my_wc_t     wc;
+  const uchar *s=(const uchar *)str;
+  const uchar *se=s+arg_length;
+  uchar       *d, *de;
+
+  if (alloc(new_length))
+    return TRUE;
+
+  d=(uchar *)Ptr;
+  de=d+new_length;
+  
+  for (str_length=new_length ; s < se && d < de ; )
+  {
+    if ((cnvres=from->mb_wc(from,&wc,s,se)) > 0 )
+    {
+      s+=cnvres;
+    }
+    else if (cnvres==MY_CS_ILSEQ)
+    {
+      s++;
+      wc='?';
+    }
+    else
+      break;
+
+outp:
+    if((cnvres=to->wc_mb(to,wc,d,de)) >0 )
+    {
+      d+=cnvres;
+    }
+    else if (cnvres==MY_CS_ILUNI && wc!='?')
+    {
+      wc='?';
+      goto outp;
+    }
+    else
+      break;
+  }
+  Ptr[new_length]=0;
+  length((uint32) (d-(uchar *)Ptr));
+  str_charset=to;
   return FALSE;
 }
 
@@ -489,7 +559,7 @@ void String::qs_append(double d)
 void String::qs_append(double *d)
 {
   double ld;
-  float8get(ld, d);
+  float8get(ld, (char*) d);
   qs_append(ld);
 }
 
@@ -523,12 +593,23 @@ int sortcmp(const String *x,const String *y)
 #endif /* USE_STRCOLL */
     x_len-=len;					// For easy end space test
     y_len-=len;
-    while (len--)
+    if (x->str_charset->sort_order)
     {
-      if (x->str_charset->sort_order[(uchar) *s++] != 
+      while (len--)
+      {
+        if (x->str_charset->sort_order[(uchar) *s++] != 
           x->str_charset->sort_order[(uchar) *t++])
-        return ((int) x->str_charset->sort_order[(uchar) s[-1]] -
-                (int) x->str_charset->sort_order[(uchar) t[-1]]);
+            return ((int) x->str_charset->sort_order[(uchar) s[-1]] -
+                  (int) x->str_charset->sort_order[(uchar) t[-1]]);
+      }
+    }
+    else
+    {
+      while (len--)
+      {
+        if (*s++ != *t++)
+            return ((int) s[-1] - (int) t[-1]);
+      }
     }
 #ifndef CMP_ENDSPACE
     /* Don't compare end space in strings */
@@ -586,264 +667,9 @@ String *copy_if_not_alloced(String *to,String *from,uint32 from_length)
     return from;				// Actually an error
   if ((to->str_length=min(from->str_length,from_length)))
     memcpy(to->Ptr,from->Ptr,to->str_length);
+  to->str_charset=from->str_charset;
   return to;
 }
 
-/* Make it easier to handle different charactersets */
-
-#ifdef USE_MB
-#define INC_PTR(cs,A,B) A+=((use_mb_flag && \
-                          my_ismbchar(cs,A,B)) ? my_ismbchar(cs,A,B) : 1)
-#else
-#define INC_PTR(cs,A,B) A++
-#endif
-
-/*
-** Compare string against string with wildcard
-**	0 if matched
-**	-1 if not matched with wildcard
-**	 1 if matched with wildcard
-*/
-
-#ifdef LIKE_CMP_TOUPPER
-#define likeconv(s,A) (uchar) my_toupper(s,A)
-#else
-#define likeconv(s,A) (uchar) (s)->sort_order[(uchar) (A)]
-#endif
-
-int wild_case_compare(CHARSET_INFO *cs, const char *str,const char *str_end,
-		      const char *wildstr,const char *wildend,
-		      char escape)
-{
-  int result= -1;				// Not found, using wildcards
-#ifdef USE_MB
-  bool use_mb_flag=use_mb(cs);
-#endif
-  while (wildstr != wildend)
-  {
-    while (*wildstr != wild_many && *wildstr != wild_one)
-    {
-      if (*wildstr == escape && wildstr+1 != wildend)
-	wildstr++;
-#ifdef USE_MB
-      int l;
-      if (use_mb_flag &&
-          (l = my_ismbchar(cs, wildstr, wildend)))
-      {
-	  if (str+l > str_end || memcmp(str, wildstr, l) != 0)
-	      return 1;
-	  str += l;
-	  wildstr += l;
-      }
-      else
-#endif
-      if (str == str_end || likeconv(cs,*wildstr++) != likeconv(cs,*str++))
-	return(1);				// No match
-      if (wildstr == wildend)
-	return (str != str_end);		// Match if both are at end
-      result=1;					// Found an anchor char
-    }
-    if (*wildstr == wild_one)
-    {
-      do
-      {
-	if (str == str_end)			// Skip one char if possible
-	  return (result);
-	INC_PTR(cs,str,str_end);
-      } while (++wildstr < wildend && *wildstr == wild_one);
-      if (wildstr == wildend)
-	break;
-    }
-    if (*wildstr == wild_many)
-    {						// Found wild_many
-      wildstr++;
-      /* Remove any '%' and '_' from the wild search string */
-      for ( ; wildstr != wildend ; wildstr++)
-      {
-	if (*wildstr == wild_many)
-	  continue;
-	if (*wildstr == wild_one)
-	{
-	  if (str == str_end)
-	    return (-1);
-	  INC_PTR(cs,str,str_end);
-	  continue;
-	}
-	break;					// Not a wild character
-      }
-      if (wildstr == wildend)
-	return(0);				// Ok if wild_many is last
-      if (str == str_end)
-	return -1;
-
-      uchar cmp;
-      if ((cmp= *wildstr) == escape && wildstr+1 != wildend)
-	cmp= *++wildstr;
-#ifdef USE_MB
-      const char* mb = wildstr;
-      int mblen;
-      LINT_INIT(mblen);
-      if (use_mb_flag)
-        mblen = my_ismbchar(cs, wildstr, wildend);
-#endif
-      INC_PTR(cs,wildstr,wildend);		// This is compared trough cmp
-      cmp=likeconv(cs,cmp);   
-      do
-      {
-#ifdef USE_MB
-        if (use_mb_flag)
-	{
-          for (;;)
-          {
-            if (str >= str_end)
-              return -1;
-            if (mblen)
-            {
-              if (str+mblen <= str_end && memcmp(str, mb, mblen) == 0)
-              {
-                str += mblen;
-                break;
-              }
-            }
-            else if (!my_ismbchar(cs, str, str_end) &&
-                     likeconv(cs,*str) == cmp)
-            {
-              str++;
-              break;
-            }
-            INC_PTR(cs,str, str_end);
-          }
-	}
-        else
-        {
-#endif /* USE_MB */
-          while (str != str_end && likeconv(cs,*str) != cmp)
-            str++;
-          if (str++ == str_end) return (-1);
-#ifdef USE_MB
-        }
-#endif
-	{
-	  int tmp=wild_case_compare(cs,str,str_end,wildstr,wildend,escape);
-	  if (tmp <= 0)
-	    return (tmp);
-	}
-      } while (str != str_end && wildstr[0] != wild_many);
-      return(-1);
-    }
-  }
-  return (str != str_end ? 1 : 0);
-}
-
-
-int wild_case_compare(String &match,String &wild, char escape)
-{
-  DBUG_ENTER("wild_case_compare");
-  DBUG_PRINT("enter",("match='%s', wild='%s', escape='%c'"
-			  ,match.ptr(),wild.ptr(),escape));
-  DBUG_RETURN(wild_case_compare(match.str_charset,match.ptr(),match.ptr()+match.length(),
-			   wild.ptr(), wild.ptr()+wild.length(),escape));
-}
-
-/*
-** The following is used when using LIKE on binary strings
-*/
-
-int wild_compare(const char *str,const char *str_end,
-		 const char *wildstr,const char *wildend,char escape)
-{
-  DBUG_ENTER("wild_compare");
-  DBUG_PRINT("enter",("str='%s', str_end='%s', wildstr='%s', wildend='%s', escape='%c'"
-			  ,str,str_end,wildstr,wildend,escape));
-  int result= -1;				// Not found, using wildcards
-  while (wildstr != wildend)
-  {
-    while (*wildstr != wild_many && *wildstr != wild_one)
-    {
-      if (*wildstr == escape && wildstr+1 != wildend)
-	wildstr++;
-      if (str == str_end || *wildstr++ != *str++)
-      {
-	DBUG_RETURN(1);
-      }
-      if (wildstr == wildend)
-      {
-	DBUG_RETURN(str != str_end);		// Match if both are at end
-      }
-      result=1;					// Found an anchor char
-    }
-    if (*wildstr == wild_one)
-    {
-      do
-      {
-	if (str == str_end)			// Skip one char if possible
-	  DBUG_RETURN(result);
-	str++;
-      } while (*++wildstr == wild_one && wildstr != wildend);
-      if (wildstr == wildend)
-	break;
-    }
-    if (*wildstr == wild_many)
-    {						// Found wild_many
-      wildstr++;
-      /* Remove any '%' and '_' from the wild search string */
-      for ( ; wildstr != wildend ; wildstr++)
-      {
-	if (*wildstr == wild_many)
-	  continue;
-	if (*wildstr == wild_one)
-	{
-	  if (str == str_end)
-	  {
-	    DBUG_RETURN(-1);
-	  }
-	  str++;
-	  continue;
-	}
-	break;					// Not a wild character
-      }
-      if (wildstr == wildend)
-      {
-	DBUG_RETURN(0);				// Ok if wild_many is last
-      }
-      if (str == str_end)
-      {
-	DBUG_RETURN(-1);
-      }
-      char cmp;
-      if ((cmp= *wildstr) == escape && wildstr+1 != wildend)
-	cmp= *++wildstr;
-      wildstr++;				// This is compared trough cmp
-      do
-      {
-	while (str != str_end && *str != cmp)
-	  str++;
-	if (str++ == str_end)
-	{ 
-	  DBUG_RETURN(-1);
-	}
-	{
-	  int tmp=wild_compare(str,str_end,wildstr,wildend,escape);
-	  if (tmp <= 0)
-	  {
-	    DBUG_RETURN(tmp);
-	  }
-	}
-      } while (str != str_end && wildstr[0] != wild_many);
-      DBUG_RETURN(-1);
-    }
-  }
-  DBUG_RETURN(str != str_end ? 1 : 0);
-}
-
-
-int wild_compare(String &match,String &wild, char escape)
-{
-  DBUG_ENTER("wild_compare");
-  DBUG_PRINT("enter",("match='%s', wild='%s', escape='%c'"
-			  ,match.ptr(),wild.ptr(),escape));
-  DBUG_RETURN(wild_compare(match.ptr(),match.ptr()+match.length(),
-		      wild.ptr(), wild.ptr()+wild.length(),escape));
-}
 
 
diff --git a/client/sql_string.h b/client/sql_string.h
index 811e49a0d02cca4b8c71f61257acb012988ac582..42f9e44698179586d1ef135d4f05edafef0e80be 100644
--- a/client/sql_string.h
+++ b/client/sql_string.h
@@ -28,8 +28,6 @@ class String;
 int sortcmp(const String *a,const String *b);
 int stringcmp(const String *a,const String *b);
 String *copy_if_not_alloced(String *a,String *b,uint32 arg_length);
-int wild_case_compare(String &match,String &wild,char escape);
-int wild_compare(String &match,String &wild,char escape);
 
 class String
 {
@@ -46,22 +44,22 @@ class String
   String(uint32 length_arg)
   { 
     alloced=0; Alloced_length=0; (void) real_alloc(length_arg); 
-    str_charset=default_charset_info;  
+    str_charset=default_charset_info;
   }
-  String(const char *str)
+  String(const char *str, CHARSET_INFO *cs)
   { 
     Ptr=(char*) str; str_length=(uint) strlen(str); Alloced_length=0; alloced=0;
-    str_charset=default_charset_info;
+    str_charset=cs;
   }
-  String(const char *str,uint32 len)
+  String(const char *str,uint32 len, CHARSET_INFO *cs)
   { 
     Ptr=(char*) str; str_length=len; Alloced_length=0; alloced=0;
-    str_charset=default_charset_info;  
+    str_charset=cs;
   }
-  String(char *str,uint32 len)
+  String(char *str,uint32 len, CHARSET_INFO *cs)
   { 
     Ptr=(char*) str; Alloced_length=str_length=len; alloced=0;
-    str_charset=default_charset_info;
+    str_charset=cs;
   }
   String(const String &str)
   { 
@@ -74,6 +72,7 @@ class String
     { sql_element_free(ptr_arg); }
   ~String() { free(); }
 
+  inline void set_charset(CHARSET_INFO *charset) { str_charset=charset; }
   inline CHARSET_INFO *charset() const { return str_charset; }
   inline uint32 length() const { return str_length;}
   inline uint32 alloced_length() const { return Alloced_length;}
@@ -102,28 +101,31 @@ class String
       Alloced_length=str.Alloced_length-offset;
     else
       Alloced_length=0;
+    str_charset=str.str_charset;
   }
-  inline void set(char *str,uint32 arg_length)
+  inline void set(char *str,uint32 arg_length, CHARSET_INFO *cs)
   {
     free();
     Ptr=(char*) str; str_length=Alloced_length=arg_length ; alloced=0;
+    str_charset=cs;
   }
-  inline void set(const char *str,uint32 arg_length)
+  inline void set(const char *str,uint32 arg_length, CHARSET_INFO *cs)
   {
     free();
     Ptr=(char*) str; str_length=arg_length; Alloced_length=0 ; alloced=0;
+    str_charset=cs;
   }
-  inline void set_quick(char *str,uint32 arg_length)
+  inline void set_quick(char *str,uint32 arg_length, CHARSET_INFO *cs)
   {
     if (!alloced)
     {
       Ptr=(char*) str; str_length=Alloced_length=arg_length;
     }
+    str_charset=cs;
   }
-  bool set(longlong num);
-  /* bool set(long num); */
-  bool set(ulonglong num);
-  bool set(double num,uint decimals=2);
+  bool set(longlong num, CHARSET_INFO *cs);
+  bool set(ulonglong num, CHARSET_INFO *cs);
+  bool set(double num,uint decimals, CHARSET_INFO *cs);
   inline void free()
   {
     if (alloced)
@@ -174,7 +176,8 @@ class String
 
   bool copy();					// Alloc string if not alloced
   bool copy(const String &s);			// Allocate new string
-  bool copy(const char *s,uint32 arg_length);	// Allocate new string
+  bool copy(const char *s,uint32 arg_length, CHARSET_INFO *cs);	// Allocate new string
+  bool copy(const char*s,uint32 arg_length, CHARSET_INFO *csfrom, CHARSET_INFO *csto);
   bool append(const String &s);
   bool append(const char *s,uint32 arg_length=0);
   bool append(IO_CACHE* file, uint32 arg_length);
@@ -203,21 +206,20 @@ class String
   friend int sortcmp(const String *a,const String *b);
   friend int stringcmp(const String *a,const String *b);
   friend String *copy_if_not_alloced(String *a,String *b,uint32 arg_length);
-  friend int wild_case_compare(String &match,String &wild,char escape);
-  friend int wild_compare(String &match,String &wild,char escape);
   uint32 numchars();
   int charpos(int i,uint32 offset=0);
 
-// added by Holyfoot for "geometry" needs
   int reserve(uint32 space_needed)
   {
     return realloc(str_length + space_needed);
   }
   int reserve(uint32 space_needed, uint32 grow_by);
 
-// these append operations do NOT check alloced memory
-// q_*** methods writes values of parameters itself
-// qs_*** methods writes string representation of value
+  /*
+    The following append operations do NOT check alloced memory
+    q_*** methods writes values of parameters itself
+    qs_*** methods writes string representation of value
+  */
   void q_append(const char &c)
   {
     Ptr[str_length++] = c;
diff --git a/configure.in b/configure.in
index 5de157a49c975fb948df0a8a38760409f3649176..d25041dea7a3a405a97d147ac61e3b768188a17f 100644
--- a/configure.in
+++ b/configure.in
@@ -15,6 +15,7 @@ SHARED_LIB_VERSION=12:0:0
 # Set all version vars based on $VERSION. How do we do this more elegant ?
 # Remember that regexps needs to quote [ and ] since this is run through m4
 MYSQL_NO_DASH_VERSION=`echo $VERSION | sed -e "s|-.*$||"`
+MYSQL_NO_DASH_VERSION=`echo $VERSION | sed -e "s|[[a-z]]*-.*$||"`
 MYSQL_BASE_VERSION=`echo $MYSQL_NO_DASH_VERSION | sed -e "s|\.[[^.]]*$||"`
 F_PART=`echo $MYSQL_BASE_VERSION | sed -e "s|\.||g"| sed -e "s|[a-zA-Z]\+||"|sed -e "s|^\(..\)$|\\10|"`
 L_PART=`echo $MYSQL_NO_DASH_VERSION | sed -e "s|^[[0-9]]\.[[0-9]]*\.||" | sed -e "s|^\(.\)$|0\\1|" | sed -e "s|[[a-z]]||"`
@@ -72,12 +73,14 @@ case $MACHINE_TYPE in
 esac
 
 # Save some variables and the command line options for mysqlbug
+SAVE_ASFLAGS="$ASFLAGS"
 SAVE_CFLAGS="$CFLAGS"
 SAVE_CXXFLAGS="$CXXFLAGS"
 SAVE_LDFLAGS="$LDFLAGS"
 SAVE_CXXLDFLAGS="$CXXLDFLAGS"
 CONF_COMMAND="$0 $ac_configure_args"
 AC_SUBST(CONF_COMMAND)
+AC_SUBST(SAVE_ASFLAGS)
 AC_SUBST(SAVE_CFLAGS)
 AC_SUBST(SAVE_CXXFLAGS)
 AC_SUBST(SAVE_LDFLAGS)
@@ -602,8 +605,9 @@ AC_ARG_ENABLE(assembler,
 AC_MSG_CHECKING(if we should use assembler functions)
 # For now we only support assembler on i386 and sparc systems
 AM_CONDITIONAL(ASSEMBLER_x86, test "$ENABLE_ASSEMBLER" = "yes" -a "$BASE_MACHINE_TYPE" = "i386")
-AM_CONDITIONAL(ASSEMBLER_sparc, test "$ENABLE_ASSEMBLER" = "yes" -a "$BASE_MACHINE_TYPE" = "sparc")
-AM_CONDITIONAL(ASSEMBLER, test "$ASSEMBLER_x86_TRUE" = "" -o "$ASSEMBLER_sparc_TRUE" = "")
+AM_CONDITIONAL(ASSEMBLER_sparc32, test "$ENABLE_ASSEMBLER" = "yes" -a "$BASE_MACHINE_TYPE" = "sparc")
+AM_CONDITIONAL(ASSEMBLER_sparc64, test "$ENABLE_ASSEMBLER" = "yes" -a "$BASE_MACHINE_TYPE" = "sparcv9")
+AM_CONDITIONAL(ASSEMBLER, test "$ASSEMBLER_x86_TRUE" = "" -o "$ASSEMBLER_sparc32_TRUE" = "")
 
 if test "$ASSEMBLER_TRUE" = ""
 then
@@ -674,7 +678,7 @@ else
   AC_MSG_RESULT([no])
 fi
 
-AC_SYS_LARGEFILE
+MYSQL_SYS_LARGEFILE
 
 # Types that must be checked AFTER large file support is checked
 AC_TYPE_SIZE_T
@@ -917,8 +921,8 @@ case $SYSTEM_TYPE in
     ;;
   *hpux10.20*)
     echo "Enabling workarounds for hpux 10.20"
-    CFLAGS="$CFLAGS -DHAVE_BROKEN_SNPRINTF -DSIGNALS_DONT_BREAK_READ -DDO_NOT_REMOVE_THREAD_WRAPPERS -DHPUX -DSIGNAL_WITH_VIO_CLOSE -DHAVE_BROKEN_PTHREAD_COND_TIMEDWAIT -DHAVE_POSIX1003_4a_MUTEX"
-    CXXFLAGS="$CXXFLAGS -DHAVE_BROKEN_SNPRINTF -D_INCLUDE_LONGLONG -DSIGNALS_DONT_BREAK_READ -DDO_NOT_REMOVE_THREAD_WRAPPERS -DHPUX -DSIGNAL_WITH_VIO_CLOSE -DHAVE_BROKEN_PTHREAD_COND_TIMEDWAIT -DHAVE_POSIX1003_4a_MUTEX"
+    CFLAGS="$CFLAGS -DHAVE_BROKEN_SNPRINTF -DSIGNALS_DONT_BREAK_READ -DDO_NOT_REMOVE_THREAD_WRAPPERS -DHPUX10 -DSIGNAL_WITH_VIO_CLOSE -DHAVE_BROKEN_PTHREAD_COND_TIMEDWAIT -DHAVE_POSIX1003_4a_MUTEX"
+    CXXFLAGS="$CXXFLAGS -DHAVE_BROKEN_SNPRINTF -D_INCLUDE_LONGLONG -DSIGNALS_DONT_BREAK_READ -DDO_NOT_REMOVE_THREAD_WRAPPERS -DHPUX10 -DSIGNAL_WITH_VIO_CLOSE -DHAVE_BROKEN_PTHREAD_COND_TIMEDWAIT -DHAVE_POSIX1003_4a_MUTEX"
     if test "$with_named_thread" = "no"
     then 
       echo "Using --with-named-thread=-lpthread"
@@ -927,13 +931,19 @@ case $SYSTEM_TYPE in
     ;;
   *hpux11.*)
     echo "Enabling workarounds for hpux 11"
-    CFLAGS="$CFLAGS -DHAVE_BROKEN_PREAD -DDONT_USE_FINITE -DHAVE_BROKEN_GETPASS -DNO_FCNTL_NONBLOCK -DDO_NOT_REMOVE_THREAD_WRAPPERS -DHAVE_BROKEN_PTHREAD_COND_TIMEDWAIT"
-    CXXFLAGS="$CXXFLAGS -DHAVE_BROKEN_PREAD -DDONT_USE_FINITE -D_INCLUDE_LONGLONG -DNO_FCNTL_NONBLOCK -DDO_NOT_REMOVE_THREAD_WRAPPERS -DHAVE_BROKEN_PTHREAD_COND_TIMEDWAIT"
+    CFLAGS="$CFLAGS -DHPUX11 -DHAVE_BROKEN_PREAD -DDONT_USE_FINITE -DHAVE_BROKEN_GETPASS -DNO_FCNTL_NONBLOCK -DDO_NOT_REMOVE_THREAD_WRAPPERS -DHAVE_BROKEN_PTHREAD_COND_TIMEDWAIT"
+    CXXFLAGS="$CXXFLAGS -DHPUX11 -DHAVE_BROKEN_PREAD -DDONT_USE_FINITE -D_INCLUDE_LONGLONG -DNO_FCNTL_NONBLOCK -DDO_NOT_REMOVE_THREAD_WRAPPERS -DHAVE_BROKEN_PTHREAD_COND_TIMEDWAIT"
     if test "$with_named_thread" = "no"
     then 
       echo "Using --with-named-thread=-lpthread"
       with_named_thread="-lpthread"
     fi
+    # Fixes for HPUX 11.0 compiler
+    if test "$ac_cv_prog_gcc" = "no"
+    then
+      CFLAGS="$CFLAGS +DD64 -DHAVE_BROKEN_INLINE"
+      CXXFLAGS="$CXXFLAGS +DD64 +O2"
+    fi
     ;;
   *rhapsody*)
     if test "$ac_cv_prog_gcc" = "yes"
@@ -966,7 +976,8 @@ case $SYSTEM_TYPE in
     ;;
   *freebsd*)
     echo "Adding fix for interrupted reads"
-    CXXFLAGS="$CXXFLAGS -DMYSQLD_NET_RETRY_COUNT=1000000"
+    CFLAGS="$CFLAGS -DHAVE_BROKEN_REALPATH"
+    CXXFLAGS="$CXXFLAGS -DMYSQLD_NET_RETRY_COUNT=1000000 -DHAVE_BROKEN_REALPATH"
     ;;
   *netbsd*)
     echo "Adding flag -Dunix"
diff --git a/dbug/Makefile.am b/dbug/Makefile.am
index 08f0164c02cacf96d872ab68ea7a74c7658e3ed4..bd512ee1d1db889180fb8d26ba78508ac2498d7a 100644
--- a/dbug/Makefile.am
+++ b/dbug/Makefile.am
@@ -15,7 +15,7 @@
 # Software Foundation, Inc., 59 Temple Place - Suite 330, Boston,
 # MA 02111-1307, USA
 
-INCLUDES =		@MT_INCLUDES@ -I$(srcdir)/../include -I../include
+INCLUDES =		@MT_INCLUDES@ -I$(top_srcdir)/include
 LDADD =			libdbug.a ../strings/libmystrings.a
 pkglib_LIBRARIES =	libdbug.a
 noinst_HEADERS =	dbug_long.h
diff --git a/dbug/dbug_add_tags.pl b/dbug/dbug_add_tags.pl
new file mode 100755
index 0000000000000000000000000000000000000000..141a2ed85f1b18e983ff53e0a5336d0d48e5f23a
--- /dev/null
+++ b/dbug/dbug_add_tags.pl
@@ -0,0 +1,73 @@
+#!/usr/bin/perl
+
+die "No files specified\n" unless $ARGV[0];
+
+$ctags="exctags -x -f - --c-types=f -u";
+
+sub get_tag {
+  local $.; local $_=<TAGS>;
+  ($symbol, $line)= /^(.*\S)\s+function\s+(\d+)/;
+  $symbol=$1 if /\s(\S+)\s*\(/;
+  $line=1e50 unless $line;
+}
+
+while($src=shift)
+{
+  warn "==> $src\n";
+ 
+  $dst=$src.$$;
+  open(TAGS, "$ctags $src|") || die "Cannot exec('$ctags $src'): $!";
+  open(SRC, "<$src") || die "Cannot open $src: $!";
+  open(DST, ">$dst") || die "Cannot create $dst: $!";
+  select DST;
+
+  &get_tag;
+  $in_func=0;
+  while(<SRC>)
+  {
+    my $orig=$_;
+    if ($in_func)
+    {
+      if (/\breturn\b/ && !/\/\*.*\breturn\b.*\*\// && !/;/ )
+      {
+        $_.=<SRC> until /;/;
+      }
+      s/(?<=\s)return\s*;/DBUG_VOID_RETURN;/;
+      s/(?<=\s)return\s*(.+)\s*;/DBUG_RETURN(\1);/s;
+      $ret_line=$. if /DBUG_(VOID_)?RETURN/; #{{
+      print "$tab  DBUG_VOID_RETURN;\n" if /^$tab}/ && $ret_line < $.-1;
+      $in_func=0 if /^$tab}/;
+      warn "$src:".($.-1)."\t$orig" if /\breturn\b/;
+    }
+    print;
+    next if $. < $line;
+    die "Something wrong: \$.=$., \$line=$line, \$symbol=$symbol\n" if $. > $line;
+    &get_tag && next if /^\s*inline /;
+    print $_=<SRC> until /{/; $tab=$`;
+    &get_tag && next if /}/; # skip one-liners
+    $semicolon=1;
+    while(<SRC>)
+    {
+      $skip=!$semicolon;
+      $semicolon= /;\s*$/;
+      print && next if $skip ||
+        (/^\s+\w+((::\w+)?|<\w+>)\s+\**\w+/ && !/^\s*return/);
+      last if /DBUG_ENTER/;
+      print "$tab  DBUG_ENTER(\"$symbol\");\n";
+      print "\n" unless $_ eq "\n";
+      last;
+    }
+    $in_func=1;
+    &get_tag;
+    redo;
+  }
+  close SRC;
+  close DST;
+  close TAGS;
+  unlink("$src.orig");
+  rename($src, "$src.orig") || die "Cannot rename $src to $src.orig: $!";
+  rename($dst, $src) || die "Cannot rename $dst to $src: $!";
+}
+
+warn "All done!\n";
+
diff --git a/extra/Makefile.am b/extra/Makefile.am
index 58776144489a9246ec3be86398a2d6f23ad7ea33..6895d7a09f85504abf850781fa34b2dc61709688 100644
--- a/extra/Makefile.am
+++ b/extra/Makefile.am
@@ -14,11 +14,11 @@
 # along with this program; if not, write to the Free Software
 # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
 
-INCLUDES =		@MT_INCLUDES@ -I$(srcdir)/../include -I../include -I..
+INCLUDES =		@MT_INCLUDES@ -I$(top_srcdir)/include
 LDADD =			@CLIENT_EXTRA_LDFLAGS@ ../mysys/libmysys.a \
 			../dbug/libdbug.a ../strings/libmystrings.a
 bin_PROGRAMS =		replace comp_err perror resolveip my_print_defaults \
-resolve_stack_dump mysql_install
+			resolve_stack_dump mysql_install
 
 # Don't update the files from bitkeeper
 %::SCCS/s.%
diff --git a/fs/Makefile.am b/fs/Makefile.am
index 33d1acd913d79afbf0fefeab7929543422ab42b3..6fea3d455a381148403f5597b9d87ed13bfab5fa 100644
--- a/fs/Makefile.am
+++ b/fs/Makefile.am
@@ -27,11 +27,8 @@ DISTCLEANFILES = CorbaFS-common.* CorbaFS-stubs.* CorbaFS-skels.* CorbaFS.h
 MYSQLDATAdir =		$(localstatedir)
 MYSQLSHAREdir =		$(pkgdatadir)
 MYSQLBASEdir=		$(prefix)
-INCLUDES =		@MT_INCLUDES@ -I$(srcdir)/../include \
-			-I$(srcdir)/../regex \
-			-I$(srcdir) -I../include -I.. -I. \
-			-I$(srcdir) -I../include -I.. -I. \
-		         $(orbit_includes)
+INCLUDES =		@MT_INCLUDES@ -I$(top_srcdir)/include \
+			-I$(top_srcdir)/regex $(orbit_includes)
 WRAPLIBS=		@WRAPLIBS@
 libexec_PROGRAMS =   mysqlcorbafsd
 noinst_PROGRAMS =mysqlfs_test 
diff --git a/heap/Makefile.am b/heap/Makefile.am
index 41d98b79ae94ce0080addb0f8b0f2a1e3f54d2b0..ec631148dced7401a4e890950e72193f7d70d532 100644
--- a/heap/Makefile.am
+++ b/heap/Makefile.am
@@ -14,7 +14,7 @@
 # along with this program; if not, write to the Free Software
 # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
 
-INCLUDES =		@MT_INCLUDES@ -I$(srcdir)/../include -I../include 
+INCLUDES =		@MT_INCLUDES@ -I$(top_srcdir)/include 
 LDADD =			libheap.a ../mysys/libmysys.a ../dbug/libdbug.a \
 			../strings/libmystrings.a
 pkglib_LIBRARIES =	libheap.a
diff --git a/heap/heapdef.h b/heap/heapdef.h
index b651bf4bcb17d8923cc7df519719895327552942..63109badb0592d05092c3adefe6a4f582cc5b463 100644
--- a/heap/heapdef.h
+++ b/heap/heapdef.h
@@ -97,7 +97,8 @@ extern uint hp_rb_null_key_length(HP_KEYDEF *keydef, const byte *key);
 extern my_bool hp_if_null_in_key(HP_KEYDEF *keyinfo, const byte *record);
 extern int hp_close(register HP_INFO *info);
 extern void hp_clear(HP_SHARE *info);
-extern uint hp_rb_pack_key(HP_KEYDEF *keydef, uchar *key, const uchar *old);
+extern uint hp_rb_pack_key(HP_KEYDEF *keydef, uchar *key, const uchar *old, 
+			   uint k_len);
 #ifdef THREAD
 extern pthread_mutex_t THR_LOCK_heap;
 #else
diff --git a/heap/hp_create.c b/heap/hp_create.c
index 6c38d54cb12007be747c36db0ab35e0a19c9bdad..40b8202d94fd21dfd4e7fba05e927219d8e72dcc 100644
--- a/heap/hp_create.c
+++ b/heap/hp_create.c
@@ -55,6 +55,22 @@ int heap_create(const char *name, uint keys, HP_KEYDEF *keydef,
 	  if (keyinfo->algorithm == HA_KEY_ALG_BTREE)
 	    keyinfo->rb_tree.size_of_element++;
 	}
+	switch (keyinfo->seg[j].type) {
+	case HA_KEYTYPE_SHORT_INT:
+	case HA_KEYTYPE_LONG_INT:
+	case HA_KEYTYPE_FLOAT:
+	case HA_KEYTYPE_DOUBLE:
+	case HA_KEYTYPE_USHORT_INT:
+	case HA_KEYTYPE_ULONG_INT:
+	case HA_KEYTYPE_LONGLONG:
+	case HA_KEYTYPE_ULONGLONG:
+	case HA_KEYTYPE_INT24:
+	case HA_KEYTYPE_UINT24:
+	case HA_KEYTYPE_INT8:
+	  keyinfo->seg[j].flag|= HA_SWAP_KEY;
+	default:
+	  break;
+	}
       }
       keyinfo->length= length;
       length+= keyinfo->rb_tree.size_of_element + 
diff --git a/heap/hp_hash.c b/heap/hp_hash.c
index e28f4725caf117b7126ed71e8d4115d3c85726c1..cd70d2ab532adee1d299d1c60048497e9c032c7d 100644
--- a/heap/hp_hash.c
+++ b/heap/hp_hash.c
@@ -30,27 +30,27 @@ ha_rows hp_rb_records_in_range(HP_INFO *info, int inx, const byte *start_key,
   TREE *rb_tree = &keyinfo->rb_tree;
   heap_rb_param custom_arg;
 
-  info->lastinx = inx;
-  custom_arg.keyseg = keyinfo->seg;
-  custom_arg.search_flag = SEARCH_FIND | SEARCH_SAME;
-  custom_arg.key_length = start_key_len;
+  info->lastinx= inx;
+  custom_arg.keyseg= keyinfo->seg;
+  custom_arg.search_flag= SEARCH_FIND | SEARCH_SAME;
   if (start_key)
   {
-    hp_rb_pack_key(keyinfo, info->recbuf, start_key);
+    custom_arg.key_length= hp_rb_pack_key(keyinfo, info->recbuf, start_key, 
+					  start_key_len);
     start_pos= tree_record_pos(rb_tree, info->recbuf, start_search_flag, 
-				&custom_arg);
+			       &custom_arg);
   }
   else
   {
     start_pos= 0;
   }
   
-  custom_arg.key_length = end_key_len;
   if (end_key)
   {
-    hp_rb_pack_key(keyinfo, info->recbuf, end_key);
+    custom_arg.key_length= hp_rb_pack_key(keyinfo, info->recbuf, end_key,
+					  end_key_len);
     end_pos= tree_record_pos(rb_tree, info->recbuf, end_search_flag, 
-				&custom_arg);
+			     &custom_arg);
   }
   else
   {
@@ -443,6 +443,43 @@ uint hp_rb_make_key(HP_KEYDEF *keydef, byte *key,
       if (!(*key++= 1 - test(rec[seg->null_pos] & seg->null_bit)))
         continue;
     }
+    if (seg->flag & HA_SWAP_KEY)
+    {
+      uint length= seg->length;
+      byte *pos= (byte*) rec + seg->start;
+      
+#ifdef HAVE_ISNAN
+      if (seg->type == HA_KEYTYPE_FLOAT)
+      {
+	float nr;
+	float4get(nr, pos);
+	if (isnan(nr))
+	{
+	  /* Replace NAN with zero */
+ 	  bzero(key, length);
+	  key+= length;
+	  continue;
+	}
+      }
+      else if (seg->type == HA_KEYTYPE_DOUBLE)
+      {
+	double nr;
+	float8get(nr, pos);
+	if (isnan(nr))
+	{
+ 	  bzero(key, length);
+	  key+= length;
+	  continue;
+	}
+      }
+#endif
+      pos+= length;
+      while (length--)
+      {
+	*key++= *--pos;
+      }
+      continue;
+    }
     memcpy(key, rec + seg->start, (size_t) seg->length);
     key+= seg->length;
   }
@@ -450,21 +487,38 @@ uint hp_rb_make_key(HP_KEYDEF *keydef, byte *key,
   return key - start_key;
 }
 
-uint hp_rb_pack_key(HP_KEYDEF *keydef, uchar *key, const uchar *old)
+uint hp_rb_pack_key(HP_KEYDEF *keydef, uchar *key, const uchar *old, uint k_len)
 {
   HA_KEYSEG *seg, *endseg;
   uchar *start_key= key;
   
-  for (seg= keydef->seg, endseg= seg + keydef->keysegs; seg < endseg; 
-       old+= seg->length, seg++)
+  for (seg= keydef->seg, endseg= seg + keydef->keysegs;
+       seg < endseg && (int) k_len > 0; old+= seg->length, seg++)
   {
     if (seg->null_bit)
     {
+      k_len--;
       if (!(*key++= (char) 1 - *old++))
+      {
+        k_len-= seg->length;
         continue;
+      }
+    }
+    if (seg->flag & HA_SWAP_KEY)
+    {
+      uint length= seg->length;
+      byte *pos= (byte*) old + length;
+      
+      k_len-= length;
+      while (length--)
+      {
+	*key++= *--pos;
+      }
+      continue;
     }
     memcpy((byte*) key, old, seg->length);
     key+= seg->length;
+    k_len-= seg->length;
   }
   return key - start_key;
 }
diff --git a/heap/hp_rkey.c b/heap/hp_rkey.c
index 4e47fd52e9b0de4df2cdd421d4deb7dc802e73e8..92d2982a457c31dde1f6dc9a4e223aff2e0da6da 100644
--- a/heap/hp_rkey.c
+++ b/heap/hp_rkey.c
@@ -36,10 +36,9 @@ int heap_rkey(HP_INFO *info, byte *record, int inx, const byte *key,
   {
     heap_rb_param custom_arg;
 
-    hp_rb_pack_key(keyinfo, info->recbuf, key);
-
     custom_arg.keyseg= info->s->keydef[inx].seg;
-    custom_arg.key_length= key_len;
+    custom_arg.key_length= info->lastkey_len= 
+			hp_rb_pack_key(keyinfo, info->recbuf, key, key_len);
     custom_arg.search_flag= SEARCH_FIND | SEARCH_SAME;
     /* for next rkey() after deletion */
     if (find_flag == HA_READ_AFTER_KEY)
@@ -48,7 +47,6 @@ int heap_rkey(HP_INFO *info, byte *record, int inx, const byte *key,
       info->last_find_flag= HA_READ_KEY_OR_PREV;
     else
       info->last_find_flag= find_flag;
-    info->lastkey_len= key_len;
     if (!(pos= tree_search_key(&keyinfo->rb_tree, info->recbuf, info->parents,
 			       &info->last_pos, find_flag, &custom_arg)))
     {
diff --git a/include/.my_sys.h.swp b/include/.my_sys.h.swp
deleted file mode 100644
index e9d01f0e65d1d4e4ce698ca12b4c8342d2ad1697..0000000000000000000000000000000000000000
Binary files a/include/.my_sys.h.swp and /dev/null differ
diff --git a/include/Makefile.am b/include/Makefile.am
index 2df8b46d36975aec93ae86b83361d64495344279..c88e1ee1e406752206fc52a7613387854bb43850 100644
--- a/include/Makefile.am
+++ b/include/Makefile.am
@@ -20,7 +20,7 @@ pkginclude_HEADERS =	dbug.h m_string.h my_sys.h my_list.h \
 			mysql.h mysql_com.h mysqld_error.h mysql_embed.h \
 		  	my_semaphore.h my_pthread.h my_no_pthread.h raid.h \
 			errmsg.h my_global.h my_net.h my_alloc.h \
-			my_getopt.h sslopt-longopts.h \
+			my_getopt.h sslopt-longopts.h typelib.h \
 			sslopt-vars.h sslopt-case.h $(BUILT_SOURCES)
 noinst_HEADERS =	config-win.h config-os2.h \
 			nisam.h heap.h merge.h my_bitmap.h\
diff --git a/include/config-win.h b/include/config-win.h
index 5bdede86a9e6f9e0fc9bc10aeae70de6634c188b..9c1c1ae48302626dde16681f16d33e52f378d48b 100644
--- a/include/config-win.h
+++ b/include/config-win.h
@@ -23,6 +23,8 @@
 #include <io.h>
 #include <malloc.h>
 
+#define HAVE_SMEM 1
+
 #if defined(__NT__)
 #define SYSTEM_TYPE	"NT"
 #elif defined(__WIN2000__)
@@ -311,3 +313,6 @@ inline double ulonglong2double(ulonglong value)
 #define statistic_add(V,C,L)	 (V)+=(C)
 #endif
 #define statistic_increment(V,L) thread_safe_increment((V),(L))
+
+#define shared_memory_buffer_length 16000
+#define default_shared_memory_base_name "MYSQL";
diff --git a/include/errmsg.h b/include/errmsg.h
index d97522f09729a2d161fe2dafd7ba7903265de3fe..703395a3742f68df641f3ed0c04e819dc5892217 100644
--- a/include/errmsg.h
+++ b/include/errmsg.h
@@ -61,14 +61,27 @@ extern const char *client_errors[];	/* Error messages */
 #define CR_PROBE_SLAVE_HOSTS    2023
 #define CR_PROBE_SLAVE_CONNECT  2024
 #define CR_PROBE_MASTER_CONNECT 2025
+#define CR_SSL_CONNECTION_ERROR 2026
 
 /* new 4.1 error codes */
-#define CR_INVALID_CONN_HANDLE	2026
-#define CR_NULL_POINTER		2027
-#define CR_NO_PREPARE_STMT	2028
-#define CR_NOT_ALL_PARAMS_BOUND	2029
-#define CR_DATA_TRUNCATED	2030
-#define CR_NO_PARAMETERS_EXISTS 2031
-#define CR_INVALID_PARAMETER_NO 2032
-#define CR_INVALID_BUFFER_USE	2033
-#define CR_UNSUPPORTED_PARAM_TYPE 2034
+#define CR_INVALID_CONN_HANDLE	2027
+#define CR_NULL_POINTER		2028
+#define CR_NO_PREPARE_STMT	2029
+#define CR_NOT_ALL_PARAMS_BOUND	2030
+#define CR_DATA_TRUNCATED	2031
+#define CR_NO_PARAMETERS_EXISTS 2032
+#define CR_INVALID_PARAMETER_NO 2033
+#define CR_INVALID_BUFFER_USE	2034
+#define CR_UNSUPPORTED_PARAM_TYPE 2035
+
+#define CR_SHARED_MEMORY_CONNECTION             2036
+#define CR_SHARED_MEMORY_CONNECT_REQUEST_ERROR  2037
+#define CR_SHARED_MEMORY_CONNECT_ANSWER_ERROR   2038
+#define CR_SHARED_MEMORY_CONNECT_FILE_MAP_ERROR 2039
+#define CR_SHARED_MEMORY_CONNECT_MAP_ERROR      2040
+#define CR_SHARED_MEMORY_FILE_MAP_ERROR         2041
+#define CR_SHARED_MEMORY_MAP_ERROR              2042
+#define CR_SHARED_MEMORY_EVENT_ERROR     	2043
+#define CR_SHARED_MEMORY_CONNECT_ABANDODED_ERROR 2044
+#define CR_SHARED_MEMORY_CONNECT_SET_ERROR      2045
+#define CR_CONN_UNKNOW_PROTOCOL 		2046
diff --git a/include/m_ctype.h b/include/m_ctype.h
index 029a1a5db393bcb12bae98eff7ff3823056c78fb..b16db5cde97156b35bc5e1ae08b89d7c243ff5be 100644
--- a/include/m_ctype.h
+++ b/include/m_ctype.h
@@ -81,21 +81,28 @@ typedef struct charset_info_st
   int     (*strnxfrm)(struct charset_info_st *,
 		      uchar *, uint, const uchar *, uint);
   my_bool (*like_range)(struct charset_info_st *,
-			const char *, uint, pchar, uint,
-			char *, char *, uint *, uint *);
-    
+			const char *s, uint s_length,
+			int w_prefix, int w_one, int w_many, 
+			uint res_length,
+			char *min_str, char *max_str,
+			uint *min_len, uint *max_len);
+  int     (*wildcmp)(struct charset_info_st *,
+  		     const char *str,const char *str_end,
+                     const char *wildstr,const char *wildend,
+                     int escape,int w_one, int w_many);
+  
   /* Multibyte routines */
   uint      mbmaxlen;
   int     (*ismbchar)(struct charset_info_st *, const char *, const char *);
   my_bool (*ismbhead)(struct charset_info_st *, uint);
   int     (*mbcharlen)(struct charset_info_st *, uint);
-    
+  
   /* Unicode convertion */
   int (*mb_wc)(struct charset_info_st *cs,my_wc_t *wc,
 	       const unsigned char *s,const unsigned char *e);
   int (*wc_mb)(struct charset_info_st *cs,my_wc_t wc,
 	       unsigned char *s,unsigned char *e);
-    
+  
   /* Functions for case and sort convertion */
   void    (*caseup_str)(struct charset_info_st *, char *);
   void    (*casedn_str)(struct charset_info_st *, char *);
@@ -107,13 +114,23 @@ typedef struct charset_info_st
   int  (*strcasecmp)(struct charset_info_st *, const char *, const char *);
   int  (*strncasecmp)(struct charset_info_st *, const char *, const char *,
 		      uint);
-    
+  
   /* Hash calculation */
   uint (*hash_caseup)(struct charset_info_st *cs, const byte *key, uint len);
   void (*hash_sort)(struct charset_info_st *cs, const uchar *key, uint len,
 		    ulong *nr1, ulong *nr2); 
-    
+  
   char    max_sort_char; /* For LIKE optimization */
+  
+  /* Charset dependant snprintf() */
+  int (*snprintf)(struct charset_info_st *, char *to, uint n, const char *fmt, ...);
+  
+  long        (*strtol)(struct charset_info_st *, const char *s, char **e, int base);
+  ulong      (*strtoul)(struct charset_info_st *, const char *s, char **e, int base);
+  longlong   (*strtoll)(struct charset_info_st *, const char *s, char **e, int base);
+  ulonglong (*strtoull)(struct charset_info_st *, const char *s, char **e, int base);
+  double      (*strtod)(struct charset_info_st *, const char *s, char **e);
+  
 } CHARSET_INFO;
 
 
@@ -150,6 +167,27 @@ extern int my_strncasecmp_8bit(CHARSET_INFO * cs, const char *, const char *, ui
 int my_mb_wc_8bit(CHARSET_INFO *cs,my_wc_t *wc, const uchar *s,const uchar *e);
 int my_wc_mb_8bit(CHARSET_INFO *cs,my_wc_t wc, uchar *s, uchar *e);
 
+int my_snprintf_8bit(struct charset_info_st *, char *to, uint n, const char *fmt, ...);
+
+long        my_strtol_8bit(CHARSET_INFO *, const char *s, char **e, int base);
+ulong      my_strtoul_8bit(CHARSET_INFO *, const char *s, char **e, int base);
+longlong   my_strtoll_8bit(CHARSET_INFO *, const char *s, char **e, int base);
+ulonglong my_strtoull_8bit(CHARSET_INFO *, const char *s, char **e, int base);
+double      my_strtod_8bit(CHARSET_INFO *, const char *s, char **e);
+
+my_bool  my_like_range_simple(CHARSET_INFO *cs,
+			const char *ptr, uint ptr_length,
+			int escape, int w_one, int w_many,
+			uint res_length,
+			char *min_str, char *max_str,
+			uint *min_length, uint *max_length);
+
+
+int my_wildcmp_8bit(CHARSET_INFO *,
+  		     const char *str,const char *str_end,
+                     const char *wildstr,const char *wildend,
+                     int escape, int w_one, int w_many);
+
 
 #ifdef USE_MB
 /* Functions for multibyte charsets */
@@ -159,6 +197,10 @@ extern void my_caseup_mb(CHARSET_INFO *, char *, uint);
 extern void my_casedn_mb(CHARSET_INFO *, char *, uint);
 extern int my_strcasecmp_mb(CHARSET_INFO * cs,const char *, const char *);
 extern int my_strncasecmp_mb(CHARSET_INFO * cs,const char *, const char *t, uint);
+int my_wildcmp_mb(CHARSET_INFO *,
+  		     const char *str,const char *str_end,
+                     const char *wildstr,const char *wildend,
+                     int escape, int w_one, int w_many);
 #endif
 
 
@@ -198,8 +240,9 @@ extern int my_strncasecmp_mb(CHARSET_INFO * cs,const char *, const char *t, uint
 #define use_strnxfrm(s)               ((s)->strnxfrm  != NULL)
 #define my_strnxfrm(s, a, b, c, d)    ((s)->strnxfrm((s), (a), (b), (c), (d)))
 #define my_strnncoll(s, a, b, c, d)   ((s)->strnncoll((s), (a), (b), (c), (d)))
-#define my_like_range(s, a, b, c, d, e, f, g, h) \
-                ((s)->like_range((s), (a), (b), (c), (d), (e), (f), (g), (h)))
+#define my_like_range(s, a, b, c, d, e, f, g, h, i, j) \
+                ((s)->like_range((s), (a), (b), (c), (d), (e), (f), (g), (h), (i), (j)))
+#define my_wildcmp(cs,s,se,w,we,e,o,m)	((cs)->wildcmp((cs),(s),(se),(w),(we),(e),(o),(m)))
 
 #define use_mb(s)                     ((s)->ismbchar != NULL)
 #define my_ismbchar(s, a, b)          ((s)->ismbchar((s), (a), (b)))
@@ -214,6 +257,12 @@ extern int my_strncasecmp_mb(CHARSET_INFO * cs,const char *, const char *t, uint
 #define my_strcasecmp(s, a, b)        ((s)->strcasecmp((s), (a), (b)))
 #define my_strncasecmp(s, a, b, l)    ((s)->strncasecmp((s), (a), (b), (l)))
 
+#define my_strtol(s, a, b, c)         ((s)->strtol((s),(a),(b),(c)))
+#define my_strtoul(s, a, b, c)        ((s)->strtoul((s),(a),(b),(c)))
+#define my_strtoll(s, a, b, c)        ((s)->strtoll((s),(a),(b),(c)))
+#define my_strtoull(s, a, b, c)       ((s)->strtoull((s),(a),(b),(c)))
+#define my_strtod(s, a, b)            ((s)->strtod((s),(a),(b)))
+
 
 /* XXX: still need to take care of this one */
 #ifdef MY_CHARSET_TIS620
diff --git a/include/my_alloc.h b/include/my_alloc.h
index 31f1fb7165f35de0147d73ac33628e8665231e0e..a3dd35d7ea3a5c3ea4842327cad8c699efefb3d2 100644
--- a/include/my_alloc.h
+++ b/include/my_alloc.h
@@ -21,7 +21,8 @@
 #ifndef _my_alloc_h
 #define _my_alloc_h
 
-#define MAX_BLOCK_USAGE_BEFORE_DROP 10
+#define ALLOC_MAX_BLOCK_TO_DROP			4096
+#define ALLOC_MAX_BLOCK_USAGE_BEFORE_DROP	10
 
 typedef struct st_used_mem
 {				   /* struct for once_alloc (block) */
diff --git a/include/my_base.h b/include/my_base.h
index 7e1df17b69df1360ecce80091c278be553e11017..b4e39952f22225c31756014490518040ecc7d069 100644
--- a/include/my_base.h
+++ b/include/my_base.h
@@ -301,8 +301,10 @@ enum data_file_type {
 
 /* For number of records */
 #ifdef BIG_TABLES
+#define rows2double(A)	ulonglong2double(A)
 typedef my_off_t	ha_rows;
 #else
+#define rows2double(A)	(double) (A)
 typedef ulong		ha_rows;
 #endif
 
diff --git a/include/my_global.h b/include/my_global.h
index d1b3c51655578db8ddaef7a255bfac80a6182e67..749a326f86fe8c9452f6fd6991410937b0a9c1df 100644
--- a/include/my_global.h
+++ b/include/my_global.h
@@ -38,6 +38,14 @@
 #define HAVE_ERRNO_AS_DEFINE
 #endif /* __CYGWIN__ */
 
+/* Macros to make switching between C and C++ mode easier */
+#ifdef __cplusplus
+#define C_MODE_START    extern "C" {
+#define C_MODE_END	}
+#else
+#define C_MODE_START
+#define C_MODE_END
+#endif
 
 #if defined(_WIN32) || defined(_WIN64) || defined(__WIN32__) || defined(WIN32)
 #include <config-win.h>
@@ -119,7 +127,12 @@
 #define _H_STRINGS
 #define _SYS_STREAM_H
 /* #define _AIX32_CURSES */	/* XXX: this breaks AIX 4.3.3 (others?). */
-#endif
+#define ulonglong2double(A) my_ulonglong2double(A)
+#define my_off_t2double(A)  my_ulonglong2double(A)
+C_MODE_START
+double my_ulonglong2double(unsigned long long A);
+C_MODE_END
+#endif /* _AIX */
 
 #ifdef HAVE_BROKEN_SNPRINTF	/* HPUX 10.20 don't have this defined */
 #undef HAVE_SNPRINTF
@@ -128,6 +141,10 @@
 #undef HAVE_PREAD
 #undef HAVE_PWRITE
 #endif
+#if defined(HAVE_BROKEN_INLINE) && !defined(__cplusplus)
+#undef inline
+#define inline
+#endif
 
 #ifdef UNDEF_HAVE_GETHOSTBYNAME_R		/* For OSF4.x */
 #undef HAVE_GETHOSTBYNAME_R
@@ -240,7 +257,7 @@
 #ifdef DONT_USE_FINITE		/* HPUX 11.x has is_finite() */
 #undef HAVE_FINITE
 #endif
-#if defined(HPUX) && defined(_LARGEFILE64_SOURCE) && defined(THREAD)
+#if defined(HPUX10) && defined(_LARGEFILE64_SOURCE) && defined(THREAD)
 /* Fix bug in setrlimit */
 #undef setrlimit
 #define setrlimit cma_setrlimit64
@@ -376,7 +393,9 @@ typedef int	my_socket;	/* File descriptor for sockets */
 #endif
 /* Type for fuctions that handles signals */
 #define sig_handler RETSIGTYPE
+C_MODE_START
 typedef void	(*sig_return)();/* Returns type from signal */
+C_MODE_END
 #if defined(__GNUC__) && !defined(_lint)
 typedef char	pchar;		/* Mixed prototypes can take char */
 typedef char	puchar;		/* Mixed prototypes can take char */
@@ -390,8 +409,10 @@ typedef int	pbool;		/* Mixed prototypes can't take char */
 typedef int	pshort;		/* Mixed prototypes can't take short int */
 typedef double	pfloat;		/* Mixed prototypes can't take float */
 #endif
+C_MODE_START
 typedef int	(*qsort_cmp)(const void *,const void *);
 typedef int	(*qsort_cmp2)(void*, const void *,const void *);
+C_MODE_END
 #ifdef HAVE_mit_thread
 #define qsort_t void
 #undef QSORT_TYPE_IS_VOID
@@ -1029,13 +1050,4 @@ typedef union {
 #define statistic_add(V,C,L)       (V)+=(C)
 #endif
 
-/* Macros to make switching between C and C++ mode easier */
-#ifdef __cplusplus
-#define C_MODE_START    extern "C" {
-#define C_MODE_END	}
-#else
-#define C_MODE_START
-#define C_MODE_END
-#endif
-
-#endif /* _global_h */
+#endif /* my_global_h */
diff --git a/include/my_net.h b/include/my_net.h
index 2f5743923cf22c59f58199c833302de52eebad9e..ec985ded76b94560ba11fefd3b2860931eaee8fa 100644
--- a/include/my_net.h
+++ b/include/my_net.h
@@ -71,7 +71,7 @@ void my_inet_ntoa(struct in_addr in, char *buf);
   Handling of gethostbyname_r()
 */
 
-#if !defined(HPUX)
+#if !defined(HPUX10)
 struct hostent;
 #endif /* HPUX */
 #if !defined(HAVE_GETHOSTBYNAME_R)
@@ -84,7 +84,7 @@ struct hostent *my_gethostbyname_r(const char *name,
 				   struct hostent *result, char *buffer,
 				   int buflen, int *h_errnop);
 #define my_gethostbyname_r_free()
-#if !defined(HAVE_GETHOSTBYNAME_R_GLIBC2_STYLE) && !defined(HPUX)
+#if !defined(HAVE_GETHOSTBYNAME_R_GLIBC2_STYLE) && !defined(HPUX10)
 #define GETHOSTBYNAME_BUFF_SIZE sizeof(struct hostent_data)
 #endif /* !defined(HAVE_GETHOSTBYNAME_R_GLIBC2_STYLE) */
 
diff --git a/include/my_pthread.h b/include/my_pthread.h
index 9b7812b7cf222c6f301317a3137634facc87ffc4..f75ca8f601a06e411712554dd344ab2eebb2b8af 100644
--- a/include/my_pthread.h
+++ b/include/my_pthread.h
@@ -428,7 +428,7 @@ struct tm *localtime_r(const time_t *clock, struct tm *res);
 
 #endif /* defined(__WIN__) */
 
-#if defined(HPUX) && !defined(DONT_REMAP_PTHREAD_FUNCTIONS)
+#if defined(HPUX10) && !defined(DONT_REMAP_PTHREAD_FUNCTIONS)
 #undef pthread_cond_timedwait
 #define pthread_cond_timedwait(a,b,c) my_pthread_cond_timedwait((a),(b),(c))
 int my_pthread_cond_timedwait(pthread_cond_t *cond, pthread_mutex_t *mutex,
diff --git a/include/my_sys.h b/include/my_sys.h
index f1b4841adb3345071142f8c2e30d2e287d1ea55e..ab5dedc0ba10c989f2c3dd6a0891c7531e243234 100644
--- a/include/my_sys.h
+++ b/include/my_sys.h
@@ -37,6 +37,7 @@ extern int NEAR my_errno;		/* Last error in mysys */
 #endif
 
 #include <stdarg.h>
+#include <typelib.h>
 
 #define MYSYS_PROGRAM_USES_CURSES()  { error_handler_hook = my_message_curses;	mysys_uses_curses=1; }
 #define MYSYS_PROGRAM_DONT_USE_CURSES()  { error_handler_hook = my_message_no_curses; mysys_uses_curses=0;}
@@ -247,12 +248,6 @@ typedef struct wild_file_pack	/* Struct to hold info when selecting files */
   my_string	*wild;		/* Pointer to wildcards */
 } WF_PACK;
 
-typedef struct st_typelib {	/* Different types saved here */
-  uint count;			/* How many types */
-  const char *name;		/* Name of typelib */
-  const char **type_names;
-} TYPELIB;
-
 enum cache_type
 {
   READ_CACHE,WRITE_CACHE,
@@ -558,6 +553,7 @@ extern char *_my_strdup_with_length(const byte *from, uint length,
 				    const char *sFile, uint uLine,
 				    myf MyFlag);
 
+
 #ifndef TERMINATE
 extern void TERMINATE(FILE *file);
 #endif
@@ -706,9 +702,6 @@ extern void freeze_size(DYNAMIC_ARRAY *array);
 #define dynamic_element(array,array_index,type) ((type)((array)->buffer) +(array_index))
 #define push_dynamic(A,B) insert_dynamic(A,B)
 
-extern int find_type(my_string x,TYPELIB *typelib,uint full_name);
-extern void make_type(my_string to,uint nr,TYPELIB *typelib);
-extern const char *get_type(TYPELIB *typelib,uint nr);
 extern my_bool init_dynamic_string(DYNAMIC_STRING *str, const char *init_str,
 				   uint init_alloc,uint alloc_increment);
 extern my_bool dynstr_append(DYNAMIC_STRING *str, const char *append);
diff --git a/include/my_tree.h b/include/my_tree.h
index 05e93df85936c3036136751359f4f54f8b4ade92..0e705e19bbaf1a5a362664366eac8b5d71e7b88f 100644
--- a/include/my_tree.h
+++ b/include/my_tree.h
@@ -83,7 +83,6 @@ void *tree_search(TREE *tree, void *key, void *custom_arg);
 int tree_walk(TREE *tree,tree_walk_action action,
 	      void *argument, TREE_WALK visit);
 int tree_delete(TREE *tree, void *key, void *custom_arg);
-
 void *tree_search_key(TREE *tree, const void *key, 
                       TREE_ELEMENT **parents, TREE_ELEMENT ***last_pos,
                       enum ha_rkey_function flag, void *custom_arg);
@@ -91,8 +90,11 @@ void *tree_search_edge(TREE *tree, TREE_ELEMENT **parents,
                         TREE_ELEMENT ***last_pos, int child_offs);
 void *tree_search_next(TREE *tree, TREE_ELEMENT ***last_pos, int l_offs, 
                        int r_offs);
-uint tree_record_pos(TREE *tree, const void *key, 
+ha_rows tree_record_pos(TREE *tree, const void *key, 
                      enum ha_rkey_function search_flag, void *custom_arg);
+
+#define TREE_ELEMENT_EXTRA_SIZE (sizeof(TREE_ELEMENT) + sizeof(void*))
+
 #ifdef	__cplusplus
 }
 #endif
diff --git a/include/myisam.h b/include/myisam.h
index acaf8bb7618341fc9bb87f82695c039b48ec69bc..f11b18824d5e08ecd55f14f14bedbabaf7c00c92 100644
--- a/include/myisam.h
+++ b/include/myisam.h
@@ -285,7 +285,7 @@ extern uint mi_get_pointer_length(ulonglong file_length, uint def);
 #define T_VERBOSE               (1L << 28)
 #define T_VERY_SILENT           (1L << 29)
 #define T_WAIT_FOREVER          (1L << 30)
-#define T_WRITE_LOOP            (1L << 31)
+#define T_WRITE_LOOP            ((ulong) 1L << 31)
 
 #define T_REP_ANY               (T_REP | T_REP_BY_SORT | T_REP_PARALLEL)
 
diff --git a/include/myisammrg.h b/include/myisammrg.h
index c3b3b39424b9be95e1ab347eaf0cbc75dfab8265..16d3528717be44a9120ac6b6ab4afba730d4b1b6 100644
--- a/include/myisammrg.h
+++ b/include/myisammrg.h
@@ -84,6 +84,7 @@ extern int myrg_rfirst(MYRG_INFO *file,byte *buf,int inx);
 extern int myrg_rlast(MYRG_INFO *file,byte *buf,int inx);
 extern int myrg_rnext(MYRG_INFO *file,byte *buf,int inx);
 extern int myrg_rprev(MYRG_INFO *file,byte *buf,int inx);
+extern int myrg_rnext_same(MYRG_INFO *file,byte *buf);
 extern int myrg_rkey(MYRG_INFO *file,byte *buf,int inx,const byte *key,
 		       uint key_len, enum ha_rkey_function search_flag);
 extern int myrg_rrnd(MYRG_INFO *file,byte *buf,ulonglong pos);
diff --git a/include/myisampack.h b/include/myisampack.h
index 31666bb184c0f9c1788532442be4c7e5a4366e6f..95793e2aaeb5f590f97e47dea6884c18544ef0eb 100644
--- a/include/myisampack.h
+++ b/include/myisampack.h
@@ -212,9 +212,9 @@
 
 /* Fix to avoid warnings when sizeof(ha_rows) == sizeof(long) */
 
-#ifdef BIG_TABLE
+#ifdef BIG_TABLES
 #define mi_rowstore(T,A)    mi_int8store(T,A)
-#define mi_rowkorr(T,A)     mi_uint8korr(T)
+#define mi_rowkorr(T)	    mi_uint8korr(T)
 #else
 #define mi_rowstore(T,A)    { mi_int4store(T,0); mi_int4store(((T)+4),A); }
 #define mi_rowkorr(T)	    mi_uint4korr((T)+4)
diff --git a/include/mysql.h b/include/mysql.h
index 710f50067241b7469dad89bbf2a0066ab9e4b516..67558e39cdb298dc93486284bdd16bf6581eae21 100644
--- a/include/mysql.h
+++ b/include/mysql.h
@@ -56,6 +56,12 @@ typedef int my_socket;
 
 #include "mysql_com.h"
 #include "mysql_version.h"
+#include "typelib.h"
+#ifndef DBUG_OFF
+#define CHECK_EXTRA_ARGUMENTS
+#endif
+
+#include "my_list.h" /* for LISTs used in 'MYSQL' and 'MYSQL_STMT' */
 
 extern unsigned int mysql_port;
 extern char *mysql_unix_port;
@@ -137,24 +143,36 @@ struct st_mysql_options {
    a read that is replication-aware
  */
   my_bool no_master_reads;
+  char *shared_memory_base_name;
+  unsigned int protocol;
 };
 
-enum mysql_option { MYSQL_OPT_CONNECT_TIMEOUT, MYSQL_OPT_COMPRESS,
-		    MYSQL_OPT_NAMED_PIPE, MYSQL_INIT_COMMAND,
-		    MYSQL_READ_DEFAULT_FILE, MYSQL_READ_DEFAULT_GROUP,
-		    MYSQL_SET_CHARSET_DIR, MYSQL_SET_CHARSET_NAME,
-		    MYSQL_OPT_LOCAL_INFILE};
+enum mysql_option 
+{
+  MYSQL_OPT_CONNECT_TIMEOUT, MYSQL_OPT_COMPRESS, MYSQL_OPT_NAMED_PIPE, MYSQL_INIT_COMMAND,
+  MYSQL_READ_DEFAULT_FILE, MYSQL_READ_DEFAULT_GROUP,MYSQL_SET_CHARSET_DIR, MYSQL_SET_CHARSET_NAME,
+  MYSQL_OPT_LOCAL_INFILE, MYSQL_OPT_PROTOCOL, MYSQL_SHARED_MEMORY_BASE_NAME
+};
 
-enum mysql_status { MYSQL_STATUS_READY,MYSQL_STATUS_GET_RESULT,
-		    MYSQL_STATUS_USE_RESULT};
+enum mysql_status 
+{
+  MYSQL_STATUS_READY,MYSQL_STATUS_GET_RESULT,MYSQL_STATUS_USE_RESULT
+};
 
+enum mysql_protocol_type 
+{
+  MYSQL_PROTOCOL_DEFAULT, MYSQL_PROTOCOL_TCP, MYSQL_PROTOCOL_SOCKET, MYSQL_PROTOCOL_PIPE, 
+  MYSQL_PROTOCOL_MEMORY
+};
 /*
   There are three types of queries - the ones that have to go to
   the master, the ones that go to a slave, and the adminstrative
   type which must happen on the pivot connectioin
 */
-enum mysql_rpl_type { MYSQL_RPL_MASTER, MYSQL_RPL_SLAVE,
-		      MYSQL_RPL_ADMIN };
+enum mysql_rpl_type 
+{
+  MYSQL_RPL_MASTER, MYSQL_RPL_SLAVE, MYSQL_RPL_ADMIN
+};
 
 
 typedef struct st_mysql
@@ -197,6 +215,8 @@ typedef struct st_mysql
   struct st_mysql* last_used_slave; /* needed for round-robin slave pick */
  /* needed for send/read/store/use result to work correctly with replication */
   struct st_mysql* last_used_con;
+
+  LIST  *stmts;                     /* list of all statements */
 } MYSQL;
 
 
@@ -411,7 +431,7 @@ int             STDCALL mysql_manager_fetch_line(MYSQL_MANAGER* con,
 */
 
 /* statement state */
-enum MY_STMT_STATE { MY_ST_UNKNOWN, MY_ST_PREPARE, MY_ST_EXECUTE };
+enum PREP_STMT_STATE { MY_ST_UNKNOWN, MY_ST_PREPARE, MY_ST_EXECUTE };
 
 /* bind structure */
 typedef struct st_mysql_bind
@@ -429,7 +449,7 @@ typedef struct st_mysql_bind
   my_bool	long_ended;		/* All data supplied for long */
   unsigned int	param_number;		/* For null count and error messages */
   void (*store_param_func)(NET *net, struct st_mysql_bind *param);
-  char *(*fetch_result)(struct st_mysql_bind *, const char *row);
+  void (*fetch_result)(struct st_mysql_bind *, unsigned char **row);
 } MYSQL_BIND;
 
 
@@ -441,6 +461,7 @@ typedef struct st_mysql_stmt
   MYSQL_RES	*result;		/* resultset */
   MYSQL_BIND	*bind;			/* row binding */
   MYSQL_FIELD	*fields;		/* prepare meta info */
+  LIST          list;                   /* list to keep track of all stmts */
   char		*query;			/* query buffer */
   MEM_ROOT	mem_root;		/* root allocations */
   MYSQL_RES	tmp_result;		/* Used by mysql_prepare_result */
@@ -449,10 +470,12 @@ typedef struct st_mysql_stmt
   unsigned long long_length;		/* long buffer alloced length */
   unsigned long	stmt_id;		/* Id for prepared statement */
   unsigned int	last_errno;		/* error code */
-  enum MY_STMT_STATE state;		/* statement state */
+  enum PREP_STMT_STATE state;		/* statement state */
   char		last_error[MYSQL_ERRMSG_SIZE]; /* error message */
   my_bool	long_alloced;		/* flag to indicate long alloced */
-  my_bool	types_supplied;		/* to indicate types supply */
+  my_bool	send_types_to_server;	/* to indicate types supply to server */
+  my_bool       param_buffers;          /* to indicate the param bound buffers */
+  my_bool       res_buffers;            /* to indicate the output bound buffers */
 } MYSQL_STMT;
 
 
diff --git a/include/mysql_com.h b/include/mysql_com.h
index 5bf0394c7b0d5c7b9836ab735b5e8815d0f80425..ebb0522e9be848e2190a99db5aa8bc1945867567 100644
--- a/include/mysql_com.h
+++ b/include/mysql_com.h
@@ -302,6 +302,7 @@ void my_thread_end(void);
 #endif
 
 #define NULL_LENGTH ((unsigned long) ~0) /* For net_store_length */
+#define MYSQL_STMT_HEADER       4
 #define	MYSQL_LONG_DATA_HEADER	8
 
 #endif
diff --git a/include/mysqld_error.h b/include/mysqld_error.h
index 125059af7fd2bcaeeebd4695922aed3f36050aa2..ed83c5e57a8201ee952866f0c133baf6f966ec20 100644
--- a/include/mysqld_error.h
+++ b/include/mysqld_error.h
@@ -259,4 +259,7 @@
 #define ER_SUBSELECT_NO_1_ROW 1240
 #define ER_UNKNOWN_STMT_HANDLER 1241
 #define ER_CORRUPT_HELP_DB 1242
-#define ER_ERROR_MESSAGES 243
+#define ER_CYCLIC_REFERENCE 1243
+#define ER_AUTO_CONVERT	1244
+#define ER_ILLEGAL_REFERENCE 1245
+#define ER_ERROR_MESSAGES 246
diff --git a/include/queues.h b/include/queues.h
index 70cb99a1513b976a912512bbf97d14c28f577459..699705d0869119d5b1052c4ebb703930108dd353 100644
--- a/include/queues.h
+++ b/include/queues.h
@@ -41,12 +41,13 @@ typedef struct st_queue {
 #define queue_element(queue,index) ((queue)->root[index+1])
 #define queue_end(queue) ((queue)->root[(queue)->elements])
 #define queue_replaced(queue) _downheap(queue,1)
+typedef int (*queue_compare)(void *,byte *, byte *);
 
 int init_queue(QUEUE *queue,uint max_elements,uint offset_to_key,
-	       pbool max_at_top, int (*compare)(void *,byte *, byte *),
+	       pbool max_at_top, queue_compare compare,
 	       void *first_cmp_arg);
 int reinit_queue(QUEUE *queue,uint max_elements,uint offset_to_key,
-                 pbool max_at_top, int (*compare)(void *,byte *, byte *),
+                 pbool max_at_top, queue_compare compare,
                  void *first_cmp_arg);
 void delete_queue(QUEUE *queue);
 void queue_insert(QUEUE *queue,byte *element);
diff --git a/include/typelib.h b/include/typelib.h
new file mode 100644
index 0000000000000000000000000000000000000000..8de94aba553438ec6094be79ac1ae586c65a5dbb
--- /dev/null
+++ b/include/typelib.h
@@ -0,0 +1,33 @@
+/* Copyright (C) 2000 MySQL AB
+
+   This program is free software; you can redistribute it and/or modify
+   it under the terms of the GNU General Public License as published by
+   the Free Software Foundation; either version 2 of the License, or
+   (at your option) any later version.
+
+   This program is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+   GNU General Public License for more details.
+
+   You should have received a copy of the GNU General Public License
+   along with this program; if not, write to the Free Software
+   Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA */
+
+
+#ifndef _typelib_h
+#define _typelib_h
+
+typedef struct st_typelib {	/* Different types saved here */
+  uint count;			/* How many types */
+  const char *name;		/* Name of typelib */
+  const char **type_names;
+} TYPELIB;
+
+extern int find_type(char *x,TYPELIB *typelib,uint full_name);
+extern void make_type(char *to,uint nr,TYPELIB *typelib);
+extern const char *get_type(TYPELIB *typelib,uint nr);
+
+extern TYPELIB sql_protocol_typelib;
+
+#endif /* _typelib_h */
diff --git a/include/violite.h b/include/violite.h
index f4f40dcb64bc79c6dcd7cccda4c425054c99662d..b8bfb2183a2e6547c93f9b434cd2781b7f54297d 100644
--- a/include/violite.h
+++ b/include/violite.h
@@ -32,7 +32,7 @@ extern "C" {
 #endif /* __cplusplus */
 
 enum enum_vio_type { VIO_CLOSED, VIO_TYPE_TCPIP, VIO_TYPE_SOCKET,
-		     VIO_TYPE_NAMEDPIPE, VIO_TYPE_SSL};
+		     VIO_TYPE_NAMEDPIPE, VIO_TYPE_SSL,VIO_TYPE_SHARED_MEMORY};
 
 #ifndef __WIN__
 #define HANDLE void *
@@ -41,6 +41,9 @@ enum enum_vio_type { VIO_CLOSED, VIO_TYPE_TCPIP, VIO_TYPE_SOCKET,
 Vio*	vio_new(my_socket sd, enum enum_vio_type type, my_bool localhost);
 #ifdef __WIN__
 Vio*	vio_new_win32pipe(HANDLE hPipe);
+Vio*	vio_new_win32shared_memory(NET *net,HANDLE handle_file_map, HANDLE handle_map,
+                                HANDLE event_server_wrote, HANDLE event_server_read,
+                                HANDLE event_client_wrote, HANDLE event_client_read);
 #endif
 void	vio_delete(Vio* vio);
 
@@ -107,6 +110,17 @@ my_bool vio_poll_read(Vio *vio,uint timeout);
 }
 #endif
 
+#ifdef HAVE_SMEM
+int vio_read_shared_memory(Vio *vio, gptr buf, int size);
+int vio_write_shared_memory(Vio *vio, const gptr buf, int size);
+int vio_close_shared_memory(Vio * vio);
+#endif
+#ifdef __WIN__
+int vio_read_pipe(Vio *vio, gptr buf, int size);
+int vio_write_pipe(Vio *vio, const gptr buf, int size);
+int vio_close_pipe(Vio * vio);
+#endif
+
 #if defined(HAVE_VIO) && !defined(DONT_MAP_VIO)
 #define vio_delete(vio) 			(vio)->viodelete(vio)
 #define vio_errno(vio)	 			(vio)->vioerrno(vio)
@@ -174,7 +188,7 @@ struct st_VioSSLConnectorFd
   SSL_METHOD* ssl_method_;
 };
 
-void sslaccept(struct st_VioSSLAcceptorFd*, Vio*, long timeout);
+int sslaccept(struct st_VioSSLAcceptorFd*, Vio*, long timeout);
 int sslconnect(struct st_VioSSLConnectorFd*, Vio*, long timeout);
 
 struct st_VioSSLConnectorFd
@@ -231,8 +245,18 @@ struct st_vio
 
 #ifdef HAVE_OPENSSL
   SSL* ssl_;
-  my_bool open_;
 #endif /* HAVE_OPENSSL */
+#ifdef HAVE_SMEM
+  HANDLE handle_file_map;
+  char *handle_map;
+  HANDLE event_server_wrote;
+  HANDLE event_server_read;
+  HANDLE event_client_wrote;
+  HANDLE event_client_read;
+  long  shared_memory_remain;
+  char *shared_memory_pos;
+  NET *net;
+#endif /* HAVE_SMEM */
 #endif /* HAVE_VIO */
 };
 #endif /* EMBEDDED_LIBRARY */
diff --git a/innobase/btr/btr0btr.c b/innobase/btr/btr0btr.c
index 7a7678b2dcf535596a5cab4e84366f856ff193ae..a1665aefab7e90b4c3cdcf1060a3a8902b56a7f1 100644
--- a/innobase/btr/btr0btr.c
+++ b/innobase/btr/btr0btr.c
@@ -274,6 +274,7 @@ btr_page_create(
 	ut_ad(mtr_memo_contains(mtr, buf_block_align(page),
 			      				MTR_MEMO_PAGE_X_FIX));
 	page_create(page, mtr);
+	buf_block_align(page)->check_index_page_at_flush = TRUE;
 	
 	btr_page_set_index_id(page, tree->id, mtr);
 }
@@ -713,6 +714,7 @@ btr_create(
 	
 	/* Create a new index page on the the allocated segment page */
 	page = page_create(frame, mtr);
+	buf_block_align(page)->check_index_page_at_flush = TRUE;
 
 	/* Set the index id of the page */
 	btr_page_set_index_id(page, index_id, mtr);
@@ -847,6 +849,7 @@ btr_page_reorganize_low(
 	segment headers, next page-field, etc.) is preserved intact */
 
 	page_create(page, mtr);
+	buf_block_align(page)->check_index_page_at_flush = TRUE;
 	
 	/* Copy the records from the temporary space to the recreated page;
 	do not copy the lock bits yet */
@@ -919,6 +922,7 @@ btr_page_empty(
 	segment headers, next page-field, etc.) is preserved intact */
 
 	page_create(page, mtr);
+	buf_block_align(page)->check_index_page_at_flush = TRUE;
 }
 
 /*****************************************************************
@@ -2291,29 +2295,54 @@ btr_check_node_ptr(
 /****************************************************************
 Checks the size and number of fields in a record based on the definition of
 the index. */
-static
+
 ibool
 btr_index_rec_validate(
 /*====================*/
-				/* out: TRUE if ok */
-	rec_t*		rec,	/* in: index record */
-	dict_index_t*	index)	/* in: index */
+					/* out: TRUE if ok */
+	rec_t*		rec,		/* in: index record */
+	dict_index_t*	index,		/* in: index */
+	ibool		dump_on_error)	/* in: TRUE if the function
+					should print hex dump of record
+					and page on error */
 {
 	dtype_t* type;
 	byte*	data;
 	ulint	len;
 	ulint	n;
 	ulint	i;
+	page_t*	page;
 	char	err_buf[1000];
+
+	page = buf_frame_align(rec);
 	
+	if (index->type & DICT_UNIVERSAL) {
+	        /* The insert buffer index tree can contain records from any
+	        other index: we cannot check the number of fields or
+	        their length */
+
+	        return(TRUE);
+	}
+
 	n = dict_index_get_n_fields(index);
 
 	if (rec_get_n_fields(rec) != n) {
-		fprintf(stderr, "Record has %lu fields, should have %lu\n",
-				rec_get_n_fields(rec), n);
+		fprintf(stderr,
+"InnoDB: Record in index %s in table %s, page %lu, at offset %lu\n"
+"InnoDB: has %lu fields, should have %lu\n",
+			index->name, index->table_name,
+			buf_frame_get_page_no(page), (ulint)(rec - page),
+			rec_get_n_fields(rec), n);
+
+		if (!dump_on_error) {
+
+			return(FALSE);
+		}
+
+		buf_page_print(page);
 
 		rec_sprintf(err_buf, 900, rec);
-	  	fprintf(stderr, "InnoDB: record %s\n", err_buf);
+	  	fprintf(stderr, "InnoDB: corrupt record %s\n", err_buf);
 
 		return(FALSE);
 	}
@@ -2324,13 +2353,25 @@ btr_index_rec_validate(
 		type = dict_index_get_nth_type(index, i);
 		
 		if (len != UNIV_SQL_NULL && dtype_is_fixed_size(type)
-		    && len != dtype_get_fixed_size(type)) {
+		    			&& len != dtype_get_fixed_size(type)) {
 			fprintf(stderr,
-			"Record field %lu len is %lu, should be %lu\n",
+"InnoDB: Record in index %s in table %s, page %lu, at offset %lu\n"
+"InnoDB: field %lu len is %lu, should be %lu\n",
+				index->name, index->table_name,
+				buf_frame_get_page_no(page),
+				(ulint)(rec - page),
 				i, len, dtype_get_fixed_size(type));
 
+			if (!dump_on_error) {
+	
+				return(FALSE);
+			}
+
+			buf_page_print(page);
+
 			rec_sprintf(err_buf, 900, rec);
-	  		fprintf(stderr, "InnoDB: record %s\n", err_buf);
+	  		fprintf(stderr,
+                             "InnoDB: corrupt record %s\n", err_buf);
 
 			return(FALSE);
 		}
@@ -2361,12 +2402,13 @@ btr_index_page_validate(
 		rec = (&cur)->rec;
 
 		if (page_cur_is_after_last(&cur)) {
+
 			break;
 		}
 
-		if (!btr_index_rec_validate(rec, index)) {
+		if (!btr_index_rec_validate(rec, index, TRUE)) {
 
-			ret = FALSE;
+			return(FALSE);
 		}
 
 		page_cur_move_to_next(&cur);
@@ -2423,25 +2465,26 @@ btr_validate_level(
 
 	index = UT_LIST_GET_FIRST(tree->tree_indexes);
 	
-	/* Now we are on the desired level */
+	/* Now we are on the desired level. Loop through the pages on that
+	level. */
 loop:
 	mtr_x_lock(dict_tree_get_lock(tree), &mtr);
 
 	/* Check ordering etc. of records */
 
 	if (!page_validate(page, index)) {
-		fprintf(stderr, "Error in page %lu in index %s\n",
-			buf_frame_get_page_no(page), index->name);
+		fprintf(stderr,
+"InnoDB: Error in page %lu in index %s table %s, index tree level %lu\n",
+			buf_frame_get_page_no(page), index->name,
+			index->table_name, level);
 
 		ret = FALSE;
-	}
+	} else if (level == 0) {
+		/* We are on level 0. Check that the records have the right
+		number of fields, and field lengths are right. */
 
-	if (level == 0) {
 		if (!btr_index_page_validate(page, index)) {
- 			fprintf(stderr,
-				"Error in page %lu in index %s, level %lu\n",
-				buf_frame_get_page_no(page), index->name,
-								level);
+
 			ret = FALSE;
 		}
 	}
@@ -2464,14 +2507,17 @@ btr_validate_level(
 			UT_LIST_GET_FIRST(tree->tree_indexes)) >= 0) {
 
  			fprintf(stderr,
-			"InnoDB: Error on pages %lu and %lu in index %s\n",
+		"InnoDB: Error on pages %lu and %lu in index %s table %s\n",
 				buf_frame_get_page_no(page),
 				right_page_no,
-				index->name);
+				index->name, index->table_name);
 
 			fprintf(stderr,
 			"InnoDB: records in wrong order on adjacent pages\n");
 
+			buf_page_print(page);
+			buf_page_print(right_page);
+
 			rec_sprintf(err_buf, 900,
 				page_rec_get_prev(page_get_supremum_rec(page)));
 	  		fprintf(stderr, "InnoDB: record %s\n", err_buf);
@@ -2494,6 +2540,7 @@ btr_validate_level(
 		/* Check father node pointers */
 	
 		node_ptr = btr_page_get_father_node_ptr(tree, page, &mtr);
+		father_page = buf_frame_align(node_ptr);
 
 		if (btr_node_ptr_get_child_page_no(node_ptr) !=
 						buf_frame_get_page_no(page)
@@ -2501,13 +2548,16 @@ btr_validate_level(
 		   	page_rec_get_prev(page_get_supremum_rec(page)),
 								&mtr)) {
  			fprintf(stderr,
-			"InnoDB: Error on page %lu in index %s\n",
+			"InnoDB: Error on page %lu in index %s table %s\n",
 				buf_frame_get_page_no(page),
-				index->name);
+				index->name, index->table_name);
 
 			fprintf(stderr,
 			"InnoDB: node pointer to the page is wrong\n");
 
+			buf_page_print(father_page);
+			buf_page_print(page);
+
 			rec_sprintf(err_buf, 900, node_ptr);
 				
 	  		fprintf(stderr, "InnoDB: node ptr %s\n", err_buf);
@@ -2528,8 +2578,6 @@ btr_validate_level(
 		   	goto node_ptr_fails;
 		}
 
-		father_page = buf_frame_align(node_ptr);
-
 		if (btr_page_get_level(page, &mtr) > 0) {
 			heap = mem_heap_create(256);
 		
@@ -2543,9 +2591,12 @@ btr_validate_level(
 			if (cmp_dtuple_rec(node_ptr_tuple, node_ptr) != 0) {
 
 	 			fprintf(stderr,
-				  "InnoDB: Error on page %lu in index %s\n",
+			"InnoDB: Error on page %lu in index %s table %s\n",
 					buf_frame_get_page_no(page),
-					index->name);
+					index->name, index->table_name);
+
+				buf_page_print(father_page);
+				buf_page_print(page);
 
 	  			fprintf(stderr,
                 	"InnoDB: Error: node ptrs differ on levels > 0\n");
@@ -2595,9 +2646,13 @@ btr_validate_level(
 			"InnoDB: node pointer to the right page is wrong\n");
 
 	 				fprintf(stderr,
-				  "InnoDB: Error on page %lu in index %s\n",
+			"InnoDB: Error on page %lu in index %s table %s\n",
 					buf_frame_get_page_no(page),
-					index->name);
+					index->name, index->table_name);
+
+					buf_page_print(father_page);
+					buf_page_print(page);
+					buf_page_print(right_page);
 				}
 			} else {
 				right_father_page = buf_frame_align(
@@ -2611,9 +2666,14 @@ btr_validate_level(
 			"InnoDB: node pointer 2 to the right page is wrong\n");
 
 	 				fprintf(stderr,
-				  "InnoDB: Error on page %lu in index %s\n",
+			"InnoDB: Error on page %lu in index %s table %s\n",
 					buf_frame_get_page_no(page),
-					index->name);
+					index->name, index->table_name);
+
+					buf_page_print(father_page);
+					buf_page_print(right_father_page);
+					buf_page_print(page);
+					buf_page_print(right_page);
 				}
 
 				if (buf_frame_get_page_no(right_father_page)
@@ -2624,9 +2684,14 @@ btr_validate_level(
 			"InnoDB: node pointer 3 to the right page is wrong\n");
 
 	 				fprintf(stderr,
-				  "InnoDB: Error on page %lu in index %s\n",
+			"InnoDB: Error on page %lu in index %s table %s\n",
 					buf_frame_get_page_no(page),
-					index->name);
+					index->name, index->table_name);
+
+					buf_page_print(father_page);
+					buf_page_print(right_father_page);
+					buf_page_print(page);
+					buf_page_print(right_page);
 				}
 			}					
 		}
diff --git a/innobase/btr/btr0cur.c b/innobase/btr/btr0cur.c
index 3d6b63def6c25943ee8f920dc7a94ccbcf28f739..24f0447d55ddd295e7381084ea06ab0948beee2f 100644
--- a/innobase/btr/btr0cur.c
+++ b/innobase/btr/btr0cur.c
@@ -121,16 +121,19 @@ btr_cur_latch_leaves(
 {
 	ulint	left_page_no;
 	ulint	right_page_no;
-
+	page_t*	get_page;
+	
 	ut_ad(tree && page && mtr);
 
 	if (latch_mode == BTR_SEARCH_LEAF) {
 	
-		btr_page_get(space, page_no, RW_S_LATCH, mtr);
+		get_page = btr_page_get(space, page_no, RW_S_LATCH, mtr);
+		buf_block_align(get_page)->check_index_page_at_flush = TRUE;
 
 	} else if (latch_mode == BTR_MODIFY_LEAF) {
 
-		btr_page_get(space, page_no, RW_X_LATCH, mtr);
+		get_page = btr_page_get(space, page_no, RW_X_LATCH, mtr);
+		buf_block_align(get_page)->check_index_page_at_flush = TRUE;
 
 	} else if (latch_mode == BTR_MODIFY_TREE) {
 
@@ -138,15 +141,22 @@ btr_cur_latch_leaves(
 		left_page_no = btr_page_get_prev(page, mtr);
 
 		if (left_page_no != FIL_NULL) {
-			btr_page_get(space, left_page_no, RW_X_LATCH, mtr);
+			get_page = btr_page_get(space, left_page_no,
+							RW_X_LATCH, mtr);
+			buf_block_align(get_page)->check_index_page_at_flush =
+									TRUE;
 		}
 				
-		btr_page_get(space, page_no, RW_X_LATCH, mtr);
+		get_page = btr_page_get(space, page_no, RW_X_LATCH, mtr);
+		buf_block_align(get_page)->check_index_page_at_flush = TRUE;
 
 		right_page_no = btr_page_get_next(page, mtr);
 
 		if (right_page_no != FIL_NULL) {
-			btr_page_get(space, right_page_no, RW_X_LATCH, mtr);
+			get_page = btr_page_get(space, right_page_no,
+							RW_X_LATCH, mtr);
+			buf_block_align(get_page)->check_index_page_at_flush =
+									TRUE;
 		}
 
 	} else if (latch_mode == BTR_SEARCH_PREV) {
@@ -157,9 +167,12 @@ btr_cur_latch_leaves(
 		if (left_page_no != FIL_NULL) {
 			cursor->left_page = btr_page_get(space, left_page_no,
 							RW_S_LATCH, mtr);
+			buf_block_align(
+			cursor->left_page)->check_index_page_at_flush = TRUE;
 		}
 
-		btr_page_get(space, page_no, RW_S_LATCH, mtr);
+		get_page = btr_page_get(space, page_no, RW_S_LATCH, mtr);
+		buf_block_align(get_page)->check_index_page_at_flush = TRUE;
 
 	} else if (latch_mode == BTR_MODIFY_PREV) {
 
@@ -169,9 +182,12 @@ btr_cur_latch_leaves(
 		if (left_page_no != FIL_NULL) {
 			cursor->left_page = btr_page_get(space, left_page_no,
 							RW_X_LATCH, mtr);
+			buf_block_align(
+			cursor->left_page)->check_index_page_at_flush = TRUE;
 		}
 
-		btr_page_get(space, page_no, RW_X_LATCH, mtr);
+		get_page = btr_page_get(space, page_no, RW_X_LATCH, mtr);
+		buf_block_align(get_page)->check_index_page_at_flush = TRUE;
 	} else {
 		ut_error;
 	}
@@ -274,6 +290,7 @@ btr_cur_search_to_nth_level(
 	if (btr_search_latch.writer == RW_LOCK_NOT_LOCKED
 		&& latch_mode <= BTR_MODIFY_LEAF && info->last_hash_succ
 		&& !estimate
+		&& mode != PAGE_CUR_LE_OR_EXTENDS
 	        && btr_search_guess_on_hash(index, info, tuple, mode,
 						latch_mode, cursor,
 						has_search_latch, mtr)) {
@@ -334,12 +351,18 @@ btr_cur_search_to_nth_level(
 	rw_latch = RW_NO_LATCH;
 	buf_mode = BUF_GET;
 
+	/* We use these modified search modes on non-leaf levels of the
+	B-tree. These let us end up in the right B-tree leaf. In that leaf
+	we use the original search mode. */
+
 	if (mode == PAGE_CUR_GE) {
 		page_mode = PAGE_CUR_L;
 	} else if (mode == PAGE_CUR_G) {
 		page_mode = PAGE_CUR_LE;
 	} else if (mode == PAGE_CUR_LE) {
 		page_mode = PAGE_CUR_LE;
+	} else if (mode == PAGE_CUR_LE_OR_EXTENDS) {
+		page_mode = PAGE_CUR_LE_OR_EXTENDS;
 	} else {
 		ut_ad(mode == PAGE_CUR_L);
 		page_mode = PAGE_CUR_L;
@@ -390,6 +413,8 @@ btr_cur_search_to_nth_level(
 
 			goto retry_page_get;
 		}
+
+		buf_block_align(page)->check_index_page_at_flush = TRUE;
 			
 #ifdef UNIV_SYNC_DEBUG					
 		if (rw_latch != RW_NO_LATCH) {
@@ -543,6 +568,8 @@ btr_cur_open_at_index_side(
 		ut_ad(0 == ut_dulint_cmp(tree->id,
 						btr_page_get_index_id(page)));
 
+		buf_block_align(page)->check_index_page_at_flush = TRUE;
+
 		if (height == ULINT_UNDEFINED) {
 			/* We are in the root node */
 
diff --git a/innobase/btr/btr0pcur.c b/innobase/btr/btr0pcur.c
index 8ca3d41f7f91fa4b50104c7fee4b4d99eb5fa2d1..b2115dfdd6c9aff7933955345286fe7b76312ae4 100644
--- a/innobase/btr/btr0pcur.c
+++ b/innobase/btr/btr0pcur.c
@@ -354,6 +354,7 @@ btr_pcur_move_to_next_page(
 	ut_ad(next_page_no != FIL_NULL);	
 
 	next_page = btr_page_get(space, next_page_no, cursor->latch_mode, mtr);
+	buf_block_align(next_page)->check_index_page_at_flush = TRUE;
 
 	btr_leaf_page_release(page, cursor->latch_mode, mtr);
 	
diff --git a/innobase/buf/buf0buf.c b/innobase/buf/buf0buf.c
index ee8e8b91f8da16d8a7be562a729ca1ed8f164a2f..c9a5ec5307f29d9818f6f374cbf62c2a692828c6 100644
--- a/innobase/buf/buf0buf.c
+++ b/innobase/buf/buf0buf.c
@@ -331,6 +331,11 @@ buf_page_print(
 						index->table_name,
 						index->name);
 		}
+	} else if (fil_page_get_type(read_buf) == FIL_PAGE_INODE) {
+		fprintf(stderr, "InnoDB: Page may be an 'inode' page\n");
+	} else if (fil_page_get_type(read_buf) == FIL_PAGE_IBUF_FREE_LIST) {
+		fprintf(stderr,
+		"InnoDB: Page may be an insert buffer free list page\n");
 	}
 }
 
@@ -351,6 +356,8 @@ buf_block_init(
 	
 	block->file_page_was_freed = FALSE;
 
+	block->check_index_page_at_flush = FALSE;
+
 	rw_lock_create(&(block->lock));
 	ut_ad(rw_lock_validate(&(block->lock)));
 
@@ -616,6 +623,29 @@ buf_page_peek_block(
 	return(block);
 }
 
+/************************************************************************
+Resets the check_index_page_at_flush field of a page if found in the buffer
+pool. */
+
+void
+buf_reset_check_index_page_at_flush(
+/*================================*/
+	ulint	space,	/* in: space id */
+	ulint	offset)	/* in: page number */
+{
+	buf_block_t*	block;
+
+	mutex_enter_fast(&(buf_pool->mutex));
+
+	block = buf_page_hash_get(space, offset);
+
+	if (block) {
+		block->check_index_page_at_flush = FALSE;
+	}
+	
+	mutex_exit(&(buf_pool->mutex));
+}
+
 /************************************************************************
 Returns the current state of is_hashed of a page. FALSE if the page is
 not in the pool. NOTE that this operation does not fix the page in the
@@ -1185,6 +1215,8 @@ buf_page_init(
 	block->space 		= space;
 	block->offset 		= offset;
 
+	block->check_index_page_at_flush = FALSE;
+	
 	block->lock_hash_val	= lock_rec_hash(space, offset);
 	block->lock_mutex	= NULL;
 	
@@ -1325,11 +1357,6 @@ buf_page_create(
 	ut_ad(mtr);
 
 	free_block = buf_LRU_get_free_block();
-
-	/* Delete possible entries for the page from the insert buffer:
-	such can exist if the page belonged to an index which was dropped */
-
-	ibuf_merge_or_delete_for_page(NULL, space, offset);	
 	
 	mutex_enter(&(buf_pool->mutex));
 
@@ -1378,6 +1405,11 @@ buf_page_create(
 
 	mutex_exit(&(buf_pool->mutex));
 
+	/* Delete possible entries for the page from the insert buffer:
+	such can exist if the page belonged to an index which was dropped */
+
+	ibuf_merge_or_delete_for_page(NULL, space, offset);	
+
 	/* Flush pages from the end of the LRU list if necessary */
 	buf_flush_free_margin();
 
diff --git a/innobase/buf/buf0flu.c b/innobase/buf/buf0flu.c
index 4c6850af078d3f2e6fd5f7244ae45e793c6b8357..78bde60c9b205385277f049ada3f3d4f633b866f 100644
--- a/innobase/buf/buf0flu.c
+++ b/innobase/buf/buf0flu.c
@@ -15,6 +15,7 @@ Created 11/11/1995 Heikki Tuuri
 
 #include "ut0byte.h"
 #include "ut0lst.h"
+#include "page0page.h"
 #include "fil0fil.h"
 #include "buf0buf.h"
 #include "buf0lru.h"
@@ -225,6 +226,24 @@ buf_flush_buffered_writes(void)
 		return;
 	}
 
+	for (i = 0; i < trx_doublewrite->first_free; i++) {
+		block = trx_doublewrite->buf_block_arr[i];
+
+		if (block->check_index_page_at_flush
+				&& !page_simple_validate(block->frame)) {
+
+			buf_page_print(block->frame);
+
+			ut_print_timestamp(stderr);
+			fprintf(stderr,
+	"  InnoDB: Apparent corruption of an index page\n"
+	"InnoDB: to be written to data file. We intentionally crash server\n"
+	"InnoDB: to prevent corrupt data from ending up in data\n"
+	"InnoDB: files.\n");
+			ut_a(0);
+		}
+	}
+
 	if (trx_doublewrite->first_free > TRX_SYS_DOUBLEWRITE_BLOCK_SIZE) {
 		len = TRX_SYS_DOUBLEWRITE_BLOCK_SIZE * UNIV_PAGE_SIZE;
 	} else {
diff --git a/innobase/configure.in b/innobase/configure.in
index 761859e5da382c3901544ff01d69b7249cc4ee3a..59d213fef123facfc09433ee4c581da6209a50e4 100644
--- a/innobase/configure.in
+++ b/innobase/configure.in
@@ -86,6 +86,8 @@ else
 fi
 
 case "$target_os" in
+       lin*)
+	 CFLAGS="$CFLAGS -DUNIV_LINUX";;
        hpux10*)
 	 CFLAGS="$CFLAGS -DUNIV_MUST_NOT_INLINE -DUNIV_HPUX -DUNIV_HPUX10";;
        hp*)
diff --git a/innobase/dict/dict0crea.c b/innobase/dict/dict0crea.c
index 60beeacf435fd81863b742f5b733ab6841d79fc3..b0f84e5663a7627d9e70fc7b96b9c937694fe94e 100644
--- a/innobase/dict/dict0crea.c
+++ b/innobase/dict/dict0crea.c
@@ -1041,7 +1041,7 @@ dict_create_or_check_foreign_constraint_tables(void)
 	que_t*		graph;
 	ulint		error;
 	trx_t*		trx;
-	char*		str;
+	char*		str;	
 
 	mutex_enter(&(dict_sys->mutex));
 
@@ -1060,20 +1060,24 @@ dict_create_or_check_foreign_constraint_tables(void)
             	return(DB_SUCCESS);
         }
 
+	mutex_exit(&(dict_sys->mutex));
+
 	trx = trx_allocate_for_mysql();
 	
 	trx->op_info = (char *) "creating foreign key sys tables";
 
+	row_mysql_lock_data_dictionary(trx);
+
 	if (table1) {
 		fprintf(stderr,
 		"InnoDB: dropping incompletely created SYS_FOREIGN table\n");
-		row_drop_table_for_mysql((char *) "SYS_FOREIGN", trx, TRUE);
+		row_drop_table_for_mysql((char *) "SYS_FOREIGN", trx);
 	}
 
 	if (table2) {
 		fprintf(stderr,
 	"InnoDB: dropping incompletely created SYS_FOREIGN_COLS table\n");
-		row_drop_table_for_mysql((char *) "SYS_FOREIGN_COLS",trx,TRUE);
+		row_drop_table_for_mysql((char *) "SYS_FOREIGN_COLS", trx);
 	}
 
 	fprintf(stderr,
@@ -1122,8 +1126,8 @@ dict_create_or_check_foreign_constraint_tables(void)
 		fprintf(stderr,
 		"InnoDB: dropping incompletely created SYS_FOREIGN tables\n");
 
-		row_drop_table_for_mysql((char *) "SYS_FOREIGN", trx, TRUE);
-		row_drop_table_for_mysql((char *) "SYS_FOREIGN_COLS",trx,TRUE);
+		row_drop_table_for_mysql((char *) "SYS_FOREIGN", trx);
+		row_drop_table_for_mysql((char *) "SYS_FOREIGN_COLS", trx);
 
 		error = DB_MUST_GET_MORE_FILE_SPACE;
 	}
@@ -1132,6 +1136,8 @@ dict_create_or_check_foreign_constraint_tables(void)
 	
 	trx->op_info = (char *) "";
 
+	row_mysql_unlock_data_dictionary(trx);
+
   	trx_free_for_mysql(trx);
 
   	if (error == DB_SUCCESS) {
@@ -1139,8 +1145,6 @@ dict_create_or_check_foreign_constraint_tables(void)
 		"InnoDB: Foreign key constraint system tables created\n");
 	}
 
-	mutex_exit(&(dict_sys->mutex));
-
 	return(error);
 }
 
diff --git a/innobase/dict/dict0dict.c b/innobase/dict/dict0dict.c
index 095c27f1c5ffdacbb670a0c3fc4aca2ded192eb9..18f27602cf0653f510ea44c9801af28a0193f50c 100644
--- a/innobase/dict/dict0dict.c
+++ b/innobase/dict/dict0dict.c
@@ -29,7 +29,17 @@ Created 1/8/1996 Heikki Tuuri
 
 dict_sys_t*	dict_sys	= NULL;	/* the dictionary system */
 
-rw_lock_t	dict_foreign_key_check_lock;
+rw_lock_t	dict_operation_lock;	/* table create, drop, etc. reserve
+					this in X-mode; implicit or backround
+					operations purge, rollback, foreign
+					key checks reserve this in S-mode; we
+					cannot trust that MySQL protects
+					implicit or background operations
+					a table drop since MySQL does not
+					know of them; therefore we need this;
+					NOTE: a transaction which reserves
+					this must keep book on the mode in
+					trx->dict_operation_lock_mode */
 
 #define	DICT_HEAP_SIZE		100	/* initial memory heap size when
 					creating a table or index object */
@@ -175,6 +185,58 @@ dict_foreign_free(
 /*==============*/
 	dict_foreign_t*	foreign);	/* in, own: foreign key struct */
 
+/************************************************************************
+Checks if the database name in two table names is the same. */
+static
+ibool
+dict_tables_have_same_db(
+/*=====================*/
+			/* out: TRUE if same db name */
+	char*	name1,	/* in: table name in the form dbname '/' tablename */
+	char*	name2)	/* in: table name in the form dbname '/' tablename */
+{
+	ulint	i;
+
+	for (i = 0; i < 100000; i++) {
+		if (name1[i] == '/' && name2[i] == '/') {
+
+			return(TRUE);
+		}
+
+		if (name1[i] != name2[i]) {
+
+			return(FALSE);
+		}
+	}
+
+	ut_a(0);
+
+	return(FALSE);
+}
+
+/************************************************************************
+Return the end of table name where we have removed dbname and '/'. */
+static
+char*
+dict_remove_db_name(
+/*================*/
+			/* out: table name */
+	char*	name)	/* in: table name in the form dbname '/' tablename */
+{
+	ulint	i;
+
+	for (i = 0; i < 100000 ; i++) {
+		if (name[i] == '/') {
+
+			return(name + i + 1);
+		}
+	}
+
+	ut_a(0);
+
+	return(NULL);
+}
+	
 /************************************************************************
 Reserves the dictionary system mutex for MySQL. */
 
@@ -509,9 +571,8 @@ dict_init(void)
 
 	UT_LIST_INIT(dict_sys->table_LRU);
 
-	rw_lock_create(&dict_foreign_key_check_lock);
-	rw_lock_set_level(&dict_foreign_key_check_lock,
-						SYNC_FOREIGN_KEY_CHECK);
+	rw_lock_create(&dict_operation_lock);
+	rw_lock_set_level(&dict_operation_lock, SYNC_DICT_OPERATION);
 }
 
 /**************************************************************************
@@ -1851,14 +1912,14 @@ dict_scan_to(
 
 /*************************************************************************
 Accepts a specified string. Comparisons are case-insensitive. */
-static
+
 char*
 dict_accept(
 /*========*/
 			/* out: if string was accepted, the pointer
 			is moved after that, else ptr is returned */
 	char*	ptr,	/* in: scan from this */
-	const char* string,	/* in: accept only this string as the next
+	const char* string,/* in: accept only this string as the next
 			non-whitespace string */
 	ibool*	success)/* out: TRUE if accepted */
 {
@@ -1920,7 +1981,8 @@ dict_scan_col(
 
 	old_ptr = ptr;
 	
-	while (!isspace(*ptr) && *ptr != ',' && *ptr != ')' && 	*ptr != '`') {
+	while (!isspace(*ptr) && *ptr != ',' && *ptr != ')' && 	*ptr != '`'
+	       && *ptr != '\0') {
 
 		ptr++;
 	}
@@ -1994,7 +2056,7 @@ dict_scan_table_name(
 
 	old_ptr = ptr;
 	
-	while (!isspace(*ptr) && *ptr != '(' && *ptr != '`') {
+	while (!isspace(*ptr) && *ptr != '(' && *ptr != '`' && *ptr != '\0') {
 		if (*ptr == '.') {
 			dot_ptr = ptr;
 		}
@@ -2017,17 +2079,28 @@ dict_scan_table_name(
 		}
 #ifdef __WIN__
 		ut_cpy_in_lower_case(second_table_name + i, old_ptr,
-				     ptr - old_ptr);
+				     				ptr - old_ptr);
 #else
-		ut_memcpy(second_table_name + i, old_ptr, ptr - old_ptr);
+		if (srv_lower_case_table_names) {
+			ut_cpy_in_lower_case(second_table_name + i, old_ptr,
+				     				ptr - old_ptr);
+		} else {
+			ut_memcpy(second_table_name + i, old_ptr,
+								ptr - old_ptr);
+		}
 #endif
 		second_table_name[i + (ptr - old_ptr)] = '\0';
 	} else {
 #ifdef __WIN__
 		ut_cpy_in_lower_case(second_table_name, old_ptr,
-				     ptr - old_ptr);
+								ptr - old_ptr);
 #else
-		ut_memcpy(second_table_name, old_ptr, ptr - old_ptr);
+		if (srv_lower_case_table_names) {
+			ut_cpy_in_lower_case(second_table_name, old_ptr,
+				   			ptr - old_ptr);
+		} else {
+			ut_memcpy(second_table_name, old_ptr, ptr - old_ptr);
+		}
 #endif
 		second_table_name[dot_ptr - old_ptr] = '/';
 		second_table_name[ptr - old_ptr] = '\0';
@@ -2044,6 +2117,44 @@ dict_scan_table_name(
 	return(ptr);
 }
 
+/*************************************************************************
+Skips one 'word', like an id. For the lexical definition of 'word', see the
+code below. */
+static
+char*
+dict_skip_word(
+/*===========*/
+			/* out: scanned to */
+	char*	ptr,	/* in: scanned to */
+	ibool*	success)/* out: TRUE if success, FALSE if just spaces left in
+			string */
+{
+	*success = FALSE;
+
+	while (isspace(*ptr)) {
+		ptr++;
+	}
+
+	if (*ptr == '\0') {
+
+		return(ptr);
+	}
+
+	if (*ptr == '`') {
+		ptr++;
+	}
+	
+	while (!isspace(*ptr) && *ptr != ',' && *ptr != '(' && 	*ptr != '`'
+	       && *ptr != '\0') {
+
+		ptr++;
+	}
+
+	*success = TRUE;
+
+	return(ptr);
+}
+
 /*************************************************************************
 Returns the number of opening brackets '(' subtracted by the number
 of closing brackets ')' between string and ptr. */
@@ -2113,7 +2224,6 @@ dict_create_foreign_constraints(
 	if (table == NULL) {
 		return(DB_ERROR);
 	}
-
 loop:
 	ptr = dict_scan_to(ptr, (char *) "FOREIGN");
 
@@ -2142,7 +2252,19 @@ dict_create_foreign_constraints(
 	ptr = dict_accept(ptr, (char *) "(", &success);
 
 	if (!success) {
-		goto loop;
+		/* MySQL allows also an index id before the '('; we
+		skip it */
+		ptr = dict_skip_word(ptr, &success);
+
+		if (!success) {
+			return(DB_CANNOT_ADD_CONSTRAINT);
+		}
+
+		ptr = dict_accept(ptr, (char *) "(", &success);
+
+		if (!success) {
+			return(DB_CANNOT_ADD_CONSTRAINT);
+		}
 	}
 
 	i = 0;
@@ -2217,6 +2339,7 @@ dict_create_foreign_constraints(
 
 	if (!success) {
 		dict_foreign_free(foreign);
+
 		return(DB_CANNOT_ADD_CONSTRAINT);
 	}
 
@@ -2230,6 +2353,7 @@ dict_create_foreign_constraints(
 	
 	if (!success) {
 		dict_foreign_free(foreign);
+
 		return(DB_CANNOT_ADD_CONSTRAINT);
 	}
 
@@ -2257,14 +2381,20 @@ dict_create_foreign_constraints(
 	ptr = dict_accept(ptr, "DELETE", &success);
 
 	if (!success) {
+		dict_foreign_free(foreign);
+		
+		return(DB_CANNOT_ADD_CONSTRAINT);
+	}
+
+	ptr = dict_accept(ptr, "RESTRICT", &success);
 
+	if (success) {
 		goto try_find_index;
 	}
 
 	ptr = dict_accept(ptr, "CASCADE", &success);
 
 	if (success) {
-
 		foreign->type = DICT_FOREIGN_ON_DELETE_CASCADE;
 
 		goto try_find_index;
@@ -2273,32 +2403,47 @@ dict_create_foreign_constraints(
 	ptr = dict_accept(ptr, "SET", &success);
 
 	if (!success) {
-
-		goto try_find_index;
+		dict_foreign_free(foreign);
+		
+		return(DB_CANNOT_ADD_CONSTRAINT);
 	}
 
 	ptr = dict_accept(ptr, "NULL", &success);
 
-	if (success) {
-		for (j = 0; j < foreign->n_fields; j++) {
-			if ((dict_index_get_nth_type(
+	if (!success) {
+		dict_foreign_free(foreign);
+		
+		return(DB_CANNOT_ADD_CONSTRAINT);
+	}
+
+	for (j = 0; j < foreign->n_fields; j++) {
+		if ((dict_index_get_nth_type(
 				foreign->foreign_index, j)->prtype)
 				& DATA_NOT_NULL) {
 
-				/* It is not sensible to define SET NULL
-				if the column is not allowed to be NULL! */
+			/* It is not sensible to define SET NULL
+			if the column is not allowed to be NULL! */
 
-				dict_foreign_free(foreign);
-				return(DB_CANNOT_ADD_CONSTRAINT);
-			}
+			dict_foreign_free(foreign);
+
+			return(DB_CANNOT_ADD_CONSTRAINT);
 		}
+	}
 
-		foreign->type = DICT_FOREIGN_ON_DELETE_SET_NULL;
+	foreign->type = DICT_FOREIGN_ON_DELETE_SET_NULL;
+	
+try_find_index:
+	/* We check that there are no superfluous words like 'ON UPDATE ...'
+	which we do not support yet. */
 
-		goto try_find_index;
+	ptr = dict_accept(ptr, (char *) "ON", &success);
+
+	if (success) {
+		dict_foreign_free(foreign);
+
+		return(DB_CANNOT_ADD_CONSTRAINT);
 	}
 	
-try_find_index:
 	/* Try to find an index which contains the columns as the first fields
 	and in the right order, and the types are the same as in
 	foreign->foreign_index */
@@ -2345,6 +2490,7 @@ dict_create_foreign_constraints(
 					referenced_table->referenced_list,
 								foreign);
 	}
+
 	goto loop;
 }
 
@@ -2843,6 +2989,14 @@ dict_update_statistics_low(
 	ulint		size;
 	ulint		sum_of_index_sizes	= 0;
 
+	/* If we have set a high innodb_force_recovery level, do not calculate
+	statistics, as a badly corrupted index can cause a crash in it. */
+
+	if (srv_force_recovery >= SRV_FORCE_NO_IBUF_MERGE) {
+
+		return;
+	}
+
 	/* Find out the sizes of the indexes and how many different values
 	for the key they approximately have */
 
@@ -3146,16 +3300,25 @@ dict_print_info_on_foreign_keys_in_create_format(
 			}
 		}
 
-		buf2 += sprintf(buf2, ") REFERENCES `%s` (",
+		if (dict_tables_have_same_db(table->name,
+					foreign->referenced_table_name)) {
+			/* Do not print the database name of the referenced
+			table */
+			buf2 += sprintf(buf2, ") REFERENCES `%s` (",
+					dict_remove_db_name(
+					foreign->referenced_table_name));
+		} else {
+			buf2 += sprintf(buf2, ") REFERENCES `%s` (",
 					foreign->referenced_table_name);
-		/* Change the '/' in the table name to '.' */
+			/* Change the '/' in the table name to '.' */
 
-		for (i = ut_strlen(buf); i > 0; i--) {
-			if (buf[i] == '/') {
+			for (i = ut_strlen(buf); i > 0; i--) {
+				if (buf[i] == '/') {
 
-				buf[i] = '.';
+					buf[i] = '.';
 
-				break;
+					break;
+				}
 			}
 		}
 	
diff --git a/innobase/dict/dict0load.c b/innobase/dict/dict0load.c
index e9caa37feccc5148e9cbec1fde48972e24b3cbf4..d8d426d2036098fd7c266caf02a7d7e7da33e1b8 100644
--- a/innobase/dict/dict0load.c
+++ b/innobase/dict/dict0load.c
@@ -335,7 +335,7 @@ dict_load_fields(
 		ut_a(btr_pcur_is_on_user_rec(&pcur, &mtr));
 		if (rec_get_deleted_flag(rec)) {
 			fprintf(stderr,
-"InnoDB: Error: data dictionary entry for table %s is corrupt!\n",
+"InnoDB: Error: data dictionary entry for table %s is corrupt!\n"
 "InnoDB: An index field is delete marked.\n",
 			table->name);
 		}
diff --git a/innobase/fil/fil0fil.c b/innobase/fil/fil0fil.c
index 3e0f21395ef17eedf4711756bb5c3f6d2be51678..98980f6c33769551306325dcbb06530c1bae2592 100644
--- a/innobase/fil/fil0fil.c
+++ b/innobase/fil/fil0fil.c
@@ -967,6 +967,7 @@ fil_extend_last_data_file(
 	fil_node_t*	node;
 	fil_space_t*	space;
 	fil_system_t*	system		= fil_system;
+	byte*		buf2;
 	byte*		buf;
 	ibool		success;
 	ulint		i;
@@ -981,19 +982,23 @@ fil_extend_last_data_file(
 
 	fil_node_prepare_for_io(node, system, space);
 
-	buf = mem_alloc(1024 * 1024);
+	buf2 = mem_alloc(1024 * 1024 + UNIV_PAGE_SIZE);
+	buf = ut_align(buf2, UNIV_PAGE_SIZE);
 
 	memset(buf, '\0', 1024 * 1024);
 
 	for (i = 0; i < size_increase / ((1024 * 1024) / UNIV_PAGE_SIZE); i++) {
 
-		success = os_file_write(node->name, node->handle, buf,
+		/* If we use native Windows aio, then also this write is
+		done using it */
+
+		success = os_aio(OS_FILE_WRITE, OS_AIO_SYNC,
+			node->name, node->handle, buf,
 			(node->size << UNIV_PAGE_SIZE_SHIFT) & 0xFFFFFFFF,
 			node->size >> (32 - UNIV_PAGE_SIZE_SHIFT),
-			1024 * 1024);
+			1024 * 1024, NULL, NULL);
 
 		if (!success) {
-
 			break;
 		}
 
@@ -1003,7 +1008,7 @@ fil_extend_last_data_file(
 		os_has_said_disk_full = FALSE;
 	}
 
-	mem_free(buf);
+	mem_free(buf2);
 
 	fil_node_complete_io(node, system, OS_FILE_WRITE);
 
@@ -1528,7 +1533,6 @@ fil_page_set_type(
 	ulint	type)	/* in: type */
 {
 	ut_ad(page);
-	ut_ad((type == FIL_PAGE_INDEX) || (type == FIL_PAGE_UNDO_LOG));
 
 	mach_write_to_2(page + FIL_PAGE_TYPE, type);
 }	
diff --git a/innobase/fsp/fsp0fsp.c b/innobase/fsp/fsp0fsp.c
index 1abb043fdc2a869f77fbe71e38398e3e7b478377..ff586819d4aa8323c0ca3a2c0759efe0a2c9df64 100644
--- a/innobase/fsp/fsp0fsp.c
+++ b/innobase/fsp/fsp0fsp.c
@@ -769,6 +769,8 @@ fsp_init_file_page_low(
 #endif
 	page = buf_frame_align(ptr);
 
+	buf_block_align(page)->check_index_page_at_flush = FALSE;	
+	
 #ifdef UNIV_BASIC_LOG_DEBUG	
 /*	printf("In log debug version: Erase the contents of the file page\n");
 */
@@ -1097,7 +1099,7 @@ fsp_fill_free_list(
 
 			/* Initialize the ibuf page in a separate
 			mini-transaction because it is low in the latching
-			order, and we must be able to release the its latch
+			order, and we must be able to release its latch
 			before returning from the fsp routine */
 			
 			mtr_start(&ibuf_mtr);
@@ -1264,7 +1266,12 @@ fsp_alloc_free_page(
 
 	free = xdes_find_bit(descr, XDES_FREE_BIT, TRUE,
 						hint % FSP_EXTENT_SIZE, mtr);
-	ut_a(free != ULINT_UNDEFINED);
+	if (free == ULINT_UNDEFINED) {
+
+		ut_print_buf(((byte*)descr) - 500, 1000);
+
+		ut_a(0);
+	}
 
 	xdes_set_bit(descr, XDES_FREE_BIT, free, FALSE, mtr);
 
@@ -1412,7 +1419,12 @@ fsp_free_extent(
 
 	descr = xdes_get_descriptor_with_space_hdr(header, space, page, mtr);
 
-	ut_a(xdes_get_state(descr, mtr) != XDES_FREE);
+	if (xdes_get_state(descr, mtr) == XDES_FREE) {
+
+		ut_print_buf(((byte*)descr) - 500, 1000);
+
+		ut_a(0);
+	}
 
 	xdes_init(descr, mtr);
 
@@ -1523,6 +1535,10 @@ fsp_alloc_seg_inode_page(
 
 	page = buf_page_get(space, page_no, RW_X_LATCH, mtr);	
 
+	buf_block_align(page)->check_index_page_at_flush = FALSE;
+
+	fil_page_set_type(page, FIL_PAGE_INODE);
+	
 	buf_page_dbg_add_level(page, SYNC_FSP_PAGE);
 
 	for (i = 0; i < FSP_SEG_INODES_PER_PAGE; i++) {
@@ -2298,6 +2314,8 @@ fseg_alloc_free_page_low(
 		fseg_mark_page_used(seg_inode, space, ret_page, mtr);
 	}
 
+	buf_reset_check_index_page_at_flush(space, ret_page);
+	
 	return(ret_page);	
 }
 
diff --git a/innobase/ibuf/ibuf0ibuf.c b/innobase/ibuf/ibuf0ibuf.c
index b7d691485cc3f87c19400a615f89e35f5ef87d86..143b3bfa5841fae81c85399cce67b4fa6fd52f48 100644
--- a/innobase/ibuf/ibuf0ibuf.c
+++ b/innobase/ibuf/ibuf0ibuf.c
@@ -1295,6 +1295,8 @@ ibuf_add_free_page(
 	flst_add_last(root + PAGE_HEADER + PAGE_BTR_IBUF_FREE_LIST,
 		      page + PAGE_HEADER + PAGE_BTR_IBUF_FREE_LIST_NODE, &mtr);
 
+	fil_page_set_type(page, FIL_PAGE_IBUF_FREE_LIST);
+		      
 	ibuf_data->seg_size++;
 	ibuf_data->free_list_len++;
 
@@ -1305,6 +1307,7 @@ ibuf_add_free_page(
 
 	ibuf_bitmap_page_set_bits(bitmap_page, page_no, IBUF_BITMAP_IBUF,
 								TRUE, &mtr);
+
 	mtr_commit(&mtr);
 
 	mutex_exit(&ibuf_mutex);
diff --git a/innobase/include/btr0btr.h b/innobase/include/btr0btr.h
index f66ad3639d45e753e0781602275b57d1b470983a..3cd44ab5175ba04f59c707062734ecb241bf6860 100644
--- a/innobase/include/btr0btr.h
+++ b/innobase/include/btr0btr.h
@@ -399,6 +399,19 @@ btr_print_tree(
 	dict_tree_t*	tree,	/* in: tree */
 	ulint		width);	/* in: print this many entries from start
 				and end */
+/****************************************************************
+Checks the size and number of fields in a record based on the definition of
+the index. */
+
+ibool
+btr_index_rec_validate(
+/*====================*/
+					/* out: TRUE if ok */
+	rec_t*		rec,		/* in: index record */
+	dict_index_t*	index,		/* in: index */
+	ibool		dump_on_error);	/* in: TRUE if the function
+					should print hex dump of record
+					and page on error */
 /******************************************************************
 Checks the consistency of an index tree. */
 
diff --git a/innobase/include/btr0pcur.h b/innobase/include/btr0pcur.h
index 05b55e4491da145e4131090f852d791b6f2be4f2..9d07dd0de185c19b37630d35d4b6f8b9570cc01d 100644
--- a/innobase/include/btr0pcur.h
+++ b/innobase/include/btr0pcur.h
@@ -298,6 +298,14 @@ btr_pcur_move_to_prev(
 				function may release the page latch */
 	mtr_t*		mtr);	/* in: mtr */
 /*************************************************************
+Moves the persistent cursor to the last record on the same page. */
+UNIV_INLINE
+void
+btr_pcur_move_to_last_on_page(
+/*==========================*/
+	btr_pcur_t*	cursor,	/* in: persistent cursor */
+	mtr_t*		mtr);	/* in: mtr */
+/*************************************************************
 Moves the persistent cursor to the next user record in the tree. If no user
 records are left, the cursor ends up 'after last in tree'. */
 UNIV_INLINE
diff --git a/innobase/include/btr0pcur.ic b/innobase/include/btr0pcur.ic
index a60140e4aa9e2b6640f37ce62de3913640457a9c..a1db2cc52dd3986268337517d7638879bcf96523 100644
--- a/innobase/include/btr0pcur.ic
+++ b/innobase/include/btr0pcur.ic
@@ -284,6 +284,24 @@ btr_pcur_move_to_prev_on_page(
 	cursor->old_stored = BTR_PCUR_OLD_NOT_STORED;
 }
 
+/*************************************************************
+Moves the persistent cursor to the last record on the same page. */
+UNIV_INLINE
+void
+btr_pcur_move_to_last_on_page(
+/*==========================*/
+	btr_pcur_t*	cursor,	/* in: persistent cursor */
+	mtr_t*		mtr)	/* in: mtr */
+{
+	UT_NOT_USED(mtr);
+	ut_ad(cursor->latch_mode != BTR_NO_LATCHES);
+	
+	page_cur_set_after_last(buf_frame_align(btr_pcur_get_rec(cursor)),
+				btr_pcur_get_page_cur(cursor));
+
+	cursor->old_stored = BTR_PCUR_OLD_NOT_STORED;
+}
+
 /*************************************************************
 Moves the persistent cursor to the next user record in the tree. If no user
 records are left, the cursor ends up 'after last in tree'. */
diff --git a/innobase/include/buf0buf.h b/innobase/include/buf0buf.h
index 591c0ec54ab5c4d3aee95a2d6c3757d1b1b5ce7d..f76c437bd1dc6603321000963d73f3ab718b7571 100644
--- a/innobase/include/buf0buf.h
+++ b/innobase/include/buf0buf.h
@@ -274,6 +274,15 @@ buf_page_peek_block(
 	ulint	space,	/* in: space id */
 	ulint	offset);/* in: page number */
 /************************************************************************
+Resets the check_index_page_at_flush field of a page if found in the buffer
+pool. */
+
+void
+buf_reset_check_index_page_at_flush(
+/*================================*/
+	ulint	space,	/* in: space id */
+	ulint	offset);/* in: page number */
+/************************************************************************
 Sets file_page_was_freed TRUE if the page is found in the buffer pool.
 This function should be called when we free a file page and want the
 debug version to check that it is not accessed any more unless
@@ -648,6 +657,14 @@ struct buf_block_struct{
 					then it can wait for this rw-lock */
 	buf_block_t*	hash;		/* node used in chaining to the page
 					hash table */
+	ibool		check_index_page_at_flush;
+					/* TRUE if we know that this is
+					an index page, and want the database
+					to check its consistency before flush;
+					note that there may be pages in the
+					buffer pool which are index pages,
+					but this flag is not set because
+					we do not keep track of all pages */
 	/* 2. Page flushing fields */
 
 	UT_LIST_NODE_T(buf_block_t) flush_list;
diff --git a/innobase/include/db0err.h b/innobase/include/db0err.h
index ddfbd5b7862efa192ab2f0f321872a54b758b5e1..86b79b65bf2292e781971be94deb79b1e51e3d90 100644
--- a/innobase/include/db0err.h
+++ b/innobase/include/db0err.h
@@ -41,7 +41,8 @@ Created 5/24/1996 Heikki Tuuri
 					which is referenced */
 #define DB_CANNOT_ADD_CONSTRAINT 38	/* adding a foreign key constraint
 					to a table failed */
-
+#define DB_CORRUPTION		39	/* data structure corruption noticed */
+					
 /* The following are partial failure codes */
 #define DB_FAIL 		1000
 #define DB_OVERFLOW 		1001
diff --git a/innobase/include/dict0dict.h b/innobase/include/dict0dict.h
index dd92c5aa4676a81e913e217afda282d5b69fc80d..b5e6e04a1def1d3a57b4e0f909b6e39d21f1c624 100644
--- a/innobase/include/dict0dict.h
+++ b/innobase/include/dict0dict.h
@@ -26,6 +26,18 @@ Created 1/8/1996 Heikki Tuuri
 #include "ut0byte.h"
 #include "trx0types.h"
 
+/*************************************************************************
+Accepts a specified string. Comparisons are case-insensitive. */
+
+char*
+dict_accept(
+/*========*/
+			/* out: if string was accepted, the pointer
+			is moved after that, else ptr is returned */
+	char*	ptr,	/* in: scan from this */
+	const char* string,/* in: accept only this string as the next
+			non-whitespace string */
+	ibool*	success);/* out: TRUE if accepted */
 /************************************************************************
 Decrements the count of open MySQL handles to a table. */
 
@@ -798,7 +810,7 @@ dict_mutex_exit_for_mysql(void);
 
 
 extern dict_sys_t*	dict_sys;	/* the dictionary system */
-extern rw_lock_t	dict_foreign_key_check_lock;
+extern rw_lock_t	dict_operation_lock;
 
 /* Dictionary system struct */
 struct dict_sys_struct{
diff --git a/innobase/include/fil0fil.h b/innobase/include/fil0fil.h
index 63e20221c16283137cdbcd9e947a2403b8618bd9..23ef0304b2d5b6705b3126635f1cc6d790950ee0 100644
--- a/innobase/include/fil0fil.h
+++ b/innobase/include/fil0fil.h
@@ -73,6 +73,8 @@ extern fil_addr_t	fil_addr_null;
 /* File page types */
 #define FIL_PAGE_INDEX		17855
 #define FIL_PAGE_UNDO_LOG	2
+#define FIL_PAGE_INODE		3
+#define FIL_PAGE_IBUF_FREE_LIST	4
 
 /* Space types */
 #define FIL_TABLESPACE 		501
diff --git a/innobase/include/lock0lock.h b/innobase/include/lock0lock.h
index 288356d3270b405e2ecf7dd775c8a9742b1636f2..d3b3d55d01500e5033fc02721b231e2c86577b0d 100644
--- a/innobase/include/lock0lock.h
+++ b/innobase/include/lock0lock.h
@@ -292,16 +292,12 @@ lock_sec_rec_modify_check_and_lock(
 	dict_index_t*	index,	/* in: secondary index */
 	que_thr_t*	thr);	/* in: query thread */
 /*************************************************************************
-Checks if locks of other transactions prevent an immediate read, or passing
-over by a read cursor, of a clustered index record. If they do, first tests
-if the query thread should anyway be suspended for some reason; if not, then
-puts the transaction and the query thread to the lock wait state and inserts a
-waiting request for a record lock to the lock queue. Sets the requested mode
-lock on the record. */
+Like the counterpart for a clustered index below, but now we read a
+secondary index record. */
 
 ulint
-lock_clust_rec_read_check_and_lock(
-/*===============================*/
+lock_sec_rec_read_check_and_lock(
+/*=============================*/
 				/* out: DB_SUCCESS, DB_LOCK_WAIT,
 				DB_DEADLOCK, or DB_QUE_THR_SUSPENDED */
 	ulint		flags,	/* in: if BTR_NO_LOCKING_FLAG bit is set,
@@ -309,18 +305,24 @@ lock_clust_rec_read_check_and_lock(
 	rec_t*		rec,	/* in: user record or page supremum record
 				which should be read or passed over by a read
 				cursor */
-	dict_index_t*	index,	/* in: clustered index */
+	dict_index_t*	index,	/* in: secondary index */
 	ulint		mode,	/* in: mode of the lock which the read cursor
 				should set on records: LOCK_S or LOCK_X; the
 				latter is possible in SELECT FOR UPDATE */
+	ulint		gap_mode,/* in: LOCK_ORDINARY, LOCK_GAP, or
+				LOCK_REC_NOT_GAP */
 	que_thr_t*	thr);	/* in: query thread */
 /*************************************************************************
-Like the counterpart for a clustered index above, but now we read a
-secondary index record. */
+Checks if locks of other transactions prevent an immediate read, or passing
+over by a read cursor, of a clustered index record. If they do, first tests
+if the query thread should anyway be suspended for some reason; if not, then
+puts the transaction and the query thread to the lock wait state and inserts a
+waiting request for a record lock to the lock queue. Sets the requested mode
+lock on the record. */
 
 ulint
-lock_sec_rec_read_check_and_lock(
-/*=============================*/
+lock_clust_rec_read_check_and_lock(
+/*===============================*/
 				/* out: DB_SUCCESS, DB_LOCK_WAIT,
 				DB_DEADLOCK, or DB_QUE_THR_SUSPENDED */
 	ulint		flags,	/* in: if BTR_NO_LOCKING_FLAG bit is set,
@@ -328,10 +330,12 @@ lock_sec_rec_read_check_and_lock(
 	rec_t*		rec,	/* in: user record or page supremum record
 				which should be read or passed over by a read
 				cursor */
-	dict_index_t*	index,	/* in: secondary index */
+	dict_index_t*	index,	/* in: clustered index */
 	ulint		mode,	/* in: mode of the lock which the read cursor
 				should set on records: LOCK_S or LOCK_X; the
 				latter is possible in SELECT FOR UPDATE */
+	ulint		gap_mode,/* in: LOCK_ORDINARY, LOCK_GAP, or
+				LOCK_REC_NOT_GAP */
 	que_thr_t*	thr);	/* in: query thread */
 /*************************************************************************
 Checks that a record is seen in a consistent read. */
@@ -509,6 +513,7 @@ lock_validate(void);
 extern lock_sys_t*	lock_sys;
 
 /* Lock modes and types */
+/* Basic modes */
 #define	LOCK_NONE	0	/* this flag is used elsewhere to note
 				consistent read */
 #define	LOCK_IS		2	/* intention shared */
@@ -519,15 +524,20 @@ extern lock_sys_t*	lock_sys;
 				in an exclusive mode */
 #define LOCK_MODE_MASK	0xF	/* mask used to extract mode from the
 				type_mode field in a lock */
+/* Lock types */
 #define LOCK_TABLE	16	/* these type values should be so high that */
 #define	LOCK_REC	32	/* they can be ORed to the lock mode */
 #define LOCK_TYPE_MASK	0xF0	/* mask used to extract lock type from the
 				type_mode field in a lock */
+/* Waiting lock flag */
 #define LOCK_WAIT	256	/* this wait bit should be so high that
 				it can be ORed to the lock mode and type;
 				when this bit is set, it means that the
 				lock has not yet been granted, it is just
 				waiting for its turn in the wait queue */
+/* Precise modes */
+#define LOCK_ORDINARY	0	/* this flag denotes an ordinary next-key lock
+				in contrast to LOCK_GAP or LOCK_REC_NOT_GAP */ 
 #define LOCK_GAP	512	/* this gap bit should be so high that
 				it can be ORed to the other flags;
 				when this bit is set, it means that the
@@ -537,7 +547,15 @@ extern lock_sys_t*	lock_sys;
 				the bit is set; locks of this type are created
 				when records are removed from the index chain
 				of records */
-#define LOCK_INSERT_INTENTION 1024 /* this bit is set when we place a waiting
+#define LOCK_REC_NOT_GAP 1024 	/* this bit means that the lock is only on
+				the index record and does NOT block inserts
+				to the gap before the index record; this is
+				used in the case when we retrieve a record
+				with a unique key, and is also used in
+				locking plain SELECTs (not part of UPDATE
+				or DELETE) when the user has set the READ
+				COMMITTED isolation level */
+#define LOCK_INSERT_INTENTION 2048 /* this bit is set when we place a waiting
 				gap type record lock request in order to let
 				an insert of an index record to wait until
 				there are no conflicting locks by other
diff --git a/innobase/include/log0recv.h b/innobase/include/log0recv.h
index baa2ba50c7de42fbb9777de8735489a04707320d..7418e4abf1ba06515268fd3a7642e6a0229a6c0a 100644
--- a/innobase/include/log0recv.h
+++ b/innobase/include/log0recv.h
@@ -334,6 +334,7 @@ extern ibool		recv_no_ibuf_operations;
 extern ibool		recv_needed_recovery;
 
 extern ibool		recv_is_making_a_backup;
+extern ulint		recv_max_parsed_page_no;
 
 /* Size of the parsing buffer; it must accommodate RECV_SCAN_SIZE many
 times! */ 
diff --git a/innobase/include/os0file.h b/innobase/include/os0file.h
index d65c7fd47e3c1e125051243450f914d787e5060c..a7624a90d5e86330791bbbcc652d75e7b1b7b749 100644
--- a/innobase/include/os0file.h
+++ b/innobase/include/os0file.h
@@ -111,6 +111,7 @@ log. */
 #define OS_WIN31     1
 #define OS_WIN95     2	
 #define OS_WINNT     3
+#define OS_WIN2000   4
 
 extern ulint	os_n_file_reads;
 extern ulint	os_n_file_writes;
@@ -122,7 +123,7 @@ Gets the operating system version. Currently works only on Windows. */
 ulint
 os_get_os_version(void);
 /*===================*/
-                  /* out: OS_WIN95, OS_WIN31, OS_WINNT (2000 == NT) */
+                  /* out: OS_WIN95, OS_WIN31, OS_WINNT, or OS_WIN2000 */
 /********************************************************************
 Creates the seek mutexes used in positioned reads and writes. */
 
diff --git a/innobase/include/os0proc.h b/innobase/include/os0proc.h
index 9da1f33e0701f9651396aa1a411d339715319605..79750e5c1f78626cd1d6757b2008f3503bb3240e 100644
--- a/innobase/include/os0proc.h
+++ b/innobase/include/os0proc.h
@@ -15,6 +15,15 @@ Created 9/30/1995 Heikki Tuuri
 typedef void*			os_process_t;
 typedef unsigned long int	os_process_id_t;
 
+/********************************************************************
+Converts the current process id to a number. It is not guaranteed that the
+number is unique. In Linux returns the 'process number' of the current
+thread. That number is the same as one sees in 'top', for example. In Linux
+the thread id is not the same as one sees in 'top'. */
+
+ulint
+os_proc_get_number(void);
+/*====================*/
 /********************************************************************
 Allocates non-cacheable memory. */
 
diff --git a/innobase/include/os0thread.h b/innobase/include/os0thread.h
index 8355afa46e9ad9fb27b8126bc7848520bb4f8982..efc8651e06df95c5fdf9df2baad9f8ea6c4121e1 100644
--- a/innobase/include/os0thread.h
+++ b/innobase/include/os0thread.h
@@ -16,11 +16,8 @@ Created 9/8/1995 Heikki Tuuri
 this is also the size of the wait slot array for MySQL threads which
 can wait inside InnoDB */
 #ifdef __WIN__
-/* Windows 95/98/ME seemed to have difficulties creating the all
-the event semaphores for the wait array slots. If the computer had
-<= 64 MB memory, InnoDB startup could take minutes or even crash.
-That is why we set this to only 1000 in Windows. */
-
+/* Create less event semaphores because Win 98/ME had difficult creating
+40000 event semaphores */
 #define	OS_THREAD_MAX_N		1000
 #else
 #define	OS_THREAD_MAX_N		10000
diff --git a/innobase/include/page0cur.h b/innobase/include/page0cur.h
index 144e0e02b215fd3e6c454e7ae71b2651e2d41d04..c3f0decdb4beec7865a37d2633c927518e5f5462 100644
--- a/innobase/include/page0cur.h
+++ b/innobase/include/page0cur.h
@@ -26,7 +26,12 @@ Created 10/4/1994 Heikki Tuuri
 #define	PAGE_CUR_GE	2
 #define	PAGE_CUR_L	3
 #define	PAGE_CUR_LE	4
-#define	PAGE_CUR_DBG	5
+#define PAGE_CUR_LE_OR_EXTENDS 5 /* This is a search mode used in
+				 "column LIKE 'abc%' ORDER BY column DESC";
+				 we have to find strings which are <= 'abc' or
+				 which extend it */
+#define	PAGE_CUR_DBG	6
+
 
 extern ulint	page_cur_short_succ;
 
diff --git a/innobase/include/page0page.h b/innobase/include/page0page.h
index 2f77127466f0d9408bac915f08c1ce8e0ba9e8e7..b5e33af5bc0d56bc986ad587a39436ac27077b1a 100644
--- a/innobase/include/page0page.h
+++ b/innobase/include/page0page.h
@@ -666,6 +666,16 @@ page_rec_validate(
 			/* out: TRUE if ok */
 	rec_t* 	rec);	/* in: record on the page */
 /*******************************************************************
+This function checks the consistency of an index page when we do not
+know the index. This is also resilient so that this should never crash
+even if the page is total garbage. */
+
+ibool
+page_simple_validate(
+/*=================*/
+			/* out: TRUE if ok */
+	page_t*	page);	/* in: index page */
+/*******************************************************************
 This function checks the consistency of an index page. */
 
 ibool
diff --git a/innobase/include/que0que.h b/innobase/include/que0que.h
index cdaeeae1fde59d574cbdf05fcae92117a3e83b85..a3ed18e2b141c5b734de603924053a360c761ba0 100644
--- a/innobase/include/que0que.h
+++ b/innobase/include/que0que.h
@@ -117,6 +117,7 @@ que_thr_stop(
 /**************************************************************************
 Moves a thread from another state to the QUE_THR_RUNNING state. Increments
 the n_active_thrs counters of the query graph and transaction. */
+
 void
 que_thr_move_to_run_state_for_mysql(
 /*================================*/
@@ -125,14 +126,17 @@ que_thr_move_to_run_state_for_mysql(
 /**************************************************************************
 A patch for MySQL used to 'stop' a dummy query thread used in MySQL
 select, when there is no error or lock wait. */
+
 void
 que_thr_stop_for_mysql_no_error(
 /*============================*/
 	que_thr_t*	thr,	/* in: query thread */
 	trx_t*		trx);	/* in: transaction */
 /**************************************************************************
-A patch for MySQL used to 'stop' a dummy query thread used in MySQL
-select. */
+A patch for MySQL used to 'stop' a dummy query thread used in MySQL. The
+query thread is stopped and made inactive, except in the case where
+it was put to the lock wait state in lock0lock.c, but the lock has already
+been granted or the transaction chosen as a victim in deadlock resolution. */
 
 void
 que_thr_stop_for_mysql(
diff --git a/innobase/include/read0read.h b/innobase/include/read0read.h
index cebb2d6701c49bb15647ce1a223e7a278e34c826..db6bf8880952fbc5e62ceeda1c9980039f540d1d 100644
--- a/innobase/include/read0read.h
+++ b/innobase/include/read0read.h
@@ -45,6 +45,14 @@ read_view_close(
 /*============*/
 	read_view_t*	view);	/* in: read view */
 /*************************************************************************
+Closes a consistent read view for MySQL. This function is called at an SQL
+statement end if the trx isolation level is <= TRX_ISO_READ_COMMITTED. */
+
+void
+read_view_close_for_mysql(
+/*======================*/
+	trx_t*	trx);	/* in: trx which has a read view */
+/*************************************************************************
 Checks if a read view sees the specified transaction. */
 UNIV_INLINE
 ibool
diff --git a/innobase/include/rem0rec.h b/innobase/include/rem0rec.h
index 12e3a8b39d6bc146f0b64fa76684f5983ac3fc6a..b28f39925c129de4d87465beb64742926d8b848b 100644
--- a/innobase/include/rem0rec.h
+++ b/innobase/include/rem0rec.h
@@ -148,12 +148,22 @@ data field in the record. */
 byte*
 rec_get_nth_field(
 /*==============*/
- 			/* out: pointer to the field, NULL if SQL null */
+ 			/* out: pointer to the field */
  	rec_t*	rec, 	/* in: record */
  	ulint	n,	/* in: index of the field */
 	ulint*	len);	/* out: length of the field; UNIV_SQL_NULL 
 			if SQL null */
 /****************************************************************
+Return field length or UNIV_SQL_NULL. */
+UNIV_INLINE
+ulint
+rec_get_nth_field_len(
+/*==================*/
+ 			/* out: length of the field; UNIV_SQL_NULL if SQL
+			null */
+ 	rec_t*	rec, 	/* in: record */
+ 	ulint	n);	/* in: index of the field */
+/****************************************************************
 Gets the physical size of a field. Also an SQL null may have a field of
 size > 0, if the data type is of a fixed size. */
 UNIV_INLINE
diff --git a/innobase/include/rem0rec.ic b/innobase/include/rem0rec.ic
index aaa3c58a003da496149761072fc69c7b980046a9..9dfd4faeec87e0527708d0d965070c472439adf3 100644
--- a/innobase/include/rem0rec.ic
+++ b/innobase/include/rem0rec.ic
@@ -65,6 +65,24 @@ a field stored to another page: */
 
 #define REC_2BYTE_EXTERN_MASK	0x4000
 
+/****************************************************************
+Return field length or UNIV_SQL_NULL. */
+UNIV_INLINE
+ulint
+rec_get_nth_field_len(
+/*==================*/
+ 			/* out: length of the field; UNIV_SQL_NULL if SQL
+			null */
+ 	rec_t*	rec, 	/* in: record */
+ 	ulint	n)	/* in: index of the field */
+{
+	ulint	len;
+
+	rec_get_nth_field(rec, n, &len);
+
+	return(len);
+}
+
 /***************************************************************
 Sets the value of the ith field SQL null bit. */
 
diff --git a/innobase/include/row0mysql.h b/innobase/include/row0mysql.h
index 8152c534f4859f43fd71fd2018664d25e626e427..44b470fe7eaa6b76a63553d056899cc613d1a84e 100644
--- a/innobase/include/row0mysql.h
+++ b/innobase/include/row0mysql.h
@@ -230,18 +230,35 @@ row_update_cascade_for_mysql(
 				or set null operation */
 	dict_table_t*	table);	/* in: table where we do the operation */
 /*************************************************************************
-Locks the data dictionary exclusively for performing a table create
-operation. */
+Locks the data dictionary exclusively for performing a table create or other
+data dictionary modification operation. */
 
 void
-row_mysql_lock_data_dictionary(void);
-/*================================*/
+row_mysql_lock_data_dictionary(
+/*===========================*/
+	trx_t*	trx);	/* in: transaction */
 /*************************************************************************
-Unlocks the data dictionary exclusively lock. */
+Unlocks the data dictionary exclusive lock. */
 
 void
-row_mysql_unlock_data_dictionary(void);
-/*==================================*/
+row_mysql_unlock_data_dictionary(
+/*=============================*/
+	trx_t*	trx);	/* in: transaction */
+/*************************************************************************
+Locks the data dictionary in shared mode from modifications, for performing
+foreign key check, rollback, or other operation invisible to MySQL. */
+
+void
+row_mysql_freeze_data_dictionary(
+/*=============================*/
+	trx_t*	trx);	/* in: transaction */
+/*************************************************************************
+Unlocks the data dictionary shared lock. */
+
+void
+row_mysql_unfreeze_data_dictionary(
+/*===============================*/
+	trx_t*	trx);	/* in: transaction */
 /*************************************************************************
 Does a table creation operation for MySQL. If the name of the created
 table ends to characters INNODB_MONITOR, then this also starts
@@ -310,11 +327,9 @@ output by the master thread. */
 int
 row_drop_table_for_mysql(
 /*=====================*/
-				/* out: error code or DB_SUCCESS */
-	char*	name,		/* in: table name */
-	trx_t*	trx,		/* in: transaction handle */
-	ibool	has_dict_mutex);/* in: TRUE if the caller already owns the
-				dictionary system mutex */
+			/* out: error code or DB_SUCCESS */
+	char*	name,	/* in: table name */
+	trx_t*	trx);	/* in: transaction handle */
 /*************************************************************************
 Drops a database for MySQL. */
 
@@ -393,6 +408,10 @@ struct row_prebuilt_struct {
 					an SQL statement: we may have to set
 					an intention lock on the table,
 					create a consistent read view etc. */
+        ibool           mysql_has_locked; /* this is set TRUE when MySQL
+			                calls external_lock on this handle
+			                with a lock flag, and set FALSE when
+			                with the F_UNLOCK flag */
 	ibool		clust_index_was_generated;
 					/* if the user did not define a
 					primary key in MySQL, then Innobase
diff --git a/innobase/include/srv0srv.h b/innobase/include/srv0srv.h
index 9de5e9ccfc90f8706d5d3bc7acd16b84405c80d9..ad6f71f7a3a44861c1390bf2c00f198ad8a72cef 100644
--- a/innobase/include/srv0srv.h
+++ b/innobase/include/srv0srv.h
@@ -28,6 +28,9 @@ extern os_event_t	srv_lock_timeout_thread_event;
 at a time */
 #define SRV_AUTO_EXTEND_INCREMENT   (8 * ((1024 * 1024) / UNIV_PAGE_SIZE))
 
+/* This is set to TRUE if the MySQL user has set it in MySQL */
+extern ibool	srv_lower_case_table_names;
+
 /* Server parameters which are read from the initfile */
 
 extern char*	srv_data_home;
@@ -57,8 +60,6 @@ extern ulint	srv_flush_log_at_trx_commit;
 
 extern byte	srv_latin1_ordering[256];/* The sort order table of the latin1
 					character set */
-extern ibool	srv_use_native_aio;		
-
 extern ulint	srv_pool_size;
 extern ulint	srv_mem_pool_size;
 extern ulint	srv_lock_table_size;
@@ -70,8 +71,9 @@ extern dulint	srv_archive_recovery_limit_lsn;
 
 extern ulint	srv_lock_wait_timeout;
 
-extern char*    srv_unix_file_flush_method_str;
+extern char*    srv_file_flush_method_str;
 extern ulint    srv_unix_file_flush_method;
+extern ulint   	srv_win_file_flush_method;
 extern ulint	srv_force_recovery;
 extern ulint	srv_thread_concurrency;
 
@@ -154,13 +156,19 @@ typedef struct srv_sys_struct	srv_sys_t;
 /* The server system */
 extern srv_sys_t*	srv_sys;
 
-/* Alternatives for the field flush option in Unix; see the InnoDB manual about
+/* Alternatives for the file flush option in Unix; see the InnoDB manual about
 what these mean */
-#define SRV_UNIX_FDATASYNC   1
+#define SRV_UNIX_FDATASYNC   1	/* This is the default; it is currently mapped
+				to a call of fsync() because fdatasync()
+				seemed to corrupt files in Linux and Solaris */
 #define SRV_UNIX_O_DSYNC     2
 #define SRV_UNIX_LITTLESYNC  3
 #define SRV_UNIX_NOSYNC      4
 
+/* Alternatives for file i/o in Windows */
+#define SRV_WIN_IO_NORMAL		1
+#define SRV_WIN_IO_UNBUFFERED		2	/* This is the default */
+
 /* Alternatives for srv_force_recovery. Non-zero values are intended
 to help the user get a damaged database up so that he can dump intact
 tables and rows with SELECT INTO OUTFILE. The database must not otherwise
@@ -311,15 +319,17 @@ srv_conc_exit_innodb(
 	trx_t*	trx);	/* in: transaction object associated with the
 			thread */
 /*******************************************************************
-Puts a MySQL OS thread to wait for a lock to be released. */
+Puts a MySQL OS thread to wait for a lock to be released. If an error
+occurs during the wait trx->error_state associated with thr is
+!= DB_SUCCESS when we return. DB_LOCK_WAIT_TIMEOUT and DB_DEADLOCK
+are possible errors. DB_DEADLOCK is returned if selective deadlock
+resolution chose this transaction as a victim. */
 
-ibool
+void
 srv_suspend_mysql_thread(
 /*=====================*/
-				/* out: TRUE if the lock wait timeout was
-				exceeded */
-	que_thr_t*	thr);	/* in: query thread associated with
-				the MySQL OS thread */
+	que_thr_t*	thr);	/* in: query thread associated with the MySQL
+				OS thread */
 /************************************************************************
 Releases a MySQL OS thread waiting for a lock to be released, if the
 thread is already suspended. */
@@ -407,3 +417,4 @@ struct srv_sys_struct{
 extern ulint	srv_n_threads_active[];
 
 #endif
+
diff --git a/innobase/include/srv0start.h b/innobase/include/srv0start.h
index 646d2c1bb0628368c434f20ab6e0395fcec3646b..24cdecb7341e7abfa4ecc64a7026527cf672c7e2 100644
--- a/innobase/include/srv0start.h
+++ b/innobase/include/srv0start.h
@@ -79,6 +79,8 @@ innobase_shutdown_for_mysql(void);
 /*=============================*/
 				/* out: DB_SUCCESS or error code */
 
+extern  ulint   srv_sizeof_trx_t_in_ha_innodb_cc;
+
 extern	ibool	srv_startup_is_before_trx_rollback_phase;
 extern	ibool	srv_is_being_shut_down;
 
diff --git a/innobase/include/sync0rw.h b/innobase/include/sync0rw.h
index 7ad38f5bc7f41f65de623ccebe23d64142195186..5aa3dcdffc303c6c355ba50502515496927f56c7 100644
--- a/innobase/include/sync0rw.h
+++ b/innobase/include/sync0rw.h
@@ -335,7 +335,8 @@ ibool
 rw_lock_own(
 /*========*/
 	rw_lock_t*	lock,		/* in: rw-lock */
-	ulint		lock_type);	/* in: lock type */
+	ulint		lock_type);	/* in: lock type: RW_LOCK_SHARED,
+					RW_LOCK_EX */
 /**********************************************************************
 Checks if somebody has locked the rw-lock in the specified mode. */
 
diff --git a/innobase/include/sync0sync.h b/innobase/include/sync0sync.h
index 5bfa0bc2d48bf6a049841c45d75a2597186d7706..320f8faf12d787bc8589860cb0fac1867c2c7e58 100644
--- a/innobase/include/sync0sync.h
+++ b/innobase/include/sync0sync.h
@@ -371,10 +371,12 @@ or row lock! */
 #define SYNC_NO_ORDER_CHECK	3000	/* this can be used to suppress
 					latching order checking */
 #define	SYNC_LEVEL_NONE		2000	/* default: level not defined */
-#define	SYNC_FOREIGN_KEY_CHECK	1001
+#define	SYNC_DICT_OPERATION	1001	/* table create, drop, etc. reserve
+					this in X-mode, implicit or backround
+					operations purge, rollback, foreign
+					key checks reserve this in S-mode */
 #define SYNC_DICT		1000
 #define SYNC_DICT_AUTOINC_MUTEX	999
-#define	SYNC_PURGE_IS_RUNNING	997
 #define SYNC_DICT_HEADER	995
 #define SYNC_IBUF_HEADER	914
 #define SYNC_IBUF_PESS_INSERT_MUTEX 912
diff --git a/innobase/include/trx0purge.h b/innobase/include/trx0purge.h
index 087be2f060eefce4bc5701ce7342cd3bcee3d6a3..049c79aec9b2c16141349aea4aab8d15da1edb2f 100644
--- a/innobase/include/trx0purge.h
+++ b/innobase/include/trx0purge.h
@@ -111,9 +111,6 @@ struct trx_purge_struct{
 					of the trx system and it never ends */
 	que_t*		query;		/* The query graph which will do the
 					parallelized purge operation */
-	rw_lock_t	purge_is_running;/* Purge operation set an x-latch here
-					while it is accessing a table: this
-					prevents dropping of the table */
 	rw_lock_t	latch;		/* The latch protecting the purge view.
 					A purge operation must acquire an
 					x-latch here for the instant at which
diff --git a/innobase/include/trx0trx.h b/innobase/include/trx0trx.h
index 9b29c481b6dc3f6ecb92cbe9692aee24d925e040..34f820f03e774e909bf96bc935b5ff21c4c6ff81 100644
--- a/innobase/include/trx0trx.h
+++ b/innobase/include/trx0trx.h
@@ -327,6 +327,7 @@ struct trx_struct{
         time_t          start_time;     /* time the trx object was created
                                         or the state last time became
                                         TRX_ACTIVE */
+	ulint		isolation_level;/* TRX_ISO_REPEATABLE_READ, ... */
 	ibool		check_foreigns;	/* normally TRUE, but if the user
 					wants to suppress foreign key checks,
 					(in table imports, for example) we
@@ -350,6 +351,9 @@ struct trx_struct{
 	/*------------------------------*/
         void*           mysql_thd;      /* MySQL thread handle corresponding
                                         to this trx, or NULL */
+	char**		mysql_query_str;/* pointer to the field in mysqld_thd
+					which contains the pointer to the
+					current SQL query string */
 	char*		mysql_log_file_name;
 					/* if MySQL binlog is used, this field
 					contains a pointer to the latest file
@@ -371,6 +375,9 @@ struct trx_struct{
 					replication has processed */
 	os_thread_id_t	mysql_thread_id;/* id of the MySQL thread associated
 					with this transaction object */
+	ulint		mysql_process_no;/* since in Linux, 'top' reports
+					process id's and not thread id's, we
+					store the process number too */
 	/*------------------------------*/
 	ulint		n_mysql_tables_in_use; /* number of Innobase tables
 					used in the processing of the current
@@ -379,9 +386,10 @@ struct trx_struct{
                                         /* how many tables the current SQL
 					statement uses, except those
 					in consistent read */
-	ibool		has_dict_foreign_key_check_lock;
-					/* TRUE if the trx currently holds
-					an s-lock on dict_foreign_... */
+	ibool		dict_operation_lock_mode;
+					/* 0, RW_S_LATCH, or RW_X_LATCH:
+					the latch mode trx currently holds
+					on dict_operation_lock */
         ibool           has_search_latch;
 			                /* TRUE if this trx has latched the
 			                search system latch in S-mode */
@@ -420,36 +428,11 @@ struct trx_struct{
 			mysql_trx_list;	/* list of transactions created for
 					MySQL */
 	/*------------------------------*/
-	mutex_t		undo_mutex;	/* mutex protecting the fields in this
-					section (down to undo_no_arr), EXCEPT
-					last_sql_stat_start, which can be
-					accessed only when we know that there
-					cannot be any activity in the undo
-					logs! */
-	dulint		undo_no;	/* next undo log record number to
-					assign */
-	trx_savept_t	last_sql_stat_start;
-					/* undo_no when the last sql statement
-					was started: in case of an error, trx
-					is rolled back down to this undo
-					number; see note at undo_mutex! */
-	trx_rseg_t*	rseg;		/* rollback segment assigned to the
-					transaction, or NULL if not assigned
-					yet */
-	trx_undo_t*	insert_undo;	/* pointer to the insert undo log, or 
-					NULL if no inserts performed yet */
-	trx_undo_t* 	update_undo;	/* pointer to the update undo log, or
-					NULL if no update performed yet */
-	dulint		roll_limit;	/* least undo number to undo during
-					a rollback */
-	ulint		pages_undone;	/* number of undo log pages undone
-					since the last undo log truncation */
-	trx_undo_arr_t*	undo_no_arr;	/* array of undo numbers of undo log
-					records which are currently processed
-					by a rollback operation */
-	/*------------------------------*/
 	ulint		error_state;	/* 0 if no error, otherwise error
-					number */
+					number; NOTE That ONLY the thread
+					doing the transaction is allowed to
+					set this field: this is NOT protected
+					by the kernel mutex */
 	void*		error_info;	/* if the error number indicates a
 					duplicate key error, a pointer to
 					the problematic index is stored here */
@@ -486,6 +469,12 @@ struct trx_struct{
 					TRX_QUE_LOCK_WAIT, this points to
 					the lock request, otherwise this is
 					NULL */
+	ibool		was_chosen_as_deadlock_victim;
+					/* when the transaction decides to wait
+					for a lock, this it sets this to FALSE;
+					if another transaction chooses this
+					transaction as a victim in deadlock
+					resolution, it sets this to TRUE */
 	time_t          wait_started;   /* lock wait started at this time */
 	UT_LIST_BASE_NODE_T(que_thr_t)
 			wait_thrs;	/* query threads belonging to this
@@ -501,6 +490,34 @@ struct trx_struct{
 	/*------------------------------*/
 	mem_heap_t*	read_view_heap;	/* memory heap for the read view */
 	read_view_t*	read_view;	/* consistent read view or NULL */
+	/*------------------------------*/
+	mutex_t		undo_mutex;	/* mutex protecting the fields in this
+					section (down to undo_no_arr), EXCEPT
+					last_sql_stat_start, which can be
+					accessed only when we know that there
+					cannot be any activity in the undo
+					logs! */
+	dulint		undo_no;	/* next undo log record number to
+					assign */
+	trx_savept_t	last_sql_stat_start;
+					/* undo_no when the last sql statement
+					was started: in case of an error, trx
+					is rolled back down to this undo
+					number; see note at undo_mutex! */
+	trx_rseg_t*	rseg;		/* rollback segment assigned to the
+					transaction, or NULL if not assigned
+					yet */
+	trx_undo_t*	insert_undo;	/* pointer to the insert undo log, or 
+					NULL if no inserts performed yet */
+	trx_undo_t* 	update_undo;	/* pointer to the update undo log, or
+					NULL if no update performed yet */
+	dulint		roll_limit;	/* least undo number to undo during
+					a rollback */
+	ulint		pages_undone;	/* number of undo log pages undone
+					since the last undo log truncation */
+	trx_undo_arr_t*	undo_no_arr;	/* array of undo numbers of undo log
+					records which are currently processed
+					by a rollback operation */
 };
 
 #define TRX_MAX_N_THREADS	32	/* maximum number of concurrent
@@ -523,6 +540,41 @@ struct trx_struct{
 #define TRX_QUE_ROLLING_BACK	3	/* transaction is rolling back */
 #define TRX_QUE_COMMITTING	4	/* transaction is committing */
 
+/* Transaction isolation levels */
+#define TRX_ISO_READ_UNCOMMITTED	1	/* dirty read: non-locking
+						SELECTs are performed so that
+						we do not look at a possible
+						earlier version of a record;
+						thus they are not 'consistent'
+						reads under this isolation
+						level; otherwise like level
+						2 */
+
+#define TRX_ISO_READ_COMMITTED		2	/* somewhat Oracle-like
+						isolation, except that in
+						range UPDATE and DELETE we
+						must block phantom rows
+						with next-key locks;
+						SELECT ... FOR UPDATE and ...
+						LOCK IN SHARE MODE only lock
+						the index records, NOT the
+						gaps before them, and thus
+						allow free inserting;
+						each consistent read reads its
+						own snapshot */
+
+#define TRX_ISO_REPEATABLE_READ		3	/* this is the default;
+						all consistent reads in the
+						same trx read the same
+						snapshot;
+						full next-key locking used
+						in locking reads to block
+						insertions into gaps */
+
+#define TRX_ISO_SERIALIZABLE		4	/* all plain SELECTs are
+						converted to LOCK IN SHARE
+						MODE reads */
+
 /* Types of a trx signal */
 #define TRX_SIG_NO_SIGNAL		100
 #define TRX_SIG_TOTAL_ROLLBACK		1
diff --git a/innobase/lock/lock0lock.c b/innobase/lock/lock0lock.c
index 866fe556af95df257e37832522e43b97c113f414..7b08d6b89b810831bbacc006f59bd386a536cb32 100644
--- a/innobase/lock/lock0lock.c
+++ b/innobase/lock/lock0lock.c
@@ -70,6 +70,11 @@ A waiting record lock can also be of the gap type. A waiting lock request
 can be granted when there is no conflicting mode lock request by another
 transaction ahead of it in the explicit lock queue.
 
+In version 4.0.5 we added yet another explicit lock type: LOCK_REC_NOT_GAP.
+It only locks the record it is placed on, not the gap before the record.
+This lock type is necessary to emulate an Oracle-like READ COMMITTED isolation
+level.
+
 -------------------------------------------------------------------------
 RULE 1: If there is an implicit x-lock on a record, and there are non-gap
 -------
@@ -294,7 +299,9 @@ struct lock_struct{
 	UT_LIST_NODE_T(lock_t)		
 			trx_locks;	/* list of the locks of the
 					transaction */
-	ulint		type_mode;	/* lock type, mode, gap flag, and
+	ulint		type_mode;	/* lock type, mode, LOCK_GAP or
+					LOCK_REC_NOT_GAP,
+					LOCK_INSERT_INTENTION,
 					wait flag, ORed */
 	hash_node_t	hash;		/* hash chain node for a record lock */
 	dict_index_t*	index;		/* index for a record lock */
@@ -309,6 +316,10 @@ Monitor will then fetch it and print */
 ibool	lock_deadlock_found = FALSE;
 char*	lock_latest_err_buf;		/* We allocate 5000 bytes for this */
 
+/* Flags for recursive deadlock search */
+#define LOCK_VICTIM_IS_START	1
+#define LOCK_VICTIM_IS_OTHER	2
+
 /************************************************************************
 Checks if a lock request results in a deadlock. */
 static
@@ -700,23 +711,23 @@ lock_rec_get_gap(
 }
 
 /*************************************************************************
-Sets the gap flag of a record lock. */
+Gets the LOCK_REC_NOT_GAP flag of a record lock. */
 UNIV_INLINE
-void
-lock_rec_set_gap(
-/*=============*/
-	lock_t*	lock,	/* in: record lock */
-	ibool	val)	/* in: value to set: TRUE or FALSE */
+ibool
+lock_rec_get_rec_not_gap(
+/*=====================*/
+			/* out: TRUE if LOCK_REC_NOT_GAP flag set */
+	lock_t*	lock)	/* in: record lock */
 {
 	ut_ad(lock);
-	ut_ad((val == TRUE) || (val == FALSE));
 	ut_ad(lock_get_type(lock) == LOCK_REC);
 
-	if (val) {
- 		lock->type_mode = lock->type_mode | LOCK_GAP;
-	} else {
-		lock->type_mode = lock->type_mode & ~LOCK_GAP;
+	if (lock->type_mode & LOCK_REC_NOT_GAP) {
+
+		return(TRUE);
 	}
+
+	return(FALSE);
 }
 
 /*************************************************************************
@@ -739,26 +750,6 @@ lock_rec_get_insert_intention(
 	return(FALSE);
 }
 
-/*************************************************************************
-Sets the waiting insert flag of a record lock. */
-UNIV_INLINE
-void
-lock_rec_set_insert_intention(
-/*==========================*/
-	lock_t*	lock,	/* in: record lock */
-	ibool	val)	/* in: value to set: TRUE or FALSE */
-{
-	ut_ad(lock);
-	ut_ad((val == TRUE) || (val == FALSE));
-	ut_ad(lock_get_type(lock) == LOCK_REC);
-
-	if (val) {
- 		lock->type_mode = lock->type_mode | LOCK_INSERT_INTENTION;
-	} else {
-		lock->type_mode = lock->type_mode & ~LOCK_INSERT_INTENTION;
-	}
-}
-
 /*************************************************************************
 Calculates if lock mode 1 is stronger or equal to lock mode 2. */
 UNIV_INLINE
@@ -848,48 +839,53 @@ lock_rec_has_to_wait(
 			/* out: TRUE if new lock has to wait for lock2 to be
 			removed */
 	trx_t*	trx,	/* in: trx of new lock */
-	ulint	mode,	/* in: LOCK_S or LOCK_X */
-	ulint	gap,	/* in: LOCK_GAP or 0 */
-	ulint	insert_intention,
-			/* in: LOCK_INSERT_INTENTION or 0 */
+	ulint	type_mode,/* in: precise mode of the new lock to set:
+			LOCK_S or LOCK_X, possibly ORed to
+			LOCK_GAP or LOCK_REC_NOT_GAP, LOCK_INSERT_INTENTION */
 	lock_t*	lock2)	/* in: another record lock; NOTE that it is assumed
 			that this has a lock bit set on the same record as
-			in lock1 */
+			in the new lock we are setting */
 {
 	ut_ad(trx && lock2);
 	ut_ad(lock_get_type(lock2) == LOCK_REC);
-	ut_ad(mode == LOCK_S || mode == LOCK_X);
-	ut_ad(gap == LOCK_GAP || gap == 0);
-	ut_ad(insert_intention == LOCK_INSERT_INTENTION
-	      				|| insert_intention == 0);
 
-	if (trx != lock2->trx && !lock_mode_compatible(mode,
+	if (trx != lock2->trx
+	    && !lock_mode_compatible(LOCK_MODE_MASK & type_mode,
 				     		lock_get_mode(lock2))) {
 
-		/* We have somewhat complex rules when gap type
-		record locks cause waits */
+		/* We have somewhat complex rules when gap type record locks
+		cause waits */
 
-		if (!gap && lock_rec_get_insert_intention(lock2)) {
+		if ((type_mode & LOCK_REC_NOT_GAP)
+						&& lock_rec_get_gap(lock2)) {
+			/* Lock on just the record does not need to wait for
+			a gap type lock */
+
+			return(FALSE);
+		}
+
+		if ((type_mode & LOCK_GAP)
+					&& lock_rec_get_rec_not_gap(lock2)) {
+		
+			/* Lock on gap does not need to wait for
+			a LOCK_REC_NOT_GAP type lock */
 
-			/* Request of a full next-key record does not
-			need to wait for an insert intention lock to be
-			removed. This is ok since our rules allow conflicting
-			locks on gaps. This eliminates a spurious deadlock
-			caused by a next-key lock waiting for an insert
-			intention lock; when the insert intention lock was
-			granted, the insert deadlocked on the waiting
-			next-key lock. */
-				
 			return(FALSE);
 		}
 
-		if (insert_intention && lock_rec_get_insert_intention(lock2)) {
+		if (lock_rec_get_insert_intention(lock2)) {
 
-			/* An insert intention is not disturbed by another
-			insert intention; this removes a spurious deadlock
-			caused by inserts which had to wait for a next-key
-			lock to be removed */
+			/* No lock request needs to wait for an insert
+			intention lock to be removed. This is ok since our
+			rules allow conflicting locks on gaps. This eliminates
+			a spurious deadlock caused by a next-key lock waiting
+			for an insert intention lock; when the insert
+			intention lock was granted, the insert deadlocked on
+			the waiting next-key lock.
 
+			Also, insert intention locks do not disturb each
+			other. */
+				
 			return(FALSE);
 		}
 
@@ -921,10 +917,7 @@ lock_has_to_wait(
 			ut_ad(lock_get_type(lock2) == LOCK_REC);
 				
 			return(lock_rec_has_to_wait(lock1->trx,
-				lock_get_mode(lock1),
-				lock_rec_get_gap(lock1),
-				lock_rec_get_insert_intention(lock1),
-				lock2));
+						lock1->type_mode, lock2));
 		}
 
 		return(TRUE);
@@ -1386,32 +1379,41 @@ lock_table_has(
 /*============= FUNCTIONS FOR ANALYZING RECORD LOCK QUEUE ================*/
 
 /*************************************************************************
-Checks if a transaction has a GRANTED explicit lock on rec, where the gap
-flag or the insert intention flag is not set, stronger or equal to mode.
-Note that locks on the supremum of a page are a special case here, since
-they are always gap type locks, even if the gap flag is not set in them. */
+Checks if a transaction has a GRANTED explicit lock on rec stronger or equal
+to precise_mode. */
 UNIV_INLINE
 lock_t*
 lock_rec_has_expl(
 /*==============*/
 			/* out: lock or NULL */
-	ulint	mode,	/* in: lock mode */
+	ulint	precise_mode,/* in: LOCK_S or LOCK_X possibly ORed to
+			LOCK_GAP or LOCK_REC_NOT_GAP,
+			for a supremum record we regard this always a gap
+			type request */
 	rec_t*	rec,	/* in: record */
 	trx_t*	trx)	/* in: transaction */
 {
 	lock_t*	lock;
-	
-	ut_ad(mutex_own(&kernel_mutex));
-	ut_ad((mode == LOCK_X) || (mode == LOCK_S));
 
+	ut_ad(mutex_own(&kernel_mutex));
+	ut_ad((precise_mode & LOCK_MODE_MASK) == LOCK_S
+	      || (precise_mode & LOCK_MODE_MASK) == LOCK_X);
+	ut_ad(!(precise_mode & LOCK_INSERT_INTENTION));
+	
 	lock = lock_rec_get_first(rec);
 
 	while (lock) {
 		if (lock->trx == trx
-		    && lock_mode_stronger_or_eq(lock_get_mode(lock), mode)
+		    && lock_mode_stronger_or_eq(lock_get_mode(lock),
+		    				precise_mode & LOCK_MODE_MASK)
 		    && !lock_get_wait(lock)
-		    && !lock_rec_get_insert_intention(lock)
-		    && !lock_rec_get_gap(lock)) {
+		    && (!lock_rec_get_rec_not_gap(lock)
+		    		|| (precise_mode & LOCK_REC_NOT_GAP)
+		    		|| page_rec_is_supremum(rec))
+		    && (!lock_rec_get_gap(lock)
+				|| (precise_mode & LOCK_GAP)
+				|| page_rec_is_supremum(rec))
+		    && (!lock_rec_get_insert_intention(lock))) {
 
 		    	return(lock);
 		}
@@ -1429,7 +1431,7 @@ lock_t*
 lock_rec_other_has_expl_req(
 /*========================*/
 			/* out: lock or NULL */
-	ulint	mode,	/* in: lock mode */
+	ulint	mode,	/* in: LOCK_S or LOCK_X */
 	ulint	gap,	/* in: LOCK_GAP if also gap locks are taken
 			into account, or 0 if not */
 	ulint	wait,	/* in: LOCK_WAIT if also waiting locks are
@@ -1471,27 +1473,21 @@ lock_t*
 lock_rec_other_has_conflicting(
 /*===========================*/
 			/* out: lock or NULL */
-	ulint	mode,	/* in: lock mode of the lock we are going to reserve */
-	ulint	gap,	/* in: LOCK_GAP if we are going to reserve a gap type
-			lock, else 0 */
-	ulint	insert_intention,
-			/* in: LOCK_INSERT_INTENTION if we are going to
-			reserve an insert intention lock */
+	ulint	mode,	/* in: LOCK_S or LOCK_X,
+			possibly ORed to LOCK_GAP or LOC_REC_NOT_GAP,
+			LOCK_INSERT_INTENTION */
 	rec_t*	rec,	/* in: record to look at */	
 	trx_t*	trx)	/* in: our transaction */
 {
 	lock_t*	lock;
 	
 	ut_ad(mutex_own(&kernel_mutex));
-	ut_ad(mode == LOCK_X || mode == LOCK_S);
-	ut_ad(gap == 0 || gap == LOCK_GAP);
-	ut_ad(insert_intention == LOCK_INSERT_INTENTION
-						|| insert_intention == 0);
+
 	lock = lock_rec_get_first(rec);
 
 	while (lock) {
-		if (lock_rec_has_to_wait(trx, mode, gap, insert_intention,
-								lock)) {
+		if (lock_rec_has_to_wait(trx, mode, lock)) {
+
 			return(lock);
 		}
 		
@@ -1607,14 +1603,14 @@ lock_rec_create(
 	page_no	= buf_frame_get_page_no(page);
 	heap_no = rec_get_heap_no(rec);
 
-	/* If rec is the supremum record, then we reset the gap bit, as
-	all locks on the supremum are automatically of the gap type, and
-	we try to avoid unnecessary memory consumption of a new record lock
-	struct for a gap type lock */
+	/* If rec is the supremum record, then we reset the gap and
+	LOCK_REC_NOT_GAP bits, as all locks on the supremum are
+	automatically of the gap type */
 
 	if (rec == page_get_supremum_rec(page)) {
+		ut_ad(!(type_mode & LOCK_REC_NOT_GAP));
 
-		type_mode = type_mode & ~LOCK_GAP;
+		type_mode = type_mode & ~(LOCK_GAP | LOCK_REC_NOT_GAP);
 	}
 
 	/* Make lock bitmap bigger by a safety margin */
@@ -1666,10 +1662,14 @@ ulint
 lock_rec_enqueue_waiting(
 /*=====================*/
 				/* out: DB_LOCK_WAIT, DB_DEADLOCK, or
-				DB_QUE_THR_SUSPENDED */
+				DB_QUE_THR_SUSPENDED, or DB_SUCCESS;
+				DB_SUCCESS means that there was a deadlock,
+				but another transaction was chosen as a
+				victim, and we got the lock immediately:
+				no need to wait then */
 	ulint		type_mode,/* in: lock mode this transaction is
-				requesting: LOCK_S or LOCK_X, ORed with
-				LOCK_GAP if a gap lock is requested, ORed
+				requesting: LOCK_S or LOCK_X, possibly ORed
+				with LOCK_GAP or LOCK_REC_NOT_GAP, ORed
 				with LOCK_INSERT_INTENTION if this waiting
 				lock request is set when performing an
 				insert of an index record */
@@ -1718,7 +1718,16 @@ index->table_name);
 		return(DB_DEADLOCK);
 	}
 
+	/* If there was a deadlock but we chose another transaction as a
+	victim, it is possible that we already have the lock now granted! */
+
+	if (trx->wait_lock == NULL) {
+
+		return(DB_SUCCESS);
+	}
+
 	trx->que_state = TRX_QUE_LOCK_WAIT;
+	trx->was_chosen_as_deadlock_victim = FALSE;
 	trx->wait_started = time(NULL);
 
 	ut_a(que_thr_stop(thr));
@@ -1744,8 +1753,8 @@ lock_rec_add_to_queue(
 /*==================*/
 				/* out: lock where the bit was set, NULL if out
 				of memory */
-	ulint		type_mode,/* in: lock mode, wait, and gap flags; type
-				is ignored and replaced by LOCK_REC */
+	ulint		type_mode,/* in: lock mode, wait, gap etc. flags;
+				type is ignored and replaced by LOCK_REC */
 	rec_t*		rec,	/* in: record on page */
 	dict_index_t*	index,	/* in: index of record */
 	trx_t*		trx)	/* in: transaction */
@@ -1759,12 +1768,11 @@ lock_rec_add_to_queue(
 	ut_ad(mutex_own(&kernel_mutex));
 	ut_ad((type_mode & (LOCK_WAIT | LOCK_GAP))
 	      || ((type_mode & LOCK_MODE_MASK) != LOCK_S)
-	      || !lock_rec_other_has_expl_req(LOCK_X, 0, LOCK_WAIT,
-						rec, trx));
+	      || !lock_rec_other_has_expl_req(LOCK_X, 0, LOCK_WAIT, rec, trx));
 	ut_ad((type_mode & (LOCK_WAIT | LOCK_GAP))
 	      || ((type_mode & LOCK_MODE_MASK) != LOCK_X)
-	      || !lock_rec_other_has_expl_req(LOCK_S, 0, LOCK_WAIT,
-						rec, trx));
+	      || !lock_rec_other_has_expl_req(LOCK_S, 0, LOCK_WAIT, rec, trx));
+
 	type_mode = type_mode | LOCK_REC;
 
 	page = buf_frame_align(rec);
@@ -1775,12 +1783,15 @@ lock_rec_add_to_queue(
 	struct for a gap type lock */
 
 	if (rec == page_get_supremum_rec(page)) {
+		ut_ad(!(type_mode & LOCK_REC_NOT_GAP));
 
-		type_mode = type_mode & ~LOCK_GAP;
+		/* There should never be LOCK_REC_NOT_GAP on a supremum
+		record, but let us play safe */
+		
+		type_mode = type_mode & ~(LOCK_GAP | LOCK_REC_NOT_GAP);
 	}
 
-	/* Look for a waiting lock request on the same record, or for a
-	similar record lock on the same page */
+	/* Look for a waiting lock request on the same record or on a gap */
 
 	heap_no = rec_get_heap_no(rec);
 	lock = lock_rec_get_first_on_page(rec);
@@ -1795,6 +1806,9 @@ lock_rec_add_to_queue(
 		lock = lock_rec_get_next_on_page(lock);
 	}
 
+	/* Look for a similar record lock on the same page: if one is found
+	and there are no waiting lock requests, we can just set the bit */
+
 	similar_lock = lock_rec_find_similar_on_page(type_mode, rec, trx);
 
 	if (similar_lock && !somebody_waits && !(type_mode & LOCK_WAIT)) {
@@ -1822,7 +1836,8 @@ lock_rec_lock_fast(
 	ibool		impl,	/* in: if TRUE, no lock is set if no wait
 				is necessary: we assume that the caller will
 				set an implicit lock */
-	ulint		mode,	/* in: lock mode */
+	ulint		mode,	/* in: lock mode: LOCK_X or LOCK_S possibly
+				ORed to either LOCK_GAP or LOCK_REC_NOT_GAP */
 	rec_t*		rec,	/* in: record */
 	dict_index_t*	index,	/* in: index of record */
 	que_thr_t* 	thr)	/* in: query thread */
@@ -1831,8 +1846,16 @@ lock_rec_lock_fast(
 	ulint	heap_no;
 
 	ut_ad(mutex_own(&kernel_mutex));
-	ut_ad((mode == LOCK_X) || (mode == LOCK_S));
-
+	ut_ad((LOCK_MODE_MASK & mode) != LOCK_S
+		|| lock_table_has(thr_get_trx(thr), index->table, LOCK_IS));
+	ut_ad((LOCK_MODE_MASK & mode) != LOCK_X
+		|| lock_table_has(thr_get_trx(thr), index->table, LOCK_IX));
+	ut_ad((LOCK_MODE_MASK & mode) == LOCK_S
+		|| (LOCK_MODE_MASK & mode) == LOCK_X);
+	ut_ad(mode - (LOCK_MODE_MASK & mode) == LOCK_GAP
+			|| mode - (LOCK_MODE_MASK & mode) == 0
+			|| mode - (LOCK_MODE_MASK & mode) == LOCK_REC_NOT_GAP);
+			
 	heap_no = rec_get_heap_no(rec);
 	
 	lock = lock_rec_get_first_on_page(rec);
@@ -1877,7 +1900,8 @@ lock_rec_lock_slow(
 	ibool		impl,	/* in: if TRUE, no lock is set if no wait is
 				necessary: we assume that the caller will set
 				an implicit lock */
-	ulint		mode,	/* in: lock mode */
+	ulint		mode,	/* in: lock mode: LOCK_X or LOCK_S possibly
+				ORed to either LOCK_GAP or LOCK_REC_NOT_GAP */
 	rec_t*		rec,	/* in: record */
 	dict_index_t*	index,	/* in: index of record */
 	que_thr_t* 	thr)	/* in: query thread */
@@ -1886,20 +1910,24 @@ lock_rec_lock_slow(
 	ulint	err;
 
 	ut_ad(mutex_own(&kernel_mutex));
-	ut_ad((mode == LOCK_X) || (mode == LOCK_S));
-
+	ut_ad((LOCK_MODE_MASK & mode) != LOCK_S
+		|| lock_table_has(thr_get_trx(thr), index->table, LOCK_IS));
+	ut_ad((LOCK_MODE_MASK & mode) != LOCK_X
+		|| lock_table_has(thr_get_trx(thr), index->table, LOCK_IX));
+	ut_ad((LOCK_MODE_MASK & mode) == LOCK_S
+		|| (LOCK_MODE_MASK & mode) == LOCK_X);
+	ut_ad(mode - (LOCK_MODE_MASK & mode) == LOCK_GAP
+			|| mode - (LOCK_MODE_MASK & mode) == 0
+			|| mode - (LOCK_MODE_MASK & mode) == LOCK_REC_NOT_GAP);
+			
 	trx = thr_get_trx(thr);
-
-	ut_ad((mode != LOCK_S) || lock_table_has(trx, index->table,
-								LOCK_IS));
-	ut_ad((mode != LOCK_X) || lock_table_has(trx, index->table,
-								LOCK_IX));
+		
 	if (lock_rec_has_expl(mode, rec, trx)) {
 		/* The trx already has a strong enough lock on rec: do
 		nothing */
 
 		err = DB_SUCCESS;
-	} else if (lock_rec_other_has_conflicting(mode, 0, 0, rec, trx)) {
+	} else if (lock_rec_other_has_conflicting(mode, rec, trx)) {
 
 		/* If another transaction has a non-gap conflicting request in
 		the queue, as this transaction does not have a lock strong
@@ -1935,7 +1963,8 @@ lock_rec_lock(
 	ibool		impl,	/* in: if TRUE, no lock is set if no wait is
 				necessary: we assume that the caller will set
 				an implicit lock */
-	ulint		mode,	/* in: lock mode */
+	ulint		mode,	/* in: lock mode: LOCK_X or LOCK_S possibly
+				ORed to either LOCK_GAP or LOCK_REC_NOT_GAP */
 	rec_t*		rec,	/* in: record */
 	dict_index_t*	index,	/* in: index of record */
 	que_thr_t* 	thr)	/* in: query thread */
@@ -1943,11 +1972,16 @@ lock_rec_lock(
 	ulint	err;
 
 	ut_ad(mutex_own(&kernel_mutex));
-	ut_ad((mode != LOCK_S) || lock_table_has(thr_get_trx(thr),
-						index->table, LOCK_IS));
-	ut_ad((mode != LOCK_X) || lock_table_has(thr_get_trx(thr),
-						index->table, LOCK_IX));
-
+	ut_ad((LOCK_MODE_MASK & mode) != LOCK_S
+		|| lock_table_has(thr_get_trx(thr), index->table, LOCK_IS));
+	ut_ad((LOCK_MODE_MASK & mode) != LOCK_X
+		|| lock_table_has(thr_get_trx(thr), index->table, LOCK_IX));
+	ut_ad((LOCK_MODE_MASK & mode) == LOCK_S
+		|| (LOCK_MODE_MASK & mode) == LOCK_X);
+	ut_ad(mode - (LOCK_MODE_MASK & mode) == LOCK_GAP
+			|| mode - (LOCK_MODE_MASK & mode) == LOCK_REC_NOT_GAP
+			|| mode - (LOCK_MODE_MASK & mode) == 0);
+			
 	if (lock_rec_lock_fast(impl, mode, rec, index, thr)) {
 
 		/* We try a simplified and faster subroutine for the most
@@ -2011,26 +2045,33 @@ lock_grant(
 	ut_ad(mutex_own(&kernel_mutex));
 
 	lock_reset_lock_and_trx_wait(lock);
-	
-	if (lock_get_mode(lock) == LOCK_AUTO_INC) {
 
-	         if (lock->trx->auto_inc_lock != NULL) {
-	                 fprintf(stderr,
-		    "InnoDB: Error: trx already had an AUTO-INC lock!\n");
-	         }
+        if (lock_get_mode(lock) == LOCK_AUTO_INC) {
 
-	         /* Store pointer to lock to trx so that we know to
-	         release it at the end of the SQL statement */
+                if (lock->trx->auto_inc_lock != NULL) {
+                        fprintf(stderr,
+                   "InnoDB: Error: trx already had an AUTO-INC lock!\n");
+                }
 
-	         lock->trx->auto_inc_lock = lock;
-	}
+                /* Store pointer to lock to trx so that we know to
+                release it at the end of the SQL statement */
+
+                lock->trx->auto_inc_lock = lock;
+        }
 
 	if (lock_print_waits) {
 		printf("Lock wait for trx %lu ends\n",
 					ut_dulint_get_low(lock->trx->id));
 	}
+
+	/* If we are resolving a deadlock by choosing another transaction
+	as a victim, then our original transaction may not be in the
+	TRX_QUE_LOCK_WAIT state, and there is no need to end the lock wait
+	for it */
 	
-	trx_end_lock_wait(lock->trx);
+	if (lock->trx->que_state == TRX_QUE_LOCK_WAIT) {	
+		trx_end_lock_wait(lock->trx);
+	}
 }
 
 /*****************************************************************
@@ -2080,7 +2121,7 @@ lock_rec_dequeue_from_page(
 	ut_ad(lock_get_type(in_lock) == LOCK_REC);
 
 	trx = in_lock->trx;
-	
+
 	space = in_lock->un_member.rec_lock.space;
 	page_no = in_lock->un_member.rec_lock.page_no;
 
@@ -2199,9 +2240,10 @@ lock_rec_reset_and_release_wait(
 }	
 
 /*****************************************************************
-Makes a record to inherit the locks of another record as gap type locks, but
-does not reset the lock bits of the other record. Also waiting lock requests
-on rec are inherited as GRANTED gap locks. */
+Makes a record to inherit the locks (except LOCK_INSERT_INTENTION type)
+of another record as gap type locks, but does not reset the lock bits of
+the other record. Also waiting lock requests on rec are inherited as
+GRANTED gap locks. */
 
 void
 lock_rec_inherit_to_gap(
@@ -2217,9 +2259,45 @@ lock_rec_inherit_to_gap(
 	lock = lock_rec_get_first(rec);
 
 	while (lock != NULL) {
-		lock_rec_add_to_queue(((lock->type_mode | LOCK_GAP)
-					& ~LOCK_WAIT),
+		if (!lock_rec_get_insert_intention(lock)) {
+			
+			lock_rec_add_to_queue(LOCK_REC | lock_get_mode(lock)
+						| LOCK_GAP,
 	 			     		heir, lock->index, lock->trx);
+	 	}
+	 	
+		lock = lock_rec_get_next(rec, lock);
+	}
+}	
+
+/*****************************************************************
+Makes a record to inherit the gap locks (except LOCK_INSERT_INTENTION type)
+of another record as gap type locks, but does not reset the lock bits of the
+other record. Also waiting lock requests are inherited as GRANTED gap locks. */
+
+void
+lock_rec_inherit_to_gap_if_gap_lock(
+/*================================*/
+	rec_t*	heir,	/* in: record which inherits */
+	rec_t*	rec)	/* in: record from which inherited; does NOT reset
+			the locks on this record */
+{
+	lock_t*	lock;
+	
+	ut_ad(mutex_own(&kernel_mutex));
+	
+	lock = lock_rec_get_first(rec);
+
+	while (lock != NULL) {
+		if (!lock_rec_get_insert_intention(lock)
+		    && (page_rec_is_supremum(rec)
+			|| !lock_rec_get_rec_not_gap(lock))) {
+			
+			lock_rec_add_to_queue(LOCK_REC | lock_get_mode(lock)
+						| LOCK_GAP,
+	 			     		heir, lock->index, lock->trx);
+	 	}
+
 		lock = lock_rec_get_next(rec, lock);
 	}
 }	
@@ -2778,9 +2856,10 @@ lock_update_insert(
 {
 	lock_mutex_enter_kernel();
 
-	/* Inherit the locks for rec, in gap mode, from the next record */
+	/* Inherit the gap-locking locks for rec, in gap mode, from the next
+	record */
 
-	lock_rec_inherit_to_gap(rec, page_rec_get_next(rec));
+	lock_rec_inherit_to_gap_if_gap_lock(rec, page_rec_get_next(rec));
 
 	lock_mutex_exit_kernel();
 }	
@@ -2859,20 +2938,23 @@ static
 ibool
 lock_deadlock_occurs(
 /*=================*/
-			/* out: TRUE if a deadlock was detected */
+			/* out: TRUE if a deadlock was detected and we
+			chose trx as a victim; FALSE if no deadlock, or
+			there was a deadlock, but we chose other
+			transaction(s) as victim(s) */
 	lock_t*	lock,	/* in: lock the transaction is requesting */
 	trx_t*	trx)	/* in: transaction */
 {
 	dict_table_t*	table;
 	dict_index_t*	index;
 	trx_t*		mark_trx;
-	ibool		ret;
+	ulint		ret;
 	ulint		cost	= 0;
 	char*		err_buf;
 
 	ut_ad(trx && lock);
 	ut_ad(mutex_own(&kernel_mutex));
-
+retry:
 	/* We check that adding this trx to the waits-for graph
 	does not produce a cycle. First mark all active transactions
 	with 0: */
@@ -2886,7 +2968,14 @@ lock_deadlock_occurs(
 
 	ret = lock_deadlock_recursive(trx, trx, lock, &cost);
 
-	if (ret) {
+	if (ret == LOCK_VICTIM_IS_OTHER) {
+		/* We chose some other trx as a victim: retry if there still
+		is a deadlock */
+
+		goto retry;
+	}
+
+	if (ret == LOCK_VICTIM_IS_START) {
 		if (lock_get_type(lock) == LOCK_TABLE) {
 			table = lock->un_member.tab_lock.table;
 			index = NULL;
@@ -2898,19 +2987,6 @@ lock_deadlock_occurs(
 		lock_deadlock_found = TRUE;
 
 		err_buf = lock_latest_err_buf + strlen(lock_latest_err_buf);
-
-		err_buf += sprintf(err_buf,
-		"*** (2) WAITING FOR THIS LOCK TO BE GRANTED:\n");
-
-		ut_a(err_buf <= lock_latest_err_buf + 4000);
-			
-		if (lock_get_type(lock) == LOCK_REC) {
-			lock_rec_print(err_buf, lock);
-			err_buf += strlen(err_buf);
-		} else {
-			lock_table_print(err_buf, lock);
-			err_buf += strlen(err_buf);
-		}
 			
 		ut_a(err_buf <= lock_latest_err_buf + 4000);
 
@@ -2923,30 +2999,39 @@ lock_deadlock_occurs(
 		sess_raise_error_low(trx, DB_DEADLOCK, lock->type_mode, table,
 						index, NULL, NULL, NULL);
 		*/
+
+		return(TRUE);
 	}
 	
-	return(ret);
+	return(FALSE);
 }
 
 /************************************************************************
 Looks recursively for a deadlock. */
 static
-ibool
+ulint
 lock_deadlock_recursive(
 /*====================*/
-				/* out: TRUE if a deadlock was detected
-				or the calculation took too long */
+				/* out: 0 if no deadlock found,
+				LOCK_VICTIM_IS_START if there was a deadlock
+				and we chose 'start' as the victim,
+				LOCK_VICTIM_IS_OTHER if a deadlock
+				was found and we chose some other trx as a
+				victim: we must do the search again in this
+				last case because there may be another
+				deadlock! */
 	trx_t*	start,		/* in: recursion starting point */
 	trx_t*	trx,		/* in: a transaction waiting for a lock */
 	lock_t*	wait_lock,	/* in: the lock trx is waiting to be granted */
 	ulint*	cost)		/* in/out: number of calculation steps thus
 				far: if this exceeds LOCK_MAX_N_STEPS_...
-				we return TRUE */
+				we return LOCK_VICTIM_IS_START */
 {
 	lock_t*	lock;
 	ulint	bit_no;
 	trx_t*	lock_trx;
 	char*	err_buf;
+	ulint	ret;
 	
 	ut_a(trx && start && wait_lock);
 	ut_ad(mutex_own(&kernel_mutex));
@@ -2955,14 +3040,14 @@ lock_deadlock_recursive(
 		/* We have already exhaustively searched the subtree starting
 		from this trx */
 
-		return(FALSE);
+		return(0);
 	}
 
 	*cost = *cost + 1;
 
 	if (*cost > LOCK_MAX_N_STEPS_IN_DEADLOCK_CHECK) {
 
-		return(TRUE);
+		return(LOCK_VICTIM_IS_START);
 	}
 
 	lock = wait_lock;
@@ -2998,6 +3083,9 @@ lock_deadlock_recursive(
 			lock_trx = lock->trx;
 
 			if (lock_trx == start) {
+				/* We came back to the recursion starting
+				point: a deadlock detected */
+				
 				err_buf = lock_latest_err_buf;
 
 				ut_sprintf_timestamp(err_buf);
@@ -3045,11 +3133,60 @@ lock_deadlock_recursive(
 			
 				ut_a(err_buf <= lock_latest_err_buf + 4000);
 
+				err_buf += sprintf(err_buf,
+			"*** (2) WAITING FOR THIS LOCK TO BE GRANTED:\n");
+
+				ut_a(err_buf <= lock_latest_err_buf + 4000);
+			
+				if (lock_get_type(start->wait_lock)
+								== LOCK_REC) {
+					lock_rec_print(err_buf,
+							start->wait_lock);
+					err_buf += strlen(err_buf);
+				} else {
+					lock_table_print(err_buf,
+							start->wait_lock);
+					err_buf += strlen(err_buf);
+				}
+
 				if (lock_print_waits) {
 					printf("Deadlock detected\n");
 				}
 
-				return(TRUE);
+				if (ut_dulint_cmp(wait_lock->trx->undo_no,
+							start->undo_no) >= 0) {
+					/* Our recursion starting point
+					transaction is 'smaller', let us
+					choose 'start' as the victim and roll
+					back it */
+
+					return(LOCK_VICTIM_IS_START);
+				}		
+
+				lock_deadlock_found = TRUE;
+
+				ut_a(err_buf <= lock_latest_err_buf + 4000);
+
+				/* Let us choose the transaction of wait_lock
+				as a victim to try to avoid deadlocking our
+				recursion starting point transaction */
+				
+				err_buf += sprintf(err_buf,
+				"*** WE ROLL BACK TRANSACTION (1)\n");
+				
+				wait_lock->trx->was_chosen_as_deadlock_victim
+								= TRUE;
+				
+				lock_cancel_waiting_and_release(wait_lock);
+
+				/* Since trx and wait_lock are no longer
+				in the waits-for graph, we can return FALSE;
+				note that our selective algorithm can choose
+				several transactions as victims, but still
+				we may end up rolling back also the recursion
+				starting point transaction! */
+
+				return(LOCK_VICTIM_IS_OTHER);
 			}
 	
 			if (lock_trx->que_state == TRX_QUE_LOCK_WAIT) {
@@ -3058,10 +3195,11 @@ lock_deadlock_recursive(
 				incompatible mode, and is itself waiting for
 				a lock */
 
-				if (lock_deadlock_recursive(start, lock_trx,
-						lock_trx->wait_lock, cost)) {
+				ret = lock_deadlock_recursive(start, lock_trx,
+						lock_trx->wait_lock, cost);
+				if (ret != 0) {
 
-					return(TRUE);
+					return(ret);
 				}
 			}
 		}
@@ -3153,12 +3291,16 @@ lock_table_remove_low(
 /*************************************************************************
 Enqueues a waiting request for a table lock which cannot be granted
 immediately. Checks for deadlocks. */
-
+static
 ulint
 lock_table_enqueue_waiting(
 /*=======================*/
 				/* out: DB_LOCK_WAIT, DB_DEADLOCK, or
-				DB_QUE_THR_SUSPENDED */
+				DB_QUE_THR_SUSPENDED, or DB_SUCCESS;
+				DB_SUCCESS means that there was a deadlock,
+				but another transaction was chosen as a
+				victim, and we got the lock immediately:
+				no need to wait then */
 	ulint		mode,	/* in: lock mode this transaction is
 				requesting */
 	dict_table_t*	table,	/* in: table */
@@ -3205,7 +3347,15 @@ table->name);
 		return(DB_DEADLOCK);
 	}
 
+	if (trx->wait_lock == NULL) {
+		/* Deadlock resolution chose another transaction as a victim,
+		and we accidentally got our lock granted! */
+	
+		return(DB_SUCCESS);
+	}
+	
 	trx->que_state = TRX_QUE_LOCK_WAIT;
+	trx->was_chosen_as_deadlock_victim = FALSE;
 	trx->wait_started = time(NULL);
 
 	ut_a(que_thr_stop(thr));
@@ -3292,7 +3442,7 @@ lock_table(
 	if (lock_table_other_has_incompatible(trx, LOCK_WAIT, table, mode)) {
 	
 		/* Another trx has a request on the table in an incompatible
-		mode: this trx must wait */
+		mode: this trx may have to wait */
 
 		err = lock_table_enqueue_waiting(mode, table, thr);
 			
@@ -3659,7 +3809,11 @@ lock_rec_print(
 	}
 
 	if (lock_rec_get_gap(lock)) {
-		buf += sprintf(buf, " gap type lock");
+		buf += sprintf(buf, " locks gap before rec");
+	}
+
+	if (lock_rec_get_rec_not_gap(lock)) {
+		buf += sprintf(buf, " locks rec but not gap");
 	}
 
 	if (lock_rec_get_insert_intention(lock)) {
@@ -3776,8 +3930,8 @@ lock_print_info(
 	mtr_t	mtr;
 
 	if (buf_end - buf < 600) {
-		sprintf(buf, "... output truncated!\n");
-	
+                sprintf(buf, "... output truncated!\n");
+
 		return;
 	}
 
@@ -3802,8 +3956,8 @@ lock_print_info(
 		if ((ulint)(buf_end - buf)
 			< 100 + strlen(lock_latest_err_buf)) {
 
-			lock_mutex_exit_kernel();
-			sprintf(buf, "... output truncated!\n");
+		        lock_mutex_exit_kernel();
+		        sprintf(buf, "... output truncated!\n");
 
 			return;
 		}
@@ -3826,8 +3980,8 @@ lock_print_info(
 
 	while (trx) {
 		if (buf_end - buf < 900) {
-			lock_mutex_exit_kernel();
-			sprintf(buf, "... output truncated!\n");
+		        lock_mutex_exit_kernel();
+		        sprintf(buf, "... output truncated!\n");
 
 			return;
 		}
@@ -3879,8 +4033,8 @@ lock_print_info(
 		buf += strlen(buf);
 		
 		if (buf_end - buf < 500) {
-			lock_mutex_exit_kernel();
-			sprintf(buf, "... output truncated!\n");
+		        lock_mutex_exit_kernel();
+		        sprintf(buf, "... output truncated!\n");
 
 			return;
 		}
@@ -3936,7 +4090,7 @@ lock_print_info(
 	}
 
 	if (buf_end - buf < 500) {
-		lock_mutex_exit_kernel();
+	        lock_mutex_exit_kernel();
 		sprintf(buf, "... output truncated!\n");
 
 		return;
@@ -4080,7 +4234,8 @@ lock_rec_queue_validate(
 		if (impl_trx && lock_rec_other_has_expl_req(LOCK_S, 0,
 				LOCK_WAIT, rec, impl_trx)) {
 
-			ut_a(lock_rec_has_expl(LOCK_X, rec, impl_trx));
+			ut_a(lock_rec_has_expl(LOCK_X | LOCK_REC_NOT_GAP, rec,
+								impl_trx));
 		}
 	}
 
@@ -4095,7 +4250,8 @@ lock_rec_queue_validate(
 		if (impl_trx && lock_rec_other_has_expl_req(LOCK_S, 0,
 				LOCK_WAIT, rec, impl_trx)) {
 
-			ut_a(lock_rec_has_expl(LOCK_X, rec, impl_trx));
+			ut_a(lock_rec_has_expl(LOCK_X | LOCK_REC_NOT_GAP, rec,
+								impl_trx));
 		}
 	}
 
@@ -4359,8 +4515,8 @@ lock_rec_insert_check_and_lock(
 
 	*inherit = TRUE;
 
-	/* If another transaction has an explicit lock request, gap or not,
-	waiting or granted, on the successor, the insert has to wait.
+	/* If another transaction has an explicit lock request which locks
+	the gap, waiting or granted, on the successor, the insert has to wait.
 
 	An exception is the case where the lock by the another transaction
 	is a gap type lock which it placed to wait for its turn to insert. We
@@ -4369,8 +4525,10 @@ lock_rec_insert_check_and_lock(
 	had to wait for their insert. Both had waiting gap type lock requests
 	on the successor, which produced an unnecessary deadlock. */
 
-	if (lock_rec_other_has_conflicting(LOCK_X, LOCK_GAP,
-				LOCK_INSERT_INTENTION, next_rec, trx)) {
+	if (lock_rec_other_has_conflicting(LOCK_X | LOCK_GAP
+				| LOCK_INSERT_INTENTION, next_rec, trx)) {
+
+		/* Note that we may get DB_SUCCESS also here! */
 		err = lock_rec_enqueue_waiting(LOCK_X | LOCK_GAP
 						| LOCK_INSERT_INTENTION,
 						next_rec, index, thr);
@@ -4418,9 +4576,11 @@ lock_rec_convert_impl_to_expl(
 		/* If the transaction has no explicit x-lock set on the
 		record, set one for it */
 
-		if (!lock_rec_has_expl(LOCK_X, rec, impl_trx)) {
+		if (!lock_rec_has_expl(LOCK_X | LOCK_REC_NOT_GAP, rec,
+								impl_trx)) {
 
-			lock_rec_add_to_queue(LOCK_REC | LOCK_X, rec, index,
+			lock_rec_add_to_queue(LOCK_REC | LOCK_X
+					      | LOCK_REC_NOT_GAP, rec, index,
 								impl_trx);
 		}
 	}
@@ -4466,7 +4626,7 @@ lock_clust_rec_modify_check_and_lock(
 
 	lock_rec_convert_impl_to_expl(rec, index);
 
-	err = lock_rec_lock(TRUE, LOCK_X, rec, index, thr);
+	err = lock_rec_lock(TRUE, LOCK_X | LOCK_REC_NOT_GAP, rec, index, thr);
 
 	lock_mutex_exit_kernel();
 
@@ -4511,7 +4671,7 @@ lock_sec_rec_modify_check_and_lock(
 
 	ut_ad(lock_table_has(thr_get_trx(thr), index->table, LOCK_IX));
 
-	err = lock_rec_lock(TRUE, LOCK_X, rec, index, thr);
+	err = lock_rec_lock(TRUE, LOCK_X | LOCK_REC_NOT_GAP, rec, index, thr);
 
 	lock_mutex_exit_kernel();
 	
@@ -4545,6 +4705,8 @@ lock_sec_rec_read_check_and_lock(
 	ulint		mode,	/* in: mode of the lock which the read cursor
 				should set on records: LOCK_S or LOCK_X; the
 				latter is possible in SELECT FOR UPDATE */
+	ulint		gap_mode,/* in: LOCK_ORDINARY, LOCK_GAP, or
+				LOCK_REC_NOT_GAP */
 	que_thr_t*	thr)	/* in: query thread */
 {
 	ulint	err;
@@ -4576,7 +4738,7 @@ lock_sec_rec_read_check_and_lock(
  		lock_rec_convert_impl_to_expl(rec, index);
 	}
 
-	err = lock_rec_lock(FALSE, mode, rec, index, thr);
+	err = lock_rec_lock(FALSE, mode | gap_mode, rec, index, thr);
 
 	lock_mutex_exit_kernel();
 
@@ -4607,13 +4769,16 @@ lock_clust_rec_read_check_and_lock(
 	ulint		mode,	/* in: mode of the lock which the read cursor
 				should set on records: LOCK_S or LOCK_X; the
 				latter is possible in SELECT FOR UPDATE */
+	ulint		gap_mode,/* in: LOCK_ORDINARY, LOCK_GAP, or
+				LOCK_REC_NOT_GAP */
 	que_thr_t*	thr)	/* in: query thread */
 {
 	ulint	err;
 
 	ut_ad(index->type & DICT_CLUSTERED);
 	ut_ad(page_rec_is_user_rec(rec) || page_rec_is_supremum(rec));
-	
+	ut_ad(gap_mode == LOCK_ORDINARY || gap_mode == LOCK_GAP
+					|| gap_mode == LOCK_REC_NOT_GAP);
 	if (flags & BTR_NO_LOCKING_FLAG) {
 
 		return(DB_SUCCESS);
@@ -4631,7 +4796,7 @@ lock_clust_rec_read_check_and_lock(
 		lock_rec_convert_impl_to_expl(rec, index);
 	}
 
-	err = lock_rec_lock(FALSE, mode, rec, index, thr);
+	err = lock_rec_lock(FALSE, mode | gap_mode, rec, index, thr);
 
 	lock_mutex_exit_kernel();
 
diff --git a/innobase/log/log0log.c b/innobase/log/log0log.c
index c798a08e2de9dc7cb23fd951a2499d94e9c5bfed..f9b785ccbd5cdda0c4a020f2a9b3d4746abd09cd 100644
--- a/innobase/log/log0log.c
+++ b/innobase/log/log0log.c
@@ -1654,8 +1654,8 @@ log_reset_first_header_and_checkpoint(
 	lsn = ut_dulint_add(start, LOG_BLOCK_HDR_SIZE);
 
 	/* Write the label of ibbackup --restore */
-	sprintf(hdr_buf + LOG_FILE_WAS_CREATED_BY_HOT_BACKUP, "ibbackup ");
-	ut_sprintf_timestamp(hdr_buf + LOG_FILE_WAS_CREATED_BY_HOT_BACKUP
+	sprintf((char*) hdr_buf + LOG_FILE_WAS_CREATED_BY_HOT_BACKUP, "ibbackup ");
+	ut_sprintf_timestamp((char*) hdr_buf + LOG_FILE_WAS_CREATED_BY_HOT_BACKUP
 						+ strlen("ibbackup "));
 	buf = hdr_buf + LOG_CHECKPOINT_1;
 	
diff --git a/innobase/log/log0recv.c b/innobase/log/log0recv.c
index 1223f9b6041382f14a1aa5799cba3b8aa38dbcbf..dfe67c444b41d3d3c3db668bfdffac7ee3512077 100644
--- a/innobase/log/log0recv.c
+++ b/innobase/log/log0recv.c
@@ -69,6 +69,8 @@ ulint	recv_previous_parsed_rec_type	= 999999;
 ulint	recv_previous_parsed_rec_offset	= 0;
 ulint	recv_previous_parsed_rec_is_multi = 0;
 
+ulint	recv_max_parsed_page_no		= 0;
+
 /************************************************************
 Creates the recovery system. */
 
@@ -141,7 +143,13 @@ recv_sys_empty_hash(void)
 /*=====================*/
 {
 	ut_ad(mutex_own(&(recv_sys->mutex)));
-	ut_a(recv_sys->n_addrs == 0);
+	if (recv_sys->n_addrs != 0) {
+		fprintf(stderr,
+"InnoDB: Error: %lu pages with log records were left unprocessed!\n"
+"InnoDB: Maximum page number with log records on it %lu\n",
+			recv_sys->n_addrs, recv_max_parsed_page_no);
+		ut_a(0);
+	}
 	
 	hash_table_free(recv_sys->addr_hash);
 	mem_heap_empty(recv_sys->heap);
@@ -1361,6 +1369,14 @@ recv_apply_log_recs_for_backup(
 		n_pages_total += file_sizes[i];
 	}
 
+	if (recv_max_parsed_page_no >= n_pages_total) {
+		printf(
+"InnoDB: Error: tablespace size %lu pages, but a log record on page %lu!\n"
+"InnoDB: Are you sure you have specified all the ibdata files right in\n"
+"InnoDB: the my.cnf file you gave as the argument to ibbackup --restore?\n",
+			n_pages_total, recv_max_parsed_page_no);
+	}
+
 	printf( 
 "InnoDB: Starting an apply batch of log records to the database...\n"
 "InnoDB: Progress in percents: ");
@@ -1381,7 +1397,7 @@ recv_apply_log_recs_for_backup(
 							&success);
 			if (!success) {
 				printf(
-"InnoDB: Error: cannot open %lu'th data file %s\n", nth_file);
+"InnoDB: Error: cannot open %lu'th data file\n", nth_file);
 
 				exit(1);
 			}
@@ -1397,7 +1413,7 @@ recv_apply_log_recs_for_backup(
 				UNIV_PAGE_SIZE);
 			if (!success) {
 				printf(
-"InnoDB: Error: cannot read page no %lu from %lu'th data file %s\n",
+"InnoDB: Error: cannot read page no %lu from %lu'th data file\n",
 				nth_page_in_file, nth_file);
 
 				exit(1);
@@ -1425,7 +1441,7 @@ recv_apply_log_recs_for_backup(
 				UNIV_PAGE_SIZE);
 			if (!success) {
 				printf(
-"InnoDB: Error: cannot write page no %lu to %lu'th data file %s\n",
+"InnoDB: Error: cannot write page no %lu to %lu'th data file\n",
 				nth_page_in_file, nth_file);
 
 				exit(1);
@@ -1701,6 +1717,10 @@ recv_parse_log_rec(
 		return(0);
 	}
 
+	if (*page_no > recv_max_parsed_page_no) {
+		recv_max_parsed_page_no = *page_no;
+	}
+	
 	return(new_ptr - ptr);
 }
 
@@ -1779,7 +1799,7 @@ recv_report_corrupt_log(
 "InnoDB: Recv offset %lu, prev %lu\n",
 		recv_previous_parsed_rec_type,
 		recv_previous_parsed_rec_is_multi,
-		ptr - recv_sys->buf,
+		(ulint)(ptr - recv_sys->buf),
 		recv_previous_parsed_rec_offset);
 
 	if ((ulint)(ptr - recv_sys->buf + 100)
diff --git a/innobase/mem/mem0dbg.c b/innobase/mem/mem0dbg.c
index 23585e494b83fe00d7e57f3d4bb36af04dc9f9b9..22d0bab0da259a9e08bda36b6ecdba30f6723c76 100644
--- a/innobase/mem/mem0dbg.c
+++ b/innobase/mem/mem0dbg.c
@@ -347,9 +347,19 @@ mem_hash_remove(
 								NULL, NULL);
 	if (error) {
 	   printf("Inconsistency in memory heap or buffer n:o %lu created\n",
-								node->nth_heap);
+							node->nth_heap);
 	   printf("in %s line %lu and tried to free in %s line %lu.\n",
 	  			node->file_name, node->line, file_name, line);
+
+	   printf(
+	   "Hex dump of 400 bytes around memory heap first block start:\n");
+
+	   ut_print_buf((byte*)(node->heap) - 200, 400);
+
+	   printf("\nDump of the mem heap:\n");
+
+	   mem_heap_validate_or_print(node->heap, NULL, TRUE, &error, &size,
+								NULL, NULL);
 	   ut_error;
 	}
 
diff --git a/innobase/os/os0file.c b/innobase/os/os0file.c
index 098d5b25e8981851ad08c78bdc601e7c60600f6a..9eae358c7fbe84d0bd04d37b3215667cf2473f4a 100644
--- a/innobase/os/os0file.c
+++ b/innobase/os/os0file.c
@@ -148,7 +148,7 @@ Gets the operating system version. Currently works only on Windows. */
 ulint
 os_get_os_version(void)
 /*===================*/
-                  /* out: OS_WIN95, OS_WIN31, OS_WINNT (2000 == NT) */
+                  /* out: OS_WIN95, OS_WIN31, OS_WINNT, OS_WIN2000 */
 {
 #ifdef __WIN__
   	OSVERSIONINFO     os_info;
@@ -162,7 +162,11 @@ os_get_os_version(void)
   	} else if (os_info.dwPlatformId == VER_PLATFORM_WIN32_WINDOWS) {
     		return(OS_WIN95);
   	} else if (os_info.dwPlatformId == VER_PLATFORM_WIN32_NT) {
-    		return(OS_WINNT);
+		if (os_info.dwMajorVersion <= 4) {
+    			return(OS_WINNT);
+    		} else {
+			return(OS_WIN2000);
+    		}
   	} else {
     		ut_error;
     		return(0);
@@ -268,9 +272,7 @@ os_file_get_last_error(void)
 }
 
 /********************************************************************
-Does error handling when a file operation fails. If we have run out
-of disk space, then the user can clean the disk. If we do not find
-a specified file, then the user can copy it to disk. */
+Does error handling when a file operation fails. */
 static
 ibool
 os_file_handle_error(
@@ -503,7 +505,11 @@ os_file_create(
 		        value 2 denotes that we do not flush the log at every
 		        commit, but only once per second */
 		} else {
-		        attributes = attributes | FILE_FLAG_NO_BUFFERING;
+			if (srv_win_file_flush_method ==
+					SRV_WIN_IO_UNBUFFERED) {
+		        	attributes = attributes
+						| FILE_FLAG_NO_BUFFERING;
+			}
 		}
 #endif
 	} else if (purpose == OS_FILE_NORMAL) {
@@ -514,7 +520,11 @@ os_file_create(
 		        value 2 denotes that we do not flush the log at every
 		        commit, but only once per second */
 		} else {
-		        attributes = attributes | FILE_FLAG_NO_BUFFERING;
+			if (srv_win_file_flush_method ==
+					SRV_WIN_IO_UNBUFFERED) {
+		        	attributes = attributes
+						| FILE_FLAG_NO_BUFFERING;
+			}
 		}
 #endif
 	} else {
@@ -1752,6 +1762,7 @@ os_aio(
 	os_aio_array_t*	array;
 	os_aio_slot_t*	slot;
 #ifdef WIN_ASYNC_IO
+	ibool		retval;
 	BOOL		ret		= TRUE;
 	DWORD		len		= n;
 	void*		dummy_mess1;
@@ -1824,6 +1835,8 @@ os_aio(
 		if (os_aio_use_native_aio) {
 #ifdef WIN_ASYNC_IO
 			os_n_file_reads++;
+			os_bytes_read_since_printout += len;
+			
 			ret = ReadFile(file, buf, (DWORD)n, &len,
 							&(slot->control));
 #elif defined(POSIX_ASYNC_IO)
@@ -1870,10 +1883,12 @@ os_aio(
 	    		    where we also use async i/o: in Windows we must
 	    		    use the same wait mechanism as for async i/o */
 	    		
-	    		    return(os_aio_windows_handle(ULINT_UNDEFINED,
+	    		    retval = os_aio_windows_handle(ULINT_UNDEFINED,
 					slot->pos,
 		    			&dummy_mess1, &dummy_mess2,
-					&dummy_type));
+					&dummy_type);
+
+			    return(retval);
 	    		}
 
 			return(TRUE);
@@ -1897,8 +1912,6 @@ os_aio(
 		goto try_again;
 	}	
 
-	ut_error;
-	
 	return(FALSE);
 }
 
@@ -1958,14 +1971,14 @@ os_aio_windows_handle(
 	n = array->n_slots / array->n_segments;
 
 	if (array == os_aio_sync_array) {
-		srv_io_thread_op_info[orig_seg] = "wait windows aio for 1 page";
+		srv_io_thread_op_info[orig_seg] = "wait Windows aio for 1 page";
 
 		ut_ad(pos < array->n_slots); 
 		os_event_wait(array->events[pos]);
 		i = pos;
 	} else {
 		srv_io_thread_op_info[orig_seg] =
-						"wait windows aio for n pages";
+						"wait Windows aio";
 		i = os_event_wait_multiple(n, (array->events) + segment * n);
 	}
 
@@ -1991,10 +2004,8 @@ os_aio_windows_handle(
 		         ut_a(TRUE == os_file_flush(slot->file));
 		}
 	} else {
-		os_file_get_last_error();
-
-		ut_error;
-
+		os_file_handle_error(slot->file, slot->name);
+		
 		ret_val = FALSE;
 	}		  
 
diff --git a/innobase/os/os0proc.c b/innobase/os/os0proc.c
index 43a2db4d306402199edaa97d3b7eb7fede62fa8d..1ee448a4a44620338378e2c88af154b6eccb4b6c 100644
--- a/innobase/os/os0proc.c
+++ b/innobase/os/os0proc.c
@@ -18,6 +18,23 @@ Created 9/30/1995 Heikki Tuuri
 
 #include "ut0mem.h"
 
+/********************************************************************
+Converts the current process id to a number. It is not guaranteed that the
+number is unique. In Linux returns the 'process number' of the current
+thread. That number is the same as one sees in 'top', for example. In Linux
+the thread id is not the same as one sees in 'top'. */
+
+ulint
+os_proc_get_number(void)
+/*====================*/
+{
+#ifdef __WIN__
+	return((ulint)GetCurrentProcessId());
+#else
+	return((ulint)getpid());
+#endif
+}
+
 /********************************************************************
 Allocates non-cacheable memory. */
 
diff --git a/innobase/os/os0sync.c b/innobase/os/os0sync.c
index 14677ede20ff2a97f7bd57387fc3feeed003b244..bac1f23a1af53ce478d2c596535bf6b793c47db0 100644
--- a/innobase/os/os0sync.c
+++ b/innobase/os/os0sync.c
@@ -66,8 +66,12 @@ os_event_create(
 	event = ut_malloc(sizeof(struct os_event_struct));
 
 	os_fast_mutex_init(&(event->os_mutex));
-	pthread_cond_init(&(event->cond_var), NULL);
 
+#if defined(UNIV_HOTBACKUP) && defined(UNIV_HPUX10)
+	pthread_cond_init(&(event->cond_var), pthread_condattr_default);
+#else
+	pthread_cond_init(&(event->cond_var), NULL);
+#endif
 	event->is_set = FALSE;
 
 	return(event);
@@ -440,9 +444,13 @@ os_fast_mutex_init(
 	ut_a(fast_mutex);
 	
 	InitializeCriticalSection((LPCRITICAL_SECTION) fast_mutex);
+#else
+#if defined(UNIV_HOTBACKUP) && defined(UNIV_HPUX10)
+	pthread_mutex_init(fast_mutex, pthread_mutexattr_default);
 #else
 	pthread_mutex_init(fast_mutex, MY_MUTEX_INIT_FAST);
 #endif
+#endif
 }
 
 /**************************************************************
diff --git a/innobase/os/os0thread.c b/innobase/os/os0thread.c
index 48aea4b8abbc6e29ab012ca9508c7e56200cfd12..30404c4e66b6f8bd4b0b6724993e1f7bb8ef34ec 100644
--- a/innobase/os/os0thread.c
+++ b/innobase/os/os0thread.c
@@ -126,8 +126,10 @@ os_thread_create(
 	os_thread_t	pthread;
 	pthread_attr_t  attr;
 
+#if !(defined(UNIV_HOTBACKUP) && defined(UNIV_HPUX10))
         pthread_attr_init(&attr);
-
+#endif
+        
 #ifdef UNIV_AIX
 	/* We must make sure a thread stack is at least 32 kB, otherwise
 	InnoDB might crash; we do not know if the default stack size on
@@ -142,16 +144,21 @@ os_thread_create(
 		 exit(1);
 	}
 #endif
-	ret = pthread_create(&pthread, &attr, start_f, arg);
 
+#if defined(UNIV_HOTBACKUP) && defined(UNIV_HPUX10)
+	ret = pthread_create(&pthread, pthread_attr_default, start_f, arg);
+#else
+	ret = pthread_create(&pthread, &attr, start_f, arg);
+#endif
         if (ret) {
 	         fprintf(stderr,
           "InnoDB: Error: pthread_create returned %d\n", ret);
 		 exit(1);
 	}
 
+#if !(defined(UNIV_HOTBACKUP) && defined(UNIV_HPUX10))
 	pthread_attr_destroy(&attr);
-
+#endif
 	if (srv_set_thread_priorities) {
 	
 	        my_pthread_setprio(pthread, srv_query_thread_priority);
diff --git a/innobase/page/page0cur.c b/innobase/page/page0cur.c
index 2909573b14b203466eb6fd63ca347f53df81a10f..bb49e9080ce0cbde77508f04c361ea2857210b1d 100644
--- a/innobase/page/page0cur.c
+++ b/innobase/page/page0cur.c
@@ -169,7 +169,7 @@ page_cur_search_with_match(
 	ut_ad(dtuple_check_typed(tuple));
 	ut_ad((mode == PAGE_CUR_L) || (mode == PAGE_CUR_LE)
 	      || (mode == PAGE_CUR_G) || (mode == PAGE_CUR_GE)
-	      || (mode == PAGE_CUR_DBG));
+	      || (mode == PAGE_CUR_LE_OR_EXTENDS) || (mode == PAGE_CUR_DBG));
 	      
 #ifdef PAGE_CUR_ADAPT
 	if ((page_header_get_field(page, PAGE_LEVEL) == 0)
@@ -232,9 +232,26 @@ page_cur_search_with_match(
 			low_matched_bytes = cur_matched_bytes;
 
 		} else if (cmp == -1) {
-			up = mid;
-			up_matched_fields = cur_matched_fields;
-			up_matched_bytes = cur_matched_bytes; 
+
+			if (mode == PAGE_CUR_LE_OR_EXTENDS
+			    && dfield_get_len(dtuple_get_nth_field(tuple,
+			    				cur_matched_fields))
+			    	== cur_matched_bytes
+			    && rec_get_nth_field_len(mid_rec,
+							cur_matched_fields)
+				!= UNIV_SQL_NULL) {
+
+				/* This means current dfield is not SQL
+			    	NULL, and the current rec field extends it */
+
+				low = mid;
+				low_matched_fields = cur_matched_fields;
+				low_matched_bytes = cur_matched_bytes;
+			} else {
+				up = mid;
+				up_matched_fields = cur_matched_fields;
+				up_matched_bytes = cur_matched_bytes;
+			}
 
 		} else if ((mode == PAGE_CUR_G) || (mode == PAGE_CUR_LE)) {
 			low = mid;
@@ -252,8 +269,8 @@ page_cur_search_with_match(
 	slot = page_dir_get_nth_slot(page, up);
 	up_rec = page_dir_slot_get_rec(slot);
 
-	/* Perform linear search until the upper and lower records
-	come to distance 1 of each other. */
+	/* Perform linear search until the upper and lower records come to
+	distance 1 of each other. */
 
    	while (page_rec_get_next(low_rec) != up_rec) {
 
@@ -272,10 +289,25 @@ page_cur_search_with_match(
 			low_matched_bytes = cur_matched_bytes;
 
 		} else if (cmp == -1) {
-			up_rec = mid_rec;
-			up_matched_fields = cur_matched_fields;
-			up_matched_bytes = cur_matched_bytes; 
-
+			if (mode == PAGE_CUR_LE_OR_EXTENDS
+			    && dfield_get_len(dtuple_get_nth_field(tuple,
+			    				cur_matched_fields))
+			    	== cur_matched_bytes
+			    && rec_get_nth_field_len(mid_rec,
+							cur_matched_fields)
+				!= UNIV_SQL_NULL) {
+
+				/* This means current dfield is not SQL
+			    	NULL, and the current rec field extends it */
+
+				low = mid;
+				low_matched_fields = cur_matched_fields;
+				low_matched_bytes = cur_matched_bytes;
+			} else {
+				up_rec = mid_rec;
+				up_matched_fields = cur_matched_fields;
+				up_matched_bytes = cur_matched_bytes;
+			}
 		} else if ((mode == PAGE_CUR_G) || (mode == PAGE_CUR_LE)) {
 			low_rec = mid_rec;
 			low_matched_fields = cur_matched_fields;
diff --git a/innobase/page/page0page.c b/innobase/page/page0page.c
index ed74736c8daf82977ef97680677c7b51b2981190..7d240bdd5b0842c52ee7e4299da955e408d5589f 100644
--- a/innobase/page/page0page.c
+++ b/innobase/page/page0page.c
@@ -1299,12 +1299,16 @@ page_rec_validate(
 	heap_no = rec_get_heap_no(rec);
 
 	if (!(n_owned <= PAGE_DIR_SLOT_MAX_N_OWNED)) {
-		fprintf(stderr, "Dir slot n owned too big %lu\n", n_owned);
+		fprintf(stderr,
+			"InnoDB: Dir slot of rec %lu, n owned too big %lu\n",
+				(ulint)(rec - page), n_owned);
 		return(FALSE);
 	}
 
 	if (!(heap_no < page_header_get_field(page, PAGE_N_HEAP))) {
-		fprintf(stderr, "Heap no too big %lu %lu\n", heap_no,
+		fprintf(stderr,
+		"InnoDB: Heap no of rec %lu too big %lu %lu\n",
+				(ulint)(rec - page), heap_no,
 				page_header_get_field(page, PAGE_N_HEAP));
 		return(FALSE);
 	}
@@ -1312,6 +1316,194 @@ page_rec_validate(
 	return(TRUE);
 }
 	
+/*******************************************************************
+This function checks the consistency of an index page when we do not
+know the index. This is also resilient so that this should never crash
+even if the page is total garbage. */
+
+ibool
+page_simple_validate(
+/*=================*/
+			/* out: TRUE if ok */
+	page_t*	page)	/* in: index page */
+{
+	page_cur_t 	cur;
+	page_dir_slot_t* slot;
+	ulint		slot_no;
+	ulint		n_slots;
+	rec_t*		rec;
+	byte*		rec_heap_top;
+	ulint		count;
+	ulint		own_count;
+	ibool		ret	= FALSE;
+
+	/* Check first that the record heap and the directory do not
+	overlap. */
+
+	n_slots = page_dir_get_n_slots(page);
+
+	if (n_slots > UNIV_PAGE_SIZE / 4) {
+		fprintf(stderr,
+	"InnoDB: Nonsensical number %lu of page dir slots\n", n_slots);
+
+		goto func_exit;
+	}
+
+	rec_heap_top = page_header_get_ptr(page, PAGE_HEAP_TOP);
+	
+	if (rec_heap_top > page_dir_get_nth_slot(page, n_slots - 1)) {
+
+		fprintf(stderr,
+    "InnoDB: Record heap and dir overlap on a page, heap top %lu, dir %lu\n",
+       		(ulint)(page_header_get_ptr(page, PAGE_HEAP_TOP) - page),
+       		(ulint)(page_dir_get_nth_slot(page, n_slots - 1) - page));
+
+       		goto func_exit;
+       	}
+
+	/* Validate the record list in a loop checking also that it is
+	consistent with the page record directory. */
+
+	count = 0;
+	own_count = 1;
+	slot_no = 0;
+	slot = page_dir_get_nth_slot(page, slot_no);
+
+	page_cur_set_before_first(page, &cur);
+
+	for (;;) {
+		rec = (&cur)->rec;
+		
+		if (rec > rec_heap_top) {
+			fprintf(stderr,
+			"InnoDB: Record %lu is above rec heap top %lu\n",
+			(ulint)(rec - page), (ulint)(rec_heap_top - page));
+
+			goto func_exit;
+		}
+
+		if (rec_get_n_owned(rec) != 0) {
+			/* This is a record pointed to by a dir slot */
+			if (rec_get_n_owned(rec) != own_count) {
+
+				fprintf(stderr,
+		"InnoDB: Wrong owned count %lu, %lu, rec %lu\n",
+				rec_get_n_owned(rec), own_count,
+				(ulint)(rec - page));
+
+				goto func_exit;
+			}
+
+			if (page_dir_slot_get_rec(slot) != rec) {
+				fprintf(stderr,
+		"InnoDB: Dir slot does not point to right rec %lu\n",
+					(ulint)(rec - page));
+
+				goto func_exit;
+			}
+						
+			own_count = 0;
+
+			if (!page_cur_is_after_last(&cur)) {
+				slot_no++;
+				slot = page_dir_get_nth_slot(page, slot_no);
+			}
+		}
+
+		if (page_cur_is_after_last(&cur)) {
+
+			break;
+		}
+
+		if (rec_get_next_offs(rec) < FIL_PAGE_DATA
+				|| rec_get_next_offs(rec) >= UNIV_PAGE_SIZE) {
+			fprintf(stderr,
+		"InnoDB: Next record offset nonsensical %lu for rec %lu\n",
+			  rec_get_next_offs(rec),
+			  (ulint)(rec - page));
+
+			goto func_exit;
+		}
+
+		count++;		
+
+		if (count > UNIV_PAGE_SIZE) {
+			fprintf(stderr,
+		"InnoDB: Page record list appears to be circular %lu\n",
+								count);
+			goto func_exit;
+		}
+		
+		page_cur_move_to_next(&cur);
+		own_count++;
+	}
+	
+	if (rec_get_n_owned(rec) == 0) {
+		fprintf(stderr, "InnoDB: n owned is zero in a supremum rec\n");
+
+		goto func_exit;
+	}
+		
+	if (slot_no != n_slots - 1) {
+		fprintf(stderr, "InnoDB: n slots wrong %lu, %lu\n",
+			slot_no, n_slots - 1);
+		goto func_exit;
+	}		
+
+	if (page_header_get_field(page, PAGE_N_RECS) + 2 != count + 1) {
+		fprintf(stderr, "InnoDB: n recs wrong %lu %lu\n",
+		page_header_get_field(page, PAGE_N_RECS) + 2,  count + 1);
+
+		goto func_exit;
+	}
+
+	/* Check then the free list */
+	rec = page_header_get_ptr(page, PAGE_FREE);
+
+	while (rec != NULL) {
+		if (rec < page + FIL_PAGE_DATA
+				|| rec >= page + UNIV_PAGE_SIZE) {
+			fprintf(stderr,
+		"InnoDB: Free list record has a nonsensical offset %lu\n",
+			(ulint)(rec - page));
+
+			goto func_exit;
+		}
+
+		if (rec > rec_heap_top) {
+			fprintf(stderr,
+		"InnoDB: Free list record %lu is above rec heap top %lu\n",
+			(ulint)(rec - page), (ulint)(rec_heap_top - page));
+
+			goto func_exit;
+		}
+
+		count++;
+		
+		if (count > UNIV_PAGE_SIZE) {
+			fprintf(stderr,
+		"InnoDB: Page free list appears to be circular %lu\n",
+								count);
+			goto func_exit;
+		}
+
+		rec = page_rec_get_next(rec);
+	}
+	
+	if (page_header_get_field(page, PAGE_N_HEAP) != count + 1) {
+
+		fprintf(stderr, "InnoDB: N heap is wrong %lu, %lu\n",
+		page_header_get_field(page, PAGE_N_HEAP), count + 1);
+
+		goto func_exit;
+	}
+
+	ret = TRUE;	
+
+func_exit:
+	return(ret);			  
+}
+
 /*******************************************************************
 This function checks the consistency of an index page. */
 
@@ -1339,6 +1531,17 @@ page_validate(
 	ulint		i;
 	char           	err_buf[1000];
 	
+	if (!page_simple_validate(page)) {
+		fprintf(stderr,
+"InnoDB: Apparent corruption in page %lu in index %s in table %s\n",
+			buf_frame_get_page_no(page), index->name,
+			index->table_name);
+
+		buf_page_print(page);
+
+		return(FALSE);
+	}
+
 	heap = mem_heap_create(UNIV_PAGE_SIZE);
 	
 	/* The following buffer is used to check that the
@@ -1357,7 +1560,7 @@ page_validate(
 	if (!(page_header_get_ptr(page, PAGE_HEAP_TOP) <=
 			page_dir_get_nth_slot(page, n_slots - 1))) {
 		fprintf(stderr,
-       	"Record heap and dir overlap on a page in index %s, %lu, %lu\n",
+"InnoDB: Record heap and dir overlap on a page in index %s, %lu, %lu\n",
        		index->name, (ulint)page_header_get_ptr(page, PAGE_HEAP_TOP),
        		(ulint)page_dir_get_nth_slot(page, n_slots - 1));
 
@@ -1385,10 +1588,14 @@ page_validate(
 		if ((count >= 2) && (!page_cur_is_after_last(&cur))) {
 			if (!(1 == cmp_rec_rec(rec, old_rec, index))) {
 				fprintf(stderr,
-					"Records in wrong order in index %s\n",
-					index->name);
+"InnoDB: Records in wrong order on page %lu index %s table %s\n",
+					buf_frame_get_page_no(page),
+					index->name,
+					index->table_name);
+
 	 		 	rec_sprintf(err_buf, 900, old_rec);
-	  			fprintf(stderr, "InnoDB: record %s\n", err_buf);
+	  			fprintf(stderr,
+				"InnoDB: previous record %s\n", err_buf);
 				
 	 		 	rec_sprintf(err_buf, 900, rec);
 	  			fprintf(stderr, "InnoDB: record %s\n", err_buf);
@@ -1410,7 +1617,7 @@ page_validate(
 				/* No other record may overlap this */
 
 				fprintf(stderr,
-				"Record overlaps another in index %s \n",
+			"InnoDB: Record overlaps another in index %s \n",
 				index->name);
 
 				goto func_exit;
@@ -1423,7 +1630,7 @@ page_validate(
 			/* This is a record pointed to by a dir slot */
 			if (rec_get_n_owned(rec) != own_count) {
 				fprintf(stderr,
-				"Wrong owned count %lu, %lu, in index %s\n",
+			"InnoDB: Wrong owned count %lu, %lu, in index %s\n",
 				rec_get_n_owned(rec), own_count,
 				index->name);
 
@@ -1432,7 +1639,7 @@ page_validate(
 
 			if (page_dir_slot_get_rec(slot) != rec) {
 				fprintf(stderr,
-				"Dir slot does not point to right rec in %s\n",
+			"InnoDB: Dir slot does not point to right rec in %s\n",
 				index->name);
 
 				goto func_exit;
@@ -1454,7 +1661,7 @@ page_validate(
 		if (rec_get_next_offs(rec) < FIL_PAGE_DATA
 				|| rec_get_next_offs(rec) >= UNIV_PAGE_SIZE) {
 			fprintf(stderr,
-			  "Next record offset wrong %lu in index %s\n",
+		"InnoDB: Next record offset wrong %lu in index %s\n",
 			  rec_get_next_offs(rec), index->name);
 
 			goto func_exit;
@@ -1467,19 +1674,20 @@ page_validate(
 	}
 	
 	if (rec_get_n_owned(rec) == 0) {
-		fprintf(stderr, "n owned is zero in index %s\n", index->name);
+		fprintf(stderr,
+			"InnoDB: n owned is zero in index %s\n", index->name);
 
 		goto func_exit;
 	}
 		
 	if (slot_no != n_slots - 1) {
-		fprintf(stderr, "n slots wrong %lu %lu in index %s\n",
+		fprintf(stderr, "InnoDB: n slots wrong %lu %lu in index %s\n",
 			slot_no, n_slots - 1, index->name);
 		goto func_exit;
 	}		
 
 	if (page_header_get_field(page, PAGE_N_RECS) + 2 != count + 1) {
-		fprintf(stderr, "n recs wrong %lu %lu in index %s\n",
+		fprintf(stderr, "InnoDB: n recs wrong %lu %lu in index %s\n",
 		page_header_get_field(page, PAGE_N_RECS) + 2,  count + 1,
 		index->name);
 
@@ -1487,7 +1695,8 @@ page_validate(
 	}
 
 	if (data_size != page_get_data_size(page)) {
-		fprintf(stderr, "Summed data size %lu, returned by func %lu\n",
+		fprintf(stderr,
+		"InnoDB: Summed data size %lu, returned by func %lu\n",
 			data_size, page_get_data_size(page));
 		goto func_exit;
 	}
@@ -1508,7 +1717,7 @@ page_validate(
 
 			if (buf[offs + i] != 0) {
 				fprintf(stderr,
-	                "Record overlaps another in free list, index %s \n",
+	     	"InnoDB: Record overlaps another in free list, index %s \n",
 				index->name);
 
 				goto func_exit;
@@ -1522,9 +1731,11 @@ page_validate(
 	
 	if (page_header_get_field(page, PAGE_N_HEAP) != count + 1) {
 
-		fprintf(stderr, "N heap is wrong %lu %lu in index %s\n",
-		page_header_get_field(page, PAGE_N_HEAP), count + 1,
-		index->name);
+		fprintf(stderr,
+		"InnoDB: N heap is wrong %lu %lu in index %s\n",
+			page_header_get_field(page, PAGE_N_HEAP), count + 1,
+				index->name);
+		goto func_exit;
 	}
 
 	ret = TRUE;	
@@ -1532,6 +1743,15 @@ page_validate(
 func_exit:
 	mem_heap_free(heap);
 
+	if (ret == FALSE) {
+		fprintf(stderr,
+"InnoDB: Apparent corruption in page %lu in index %s in table %s\n",
+			buf_frame_get_page_no(page), index->name,
+			index->table_name);
+
+		buf_page_print(page);
+	}
+	
 	return(ret);			  
 }
 
diff --git a/innobase/pars/lexyy.c b/innobase/pars/lexyy.c
index 782fca35f661613ce4e837b28e198e6fdb52c62d..71507ccd8688876ebc53e5e42fee3127c6fa7273 100644
--- a/innobase/pars/lexyy.c
+++ b/innobase/pars/lexyy.c
@@ -4,8 +4,6 @@
  * $Header: /home/daffy/u0/vern/flex/RCS/flex.skl,v 2.91 96/09/10 16:58:48 vern Exp $
  */
 
-#include "univ.i"
-
 #define FLEX_SCANNER
 #define YY_FLEX_MAJOR_VERSION 2
 #define YY_FLEX_MINOR_VERSION 5
@@ -609,11 +607,8 @@ How to make the InnoDB parser and lexer C files:
 
 6. Remove the #include of unistd.h from about line 2500 of lexyy.c
 
-7. Move #include <math.h> in pars0grm.c after #include "univ.i" to remove
-   a large file compilation error on AIX.
-
-8. Move #include "univ.i" in lexyy.c to the file start to remove a large
-   file compilation error on AIX.
+7. Add '#include "univ.i"' before #include <stdio.h> in lexyy.c
+   (Needed for AIX)
 
 These instructions seem to work at least with bison-1.28 and flex-2.5.4 on
 Linux.
@@ -621,6 +616,7 @@ Linux.
 #line 36 "pars0lex.l"
 #define YYSTYPE que_node_t*
 
+#include "univ.i"
 #include "pars0pars.h"
 #include "pars0grm.h"
 #include "pars0sym.h"
diff --git a/innobase/pars/pars0grm.c b/innobase/pars/pars0grm.c
index ce575063610802638446022b4bcc20a8b6fff1f9..05b7539808417ca44fc2d0fa24351e362771f8c9 100644
--- a/innobase/pars/pars0grm.c
+++ b/innobase/pars/pars0grm.c
@@ -102,8 +102,6 @@ que_node_t */
 #include "que0que.h"
 #include "row0sel.h"
 
-#include <math.h>
-
 #define YYSTYPE que_node_t*
 
 /* #define __STDC__ */
diff --git a/innobase/que/que0que.c b/innobase/que/que0que.c
index 7fa444f674119c6490a3a92eaed6e4425d9706fe..a96c8840a03bf01ada0c7d3bf0ebeaefdc7f89e3 100644
--- a/innobase/que/que0que.c
+++ b/innobase/que/que0que.c
@@ -1046,14 +1046,16 @@ que_thr_stop(
 }
 
 /**************************************************************************
-A patch for MySQL used to 'stop' a dummy query thread used in MySQL. */
+A patch for MySQL used to 'stop' a dummy query thread used in MySQL. The
+query thread is stopped and made inactive, except in the case where
+it was put to the lock wait state in lock0lock.c, but the lock has already
+been granted or the transaction chosen as a victim in deadlock resolution. */
 
 void
 que_thr_stop_for_mysql(
 /*===================*/
 	que_thr_t*	thr)	/* in: query thread */
 {
-	ibool	stopped 	= FALSE;
 	trx_t*	trx;
 
 	trx = thr_get_trx(thr);
@@ -1067,13 +1069,10 @@ que_thr_stop_for_mysql(
 
 			/* Error handling built for the MySQL interface */
 			thr->state = QUE_THR_COMPLETED;
-
-			stopped = TRUE;
-		}
-		
-		if (!stopped) {
-			/* It must have been a lock wait but the
-			lock was already released */
+		} else {
+			/* It must have been a lock wait but the lock was
+			already released, or this transaction was chosen
+			as a victim in selective deadlock resolution */
 
 			mutex_exit(&kernel_mutex);
 
@@ -1081,6 +1080,10 @@ que_thr_stop_for_mysql(
 		}
 	}
 		
+	ut_ad(thr->is_active == TRUE);
+	ut_ad(trx->n_active_thrs == 1);
+	ut_ad(thr->graph->n_active_thrs == 1);
+
 	thr->is_active = FALSE;
 	(thr->graph)->n_active_thrs--;
 
@@ -1132,6 +1135,9 @@ que_thr_stop_for_mysql_no_error(
 	trx_t*		trx)	/* in: transaction */
 {
 	ut_ad(thr->state == QUE_THR_RUNNING);
+	ut_ad(thr->is_active == TRUE);
+	ut_ad(trx->n_active_thrs == 1);
+	ut_ad(thr->graph->n_active_thrs == 1);
 		
 	if (thr->magic_n != QUE_THR_MAGIC_N) {
 		fprintf(stderr,
diff --git a/innobase/read/read0read.c b/innobase/read/read0read.c
index a5048c0c9092e63b8b92ac79c73ff1236704caa3..5c1d2d5418e299531a0f450b9a5256011009c16e 100644
--- a/innobase/read/read0read.c
+++ b/innobase/read/read0read.c
@@ -200,6 +200,28 @@ read_view_close(
 	UT_LIST_REMOVE(view_list, trx_sys->view_list, view);
 } 
 
+/*************************************************************************
+Closes a consistent read view for MySQL. This function is called at an SQL
+statement end if the trx isolation level is <= TRX_ISO_READ_COMMITTED. */
+
+void
+read_view_close_for_mysql(
+/*======================*/
+	trx_t*	trx)	/* in: trx which has a read view */
+{
+	ut_a(trx->read_view);
+
+	mutex_enter(&kernel_mutex);
+
+	read_view_close(trx->read_view);
+
+	mem_heap_empty(trx->read_view_heap);
+
+	trx->read_view = NULL;
+
+	mutex_exit(&kernel_mutex);
+}
+	
 /*************************************************************************
 Prints a read view to stderr. */
 
diff --git a/innobase/rem/rem0cmp.c b/innobase/rem/rem0cmp.c
index c50516dfc8b60f3f3e607a791b2d74aca9aff3a7..e9740d7ea782c80eb37d70d63b0fdb7f903818d0 100644
--- a/innobase/rem/rem0cmp.c
+++ b/innobase/rem/rem0cmp.c
@@ -353,7 +353,7 @@ cmp_data_data_slow(
 		data2++;
 	}
 
-	return(0);
+	return(0);		/* Not reached */
 }
 
 /*****************************************************************
diff --git a/innobase/row/row0ins.c b/innobase/row/row0ins.c
index 941c9d5759d278ee1001ab48d5481430eb8e74c5..d0a5cfec604aeb259e5e4da9b303125766cdd193 100644
--- a/innobase/row/row0ins.c
+++ b/innobase/row/row0ins.c
@@ -321,59 +321,6 @@ row_ins_clust_index_entry_by_modify(
 	return(err);
 }
 
-/*******************************************************************
-Checks if a unique key violation to rec would occur at the index entry
-insert. */
-static
-ibool
-row_ins_dupl_error_with_rec(
-/*========================*/
-				/* out: TRUE if error */
-	rec_t*		rec,	/* in: user record; NOTE that we assume
-				that the caller already has a record lock on
-				the record! */
-	dtuple_t*	entry,	/* in: entry to insert */
-	dict_index_t*	index)	/* in: index */
-{
-	ulint	matched_fields;
-	ulint	matched_bytes;
-	ulint	n_unique;
-	ulint   i;
-	
-	n_unique = dict_index_get_n_unique(index);
-
-	matched_fields = 0;
-	matched_bytes = 0;
-
-	cmp_dtuple_rec_with_match(entry, rec, &matched_fields, &matched_bytes);
-
-	if (matched_fields < n_unique) {
-
-	        return(FALSE);
-	}
-
-	/* In a unique secondary index we allow equal key values if they
-	contain SQL NULLs */
-
-	if (!(index->type & DICT_CLUSTERED)) {
-
-	        for (i = 0; i < n_unique; i++) {
-	                if (UNIV_SQL_NULL == dfield_get_len(
-                                         dtuple_get_nth_field(entry, i))) {
-
-	                        return(FALSE);
-	                }
-	        }
-	}
-
-	if (!rec_get_deleted_flag(rec)) {
-
-	        return(TRUE);
-	}
-
-	return(FALSE);
-}	
-
 /*************************************************************************
 Either deletes or sets the referencing columns SQL NULL in a child row.
 Used in ON DELETE ... clause for foreign keys when a parent row is
@@ -533,8 +480,12 @@ row_ins_foreign_delete_or_set_null(
 	err = lock_table(0, table, LOCK_IX, thr);
 
 	if (err == DB_SUCCESS) {
+		/* Here it suffices to use a LOCK_REC_NOT_GAP type lock;
+		we already have a normal shared lock on the appropriate
+		gap if the search criterion was not unique */
+		
 		err = lock_clust_rec_read_check_and_lock(0, clust_rec,
-						clust_index, LOCK_X, thr);
+				clust_index, LOCK_X, LOCK_REC_NOT_GAP, thr);
 	}
 	
 	if (err != DB_SUCCESS) {
@@ -630,12 +581,14 @@ row_ins_foreign_delete_or_set_null(
 
 /*************************************************************************
 Sets a shared lock on a record. Used in locking possible duplicate key
-records. */
+records and also in checking foreign key constraints. */
 static
 ulint
 row_ins_set_shared_rec_lock(
 /*========================*/
 				/* out: DB_SUCCESS or error code */
+	ulint		type, 	/* in: LOCK_ORDINARY, LOCK_GAP, or
+				LOCK_REC_NOT_GAP type lock */
 	rec_t*		rec,	/* in: record */
 	dict_index_t*	index,	/* in: index */
 	que_thr_t*	thr)	/* in: query thread */	
@@ -644,10 +597,10 @@ row_ins_set_shared_rec_lock(
 
 	if (index->type & DICT_CLUSTERED) {
 		err = lock_clust_rec_read_check_and_lock(0, rec, index, LOCK_S,
-									thr);
+								type, thr);
 	} else {
 		err = lock_sec_rec_read_check_and_lock(0, rec, index, LOCK_S,
-									thr);
+								type, thr);
 	}
 
 	return(err);
@@ -656,7 +609,7 @@ row_ins_set_shared_rec_lock(
 /*******************************************************************
 Checks if foreign key constraint fails for an index entry. Sets shared locks
 which lock either the success or the failure of the constraint. NOTE that
-the caller must have a shared latch on dict_foreign_key_check_lock. */
+the caller must have a shared latch on dict_operation_lock. */
 
 ulint
 row_ins_check_foreign_constraint(
@@ -679,7 +632,7 @@ row_ins_check_foreign_constraint(
 	dict_table_t*	check_table;
 	dict_index_t*	check_index;
 	ulint		n_fields_cmp;
-	ibool           timeout_expired;
+	ibool		unique_search;
 	rec_t*		rec;
 	btr_pcur_t	pcur;
 	ibool		moved;
@@ -689,7 +642,9 @@ row_ins_check_foreign_constraint(
 	mtr_t		mtr;
 
 run_again:
-	ut_ad(rw_lock_own(&dict_foreign_key_check_lock, RW_LOCK_SHARED));
+	ut_ad(rw_lock_own(&dict_operation_lock, RW_LOCK_SHARED));
+	
+	err = DB_SUCCESS;
 
 	if (thr_get_trx(thr)->check_foreigns == FALSE) {
 		/* The user has suppressed foreign key checks currently for
@@ -748,6 +703,14 @@ row_ins_check_foreign_constraint(
 
 	dtuple_set_n_fields_cmp(entry, foreign->n_fields);
 
+	if (dict_index_get_n_unique(check_index) <= foreign->n_fields) {
+		/* We can just set a LOCK_REC_NOT_GAP type lock */
+	
+		unique_search = TRUE;
+	} else {
+		unique_search = FALSE;
+	}
+
 	btr_pcur_open(check_index, entry, PAGE_CUR_GE,
 					BTR_SEARCH_LEAF, &pcur, &mtr);
 
@@ -761,25 +724,45 @@ row_ins_check_foreign_constraint(
 			goto next_rec;
 		}
 		
-		/* Try to place a lock on the index record */
-
-		err = row_ins_set_shared_rec_lock(rec, check_index, thr);
-
-		if (err != DB_SUCCESS) {
-
-			break;
-		}
-
 		if (rec == page_get_supremum_rec(buf_frame_align(rec))) {
 		
+			err = row_ins_set_shared_rec_lock(LOCK_ORDINARY, rec,
+							check_index, thr);
+			if (err != DB_SUCCESS) {
+
+				break;
+			}
+
 			goto next_rec;
 		}
 
 		cmp = cmp_dtuple_rec(entry, rec);
 
 		if (cmp == 0) {
-			if (!rec_get_deleted_flag(rec)) {
+			if (rec_get_deleted_flag(rec)) {
+				err = row_ins_set_shared_rec_lock(LOCK_ORDINARY,
+							rec, check_index, thr);
+				if (err != DB_SUCCESS) {
+
+					break;
+				}
+			} else {
 				/* Found a matching record */
+				
+				if (unique_search) {
+					err = row_ins_set_shared_rec_lock(
+							LOCK_REC_NOT_GAP,
+							rec, check_index, thr);
+				} else {
+					err = row_ins_set_shared_rec_lock(
+							LOCK_ORDINARY,
+							rec, check_index, thr);
+				}
+				
+				if (err != DB_SUCCESS) {
+
+					break;
+				}
 
 /*				printf(
 "FOREIGN: Found matching record from %s %s\n",
@@ -807,6 +790,13 @@ row_ins_check_foreign_constraint(
 		}
 
 		if (cmp < 0) {
+			err = row_ins_set_shared_rec_lock(LOCK_GAP,
+						rec, check_index, thr);
+			if (err != DB_SUCCESS) {
+
+				break;
+			}
+
 			if (check_ref) {			
 				err = DB_NO_REFERENCED_ROW;
 			} else {
@@ -844,14 +834,14 @@ row_ins_check_foreign_constraint(
 
 		que_thr_stop_for_mysql(thr);
 
-		timeout_expired = srv_suspend_mysql_thread(thr);
+		srv_suspend_mysql_thread(thr);
 	
-		if (!timeout_expired) {
+		if (thr_get_trx(thr)->error_state == DB_SUCCESS) {
 
 		        goto run_again;
 		}
 
-		err = DB_LOCK_WAIT_TIMEOUT;
+		err = thr_get_trx(thr)->error_state;
 	}
 
 	return(err);
@@ -890,21 +880,16 @@ row_ins_check_foreign_constraints(
 									trx);
 			}
 
-			if (!trx->has_dict_foreign_key_check_lock) {
+			if (0 == trx->dict_operation_lock_mode) {
 				got_s_lock = TRUE;
 
-				rw_lock_s_lock(&dict_foreign_key_check_lock);
-
-				trx->has_dict_foreign_key_check_lock = TRUE;
+				row_mysql_freeze_data_dictionary(trx);
 			}
 
 			err = row_ins_check_foreign_constraint(TRUE, foreign,
 						table, index, entry, thr);
 			if (got_s_lock) {
-
-				rw_lock_s_unlock(&dict_foreign_key_check_lock);	
-
-				trx->has_dict_foreign_key_check_lock = FALSE;
+				row_mysql_unfreeze_data_dictionary(trx);
 			}
 				
 			if (err != DB_SUCCESS) {
@@ -918,6 +903,59 @@ row_ins_check_foreign_constraints(
 	return(DB_SUCCESS);
 }
 
+/*******************************************************************
+Checks if a unique key violation to rec would occur at the index entry
+insert. */
+static
+ibool
+row_ins_dupl_error_with_rec(
+/*========================*/
+				/* out: TRUE if error */
+	rec_t*		rec,	/* in: user record; NOTE that we assume
+				that the caller already has a record lock on
+				the record! */
+	dtuple_t*	entry,	/* in: entry to insert */
+	dict_index_t*	index)	/* in: index */
+{
+	ulint	matched_fields;
+	ulint	matched_bytes;
+	ulint	n_unique;
+	ulint   i;
+	
+	n_unique = dict_index_get_n_unique(index);
+
+	matched_fields = 0;
+	matched_bytes = 0;
+
+	cmp_dtuple_rec_with_match(entry, rec, &matched_fields, &matched_bytes);
+
+	if (matched_fields < n_unique) {
+
+	        return(FALSE);
+	}
+
+	/* In a unique secondary index we allow equal key values if they
+	contain SQL NULLs */
+
+	if (!(index->type & DICT_CLUSTERED)) {
+
+	        for (i = 0; i < n_unique; i++) {
+	                if (UNIV_SQL_NULL == dfield_get_len(
+                                         dtuple_get_nth_field(entry, i))) {
+
+	                        return(FALSE);
+	                }
+	        }
+	}
+
+	if (!rec_get_deleted_flag(rec)) {
+
+	        return(TRUE);
+	}
+
+	return(FALSE);
+}	
+
 /*******************************************************************
 Scans a unique non-clustered index at a given index entry to determine
 whether a uniqueness violation has occurred for the key value of the entry.
@@ -976,9 +1014,10 @@ row_ins_scan_sec_index_for_duplicate(
 			goto next_rec;
 		}
 				
-		/* Try to place a lock on the index record */	
+		/* Try to place a lock on the index record */
 
-		err = row_ins_set_shared_rec_lock(rec, index, thr);
+		err = row_ins_set_shared_rec_lock(LOCK_ORDINARY, rec, index,
+									thr);
 
 		if (err != DB_SUCCESS) {
 
@@ -1082,8 +1121,8 @@ row_ins_duplicate_error_in_clust(
 			sure that in roll-forward we get the same duplicate
 			errors as in original execution */
 		
-			err = row_ins_set_shared_rec_lock(rec, cursor->index,
-									thr);
+			err = row_ins_set_shared_rec_lock(LOCK_REC_NOT_GAP,
+						rec, cursor->index, thr);
 			if (err != DB_SUCCESS) {
 					
 				return(err);
@@ -1105,8 +1144,8 @@ row_ins_duplicate_error_in_clust(
 
 		if (rec != page_get_supremum_rec(page)) {
 
-			err = row_ins_set_shared_rec_lock(rec, cursor->index,
-									thr);
+			err = row_ins_set_shared_rec_lock(LOCK_REC_NOT_GAP,
+						rec, cursor->index, thr);
 			if (err != DB_SUCCESS) {
 					
 				return(err);
diff --git a/innobase/row/row0mysql.c b/innobase/row/row0mysql.c
index cea8f1316fea619b7e1943329a2183e8f5dc596d..9ce86b5d4876256ccd36bd2be675a472ab8ee720 100644
--- a/innobase/row/row0mysql.c
+++ b/innobase/row/row0mysql.c
@@ -27,6 +27,7 @@ Created 9/17/2000 Heikki Tuuri
 #include "lock0lock.h"
 #include "rem0cmp.h"
 #include "log0log.h"
+#include "btr0sea.h"
 
 /* A dummy variable used to fool the compiler */
 ibool	row_mysql_identically_false	= FALSE;
@@ -197,13 +198,13 @@ row_mysql_handle_errors(
 				/* out: TRUE if it was a lock wait and
 				we should continue running the query thread */
 	ulint*		new_err,/* out: possible new error encountered in
-				rollback, or the old error which was
-				during the function entry */
+				lock wait, or if no new error, the value
+				of trx->error_state at the entry of this
+				function */
 	trx_t*		trx,	/* in: transaction */
 	que_thr_t*	thr,	/* in: query thread */
 	trx_savept_t*	savept)	/* in: savepoint or NULL */
 {
-	ibool	timeout_expired;
 	ulint	err;
 
 handle_new_error:
@@ -240,11 +241,9 @@ row_mysql_handle_errors(
 		/* MySQL will roll back the latest SQL statement */
 	} else if (err == DB_LOCK_WAIT) {
 
-		timeout_expired = srv_suspend_mysql_thread(thr);
-
-		if (timeout_expired) {
-			trx->error_state = DB_LOCK_WAIT_TIMEOUT;
+		srv_suspend_mysql_thread(thr);
 
+		if (trx->error_state != DB_SUCCESS) {
 			que_thr_stop_for_mysql(thr);
 
 			goto handle_new_error;
@@ -321,6 +320,8 @@ row_create_prebuilt(
 
 	prebuilt->sql_stat_start = TRUE;
 
+	prebuilt->mysql_has_locked = FALSE;
+
 	prebuilt->index = NULL;
 	prebuilt->n_template = 0;
 	prebuilt->mysql_template = NULL;
@@ -1000,8 +1001,8 @@ row_update_cascade_for_mysql(
 				or set null operation */
 	dict_table_t*	table)	/* in: table where we do the operation */
 {
-	ulint		err;
-	trx_t*		trx;
+	ulint	err;
+	trx_t*	trx;
 
 	trx = thr_get_trx(thr);
 run_again:
@@ -1012,11 +1013,28 @@ row_update_cascade_for_mysql(
 
 	err = trx->error_state;
 
+	/* Note that the cascade node is a subnode of another InnoDB
+	query graph node. We do a normal lock wait in this node, but
+	all errors are handled by the parent node. */
+
 	if (err == DB_LOCK_WAIT) {
-		que_thr_stop_for_mysql(thr);
+		/* Handle lock wait here */
 	
-		row_mysql_handle_errors(&err, trx, thr, NULL);
+		que_thr_stop_for_mysql(thr);
+
+		srv_suspend_mysql_thread(thr);
+
+		/* Note that a lock wait may also end in a lock wait timeout,
+		or this transaction is picked as a victim in selective
+		deadlock resolution */
+
+		if (trx->error_state != DB_SUCCESS) {
 
+			return(trx->error_state);
+		}
+
+		/* Retry operation after a normal lock wait */
+		
 		goto run_again;
 	}
 
@@ -1136,32 +1154,73 @@ row_mysql_recover_tmp_table(
 }
 
 /*************************************************************************
-Locks the data dictionary exclusively for performing a table create
-operation. */
+Locks the data dictionary in shared mode from modifications, for performing
+foreign key check, rollback, or other operation invisible to MySQL. */
+
+void
+row_mysql_freeze_data_dictionary(
+/*=============================*/
+	trx_t*	trx)	/* in: transaction */
+{
+	ut_a(trx->dict_operation_lock_mode == 0);
+	
+	rw_lock_s_lock(&dict_operation_lock);
+
+	trx->dict_operation_lock_mode = RW_S_LATCH;
+}
+
+/*************************************************************************
+Unlocks the data dictionary shared lock. */
+
+void
+row_mysql_unfreeze_data_dictionary(
+/*===============================*/
+	trx_t*	trx)	/* in: transaction */
+{
+	ut_a(trx->dict_operation_lock_mode == RW_S_LATCH);
+
+	rw_lock_s_unlock(&dict_operation_lock);
+
+	trx->dict_operation_lock_mode = 0;
+}
+
+/*************************************************************************
+Locks the data dictionary exclusively for performing a table create or other
+data dictionary modification operation. */
 
 void
-row_mysql_lock_data_dictionary(void)
-/*================================*/
+row_mysql_lock_data_dictionary(
+/*===========================*/
+	trx_t*	trx)	/* in: transaction */
 {
+	ut_a(trx->dict_operation_lock_mode == 0);
+	
 	/* Serialize data dictionary operations with dictionary mutex:
 	no deadlocks or lock waits can occur then in these operations */
 
-	rw_lock_x_lock(&(dict_foreign_key_check_lock));
+	rw_lock_x_lock(&dict_operation_lock);
+	trx->dict_operation_lock_mode = RW_X_LATCH;
+
 	mutex_enter(&(dict_sys->mutex));
 }
 
 /*************************************************************************
-Unlocks the data dictionary exclusively lock. */
+Unlocks the data dictionary exclusive lock. */
 
 void
-row_mysql_unlock_data_dictionary(void)
-/*==================================*/
+row_mysql_unlock_data_dictionary(
+/*=============================*/
+	trx_t*	trx)	/* in: transaction */
 {
+	ut_a(trx->dict_operation_lock_mode == RW_X_LATCH);
+
 	/* Serialize data dictionary operations with dictionary mutex:
 	no deadlocks can occur then in these operations */
 
 	mutex_exit(&(dict_sys->mutex));
-	rw_lock_x_unlock(&(dict_foreign_key_check_lock));
+	rw_lock_x_unlock(&dict_operation_lock);
+
+	trx->dict_operation_lock_mode = 0;
 }
 
 /*************************************************************************
@@ -1184,6 +1243,8 @@ row_create_table_for_mysql(
 	ulint		err;
 
 	ut_ad(trx->mysql_thread_id == os_thread_get_curr_id());
+	ut_ad(rw_lock_own(&dict_operation_lock, RW_LOCK_EX));
+	ut_ad(trx->dict_operation_lock_mode == RW_X_LATCH);
 	ut_ad(mutex_own(&(dict_sys->mutex)));
 	
 	if (srv_created_new_raw) {
@@ -1332,7 +1393,7 @@ row_create_table_for_mysql(
 			fprintf(stderr, 
      "InnoDB: Warning: cannot create table %s because tablespace full\n",
 				 table->name);
-		     	row_drop_table_for_mysql(table->name, trx, TRUE);
+		     	row_drop_table_for_mysql(table->name, trx);
 		} else {
 		       	ut_a(err == DB_DUPLICATE_KEY);
 
@@ -1383,7 +1444,8 @@ row_create_index_for_mysql(
 	ulint		namelen;
 	ulint		keywordlen;
 	ulint		err;
-	
+
+	ut_ad(rw_lock_own(&dict_operation_lock, RW_LOCK_EX));
 	ut_ad(mutex_own(&(dict_sys->mutex)));
 	ut_ad(trx->mysql_thread_id == os_thread_get_curr_id());
 	
@@ -1425,7 +1487,7 @@ row_create_index_for_mysql(
 
 		trx_general_rollback_for_mysql(trx, FALSE, NULL);
 
-		row_drop_table_for_mysql(index->table_name, trx, TRUE);
+		row_drop_table_for_mysql(index->table_name, trx);
 
 		trx->error_state = DB_SUCCESS;
 	}
@@ -1464,6 +1526,7 @@ row_table_add_foreign_constraints(
 	ulint	err;
 
 	ut_ad(mutex_own(&(dict_sys->mutex)));
+	ut_ad(rw_lock_own(&dict_operation_lock, RW_LOCK_EX));
 	ut_a(sql_string);
 	
 	trx->op_info = (char *) "adding foreign keys";
@@ -1498,7 +1561,7 @@ row_table_add_foreign_constraints(
 
 		trx_general_rollback_for_mysql(trx, FALSE, NULL);
 
-		row_drop_table_for_mysql(name, trx, TRUE);
+		row_drop_table_for_mysql(name, trx);
 
 		trx->error_state = DB_SUCCESS;
 	}
@@ -1529,7 +1592,7 @@ row_drop_table_for_mysql_in_background(
 							name); */
   	/* Drop the table in InnoDB */
 
-  	error = row_drop_table_for_mysql(name, trx, FALSE);
+  	error = row_drop_table_for_mysql(name, trx);
 
 	if (error != DB_SUCCESS) {
 		fprintf(stderr,
@@ -1688,9 +1751,7 @@ row_drop_table_for_mysql(
 /*=====================*/
 				/* out: error code or DB_SUCCESS */
 	char*	name,		/* in: table name */
-	trx_t*	trx,		/* in: transaction handle */
-	ibool	has_dict_mutex)	/* in: TRUE if the caller already owns the
-				dictionary system mutex */
+	trx_t*	trx)		/* in: transaction handle */
 {
 	dict_table_t*	table;
 	que_thr_t*	thr;
@@ -1702,6 +1763,7 @@ row_drop_table_for_mysql(
 	ulint		namelen;
 	ulint		keywordlen;
 	ulint		rounds	= 0;
+	ibool		locked_dictionary	= FALSE;
 	char		buf[10000];
 
 	ut_ad(trx->mysql_thread_id == os_thread_get_curr_id());
@@ -1845,13 +1907,18 @@ row_drop_table_for_mysql(
 	/* Serialize data dictionary operations with dictionary mutex:
 	no deadlocks can occur then in these operations */
 
-	if (!has_dict_mutex) {
-		/* Prevent foreign key checks while we are dropping the table */
-		rw_lock_x_lock(&(dict_foreign_key_check_lock));
+	if (trx->dict_operation_lock_mode != RW_X_LATCH) {
+		/* Prevent foreign key checks etc. while we are dropping the
+		table */
+
+		row_mysql_lock_data_dictionary(trx);
 
-		mutex_enter(&(dict_sys->mutex));
+		locked_dictionary = TRUE;
 	}
 
+	ut_ad(mutex_own(&(dict_sys->mutex)));
+	ut_ad(rw_lock_own(&dict_operation_lock, RW_LOCK_EX));
+	
 	graph = pars_sql(buf);
 
 	ut_a(graph);
@@ -1861,9 +1928,6 @@ row_drop_table_for_mysql(
 
 	graph->fork_type = QUE_FORK_MYSQL_INTERFACE;
 
-	/* Prevent purge from running while we are dropping the table */
-	rw_lock_s_lock(&(purge_sys->purge_is_running));
-
 	table = dict_table_get_low(name);
 
 	if (!table) {
@@ -1944,12 +2008,10 @@ row_drop_table_for_mysql(
 
 		}
 	}
-funct_exit:	
-	rw_lock_s_unlock(&(purge_sys->purge_is_running));
+funct_exit:
 
-	if (!has_dict_mutex) {
-		mutex_exit(&(dict_sys->mutex));
-		rw_lock_x_unlock(&(dict_foreign_key_check_lock));
+	if (locked_dictionary) {
+		row_mysql_unlock_data_dictionary(trx);	
 	}
 
 	que_graph_free(graph);
@@ -1985,8 +2047,7 @@ row_drop_database_for_mysql(
 	
 	trx_start_if_not_started(trx);
 loop:
-	rw_lock_x_lock(&(dict_foreign_key_check_lock));
-	mutex_enter(&(dict_sys->mutex));
+	row_mysql_lock_data_dictionary(trx);
 
 	while ((table_name = dict_get_first_table_name_in_db(name))) {
 		ut_a(memcmp(table_name, name, strlen(name)) == 0);
@@ -1999,8 +2060,7 @@ row_drop_database_for_mysql(
 		the table */
 
 		if (table->n_mysql_handles_opened > 0) {
-		        mutex_exit(&(dict_sys->mutex));
-			rw_lock_x_unlock(&(dict_foreign_key_check_lock));
+			row_mysql_unlock_data_dictionary(trx);
 
 			ut_print_timestamp(stderr);
 			fprintf(stderr,
@@ -2015,7 +2075,7 @@ row_drop_database_for_mysql(
 		        goto loop;
 		}
 
-		err = row_drop_table_for_mysql(table_name, trx, TRUE);
+		err = row_drop_table_for_mysql(table_name, trx);
 
 		mem_free(table_name);
 
@@ -2027,8 +2087,7 @@ row_drop_database_for_mysql(
 		}
 	}
 
-	mutex_exit(&(dict_sys->mutex));
-	rw_lock_x_unlock(&(dict_foreign_key_check_lock));
+	row_mysql_unlock_data_dictionary(trx);
 	
 	trx_commit_for_mysql(trx);
 
@@ -2165,8 +2224,7 @@ row_rename_table_for_mysql(
 	/* Serialize data dictionary operations with dictionary mutex:
 	no deadlocks can occur then in these operations */
 
-	rw_lock_x_lock(&(dict_foreign_key_check_lock));
-	mutex_enter(&(dict_sys->mutex));
+	row_mysql_lock_data_dictionary(trx);
 
 	table = dict_table_get_low(old_name);
 
@@ -2248,8 +2306,7 @@ row_rename_table_for_mysql(
 		}
 	}
 funct_exit:	
-	mutex_exit(&(dict_sys->mutex));
-	rw_lock_x_unlock(&(dict_foreign_key_check_lock));
+	row_mysql_unlock_data_dictionary(trx);
 
 	que_graph_free(graph);
 	
@@ -2394,18 +2451,28 @@ row_check_table_for_mysql(
 	row_prebuilt_t*	prebuilt)	/* in: prebuilt struct in MySQL
 					handle */
 {
-	dict_table_t*	table	= prebuilt->table;
+	dict_table_t*	table		= prebuilt->table;
 	dict_index_t*	index;
 	ulint		n_rows;
 	ulint		n_rows_in_table	= ULINT_UNDEFINED;
-	ulint		ret 	= DB_SUCCESS;
-
+	ulint		ret 		= DB_SUCCESS;
+	ulint		old_isolation_level;
+	
 	prebuilt->trx->op_info = (char *) "checking table";
 
+	old_isolation_level = prebuilt->trx->isolation_level;
+
+	/* We must run the index record counts at an isolation level
+	>= READ COMMITTED, because a dirty read can see a wrong number
+	of records in some index; to play safe, we use always
+	REPEATABLE READ here */
+
+	prebuilt->trx->isolation_level = TRX_ISO_REPEATABLE_READ;
+	
 	index = dict_table_get_first_index(table);
 
 	while (index != NULL) {
-      /*        fprintf(stderr, "Validating index %s\n", index->name); */
+      		/* fprintf(stderr, "Validating index %s\n", index->name); */
 	
 		if (!btr_validate_tree(index->tree)) {
 			ret = DB_ERROR;
@@ -2433,6 +2500,9 @@ row_check_table_for_mysql(
 		index = dict_table_get_next_index(index);
 	}
 
+	/* Restore the original isolation level */
+	prebuilt->trx->isolation_level = old_isolation_level;
+	
 	/* We validate also the whole adaptive hash index for all tables
 	at every CHECK TABLE */
 
diff --git a/innobase/row/row0purge.c b/innobase/row/row0purge.c
index 60e057b816ef45ad98d250bd7c70e171df5fca01..b64003f22d47ead4273d1e221e4d4ba6e9a8c712 100644
--- a/innobase/row/row0purge.c
+++ b/innobase/row/row0purge.c
@@ -24,6 +24,7 @@ Created 3/14/1997 Heikki Tuuri
 #include "row0row.h"
 #include "row0upd.h"
 #include "row0vers.h"
+#include "row0mysql.h"
 #include "log0log.h"
 
 /************************************************************************
@@ -453,7 +454,9 @@ static
 ibool
 row_purge_parse_undo_rec(
 /*=====================*/
-				/* out: TRUE if purge operation required */
+				/* out: TRUE if purge operation required:
+				NOTE that then the CALLER must unfreeze
+				data dictionary! */
 	purge_node_t*	node,	/* in: row undo node */
 	ibool*		updated_extern,
 				/* out: TRUE if an externally stored field
@@ -462,6 +465,7 @@ row_purge_parse_undo_rec(
 {
 	dict_index_t*	clust_index;
 	byte*		ptr;
+	trx_t*		trx;
 	dulint		undo_no;
 	dulint		table_id;
 	dulint		trx_id;
@@ -471,6 +475,8 @@ row_purge_parse_undo_rec(
 	ulint		cmpl_info;
 	
 	ut_ad(node && thr);
+
+	trx = thr_get_trx(thr);
 	
 	ptr = trx_undo_rec_get_pars(node->undo_rec, &type, &cmpl_info,
 					updated_extern, &undo_no, &table_id);
@@ -493,18 +499,21 @@ row_purge_parse_undo_rec(
 	    	return(FALSE);
 	}
 	
- 	mutex_enter(&(dict_sys->mutex));
+	/* Prevent DROP TABLE etc. from running when we are doing the purge
+	for this row */
 
-	node->table = dict_table_get_on_id_low(table_id, thr_get_trx(thr));
+	row_mysql_freeze_data_dictionary(trx);
 
-	rw_lock_x_lock(&(purge_sys->purge_is_running));
+	mutex_enter(&(dict_sys->mutex));
 
- 	mutex_exit(&(dict_sys->mutex));
+	node->table = dict_table_get_on_id_low(table_id, thr_get_trx(thr));
 	
+	mutex_exit(&(dict_sys->mutex));
+
 	if (node->table == NULL) {
 		/* The table has been dropped: no need to do purge */
 
-		rw_lock_x_unlock(&(purge_sys->purge_is_running));
+		row_mysql_unfreeze_data_dictionary(trx);
 
 		return(FALSE);
 	}
@@ -514,7 +523,7 @@ row_purge_parse_undo_rec(
 	if (clust_index == NULL) {
 		/* The table was corrupt in the data dictionary */
 
-		rw_lock_x_unlock(&(purge_sys->purge_is_running));
+		row_mysql_unfreeze_data_dictionary(trx);
 
 		return(FALSE);
 	}
@@ -552,9 +561,12 @@ row_purge(
 	dulint	roll_ptr;
 	ibool	purge_needed;
 	ibool	updated_extern;
+	trx_t*	trx;
 	
 	ut_ad(node && thr);
 
+	trx = thr_get_trx(thr);
+	
 	node->undo_rec = trx_purge_fetch_next_rec(&roll_ptr,
 						&(node->reservation),
 						node->heap);
@@ -573,6 +585,8 @@ row_purge(
 	} else {
 		purge_needed = row_purge_parse_undo_rec(node, &updated_extern,
 									thr);
+		/* If purge_needed == TRUE, we must also remember to unfreeze
+		data dictionary! */
 	}
 
 	if (purge_needed) {
@@ -594,7 +608,7 @@ row_purge(
 			btr_pcur_close(&(node->pcur));
 		}
 
-		rw_lock_x_unlock(&(purge_sys->purge_is_running));		
+		row_mysql_unfreeze_data_dictionary(trx);
 	}
 
 	/* Do some cleanup */
diff --git a/innobase/row/row0sel.c b/innobase/row/row0sel.c
index 4af04251996dca41f986724ee22e85e2d803e163..ce6ed091a487e65fb220472a2729e953d21cbbf5 100644
--- a/innobase/row/row0sel.c
+++ b/innobase/row/row0sel.c
@@ -606,7 +606,7 @@ row_sel_get_clust_rec(
 		/* Try to place a lock on the index record */
 		
 		err = lock_clust_rec_read_check_and_lock(0, clust_rec, index,
-						node->row_lock_mode, thr);
+					node->row_lock_mode, LOCK_ORDINARY, thr);
 		if (err != DB_SUCCESS) {
 
 			return(err);
@@ -621,7 +621,7 @@ row_sel_get_clust_rec(
 							node->read_view)) {
 
 			err = row_sel_build_prev_vers(node->read_view, plan,
-						clust_rec, &old_vers, mtr);
+					clust_rec, &old_vers, mtr);
 			if (err != DB_SUCCESS) {
 
 				return(err);
@@ -678,16 +678,17 @@ sel_set_rec_lock(
 	rec_t*		rec,	/* in: record */
 	dict_index_t*	index,	/* in: index */
 	ulint		mode,	/* in: lock mode */
+	ulint		type, 	/* in: LOCK_ORDINARY, LOCK_GAP, or LOC_REC_NOT_GAP */
 	que_thr_t*	thr)	/* in: query thread */	
 {
 	ulint	err;
 
 	if (index->type & DICT_CLUSTERED) {
 		err = lock_clust_rec_read_check_and_lock(0, rec, index, mode,
-									thr);
+							type, thr);
 	} else {
 		err = lock_sec_rec_read_check_and_lock(0, rec, index, mode,
-									thr);
+							type, thr);
 	}
 
 	return(err);
@@ -1154,7 +1155,7 @@ row_sel(
 		
 		if (!consistent_read) {
 			err = sel_set_rec_lock(page_rec_get_next(rec), index,
-						node->row_lock_mode, thr);
+				node->row_lock_mode, LOCK_ORDINARY, thr);
 			if (err != DB_SUCCESS) {
 				/* Note that in this case we will store in pcur
 				the PREDECESSOR of the record we are waiting
@@ -1180,8 +1181,8 @@ row_sel(
 	if (!consistent_read) {
 		/* Try to place a lock on the index record */	
 
-		err = sel_set_rec_lock(rec, index, node->row_lock_mode, thr);
-
+		err = sel_set_rec_lock(rec, index, node->row_lock_mode,
+						LOCK_ORDINARY, thr);
 		if (err != DB_SUCCESS) {
 
 			goto lock_wait_or_error;
@@ -2200,6 +2201,7 @@ row_sel_get_clust_rec_for_mysql(
 	rec_t*		old_vers;
 	ulint		err;
 	trx_t*		trx;
+	char		err_buf[1000];
 
 	*out_rec = NULL;
 	
@@ -2213,14 +2215,41 @@ row_sel_get_clust_rec_for_mysql(
 
 	clust_rec = btr_pcur_get_rec(prebuilt->clust_pcur);
 
-	ut_ad(page_rec_is_user_rec(clust_rec));
+	if (!page_rec_is_user_rec(clust_rec)) {
+		ut_print_timestamp(stderr);
+	  	fprintf(stderr,
+		"  InnoDB: error clustered record for sec rec not found\n"
+		"InnoDB: index %s table %s\n", sec_index->name,
+		  	sec_index->table->name);
+
+	  	rec_sprintf(err_buf, 900, rec);
+	  	fprintf(stderr, "InnoDB: sec index record %s\n", err_buf);
+
+	  	rec_sprintf(err_buf, 900, clust_rec);
+	  	fprintf(stderr, "InnoDB: clust index record %s\n", err_buf);
+
+		trx = thr_get_trx(thr);
+		trx_print(err_buf, trx);
+
+	  	fprintf(stderr,
+		"%s\nInnoDB: Make a detailed bug report and send it\n",
+							err_buf);
+	  	fprintf(stderr, "InnoDB: to mysql@lists.mysql.com\n");
+
+		clust_rec = NULL;
+
+		goto func_exit;
+	}
 
 	if (prebuilt->select_lock_type != LOCK_NONE) {
-		/* Try to place a lock on the index record */
+		/* Try to place a lock on the index record; we are searching
+		the clust rec with a unique condition, hence
+		we set a LOCK_REC_NOT_GAP type lock */
 		
 		err = lock_clust_rec_read_check_and_lock(0, clust_rec,
 					clust_index,
-					prebuilt->select_lock_type, thr);
+					prebuilt->select_lock_type,
+					LOCK_REC_NOT_GAP, thr);
 		if (err != DB_SUCCESS) {
 
 			return(err);
@@ -2232,8 +2261,12 @@ row_sel_get_clust_rec_for_mysql(
 		trx = thr_get_trx(thr);
 
 		old_vers = NULL;
-		
-		if (!lock_clust_rec_cons_read_sees(clust_rec, clust_index,
+
+		/* If the isolation level allows reading of uncommitted data,
+		then we never look for an earlier version */
+
+		if (trx->isolation_level > TRX_ISO_READ_UNCOMMITTED
+		    && !lock_clust_rec_cons_read_sees(clust_rec, clust_index,
 							trx->read_view)) {
 
 			err = row_sel_build_prev_vers_for_mysql(
@@ -2275,6 +2308,7 @@ row_sel_get_clust_rec_for_mysql(
 		}
 	}
 
+func_exit:
 	*out_rec = clust_rec;
 
 	if (prebuilt->select_lock_type == LOCK_X) {
@@ -2407,7 +2441,7 @@ row_sel_push_cache_row_for_mysql(
 /*************************************************************************
 Tries to do a shortcut to fetch a clustered index record with a unique key,
 using the hash index if possible (not always). We assume that the search
-mode is PAGE_CUR_GE, it is a consistent read, trx has already a read view,
+mode is PAGE_CUR_GE, it is a consistent read, there is a read view in trx,
 btr search latch has been locked in S-mode. */
 static
 ulint
@@ -2426,7 +2460,7 @@ row_sel_try_search_shortcut_for_mysql(
 	
 	ut_ad(index->type & DICT_CLUSTERED);
 	ut_ad(!prebuilt->templ_contains_blob);
-
+	
 	btr_pcur_open_with_no_init(index, search_tuple, PAGE_CUR_GE,
 					BTR_SEARCH_LEAF, pcur,
 #ifndef UNIV_SEARCH_DEBUG
@@ -2516,17 +2550,23 @@ row_search_for_mysql(
 	ibool		was_lock_wait;
 	ulint		ret;
 	ulint		shortcut;
+	ibool		unique_search			= FALSE;
 	ibool		unique_search_from_clust_index	= FALSE;
 	ibool		mtr_has_extra_clust_latch 	= FALSE;
 	ibool		moves_up 			= FALSE;
+	ibool		set_also_gap_locks		= TRUE;
+					/* if the query is a plain
+					locking SELECT, and the isolation
+					level is <= TRX_ISO_READ_COMMITTED,
+					then this is set to FALSE */
+	ibool		success;
 	ulint		cnt				= 0;
+	ulint		next_offs;
 	mtr_t		mtr;
 	
 	ut_ad(index && pcur && search_tuple);
 	ut_ad(trx->mysql_thread_id == os_thread_get_curr_id());
-	
-	ut_ad(sync_thread_levels_empty_gen(FALSE));
-	
+		
 	if (prebuilt->magic_n != ROW_PREBUILT_ALLOCATED) {
 		fprintf(stderr,
 		"InnoDB: Error: trying to free a corrupt\n"
@@ -2543,6 +2583,9 @@ row_search_for_mysql(
 	
 	printf("N tables locked %lu\n", trx->mysql_n_tables_locked);
 */
+	/*-------------------------------------------------------------*/
+	/* PHASE 1: Try to pop the row from the prefetch cache */
+
 	if (direction == 0) {
 		trx->op_info = (char *) "starting index read";
 	
@@ -2608,18 +2651,35 @@ row_search_for_mysql(
 
 	mtr_start(&mtr);
 
-	/* Since we must release the search system latch when we retrieve an
-	externally stored field, we cannot use the adaptive hash index in a
-	search in the case the row may be long and there may be externally
-	stored fields */
+	/* In a search where at most one record in the index may match, we
+	can use a LOCK_REC_NOT_GAP type record lock when locking a non-delete
+	marked matching record.
+
+	Note that in a unique secondary index there may be different delete
+	marked versions of a record where only the primary key values differ:
+	thus in a secondary index we must use next-key locks when locking
+	delete marked records. */
 	
 	if (match_mode == ROW_SEL_EXACT
-		&& index->type & DICT_UNIQUE
-		&& index->type & DICT_CLUSTERED
-		&& !prebuilt->templ_contains_blob
-		&& (prebuilt->mysql_row_len < UNIV_PAGE_SIZE / 8)
-		&& dtuple_get_n_fields(search_tuple)
+	    && index->type & DICT_UNIQUE
+	    && dtuple_get_n_fields(search_tuple)
 				== dict_index_get_n_unique(index)) {
+		unique_search = TRUE;
+	}
+
+	/*-------------------------------------------------------------*/
+	/* PHASE 2: Try fast adaptive hash index search if possible */
+
+	/* Next test if this is the special case where we can use the fast
+	adaptive hash index to try the search. Since we must release the
+	search system latch when we retrieve an externally stored field, we
+	cannot use the adaptive hash index in a search in the case the row
+	may be long and there may be externally stored fields */
+
+	if (unique_search	
+	    && index->type & DICT_CLUSTERED
+	    && !prebuilt->templ_contains_blob
+	    && (prebuilt->mysql_row_len < UNIV_PAGE_SIZE / 8)) {
 
 		if (direction == ROW_SEL_NEXT) {
 			/* MySQL sometimes seems to do fetch next even
@@ -2642,8 +2702,9 @@ row_search_for_mysql(
 
 		unique_search_from_clust_index = TRUE;
 
-		if (trx->mysql_n_tables_locked == 0
-					&& !prebuilt->sql_stat_start) {
+		if (prebuilt->select_lock_type == LOCK_NONE
+		    && trx->isolation_level > TRX_ISO_READ_UNCOMMITTED
+		    && trx->read_view) {
 
 			/* This is a SELECT query done as a consistent read,
 			and the read view has already been allocated:
@@ -2722,13 +2783,34 @@ row_search_for_mysql(
 			mtr_start(&mtr);
 		}
 	}
-no_shortcut:	
+
+no_shortcut:
+	/*-------------------------------------------------------------*/
+	/* PHASE 3: Open or restore index cursor position */
+
 	if (trx->has_search_latch) {
 		rw_lock_s_unlock(&btr_search_latch);
 		trx->has_search_latch = FALSE;
 	}			
 
 	trx_start_if_not_started(trx);
+
+	if (trx->isolation_level <= TRX_ISO_READ_COMMITTED
+	    && prebuilt->select_lock_type != LOCK_NONE
+	    && trx->mysql_query_str) {
+
+		/* Scan the MySQL query string; check if SELECT is the first
+	        word there */
+
+		dict_accept(*trx->mysql_query_str, "SELECT", &success);
+
+		if (success) {
+			/* It is a plain locking SELECT and the isolation
+			level is low: do not lock gaps */
+
+			set_also_gap_locks = FALSE;
+		}
+	}
 	
 	/* Note that if the search mode was GE or G, then the cursor
 	naturally moves upward (in fetch next) in alphabetical order,
@@ -2793,8 +2875,10 @@ row_search_for_mysql(
 		prebuilt->sql_stat_start = FALSE;
 	}
 
-	/*-------------------------------------------------------------*/
 rec_loop:
+	/*-------------------------------------------------------------*/
+	/* PHASE 4: Look for matching records in a loop */
+	
 	cons_read_requires_clust_rec = FALSE;
 
 	rec = btr_pcur_get_rec(pcur);
@@ -2812,37 +2896,88 @@ row_search_for_mysql(
 
 		goto next_rec;
 	}
-				
-	if (prebuilt->select_lock_type != LOCK_NONE) {
-		/* Try to place a lock on the index record */	
 
-		err = sel_set_rec_lock(rec, index, prebuilt->select_lock_type,
-									thr);
-		if (err != DB_SUCCESS) {
+	if (rec == page_get_supremum_rec(buf_frame_align(rec))) {
 
-			goto lock_wait_or_error;
-		}
-	}
+		if (prebuilt->select_lock_type != LOCK_NONE
+		    && set_also_gap_locks) {
 
-	if (rec == page_get_supremum_rec(buf_frame_align(rec))) {
+			/* Try to place a lock on the index record */	
+
+			err = sel_set_rec_lock(rec, index,
+						prebuilt->select_lock_type,
+						LOCK_ORDINARY, thr);
+			if (err != DB_SUCCESS) {
 
+				goto lock_wait_or_error;
+			}
+		}
 		/* A page supremum record cannot be in the result set: skip
-		it now when we have placed a possible lock on it */		
+		it now that we have placed a possible lock on it */
 		
 		goto next_rec;
 	}
 
-	ut_ad(page_rec_is_user_rec(rec));
+	/*-------------------------------------------------------------*/
+	/* Do sanity checks in case our cursor has bumped into page
+	corruption */
+	
+	next_offs = rec_get_next_offs(rec);
+
+	if (next_offs >= UNIV_PAGE_SIZE || next_offs < PAGE_SUPREMUM) {
+
+		if (srv_force_recovery == 0 || moves_up == FALSE) {
+			ut_print_timestamp(stderr);
+			fprintf(stderr,
+"  InnoDB: Index corruption: rec offs %lu next offs %lu, page no %lu,\n"
+"InnoDB: index %s, table %s. Run CHECK TABLE to table. You may need to\n"
+"InnoDB: restore from a backup, or dump + drop + reimport the table.\n",
+			   (ulint)(rec - buf_frame_align(rec)), next_offs,
+			   buf_frame_get_page_no(rec), index->name,
+			   index->table_name);
+		
+			err = DB_CORRUPTION;
 
-	if (unique_search_from_clust_index && btr_pcur_get_up_match(pcur)
-					== dtuple_get_n_fields(search_tuple)) {
-		/* The record matches enough */
+			goto lock_wait_or_error;
+		} else {
+			/* The user may be dumping a corrupt table. Jump
+			over the corruption to recover as much as possible. */
 
-		ut_ad(mode == PAGE_CUR_GE);
-#ifdef UNIV_SEARCH_DEBUG
-		ut_a(0 == cmp_dtuple_rec(search_tuple, rec));
-#endif	
-	} else if (match_mode == ROW_SEL_EXACT) {
+			fprintf(stderr,
+"InnoDB: Index corruption: rec offs %lu next offs %lu, page no %lu,\n"
+"InnoDB: index %s, table %s. We try to skip the rest of the page.\n",
+			   (ulint)(rec - buf_frame_align(rec)), next_offs,
+			   buf_frame_get_page_no(rec), index->name,
+			   index->table_name);
+
+			btr_pcur_move_to_last_on_page(pcur, &mtr);
+
+			goto next_rec;
+		}
+	}
+
+	if (srv_force_recovery > 0) {
+		if (!rec_validate(rec) || !btr_index_rec_validate(rec, index,
+								FALSE)) {
+			fprintf(stderr,
+"InnoDB: Index record corruption: rec offs %lu next offs %lu, page no %lu,\n"
+"InnoDB: index %s, table %s. We try to skip the record.\n",
+			   (ulint)(rec - buf_frame_align(rec)), next_offs,
+			   buf_frame_get_page_no(rec), index->name,
+			   index->table_name);
+
+			goto next_rec;
+		}
+	}
+
+	/*-------------------------------------------------------------*/
+
+	/* Note that we cannot trust the up_match value in the cursor at this
+	place because we can arrive here after moving the cursor! Thus
+	we have to recompare rec and search_tuple to determine if they
+	match enough. */
+
+	if (match_mode == ROW_SEL_EXACT) {
 		/* Test if the index record matches completely to search_tuple
 		in prebuilt: if not, then we return with DB_RECORD_NOT_FOUND */
 
@@ -2850,6 +2985,19 @@ row_search_for_mysql(
 		
 		if (0 != cmp_dtuple_rec(search_tuple, rec)) {
 
+			if (prebuilt->select_lock_type != LOCK_NONE
+		    	    && set_also_gap_locks) {
+				/* Try to place a lock on the index record */	
+
+				err = sel_set_rec_lock(rec, index,
+						prebuilt->select_lock_type,
+						LOCK_GAP, thr);
+				if (err != DB_SUCCESS) {
+
+					goto lock_wait_or_error;
+				}
+			}
+
 			btr_pcur_store_position(pcur, &mtr);
 
 			ret = DB_RECORD_NOT_FOUND;
@@ -2862,6 +3010,19 @@ row_search_for_mysql(
 
 		if (!cmp_dtuple_is_prefix_of_rec(search_tuple, rec)) {
 			
+			if (prebuilt->select_lock_type != LOCK_NONE
+			    && set_also_gap_locks) {
+				/* Try to place a lock on the index record */	
+
+				err = sel_set_rec_lock(rec, index,
+						prebuilt->select_lock_type,
+						LOCK_GAP, thr);
+				if (err != DB_SUCCESS) {
+
+					goto lock_wait_or_error;
+				}
+			}
+
 			btr_pcur_store_position(pcur, &mtr);
 
 			ret = DB_RECORD_NOT_FOUND;
@@ -2874,16 +3035,39 @@ row_search_for_mysql(
 	/* We are ready to look at a possible new index entry in the result
 	set: the cursor is now placed on a user record */
 
-	/* Get the right version of the row in a consistent read */
-
-	if (prebuilt->select_lock_type == LOCK_NONE) {
+	if (prebuilt->select_lock_type != LOCK_NONE) {
+		/* Try to place a lock on the index record; note that delete
+		marked records are a special case in a unique search. If there
+		is a non-delete marked record, then it is enough to lock its
+		existence with LOCK_REC_NOT_GAP. */
+
+		if (!set_also_gap_locks
+		    || (unique_search && !rec_get_deleted_flag(rec))) {
+			err = sel_set_rec_lock(rec, index,
+						prebuilt->select_lock_type,
+						LOCK_REC_NOT_GAP, thr);
+		} else {
+			err = sel_set_rec_lock(rec, index,
+						prebuilt->select_lock_type,
+						LOCK_ORDINARY, thr);
+		}
+		
+		if (err != DB_SUCCESS) {
 
+			goto lock_wait_or_error;
+		}
+	} else {
 		/* This is a non-locking consistent read: if necessary, fetch
 		a previous version of the record */
 
 		cons_read_requires_clust_rec = FALSE;
 
-		if (index == clust_index) {
+		if (trx->isolation_level == TRX_ISO_READ_UNCOMMITTED) {
+
+			/* Do nothing: we let a non-locking SELECT read the
+			latest version of the record */
+		
+		} else if (index == clust_index) {
 			
 			if (!lock_clust_rec_cons_read_sees(rec, index,
 							trx->read_view)) {
@@ -3020,8 +3204,11 @@ row_search_for_mysql(
 	ret = DB_SUCCESS;
 
 	goto normal_return;
-	/*-------------------------------------------------------------*/	
+
 next_rec:
+	/*-------------------------------------------------------------*/	
+	/* PHASE 5: Move the cursor to the next index record */
+	
 	if (mtr_has_extra_clust_latch) {
 		/* We must commit mtr if we are moving to the next
 		non-clustered index record, because we could break the
@@ -3064,8 +3251,10 @@ row_search_for_mysql(
 	cnt++;
 
 	goto rec_loop;
-	/*-------------------------------------------------------------*/
+
 lock_wait_or_error:
+	/*-------------------------------------------------------------*/
+
 	btr_pcur_store_position(pcur, &mtr);
 
 	mtr_commit(&mtr);
@@ -3096,6 +3285,7 @@ row_search_for_mysql(
 	return(err);
 
 normal_return:
+	/*-------------------------------------------------------------*/
 	que_thr_stop_for_mysql_no_error(thr, trx);
 
 	mtr_commit(&mtr);
@@ -3156,10 +3346,12 @@ row_search_check_if_query_cache_permitted(
 
 		ret = TRUE;
 		
-		/* Assign a read view for the transaction if it does not yet
-		have one */
+		/* If the isolation level is high, assign a read view for the
+		transaction if it does not yet have one */
+
+		if (trx->isolation_level >= TRX_ISO_REPEATABLE_READ
+		    && !trx->read_view) {
 
-		if (!trx->read_view) {
 			trx->read_view = read_view_open_now(trx,
 						trx->read_view_heap);
 		}
diff --git a/innobase/row/row0uins.c b/innobase/row/row0uins.c
index 9990f893432f10b1e6cb3a07b33653195ae11fef..fff67dcd62786b2ce8a9b10462ab259385de22cf 100644
--- a/innobase/row/row0uins.c
+++ b/innobase/row/row0uins.c
@@ -254,7 +254,8 @@ row_undo_ins_parse_undo_rec(
 	node->table = dict_table_get_on_id(table_id, node->trx);
 
 	if (node->table == NULL) {
-	  return;
+
+		return;
 	}
 
 	clust_index = dict_table_get_first_index(node->table);
@@ -281,7 +282,7 @@ row_undo_ins(
 	
 	ut_ad(node && thr);
 	ut_ad(node->state == UNDO_NODE_INSERT);
-
+	
 	row_undo_ins_parse_undo_rec(node, thr);
 
 	if (node->table == NULL) {
@@ -292,6 +293,7 @@ row_undo_ins(
 
 	if (!found) {
 	        trx_undo_rec_release(node->trx, node->undo_no);
+
 		return(DB_SUCCESS);
 	}
 
diff --git a/innobase/row/row0undo.c b/innobase/row/row0undo.c
index 5119254f40514055a9923320343c93936f25039f..01b0b1ab41ea7ad0a0d18d9d69cc6949d176a171 100644
--- a/innobase/row/row0undo.c
+++ b/innobase/row/row0undo.c
@@ -24,6 +24,7 @@ Created 1/8/1997 Heikki Tuuri
 #include "row0row.h"
 #include "row0uins.h"
 #include "row0umod.h"
+#include "row0mysql.h"
 #include "srv0srv.h"
 
 /* How to undo row operations?
@@ -204,6 +205,7 @@ row_undo(
 	ulint	err;
 	trx_t*	trx;
 	dulint	roll_ptr;
+	ibool	froze_data_dict	= FALSE;
 	
 	ut_ad(node && thr);
 	
@@ -211,7 +213,6 @@ row_undo(
 
 	if (node->state == UNDO_NODE_FETCH_NEXT) {
 
-		/* The call below also starts &mtr */
 		node->undo_rec = trx_roll_pop_top_rec_of_trx(trx,
 							trx->roll_limit,
 							&roll_ptr,
@@ -254,6 +255,18 @@ row_undo(
 		}
 	}
 
+	/* Prevent DROP TABLE etc. while we are rolling back this row.
+        If we are doing a TABLE CREATE or some other dictionary operation,
+        then we already have dict_operation_lock locked in x-mode. Do not
+        try to lock again in s-mode, because that would cause a hang. */
+
+	if (trx->dict_operation_lock_mode == 0) {
+        
+	        row_mysql_freeze_data_dictionary(trx);
+
+	        froze_data_dict = TRUE;
+	}
+
 	if (node->state == UNDO_NODE_INSERT) {
 
 		err = row_undo_ins(node, thr);
@@ -264,6 +277,11 @@ row_undo(
 		err = row_undo_mod(node, thr);
 	}
 
+	if (froze_data_dict) {
+
+	        row_mysql_unfreeze_data_dictionary(trx);
+	}
+
 	/* Do some cleanup */
 	btr_pcur_close(&(node->pcur));
 
diff --git a/innobase/row/row0upd.c b/innobase/row/row0upd.c
index 25c82f39da9bebe1cb865617421108e714c85e96..1231c94da63c7cd3327a11c37b98476019b72b07 100644
--- a/innobase/row/row0upd.c
+++ b/innobase/row/row0upd.c
@@ -79,7 +79,7 @@ ibool
 row_upd_index_is_referenced(
 /*========================*/
 				/* out: TRUE if referenced; NOTE that since
-				we do not hold dict_foreign_key_check_lock
+				we do not hold dict_operation_lock
 				when leaving the function, it may be that
 				the referencing table has been dropped when
 				we leave this function: this function is only
@@ -89,14 +89,16 @@ row_upd_index_is_referenced(
 {
 	dict_table_t*	table		= index->table;
 	dict_foreign_t*	foreign;
+	ibool		froze_data_dict	= FALSE;
 
 	if (!UT_LIST_GET_FIRST(table->referenced_list)) {
 
 		return(FALSE);
 	}
 
-	if (!trx->has_dict_foreign_key_check_lock) {
-		rw_lock_s_lock(&dict_foreign_key_check_lock);
+	if (trx->dict_operation_lock_mode == 0) {
+		row_mysql_freeze_data_dictionary(trx);
+		froze_data_dict = TRUE;
 	}
 
 	foreign = UT_LIST_GET_FIRST(table->referenced_list);
@@ -104,8 +106,8 @@ row_upd_index_is_referenced(
 	while (foreign) {
 		if (foreign->referenced_index == index) {
 
-			if (!trx->has_dict_foreign_key_check_lock) {
-				rw_lock_s_unlock(&dict_foreign_key_check_lock);
+			if (froze_data_dict) {
+				row_mysql_unfreeze_data_dictionary(trx);
 			}
 
 			return(TRUE);
@@ -114,8 +116,8 @@ row_upd_index_is_referenced(
 		foreign = UT_LIST_GET_NEXT(referenced_list, foreign);
 	}
 	
-	if (!trx->has_dict_foreign_key_check_lock) {
-		rw_lock_s_unlock(&dict_foreign_key_check_lock);
+	if (froze_data_dict) {
+		row_mysql_unfreeze_data_dictionary(trx);
 	}
 
 	return(FALSE);
@@ -162,12 +164,10 @@ row_upd_check_references_constraints(
 
 	mtr_start(mtr);	
 	
-	if (!trx->has_dict_foreign_key_check_lock) {
+	if (trx->dict_operation_lock_mode == 0) {
 		got_s_lock = TRUE;
 
-		rw_lock_s_lock(&dict_foreign_key_check_lock);
-
-		trx->has_dict_foreign_key_check_lock = TRUE;
+		row_mysql_freeze_data_dictionary(trx);
 	}
 		
 	foreign = UT_LIST_GET_FIRST(table->referenced_list);
@@ -189,7 +189,7 @@ row_upd_check_references_constraints(
 			}
 
 			/* NOTE that if the thread ends up waiting for a lock
-			we will release dict_foreign_key_check_lock
+			we will release dict_operation_lock
 			temporarily! But the counter on the table
 			protects 'foreign' from being dropped while the check
 			is running. */
@@ -211,10 +211,7 @@ row_upd_check_references_constraints(
 
 			if (err != DB_SUCCESS) {
 				if (got_s_lock) {
-					rw_lock_s_unlock(
-						&dict_foreign_key_check_lock);	
-					trx->has_dict_foreign_key_check_lock
-								= FALSE;
+					row_mysql_unfreeze_data_dictionary(trx);
 				}
 
 				mem_heap_free(heap);
@@ -227,8 +224,7 @@ row_upd_check_references_constraints(
 	}
 
 	if (got_s_lock) {
-		rw_lock_s_unlock(&dict_foreign_key_check_lock);	
-		trx->has_dict_foreign_key_check_lock = FALSE;
+		row_mysql_unfreeze_data_dictionary(trx);
 	}
 
 	mem_heap_free(heap);
diff --git a/innobase/srv/srv0srv.c b/innobase/srv/srv0srv.c
index d754f603efca20ecf991d93583c86fdfbb04e401..f9eba721cbcdfdee45084c26d6c6a5bfb3281df8 100644
--- a/innobase/srv/srv0srv.c
+++ b/innobase/srv/srv0srv.c
@@ -51,6 +51,10 @@ Created 10/8/1995 Heikki Tuuri
 #include "srv0start.h"
 #include "row0mysql.h"
 
+/* This is set to TRUE if the MySQL user has set it in MySQL; currently
+affects only FOREIGN KEY definition parsing */
+ibool	srv_lower_case_table_names	= FALSE;
+
 /* Buffer which can be used in printing fatal error messages */
 char	srv_fatal_errbuf[5000];
 
@@ -135,8 +139,6 @@ byte	srv_latin1_ordering[256]	/* The sort order table of the latin1
 , 0x44, 0x4E, 0x4F, 0x4F, 0x4F, 0x4F, 0x5D, 0xF7
 , 0xD8, 0x55, 0x55, 0x55, 0x59, 0x59, 0xDE, 0xFF
 };
-
-ibool	srv_use_native_aio	= FALSE;
 		
 ulint	srv_pool_size		= ULINT_MAX;	/* size in database pages;
 						MySQL originally sets this
@@ -151,8 +153,9 @@ dulint	srv_archive_recovery_limit_lsn;
 
 ulint	srv_lock_wait_timeout	= 1024 * 1024 * 1024;
 
-char*   srv_unix_file_flush_method_str = NULL;
-ulint   srv_unix_file_flush_method = 0;
+char*   srv_file_flush_method_str = NULL;
+ulint   srv_unix_file_flush_method = SRV_UNIX_FDATASYNC;
+ulint   srv_win_file_flush_method = SRV_WIN_IO_UNBUFFERED;
 
 /* If the following is != 0 we do not allow inserts etc. This protects
 the user from forgetting the innodb_force_recovery keyword to my.cnf */
@@ -281,6 +284,9 @@ time_t	srv_last_monitor_time;
 
 mutex_t srv_innodb_monitor_mutex;
 
+ulint	srv_main_thread_process_no	= 0;
+ulint	srv_main_thread_id		= 0;
+
 /*
 	IMPLEMENTATION OF THE SERVER MAIN PROGRAM
 	=========================================
@@ -2046,13 +2052,15 @@ srv_table_reserve_slot_for_mysql(void)
 }
 
 /*******************************************************************
-Puts a MySQL OS thread to wait for a lock to be released. */
+Puts a MySQL OS thread to wait for a lock to be released. If an error
+occurs during the wait trx->error_state associated with thr is
+!= DB_SUCCESS when we return. DB_LOCK_WAIT_TIMEOUT and DB_DEADLOCK
+are possible errors. DB_DEADLOCK is returned if selective deadlock
+resolution chose this transaction as a victim. */
 
-ibool
+void
 srv_suspend_mysql_thread(
 /*=====================*/
-				/* out: TRUE if the lock wait timeout was
-				exceeded */
 	que_thr_t*	thr)	/* in: query thread associated with the MySQL
 				OS thread */
 {
@@ -2060,6 +2068,7 @@ srv_suspend_mysql_thread(
 	os_event_t	event;
 	double		wait_time;
 	trx_t*		trx;
+	ibool		had_dict_lock	= FALSE;
 	
 	ut_ad(!mutex_own(&kernel_mutex));
 
@@ -2069,15 +2078,28 @@ srv_suspend_mysql_thread(
 
 	mutex_enter(&kernel_mutex);
 
+	trx->error_state = DB_SUCCESS;
+
 	if (thr->state == QUE_THR_RUNNING) {
 
-		/* The lock has already been released: no need to suspend */
+		ut_ad(thr->is_active == TRUE);
+	
+		/* The lock has already been released or this transaction
+		was chosen as a deadlock victim: no need to suspend */
+
+		if (trx->was_chosen_as_deadlock_victim) {
+
+			trx->error_state = DB_DEADLOCK;
+			trx->was_chosen_as_deadlock_victim = FALSE;
+		}
 
 		mutex_exit(&kernel_mutex);
 
-		return(FALSE);
+		return;
 	}
 	
+	ut_ad(thr->is_active == FALSE);
+
 	slot = srv_table_reserve_slot_for_mysql();
 
 	event = slot->event;
@@ -2101,18 +2123,22 @@ srv_suspend_mysql_thread(
 	srv_conc_force_exit_innodb(thr_get_trx(thr));
 
 	/* Release possible foreign key check latch */
-	if (trx->has_dict_foreign_key_check_lock) {
+	if (trx->dict_operation_lock_mode == RW_S_LATCH) {
+
+		had_dict_lock = TRUE;
 
-		rw_lock_s_unlock(&dict_foreign_key_check_lock);
+		row_mysql_unfreeze_data_dictionary(trx);
 	}
 
+	ut_a(trx->dict_operation_lock_mode == 0);
+
 	/* Wait for the release */
 	
 	os_event_wait(event);
 
-	if (trx->has_dict_foreign_key_check_lock) {
+	if (had_dict_lock) {
 
-		rw_lock_s_lock(&dict_foreign_key_check_lock);
+		row_mysql_freeze_data_dictionary(trx);
 	}
 
 	/* Return back inside InnoDB */
@@ -2127,14 +2153,19 @@ srv_suspend_mysql_thread(
 
 	wait_time = ut_difftime(ut_time(), slot->suspend_time);
 	
+	if (trx->was_chosen_as_deadlock_victim) {
+
+		trx->error_state = DB_DEADLOCK;
+		trx->was_chosen_as_deadlock_victim = FALSE;
+	}
+
 	mutex_exit(&kernel_mutex);
 
 	if (srv_lock_wait_timeout < 100000000 && 
 	    			wait_time > (double)srv_lock_wait_timeout) {
-	   	return(TRUE);
-	}
 
-	return(FALSE);
+	    	trx->error_state = DB_LOCK_WAIT_TIMEOUT;
+	}
 }
 
 /************************************************************************
@@ -2300,9 +2331,19 @@ srv_sprintf_innodb_monitor(
 		       "ROW OPERATIONS\n"
 		       "--------------\n");
 	buf += sprintf(buf,
-	"%ld queries inside InnoDB, %ld queries in queue; main thread: %s\n",
-			srv_conc_n_threads, srv_conc_n_waiting_threads,
+	"%ld queries inside InnoDB, %ld queries in queue\n",
+			srv_conc_n_threads, srv_conc_n_waiting_threads);
+#ifdef UNIV_LINUX
+	buf += sprintf(buf,
+	"Main thread process no %lu, state: %s\n",
+			srv_main_thread_process_no,
+			srv_main_thread_op_info);
+#else
+	buf += sprintf(buf,
+	"Main thread id %lu, state: %s\n",
+			srv_main_thread_id,
 			srv_main_thread_op_info);
+#endif
 	buf += sprintf(buf,
 	"Number of rows inserted %lu, updated %lu, deleted %lu, read %lu\n",
 			srv_n_rows_inserted, 
@@ -2636,6 +2677,9 @@ srv_master_thread(
 	
 	UT_NOT_USED(arg);
 
+	srv_main_thread_process_no = os_proc_get_number();
+	srv_main_thread_id = os_thread_pf(os_thread_get_curr_id());
+	
 	srv_table_reserve_slot(SRV_MASTER);	
 
 	mutex_enter(&kernel_mutex);
diff --git a/innobase/srv/srv0start.c b/innobase/srv/srv0start.c
index dfa122b2ece27afa4f4d6474b1a7e4d477e4e703..d6e8a8dcb4acd961b8d21e370f1d644ca3034b8d 100644
--- a/innobase/srv/srv0start.c
+++ b/innobase/srv/srv0start.c
@@ -56,6 +56,10 @@ Created 2/16/1996 Heikki Tuuri
 #include "srv0start.h"
 #include "que0que.h"
 
+ibool           srv_start_has_been_called  = FALSE;
+
+ulint           srv_sizeof_trx_t_in_ha_innodb_cc;
+
 ibool           srv_startup_is_before_trx_rollback_phase = FALSE;
 ibool           srv_is_being_started = FALSE;
 ibool           srv_was_started      = FALSE;
@@ -515,7 +519,7 @@ srv_calc_high32(
 }
 
 /*************************************************************************
-Creates or opens the log files. */
+Creates or opens the log files and closes them. */
 static
 ulint
 open_or_create_log_file(
@@ -640,7 +644,7 @@ open_or_create_log_file(
 }
 
 /*************************************************************************
-Creates or opens database data files. */
+Creates or opens database data files and closes them. */
 static
 ulint
 open_or_create_data_files(
@@ -960,36 +964,91 @@ innobase_start_or_create_for_mysql(void)
 "InnoDB: !!!!!!!!!!!!!! UNIV_MEM_DEBUG switched on !!!!!!!!!!!!!!!\n"); 
 #endif
 
+        if (srv_sizeof_trx_t_in_ha_innodb_cc != (ulint)sizeof(trx_t)) {
+	        fprintf(stderr,
+  "InnoDB: Error: trx_t size is %lu in ha_innodb.cc but %lu in srv0start.c\n"
+  "InnoDB: Check that pthread_mutex_t is defined in the same way in these\n"
+  "InnoDB: compilation modules. Cannot continue.\n",
+		  srv_sizeof_trx_t_in_ha_innodb_cc, (ulint)sizeof(trx_t));
+		return(DB_ERROR);
+	}
+
+	/* Since InnoDB does not currently clean up all its internal data
+	   structures in MySQL Embedded Server Library server_end(), we
+	   print an error message if someone tries to start up InnoDB a
+	   second time during the process lifetime. */
+
+	if (srv_start_has_been_called) {
+	        fprintf(stderr,
+"InnoDB: Error:startup called second time during the process lifetime.\n"
+"InnoDB: In the MySQL Embedded Server Library you cannot call server_init()\n"
+"InnoDB: more than once during the process lifetime.\n");
+	}
+
+	srv_start_has_been_called = TRUE;
+
 	log_do_write = TRUE;
 /*	yydebug = TRUE; */
 
 	srv_is_being_started = TRUE;
         srv_startup_is_before_trx_rollback_phase = TRUE;
+	os_aio_use_native_aio = FALSE;
+
+#ifdef __WIN__
+	if (os_get_os_version() == OS_WIN95
+	    || os_get_os_version() == OS_WIN31
+	    || os_get_os_version() == OS_WINNT) {
+
+	  	/* On Win 95, 98, ME, Win32 subsystem for Windows 3.1,
+		and NT use simulated aio. In NT Windows provides async i/o,
+		but when run in conjunction with InnoDB Hot Backup, it seemed
+		to corrupt the data files. */
+
+	  	os_aio_use_native_aio = FALSE;
+	} else {
+	  	/* On Win 2000 and XP use async i/o */
+	  	os_aio_use_native_aio = TRUE;
+	}
+#endif	
+        if (srv_file_flush_method_str == NULL) {
+        	/* These are the default options */
 
-	if (0 == ut_strcmp(srv_unix_file_flush_method_str, "fdatasync")) {
+		srv_unix_file_flush_method = SRV_UNIX_FDATASYNC;
+
+		srv_win_file_flush_method = SRV_WIN_IO_UNBUFFERED;
+#ifndef __WIN__        
+	} else if (0 == ut_strcmp(srv_file_flush_method_str, "fdatasync")) {
 	  	srv_unix_file_flush_method = SRV_UNIX_FDATASYNC;
 
-	} else if (0 == ut_strcmp(srv_unix_file_flush_method_str, "O_DSYNC")) {
+	} else if (0 == ut_strcmp(srv_file_flush_method_str, "O_DSYNC")) {
 	  	srv_unix_file_flush_method = SRV_UNIX_O_DSYNC;
 
-	} else if (0 == ut_strcmp(srv_unix_file_flush_method_str,
+	} else if (0 == ut_strcmp(srv_file_flush_method_str,
 				  "littlesync")) {
 	  	srv_unix_file_flush_method = SRV_UNIX_LITTLESYNC;
 
-	} else if (0 == ut_strcmp(srv_unix_file_flush_method_str, "nosync")) {
+	} else if (0 == ut_strcmp(srv_file_flush_method_str, "nosync")) {
 	  	srv_unix_file_flush_method = SRV_UNIX_NOSYNC;
+#else
+	} else if (0 == ut_strcmp(srv_file_flush_method_str, "normal")) {
+	  	srv_win_file_flush_method = SRV_WIN_IO_NORMAL;
+	  	os_aio_use_native_aio = FALSE;
+
+	} else if (0 == ut_strcmp(srv_file_flush_method_str, "unbuffered")) {
+	  	srv_win_file_flush_method = SRV_WIN_IO_UNBUFFERED;
+	  	os_aio_use_native_aio = FALSE;
+
+	} else if (0 == ut_strcmp(srv_file_flush_method_str,
+							"async_unbuffered")) {
+	  	srv_win_file_flush_method = SRV_WIN_IO_UNBUFFERED;	
+#endif
 	} else {
 	  	fprintf(stderr, 
           	"InnoDB: Unrecognized value %s for innodb_flush_method\n",
-          				srv_unix_file_flush_method_str);
+          				srv_file_flush_method_str);
 	  	return(DB_ERROR);
 	}
 
-	/*
-	printf("srv_unix set to %lu\n", srv_unix_file_flush_method);
-	*/
-	os_aio_use_native_aio = srv_use_native_aio;
-
 	err = srv_boot();
 
 	if (err != DB_SUCCESS) {
@@ -999,34 +1058,15 @@ innobase_start_or_create_for_mysql(void)
 
 	/* Restrict the maximum number of file i/o threads */
 	if (srv_n_file_io_threads > SRV_MAX_N_IO_THREADS) {
+
 		srv_n_file_io_threads = SRV_MAX_N_IO_THREADS;
 	}
 
-#if !(defined(WIN_ASYNC_IO) || defined(POSIX_ASYNC_IO))
-	/* In simulated aio we currently have use only for 4 threads */
-
-	os_aio_use_native_aio = FALSE;
-
-	srv_n_file_io_threads = 4;
-#endif
-
-#ifdef __WIN__
-	if (os_get_os_version() == OS_WIN95
-	    || os_get_os_version() == OS_WIN31) {
+	if (!os_aio_use_native_aio) {
+ 		/* In simulated aio we currently have use only for 4 threads */
 
-	  	/* On Win 95, 98, ME, and Win32 subsystem for Windows 3.1 use
-	     	simulated aio */
+		srv_n_file_io_threads = 4;
 
-	  	os_aio_use_native_aio = FALSE;
-	  	srv_n_file_io_threads = 4;
-	} else {
-	  	/* On NT and Win 2000 always use aio */
-	  	os_aio_use_native_aio = TRUE;
-	}
-#endif
-	os_aio_use_native_aio = FALSE;
-	
-	if (!os_aio_use_native_aio) {
 		os_aio_init(8 * SRV_N_PENDING_IOS_PER_THREAD
 						* srv_n_file_io_threads,
 					srv_n_file_io_threads,
@@ -1047,15 +1087,6 @@ innobase_start_or_create_for_mysql(void)
 	
 	lock_sys_create(srv_lock_table_size);
 
-#ifdef POSIX_ASYNC_IO
-	if (os_aio_use_native_aio) {
-		/* There is only one thread per async io array:
-		one for ibuf i/o, one for log i/o, one for ordinary reads,
-		one for ordinary writes; we need only 4 i/o threads */
-
-		srv_n_file_io_threads = 4;
-	}
-#endif
 	/* Create i/o-handler threads: */
 
 	for (i = 0; i < srv_n_file_io_threads; i++) {
@@ -1365,7 +1396,7 @@ innobase_start_or_create_for_mysql(void)
 	if (0 != os_fast_mutex_trylock(&srv_os_test_mutex)) {
 	        fprintf(stderr,
 "InnoDB: Error: pthread_mutex_trylock returns an unexpected value on\n"
-		  "InnoDB: success! Cannot continue.\n");
+"InnoDB: success! Cannot continue.\n");
 	        exit(1);
 	}
 
@@ -1375,11 +1406,17 @@ innobase_start_or_create_for_mysql(void)
 
 	os_fast_mutex_unlock(&srv_os_test_mutex);
 
-	if (srv_print_verbose_log)
-	{
-	  ut_print_timestamp(stderr);
-	  fprintf(stderr, "  InnoDB: Started\n");
+	if (srv_print_verbose_log) {
+	  	ut_print_timestamp(stderr);
+	  	fprintf(stderr, "  InnoDB: Started\n");
 	}
+
+	if (srv_force_recovery > 0) {
+		fprintf(stderr,
+		"InnoDB: !!! innodb_force_recovery is set to %lu !!!\n",
+			srv_force_recovery);
+	}	
+
 	return((int) DB_SUCCESS);
 }
 
diff --git a/innobase/stamp-h.in b/innobase/stamp-h.in
deleted file mode 100644
index 9788f70238c91894045d22366fa941580826c3c1..0000000000000000000000000000000000000000
--- a/innobase/stamp-h.in
+++ /dev/null
@@ -1 +0,0 @@
-timestamp
diff --git a/innobase/sync/sync0rw.c b/innobase/sync/sync0rw.c
index fe837b119f30d4c4d4c298dfaaaa466d5a173aba..b214bca04702ccf67983facb108cce70f5604c49 100644
--- a/innobase/sync/sync0rw.c
+++ b/innobase/sync/sync0rw.c
@@ -663,7 +663,8 @@ rw_lock_own(
 /*========*/
 					/* out: TRUE if locked */
 	rw_lock_t*	lock,		/* in: rw-lock */
-	ulint		lock_type)	/* in: lock type */
+	ulint		lock_type)	/* in: lock type: RW_LOCK_SHARED,
+					RW_LOCK_EX */
 {
 	rw_lock_debug_t*	info;
 
diff --git a/innobase/sync/sync0sync.c b/innobase/sync/sync0sync.c
index 3ea996afd6bfcae79e15109e92434f314b367289..376be2e723a2c905c2fc1fe3065f2bdf7512b7bb 100644
--- a/innobase/sync/sync0sync.c
+++ b/innobase/sync/sync0sync.c
@@ -901,8 +901,7 @@ sync_thread_levels_empty_gen(
 
 		if (slot->latch != NULL && (!dict_mutex_allowed ||
 				(slot->level != SYNC_DICT
-				&& slot->level != SYNC_FOREIGN_KEY_CHECK
-				&& slot->level != SYNC_PURGE_IS_RUNNING))) {
+				&& slot->level != SYNC_DICT_OPERATION))) {
 
 			lock = slot->latch;
 			mutex = slot->latch;
@@ -1087,12 +1086,10 @@ sync_thread_add_level(
 						SYNC_IBUF_PESS_INSERT_MUTEX));
 	} else if (level == SYNC_DICT_AUTOINC_MUTEX) {
 		ut_a(sync_thread_levels_g(array, SYNC_DICT_AUTOINC_MUTEX));
-	} else if (level == SYNC_FOREIGN_KEY_CHECK) {
-		ut_a(sync_thread_levels_g(array, SYNC_FOREIGN_KEY_CHECK));
+	} else if (level == SYNC_DICT_OPERATION) {
+		ut_a(sync_thread_levels_g(array, SYNC_DICT_OPERATION));
 	} else if (level == SYNC_DICT_HEADER) {
 		ut_a(sync_thread_levels_g(array, SYNC_DICT_HEADER));
-	} else if (level == SYNC_PURGE_IS_RUNNING) {
-		ut_a(sync_thread_levels_g(array, SYNC_PURGE_IS_RUNNING));
 	} else if (level == SYNC_DICT) {
 		ut_a(buf_debug_prints
 		     || sync_thread_levels_g(array, SYNC_DICT));
diff --git a/innobase/trx/trx0purge.c b/innobase/trx/trx0purge.c
index 97362d00b4b5f3f2d7e729f84850b1ee9786a137..d58240d3c1187c30c3fc9b374a8e1cd7188064fc 100644
--- a/innobase/trx/trx0purge.c
+++ b/innobase/trx/trx0purge.c
@@ -209,9 +209,6 @@ trx_purge_sys_create(void)
 	purge_sys->purge_undo_no = ut_dulint_zero;
 	purge_sys->next_stored = FALSE;
 	
-	rw_lock_create(&(purge_sys->purge_is_running));
-	rw_lock_set_level(&(purge_sys->purge_is_running),
-						SYNC_PURGE_IS_RUNNING);
 	rw_lock_create(&(purge_sys->latch));
 	rw_lock_set_level(&(purge_sys->latch), SYNC_PURGE_LATCH);
 
diff --git a/innobase/trx/trx0roll.c b/innobase/trx/trx0roll.c
index 4c2ee5dc9be98d77e2f851fbeb9b4e6910208225..1f0e0c58ac7204052b3dc8004021a87da0a420d2 100644
--- a/innobase/trx/trx0roll.c
+++ b/innobase/trx/trx0roll.c
@@ -254,7 +254,7 @@ trx_rollback_or_clean_all_without_sess(void)
 	mutex_exit(&kernel_mutex);
 
 	if (trx->dict_operation) {
-		mutex_enter(&(dict_sys->mutex));
+		row_mysql_lock_data_dictionary(trx);
 	}
 
 	que_run_threads(thr);
@@ -290,14 +290,14 @@ trx_rollback_or_clean_all_without_sess(void)
 			fprintf(stderr,
 "InnoDB: Table found: dropping table %s in recovery\n", table->name);
 
-			err = row_drop_table_for_mysql(table->name, trx,
-								TRUE);
+			err = row_drop_table_for_mysql(table->name, trx);
+
 			ut_a(err == (int) DB_SUCCESS);
 		}
 	}
 
 	if (trx->dict_operation) {
-		mutex_exit(&(dict_sys->mutex));
+		row_mysql_unlock_data_dictionary(trx);
 	}
 
 	fprintf(stderr, "InnoDB: Rolling back of trx id %lu %lu completed\n",
diff --git a/innobase/trx/trx0trx.c b/innobase/trx/trx0trx.c
index 994a6777924f235505869cc14235a26a075bee7a..f0077f941de43eded42ab4c40fae70cf2455ade2 100644
--- a/innobase/trx/trx0trx.c
+++ b/innobase/trx/trx0trx.c
@@ -23,7 +23,7 @@ Created 3/26/1996 Heikki Tuuri
 #include "srv0srv.h"
 #include "thr0loc.h"
 #include "btr0sea.h"
-
+#include "os0proc.h"
 
 /* Copy of the prototype for innobase_mysql_print_thd: this
 copy MUST be equal to the one in mysql/sql/ha_innobase.cc ! */
@@ -85,12 +85,14 @@ trx_create(
 	trx->conc_state = TRX_NOT_STARTED;
 	trx->start_time = time(NULL);
 
+	trx->isolation_level = TRX_ISO_REPEATABLE_READ;
 	trx->check_foreigns = TRUE;
 	trx->check_unique_secondary = TRUE;
 
 	trx->dict_operation = FALSE;
 
 	trx->mysql_thd = NULL;
+	trx->mysql_query_str = NULL;
 
 	trx->n_mysql_tables_in_use = 0;
 	trx->mysql_n_tables_locked = 0;
@@ -127,12 +129,13 @@ trx_create(
 	trx->graph = NULL;
 
 	trx->wait_lock = NULL;
+	trx->was_chosen_as_deadlock_victim = FALSE;
 	UT_LIST_INIT(trx->wait_thrs);
 
 	trx->lock_heap = mem_heap_create_in_buffer(256);
 	UT_LIST_INIT(trx->trx_locks);
 
-	trx->has_dict_foreign_key_check_lock = FALSE;
+	trx->dict_operation_lock_mode = 0;
 	trx->has_search_latch = FALSE;
 	trx->search_latch_timeout = BTR_SEA_TIMEOUT;
 
@@ -175,6 +178,8 @@ trx_allocate_for_mysql(void)
 	mutex_exit(&kernel_mutex);
 
 	trx->mysql_thread_id = os_thread_get_curr_id();
+
+	trx->mysql_process_no = os_proc_get_number();
 	
 	return(trx);
 }
@@ -257,6 +262,8 @@ trx_free(
 	ut_a(!trx->has_search_latch);
 	ut_a(!trx->auto_inc_lock);
 
+	ut_a(trx->dict_operation_lock_mode == 0);
+
 	if (trx->lock_heap) {
 		mem_heap_free(trx->lock_heap);
 	}
@@ -1497,9 +1504,12 @@ trx_print(
   		default: buf += sprintf(buf, " state %lu", trx->conc_state);
   	}
 
+#ifdef UNIV_LINUX
+        buf += sprintf(buf, ", process no %lu", trx->mysql_process_no);
+#else
         buf += sprintf(buf, ", OS thread id %lu",
 		       os_thread_pf(trx->mysql_thread_id));
-
+#endif
 	if (ut_strlen(trx->op_info) > 0) {
 		buf += sprintf(buf, " %s", trx->op_info);
 	}
diff --git a/innobase/ut/ut0mem.c b/innobase/ut/ut0mem.c
index 2a7643551ad81c400f8a825a9bf2408c4855835c..03f15031fdf54010e18125caf043b8f64a7fd52b 100644
--- a/innobase/ut/ut0mem.c
+++ b/innobase/ut/ut0mem.c
@@ -90,6 +90,12 @@ ut_malloc_low(
 		"InnoDB: on Linux we get a stack trace.\n",
 		                  n, ut_total_allocated_memory, errno);
 
+		/* Flush stderr to make more probable that the error
+		message gets in the error file before we generate a seg
+		fault */
+
+		fflush(stderr);
+
 	        os_fast_mutex_unlock(&ut_list_mutex);
 
 		/* Make an intentional seg fault so that we get a stack
diff --git a/isam/Makefile.am b/isam/Makefile.am
index 8f23138f29f8a86d75f54fc52505a62dc1c5d220..6d9e4176d434220c061b02a5053fea5b6cd137e1 100644
--- a/isam/Makefile.am
+++ b/isam/Makefile.am
@@ -14,7 +14,7 @@
 # along with this program; if not, write to the Free Software
 # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
 
-INCLUDES =		@MT_INCLUDES@ -I$(srcdir)/../include -I../include 
+INCLUDES =		@MT_INCLUDES@ -I$(top_srcdir)/include 
 LDADD =			@CLIENT_EXTRA_LDFLAGS@ libnisam.a ../mysys/libmysys.a \
 			../dbug/libdbug.a ../strings/libmystrings.a
 pkglib_LIBRARIES =	libnisam.a
diff --git a/isam/pack_isam.c b/isam/pack_isam.c
index ebe616714f5b976437fd159185c0594049db782c..09825dd137f0eaf1d442ece3f39d04c038c08986 100644
--- a/isam/pack_isam.c
+++ b/isam/pack_isam.c
@@ -67,7 +67,7 @@ struct st_file_buffer {
   char *buffer,*pos,*end;
   my_off_t pos_in_file;
   int bits;
-  uint byte;
+  uint bytes;
 };
 
 struct st_huff_tree;
@@ -1835,7 +1835,7 @@ static void init_file_buffer(File file, pbool read_buffer)
     file_buffer.pos=file_buffer.buffer;
     file_buffer.bits=BITS_SAVED;
   }
-  file_buffer.byte=0;
+  file_buffer.bytes=0;
 }
 
 
@@ -1866,13 +1866,13 @@ static void write_bits (register ulong value, register uint bits)
 {
   if ((file_buffer.bits-=(int) bits) >= 0)
   {
-    file_buffer.byte|=value << file_buffer.bits;
+    file_buffer.bytes|=value << file_buffer.bits;
   }
   else
   {
     reg3 uint byte_buff;
     bits= (uint) -file_buffer.bits;
-    byte_buff=file_buffer.byte | (uint) (value >> bits);
+    byte_buff=file_buffer.bytes | (uint) (value >> bits);
 #if BITS_SAVED == 32
     *file_buffer.pos++= (byte) (byte_buff >> 24) ;
     *file_buffer.pos++= (byte) (byte_buff >> 16) ;
@@ -1898,7 +1898,7 @@ static void write_bits (register ulong value, register uint bits)
     if (file_buffer.pos >= file_buffer.end)
       VOID(flush_buffer((uint) ~0));
     file_buffer.bits=(int) (BITS_SAVED - bits);
-    file_buffer.byte=(uint) (value << (BITS_SAVED - bits));
+    file_buffer.bytes=(uint) (value << (BITS_SAVED - bits));
   }
   return;
 }
@@ -1910,7 +1910,7 @@ static void flush_bits (void)
   uint bits,byte_buff;
 
   bits=(file_buffer.bits) & ~7;
-  byte_buff = file_buffer.byte >> bits;
+  byte_buff = file_buffer.bytes >> bits;
   bits=BITS_SAVED - bits;
   while (bits > 0)
   {
@@ -1918,7 +1918,7 @@ static void flush_bits (void)
     *file_buffer.pos++= (byte) (uchar) (byte_buff >> bits) ;
   }
   file_buffer.bits=BITS_SAVED;
-  file_buffer.byte=0;
+  file_buffer.bytes=0;
   return;
 }
 
diff --git a/libmysql/Makefile.am b/libmysql/Makefile.am
index 3d380c1407622c626648c9c4da81193b1b796c84..1d5a5b19180157161a74a7029e75a2ab53a3de54 100644
--- a/libmysql/Makefile.am
+++ b/libmysql/Makefile.am
@@ -20,8 +20,7 @@
 target =	libmysqlclient.la
 target_defs =	-DUNDEF_THREADS_HACK -DDONT_USE_RAID @LIB_EXTRA_CCFLAGS@ -DMYSQL_CLIENT
 LIBS =		@CLIENT_LIBS@
-INCLUDES =	-I$(srcdir)/../include -I../include \
-		-I$(srcdir)/.. -I$(top_srcdir) -I.. $(openssl_includes)
+INCLUDES =	-I$(top_srcdir)/include $(openssl_includes)
 
 include $(srcdir)/Makefile.shared
 
diff --git a/libmysql/errmsg.c b/libmysql/errmsg.c
index 581bb184ff3fd9c54f7920480d96551090b3f69e..bfd253728cedab4b2bf7257fa0c0699b88bd0369 100644
--- a/libmysql/errmsg.c
+++ b/libmysql/errmsg.c
@@ -50,6 +50,7 @@ const char *client_errors[]=
   "Error on SHOW SLAVE HOSTS:",
   "Error connecting to slave:",
   "Error connecting to master:",
+  "SSL connection error",
   "Invalid connection handle",
   "Invalid use of null pointer",
   "Statement not prepared",
@@ -58,7 +59,18 @@ const char *client_errors[]=
   "No parameters exists in the statement",
   "Invalid parameter number",
   "Can't send long data for non string or binary data types (parameter: %d)",
-  "Using not supported parameter type: %d  (parameter: %d)"
+  "Using un supported parameter type: %d  (parameter: %d)"
+  "Shared memory (%lu)",
+  "Can't open shared memory. Request event don't create  (%lu)",
+  "Can't open shared memory. Answer event don't create  (%lu)",
+  "Can't open shared memory. File mapping don't create  (%lu)",
+  "Can't open shared memory. Map of memory don't create  (%lu)",
+  "Can't open shared memory. File mapping don't create for client (%lu)",
+  "Can't open shared memory. Map of memory don't create for client (%lu)",
+  "Can't open shared memory. %s event don't create for client (%lu)",
+  "Can't open shared memory. Server abandoded and don't sent the answer event (%lu)",
+  "Can't open shared memory. Can't send the request event to server (%lu)",
+  "Wrong or unknown protocol"
 };
 
 /* Start of code added by Roberto M. Serqueira - martinsc@uol.com.br - 05.24.2001 */
@@ -92,6 +104,7 @@ const char *client_errors[]=
   "Error on SHOW SLAVE HOSTS:",
   "Error connecting to slave:",
   "Error connecting to master:",
+  "SSL connection error",
   "Invalid connection handle",
   "Invalid use of null pointer",
   "Statement not prepared",
@@ -100,7 +113,18 @@ const char *client_errors[]=
   "No parameters exists in the statement",
   "Invalid parameter number",
   "Can't send long data for non string or binary data types (parameter: %d)",
-  "Using not supported parameter type: %d  (parameter: %d)"
+  "Using un supported parameter type: %d  (parameter: %d)"
+  "Shared memory (%lu)",
+  "Can't open shared memory. Request event don't create  (%lu)",
+  "Can't open shared memory. Answer event don't create  (%lu)",
+  "Can't open shared memory. File mapping don't create  (%lu)",
+  "Can't open shared memory. Map of memory don't create  (%lu)",
+  "Can't open shared memory. File mapping don't create for client (%lu)",
+  "Can't open shared memory. Map of memory don't create for client (%lu)",
+  "Can't open shared memory. %s event don't create for client (%lu)",
+  "Can't open shared memory. Server abandoded and don't sent the answer event (%lu)",
+  "Can't open shared memory. Can't send the request event to server (%lu)",
+  "Wrong or unknown protocol"
 };
 
 #else /* ENGLISH */
@@ -132,6 +156,7 @@ const char *client_errors[]=
   "Error on SHOW SLAVE HOSTS:",
   "Error connecting to slave:",
   "Error connecting to master:",
+  "SSL connection error",
   "Invalid connection handle",
   "Invalid use of null pointer",
   "Statement not prepared",
@@ -140,7 +165,18 @@ const char *client_errors[]=
   "No parameters exists in the statement",
   "Invalid parameter number",
   "Can't send long data for non string or binary data types (parameter: %d)",
-  "Using not supported parameter type: %d  (parameter: %d)"
+  "Using un supported parameter type: %d  (parameter: %d)"
+  "Shared memory (%lu)",
+  "Can't open shared memory. Request event don't create  (%lu)",
+  "Can't open shared memory. Answer event don't create  (%lu)",
+  "Can't open shared memory. File mapping don't create  (%lu)",
+  "Can't open shared memory. Map of memory don't create  (%lu)",
+  "Can't open shared memory. File mapping don't create for client (%lu)",
+  "Can't open shared memory. Map of memory don't create for client (%lu)",
+  "Can't open shared memory. %s event don't create for client (%lu)",
+  "Can't open shared memory. Server abandoded and don't sent the answer event (%lu)",
+  "Can't open shared memory. Can't send the request event to server (%lu)",
+  "Wrong or unknown protocol"
 };
 #endif
 
diff --git a/libmysql/libmysql.c b/libmysql/libmysql.c
index f164582889ee0173dd09710526ffab0635275421..352ac520fedf7c025dc38b6625494cc3bbf9a410 100644
--- a/libmysql/libmysql.c
+++ b/libmysql/libmysql.c
@@ -84,6 +84,15 @@ ulong		net_write_timeout= NET_WRITE_TIMEOUT;
 #define SOCKET_ERROR -1
 #endif /* __WIN__ */
 
+#ifdef HAVE_SMEM
+char *shared_memory_base_name=0;
+const char *def_shared_memory_base_name=default_shared_memory_base_name;
+#endif
+
+const char *sql_protocol_names_lib[] =
+{ "TCP", "SOCKET", "PIPE", "MEMORY",NullS };
+TYPELIB sql_protocol_typelib = {array_elements(sql_protocol_names_lib)-1,"",
+			   sql_protocol_names_lib};
 /*
   If allowed through some configuration, then this needs to
   be changed
@@ -105,6 +114,7 @@ static my_bool send_file_to_server(MYSQL *mysql,const char *filename);
 static sig_handler pipe_sig_handler(int sig);
 static ulong mysql_sub_escape_string(CHARSET_INFO *charset_info, char *to,
 				     const char *from, ulong length);
+static my_bool stmt_close(MYSQL_STMT *stmt, my_bool skip_list);
 
 static my_bool org_my_init_done=0;
 
@@ -233,7 +243,7 @@ my_bool my_connect(my_socket s, const struct sockaddr *name,
   {
     tv.tv_sec = (long) timeout;
     tv.tv_usec = 0;
-#if defined(HPUX) && defined(THREAD)
+#if defined(HPUX10) && defined(THREAD)
     if ((res = select(s+1, NULL, (int*) &sfds, NULL, &tv)) >= 0)
       break;
 #else
@@ -336,6 +346,190 @@ HANDLE create_named_pipe(NET *net, uint connect_timeout, char **arg_host,
 }
 #endif
 
+/* 
+  Create new shared memory connection, return handler of connection
+
+  SYNOPSIS
+    create_shared_memory()
+    mysql  Pointer of mysql structure
+    net    Pointer of net structure 
+    connect_timeout Timeout of connection
+*/
+#ifdef HAVE_SMEM
+HANDLE create_shared_memory(MYSQL *mysql,NET *net, uint connect_timeout)
+{
+  ulong smem_buffer_length = shared_memory_buffer_length + 4;
+/*  
+  event_connect_request is event object for start connection actions 
+  event_connect_answer is event object for confirm, that server put data
+  handle_connect_file_map is file-mapping object, use for create shared memory  
+  handle_connect_map is pointer on shared memory
+  handle_map is pointer on shared memory for client
+  event_server_wrote,
+  event_server_read,
+  event_client_wrote,
+  event_client_read are events for transfer data between server and client
+  handle_file_map is file-mapping object, use for create shared memory
+*/
+  HANDLE event_connect_request = NULL;
+  HANDLE event_connect_answer = NULL;
+  HANDLE handle_connect_file_map = NULL;
+  char *handle_connect_map = NULL;
+
+  char *handle_map = NULL;
+  HANDLE event_server_wrote = NULL;
+  HANDLE event_server_read = NULL;
+  HANDLE event_client_wrote = NULL;
+  HANDLE event_client_read = NULL;
+  HANDLE handle_file_map = NULL;
+  ulong connect_number; 
+  char connect_number_char[22], *p;
+  char tmp[64];
+  char *suffix_pos;  
+  DWORD error_allow = 0;
+  DWORD error_code = 0;
+  char *shared_memory_base_name = mysql->options.shared_memory_base_name;
+
+/*
+  The name of event and file-mapping events create agree next rule:
+            shared_memory_base_name+unique_part
+  Where:
+    shared_memory_base_name is unique value for each server
+    unique_part is uniquel value for each object (events and file-mapping)
+*/
+  suffix_pos = strxmov(tmp,shared_memory_base_name,"_",NullS);
+  strmov(suffix_pos, "CONNECT_REQUEST");
+  if ((event_connect_request = OpenEvent(EVENT_ALL_ACCESS,FALSE,tmp)) == NULL) 
+  {
+    error_allow = CR_SHARED_MEMORY_CONNECT_REQUEST_ERROR;
+    goto err;
+  }
+  strmov(suffix_pos, "CONNECT_ANSWER");
+  if ((event_connect_answer = OpenEvent(EVENT_ALL_ACCESS,FALSE,tmp)) == NULL) 
+  {
+    error_allow = CR_SHARED_MEMORY_CONNECT_ANSWER_ERROR;
+    goto err;
+  }
+  strmov(suffix_pos, "CONNECT_DATA");
+  if ((handle_connect_file_map = OpenFileMapping(FILE_MAP_WRITE,FALSE,tmp)) == NULL) 
+  {
+    error_allow = CR_SHARED_MEMORY_CONNECT_FILE_MAP_ERROR;
+    goto err;
+  }
+  if ((handle_connect_map = MapViewOfFile(handle_connect_file_map,FILE_MAP_WRITE,0,0,sizeof(DWORD))) == NULL) 
+  {
+    error_allow = CR_SHARED_MEMORY_CONNECT_MAP_ERROR;
+    goto err;
+  }
+/*
+ Send to server request of connection
+*/
+  if (!SetEvent(event_connect_request)) 
+  {
+    error_allow = CR_SHARED_MEMORY_CONNECT_SET_ERROR;
+    goto err;
+  }
+/*
+  Wait of answer from server
+*/
+  if (WaitForSingleObject(event_connect_answer,connect_timeout*1000) != WAIT_OBJECT_0)
+  {
+    error_allow = CR_SHARED_MEMORY_CONNECT_ABANDODED_ERROR;
+    goto err;
+  }
+/*
+  Get number of connection
+*/
+  connect_number = uint4korr(handle_connect_map);/*WAX2*/
+  p = int2str(connect_number, connect_number_char, 10);
+
+/*
+  The name of event and file-mapping events create agree next rule:
+    shared_memory_base_name+unique_part+number_of_connection
+  Where:
+    shared_memory_base_name is uniquel value for each server
+    unique_part is uniquel value for each object (events and file-mapping)
+    number_of_connection is number of connection between server and client
+*/
+  suffix_pos = strxmov(tmp,shared_memory_base_name,"_",connect_number_char,"_",NullS);
+  strmov(suffix_pos, "DATA");
+  if ((handle_file_map = OpenFileMapping(FILE_MAP_WRITE,FALSE,tmp)) == NULL)
+  {
+    error_allow = CR_SHARED_MEMORY_FILE_MAP_ERROR;
+    goto err2;    
+  }
+  if ((handle_map = MapViewOfFile(handle_file_map,FILE_MAP_WRITE,0,0,smem_buffer_length)) == NULL)
+  {
+    error_allow = CR_SHARED_MEMORY_MAP_ERROR;
+    goto err2;
+  }
+
+  strmov(suffix_pos, "SERVER_WROTE");
+  if ((event_server_wrote = OpenEvent(EVENT_ALL_ACCESS,FALSE,tmp)) == NULL)
+  {
+    error_allow = CR_SHARED_MEMORY_EVENT_ERROR;
+    goto err2;
+  }
+
+  strmov(suffix_pos, "SERVER_READ");
+  if ((event_server_read = OpenEvent(EVENT_ALL_ACCESS,FALSE,tmp)) == NULL)
+  {
+    error_allow = CR_SHARED_MEMORY_EVENT_ERROR;
+    goto err2;
+  }
+
+  strmov(suffix_pos, "CLIENT_WROTE");
+  if ((event_client_wrote = OpenEvent(EVENT_ALL_ACCESS,FALSE,tmp)) == NULL)
+  {
+    error_allow = CR_SHARED_MEMORY_EVENT_ERROR;
+    goto err2;
+  }
+
+  strmov(suffix_pos, "CLIENT_READ");
+  if ((event_client_read = OpenEvent(EVENT_ALL_ACCESS,FALSE,tmp)) == NULL)
+  {
+    error_allow = CR_SHARED_MEMORY_EVENT_ERROR;
+    goto err2;
+  }
+/*
+  Set event that server should send data
+*/
+  SetEvent(event_server_read);
+
+err2:   
+  if (error_allow == 0) 
+  {
+    net->vio = vio_new_win32shared_memory(net,handle_file_map,handle_map,event_server_wrote,
+                                          event_server_read,event_client_wrote,event_client_read);        
+  } 
+  else 
+  {
+    error_code = GetLastError();
+    if (event_server_read) CloseHandle(event_server_read);
+    if (event_server_wrote) CloseHandle(event_server_wrote);
+    if (event_client_read) CloseHandle(event_client_read);
+    if (event_client_wrote) CloseHandle(event_client_wrote);
+    if (handle_map) UnmapViewOfFile(handle_map);
+    if (handle_file_map) CloseHandle(handle_file_map);
+  }
+err:
+  if (error_allow) error_code = GetLastError();
+  if (event_connect_request) CloseHandle(event_connect_request);
+  if (event_connect_answer) CloseHandle(event_connect_answer);
+  if (handle_connect_map) UnmapViewOfFile(handle_connect_map);
+  if (handle_connect_file_map) CloseHandle(handle_connect_file_map);
+  if (error_allow) 
+  {
+    net->last_errno=error_allow;
+    if (error_allow == CR_SHARED_MEMORY_EVENT_ERROR)
+      sprintf(net->last_error,ER(net->last_errno),suffix_pos,error_code);
+    else
+      sprintf(net->last_error,ER(net->last_errno),error_code);
+    return(INVALID_HANDLE_VALUE);
+  } 
+  return(handle_map);
+};
+#endif
 
 /*****************************************************************************
   read a packet from server. Give error message if socket was down
@@ -734,8 +928,8 @@ static const char *default_options[]=
   "character-sets-dir", "default-character-set", "interactive-timeout",
   "connect-timeout", "local-infile", "disable-local-infile",
   "replication-probe", "enable-reads-from-master", "repl-parse-query",
-  "ssl-cipher",
- NullS
+  "ssl-cipher","protocol", "shared_memory_base_name",
+  NullS
 };
 
 static TYPELIB option_types={array_elements(default_options)-1,
@@ -794,9 +988,8 @@ static void mysql_read_default_options(struct st_mysql_options *options,
 	    options->password=my_strdup(opt_arg,MYF(MY_WME));
 	  }
 	  break;
-	case 5:				/* pipe */
-	  options->named_pipe=1;	/* Force named pipe */
-	  break;
+        case 5:
+          options->protocol = MYSQL_PROTOCOL_PIPE;
 	case 20:			/* connect_timeout */
 	case 6:				/* timeout */
 	  if (opt_arg)
@@ -889,6 +1082,20 @@ static void mysql_read_default_options(struct st_mysql_options *options,
 	case 25: /* repl-parse-query */
 	  options->rpl_parse= 1;
 	  break;
+        case 27:/* protocol */
+          if ((options->protocol = find_type(opt_arg, &sql_protocol_typelib,0)) == ~(ulong) 0)
+          {
+            fprintf(stderr, "Unknown option to protocol: %s\n", opt_arg);
+            exit(1);
+          }
+          break;
+        case 28: /*shared_memory_base_name*/
+#ifdef HAVE_SMEM
+          if (options->shared_memory_base_name != def_shared_memory_base_name)
+            my_free(options->shared_memory_base_name,MYF(MY_ALLOW_ZERO_PTR));
+          options->shared_memory_base_name=my_strdup(opt_arg,MYF(MY_WME));
+#endif
+          break;        
 	default:
 	  DBUG_PRINT("warning",("unknown option: %s",option[0]));
 	}
@@ -1449,6 +1656,9 @@ mysql_init(MYSQL *mysql)
 #ifdef ENABLED_LOCAL_INFILE
   mysql->options.client_flag|= CLIENT_LOCAL_FILES;
 #endif
+#ifdef HAVE_SMEM
+  mysql->options.shared_memory_base_name=(char*)def_shared_memory_base_name;
+#endif    
   return mysql;
 }
 
@@ -1531,7 +1741,7 @@ mysql_ssl_set(MYSQL *mysql __attribute__((unused)) ,
 static void
 mysql_ssl_free(MYSQL *mysql __attribute__((unused)))
 {
-#ifdef HAVE_OPENSSL
+#ifdef HAVE_OPENSLL
   my_free(mysql->options.ssl_key, MYF(MY_ALLOW_ZERO_PTR));
   my_free(mysql->options.ssl_cert, MYF(MY_ALLOW_ZERO_PTR));
   my_free(mysql->options.ssl_ca, MYF(MY_ALLOW_ZERO_PTR));
@@ -1545,7 +1755,7 @@ mysql_ssl_free(MYSQL *mysql __attribute__((unused)))
   mysql->options.ssl_cipher= 0;
   mysql->options.use_ssl = FALSE;
   mysql->connector_fd = 0;
-#endif /* HAVE_OPENSSL */
+#endif /* HAVE_OPENSLL */
 }
 
 /**************************************************************************
@@ -1598,6 +1808,7 @@ mysql_real_connect(MYSQL *mysql,const char *host, const char *user,
 #endif
   init_sigpipe_variables
   DBUG_ENTER("mysql_real_connect");
+  LINT_INIT(host_info);
 
   DBUG_PRINT("enter",("host: %s  db: %s  user: %s",
 		      host ? host : "(Null)",
@@ -1645,9 +1856,38 @@ mysql_real_connect(MYSQL *mysql,const char *host, const char *user,
   /*
   ** Grab a socket and connect it to the server
   */
-
+#if defined(HAVE_SMEM)
+  if ((!mysql->options.protocol || mysql->options.protocol == MYSQL_PROTOCOL_MEMORY)&&
+      (!host || !strcmp(host,LOCAL_HOST)))
+  {
+    if ((create_shared_memory(mysql,net, mysql->options.connect_timeout)) == 
+          INVALID_HANDLE_VALUE)
+    {
+      DBUG_PRINT("error",
+        ("host: '%s'  socket: '%s'  shared memory: %s  have_tcpip: %d",
+          host ? host : "<null>",
+          unix_socket ? unix_socket : "<null>",
+          (int) mysql->options.shared_memory_base_name,
+          (int) have_tcpip));
+	  if (mysql->options.protocol == MYSQL_PROTOCOL_MEMORY)
+	    goto error;		
+/* 
+Try also with PIPE or TCP/IP
+*/
+    }  
+    else
+    {
+      mysql->options.protocol=MYSQL_PROTOCOL_MEMORY;
+      sock=0;
+      unix_socket = 0;
+      host=mysql->options.shared_memory_base_name;
+      host_info=(char*) ER(CR_SHARED_MEMORY_CONNECTION);
+    }
+  } else
+#endif //HAVE_SMEM
 #if defined(HAVE_SYS_UN_H)
-  if ((!host || !strcmp(host,LOCAL_HOST)) && (unix_socket || mysql_unix_port))
+  if ((!mysql->options.protocol || mysql->options.protocol == MYSQL_PROTOCOL_SOCKET)&&
+     (!host || !strcmp(host,LOCAL_HOST)) && (unix_socket || mysql_unix_port))
   {
     host=LOCAL_HOST;
     if (!unix_socket)
@@ -1672,46 +1912,42 @@ mysql_real_connect(MYSQL *mysql,const char *host, const char *user,
       sprintf(net->last_error,ER(net->last_errno),unix_socket,socket_errno);
       goto error;
     }
+    else
+      mysql->options.protocol=MYSQL_PROTOCOL_SOCKET;
   }
   else
 #elif defined(__WIN__)
+  if ((!mysql->options.protocol || mysql->options.protocol == MYSQL_PROTOCOL_PIPE)&&
+      ((unix_socket || !host && is_NT() ||
+	host && !strcmp(host,LOCAL_HOST_NAMEDPIPE) ||!have_tcpip))&&(!net->vio))
   {
-    if ((unix_socket ||
-	 !host && is_NT() ||
-	 host && !strcmp(host,LOCAL_HOST_NAMEDPIPE) ||
-	 mysql->options.named_pipe || !have_tcpip))
+    sock=0;
+    if ((hPipe=create_named_pipe(net, mysql->options.connect_timeout,
+		   (char**) &host, (char**) &unix_socket)) ==
+                    INVALID_HANDLE_VALUE)
     {
-      sock=0;
-      if ((hPipe=create_named_pipe(net, mysql->options.connect_timeout,
-				   (char**) &host, (char**) &unix_socket)) ==
-	  INVALID_HANDLE_VALUE)
-      {
-	DBUG_PRINT("error",
-		   ("host: '%s'  socket: '%s'  named_pipe: %d  have_tcpip: %d",
-		    host ? host : "<null>",
-		    unix_socket ? unix_socket : "<null>",
-		    (int) mysql->options.named_pipe,
-		    (int) have_tcpip));
-	if (mysql->options.named_pipe ||
-	    (host && !strcmp(host,LOCAL_HOST_NAMEDPIPE)) ||
-	    (unix_socket && !strcmp(unix_socket,MYSQL_NAMEDPIPE)))
-	{
-	  net->last_errno= CR_SERVER_LOST;
-	  strmov(net->last_error,ER(net->last_errno));    
-	  goto error;		/* User only requested named pipes */
-	}
-	/* Try also with TCP/IP */
-      }
-      else
-      {
-	net->vio=vio_new_win32pipe(hPipe);
-	sprintf(host_info=buff, ER(CR_NAMEDPIPE_CONNECTION), host,
-		unix_socket);
-      }
+      DBUG_PRINT("error",
+                ("host: '%s'  socket: '%s'  have_tcpip: %d",
+                host ? host : "<null>",
+                unix_socket ? unix_socket : "<null>",
+                (int) have_tcpip));
+      if (mysql->options.protocol == MYSQL_PROTOCOL_PIPE ||
+          (host && !strcmp(host,LOCAL_HOST_NAMEDPIPE)) ||
+          (unix_socket && !strcmp(unix_socket,MYSQL_NAMEDPIPE)))
+            goto error;		
+	    /* 
+            Try also with TCP/IP 
+            */
+    }
+    else
+    {
+      net->vio=vio_new_win32pipe(hPipe);
+      sprintf(host_info=buff, ER(CR_NAMEDPIPE_CONNECTION), host,
+        unix_socket);
     }
   }
-  if (hPipe == INVALID_HANDLE_VALUE)
 #endif
+  if ((!mysql->options.protocol || mysql->options.protocol == MYSQL_PROTOCOL_TCP)&&(!net->vio))
   {
     unix_socket=0;				/* This is not used */
     if (!port)
@@ -1766,6 +2002,14 @@ mysql_real_connect(MYSQL *mysql,const char *host, const char *user,
       goto error;
     }
   }
+  else
+    if (!net->vio)
+    {
+      DBUG_PRINT("error",("Unknow protocol %d ",mysql->options.protocol));
+      net->last_errno= CR_CONN_UNKNOW_PROTOCOL;
+      sprintf(net->last_error ,ER(CR_CONN_UNKNOW_PROTOCOL));
+      goto error;
+    };
 
   if (!net->vio || my_net_init(net, net->vio))
   {
@@ -1946,15 +2190,18 @@ mysql_real_connect(MYSQL *mysql,const char *host, const char *user,
 				       options->ssl_capath,
 				       options->ssl_cipher)))
     {
-      /* TODO: Change to SSL error */
-      net->last_errno= CR_SERVER_LOST;
+      net->last_errno= CR_SSL_CONNECTION_ERROR;
       strmov(net->last_error,ER(net->last_errno));    
       goto error;
     }
     DBUG_PRINT("info", ("IO layer change in progress..."));
-    /* TODO:  Add proper error checking here, with return error message */
-    sslconnect((struct st_VioSSLConnectorFd*)(mysql->connector_fd),
-	       mysql->net.vio, (long) (mysql->options.connect_timeout));
+    if(sslconnect((struct st_VioSSLConnectorFd*)(mysql->connector_fd),
+	        mysql->net.vio, (long) (mysql->options.connect_timeout)))
+    {
+      net->last_errno= CR_SSL_CONNECTION_ERROR;
+      strmov(net->last_error,ER(net->last_errno));
+      goto error;    
+    }
     DBUG_PRINT("info", ("IO layer change done!"));
   }
 #endif /* HAVE_OPENSSL */
@@ -2169,6 +2416,10 @@ mysql_close(MYSQL *mysql)
 #ifdef HAVE_OPENSSL
     mysql_ssl_free(mysql);
 #endif /* HAVE_OPENSSL */
+#ifdef HAVE_SMEM
+    if (mysql->options.shared_memory_base_name != def_shared_memory_base_name)
+      my_free(mysql->options.shared_memory_base_name,MYF(MY_ALLOW_ZERO_PTR));
+#endif /* HAVE_SMEM */
     /* Clear pointers for better safety */
     mysql->host_info=mysql->user=mysql->passwd=mysql->db=0;
     bzero((char*) &mysql->options,sizeof(mysql->options));
@@ -2186,6 +2437,16 @@ mysql_close(MYSQL *mysql)
       }
       mysql->rpl_pivot=0;
     }
+    if (mysql->stmts)
+    {
+      /* Free any open prepared statements */
+      LIST *element, *next_element;
+      for (element= mysql->stmts; element; element= next_element)
+      {
+        next_element= element->next;
+        stmt_close((MYSQL_STMT *)element->data, 0);
+      }      
+    }
     if (mysql != mysql->master)
       mysql_close(mysql->master);
     if (mysql->free_me)
@@ -2321,7 +2582,7 @@ my_bool STDCALL mysql_read_query_result(MYSQL *mysql)
   {
     mysql->affected_rows= net_field_length_ll(&pos);
     mysql->insert_id=	  net_field_length_ll(&pos);
-    if (mysql->server_capabilities & CLIENT_PROTOCOL_41)
+    if (protocol_41(mysql))
     {
       mysql->server_status=uint2korr(pos); pos+=2;
       mysql->warning_count=uint2korr(pos); pos+=2;
@@ -2888,7 +3149,7 @@ mysql_options(MYSQL *mysql,enum mysql_option option, const char *arg)
     mysql->options.compress= 1;			/* Remember for connect */
     break;
   case MYSQL_OPT_NAMED_PIPE:
-    mysql->options.named_pipe=1;		/* Force named pipe */
+    mysql->options.protocol=MYSQL_PROTOCOL_PIPE; /* Force named pipe */
     break;
   case MYSQL_OPT_LOCAL_INFILE:			/* Allow LOAD DATA LOCAL ?*/
     if (!arg || test(*(uint*) arg))
@@ -2916,6 +3177,16 @@ mysql_options(MYSQL *mysql,enum mysql_option option, const char *arg)
     my_free(mysql->options.charset_name,MYF(MY_ALLOW_ZERO_PTR));
     mysql->options.charset_name=my_strdup(arg,MYF(MY_WME));
     break;
+  case MYSQL_OPT_PROTOCOL:
+    mysql->options.protocol= *(uint*) arg;
+    break;
+  case MYSQL_SHARED_MEMORY_BASE_NAME:
+#ifdef HAVE_SMEM
+    if (mysql->options.shared_memory_base_name != def_shared_memory_base_name)
+      my_free(mysql->options.shared_memory_base_name,MYF(MY_ALLOW_ZERO_PTR));
+    mysql->options.shared_memory_base_name=my_strdup(arg,MYF(MY_WME));
+#endif
+    break;
   default:
     DBUG_RETURN(1);
   }
@@ -3394,10 +3665,10 @@ MYSQL_STMT *STDCALL
 mysql_prepare(MYSQL  *mysql, const char *query, ulong length)
 {
   MYSQL_STMT  *stmt;
-  DBUG_ENTER("mysql_real_prepare");
+  DBUG_ENTER("mysql_prepare");
   DBUG_ASSERT(mysql != 0);
 
-#ifdef EXTRA_CHECK_ARGUMENTS
+#ifdef CHECK_EXTRA_ARGUMENTS
   if (!query)
   {
     set_mysql_error(mysql, CR_NULL_POINTER);
@@ -3415,19 +3686,20 @@ mysql_prepare(MYSQL  *mysql, const char *query, ulong length)
   }
   if (simple_command(mysql, COM_PREPARE, query, length, 1))
   {
-    mysql_stmt_close(stmt);
+    stmt_close(stmt, 1);
     DBUG_RETURN(0);
   }
-  stmt->state=		MY_ST_PREPARE;
 
   init_alloc_root(&stmt->mem_root,8192,0);
   if (read_prepare_result(mysql, stmt))
   {
-    mysql_stmt_close(stmt);
+    stmt_close(stmt, 1);
     DBUG_RETURN(0);
   }
-
-  stmt->mysql=		mysql;
+  stmt->state= MY_ST_PREPARE;
+  stmt->mysql= mysql;
+  mysql->stmts= list_add(mysql->stmts, &stmt->list);
+  stmt->list.data= stmt;
   DBUG_PRINT("info", ("Parameter count: %ld", stmt->param_count));
   DBUG_RETURN(stmt);
 }
@@ -3563,7 +3835,7 @@ static void store_param_str(NET *net, MYSQL_BIND *param)
   ulong length= *param->length;
   char *to= (char *) net_store_length((char *) net->write_pos, length);
   memcpy(to, param->buffer, length);
-  net->write_pos+= length;
+  net->write_pos= to+length;
 }
 
 
@@ -3597,17 +3869,19 @@ static my_bool store_param(MYSQL_STMT *stmt, MYSQL_BIND *param)
   MYSQL *mysql= stmt->mysql;
   NET	*net  = &mysql->net;
   DBUG_ENTER("store_param");
-  DBUG_PRINT("enter",("type : %d, buffer :%lx", param->buffer_type,
-		      param->buffer));
-
-  /* Allocate for worst case (long string) */
-  if ((my_realloc_str(net, 9 + *param->length)))
-    return 1;
-  if (!param->buffer)
+  DBUG_PRINT("enter",("type: %d, buffer:%lx, length: %d", param->buffer_type,
+    param->buffer ? param->buffer : "0", *param->length));
+  
+  if (param->is_null || param->buffer_type == MYSQL_TYPE_NULL)
     store_param_null(net, param);
   else
+  {
+    /* Allocate for worst case (long string) */  
+    if ((my_realloc_str(net, 9 + *param->length)))
+      DBUG_RETURN(1);
     (*param->store_param_func)(net, param);
-  DBUG_RETURN(1);
+  }
+  DBUG_RETURN(0);
 }
 
 
@@ -3619,13 +3893,13 @@ static my_bool execute(MYSQL_STMT * stmt, char *packet, ulong length)
 {
   MYSQL *mysql= stmt->mysql;
   NET	*net= &mysql->net;
-  char buff[4];
+  char buff[MYSQL_STMT_HEADER];
   DBUG_ENTER("execute");
   DBUG_PRINT("enter",("packet: %s, length :%d",packet ? packet :" ", length));
 
   mysql->last_used_con= mysql;
   int4store(buff, stmt->stmt_id);		/* Send stmt id to server */
-  if (advanced_command(mysql, COM_EXECUTE, buff, sizeof(buff), packet,
+  if (advanced_command(mysql, COM_EXECUTE, buff, MYSQL_STMT_HEADER, packet,
 		       length, 1) ||
       mysql_read_query_result(mysql))
   {
@@ -3633,12 +3907,14 @@ static my_bool execute(MYSQL_STMT * stmt, char *packet, ulong length)
     DBUG_RETURN(1);
   }
   stmt->state= MY_ST_EXECUTE;
-
-  if (stmt->bind)
+  mysql_free_result(stmt->result);
+#if USED_IN_FETCH
+  if (stmt->res_buffers) /* Result buffers exists, cache results */
   {
     mysql_free_result(stmt->result);
     stmt->result= mysql_store_result(mysql);
   }
+  #endif
   DBUG_RETURN(0);
 }
 
@@ -3649,8 +3925,6 @@ static my_bool execute(MYSQL_STMT * stmt, char *packet, ulong length)
 
 int STDCALL mysql_execute(MYSQL_STMT *stmt)
 {
-  ulong length;
-  uint null_count;
   DBUG_ENTER("mysql_execute");
 
   if (stmt->state == MY_ST_UNKNOWN)
@@ -3664,14 +3938,18 @@ int STDCALL mysql_execute(MYSQL_STMT *stmt)
     NET        *net= &stmt->mysql->net;
     MYSQL_BIND *param, *param_end;
     char       *param_data;
-    my_bool result;
+    ulong length;
+    uint null_count;
+    my_bool    result;
 
-    if (!stmt->params)
+#ifdef CHECK_EXTRA_ARGUMENTS
+    if (!stmt->param_buffers)
     {
       /* Parameters exists, but no bound buffers */
       set_stmt_error(stmt, CR_NOT_ALL_PARAMS_BOUND);
       DBUG_RETURN(1);
     }
+#endif
     net_clear(net);				/* Sets net->write_pos */
     /* Reserve place for null-marker bytes */
     null_count= (stmt->param_count+7) /8;
@@ -3680,10 +3958,9 @@ int STDCALL mysql_execute(MYSQL_STMT *stmt)
     param_end= stmt->params + stmt->param_count;
 
     /* In case if buffers (type) altered, indicate to server */
-    *(net->write_pos)++= (uchar) stmt->types_supplied;
-    if (!stmt->types_supplied)
+    *(net->write_pos)++= (uchar) stmt->send_types_to_server;
+    if (stmt->send_types_to_server)
     {
-      stmt->types_supplied=1;
       /*
 	Store types of parameters in first in first package
 	that is sent to the server.
@@ -3697,21 +3974,22 @@ int STDCALL mysql_execute(MYSQL_STMT *stmt)
       /* Check for long data which has not been propery given/terminated */
       if (param->is_long_data)
       {
-	if (!param->long_ended)
-	  DBUG_RETURN(MYSQL_NEED_DATA);
+        if (!param->long_ended)
+          DBUG_RETURN(MYSQL_NEED_DATA);
       }
       else if (store_param(stmt, param))
-	DBUG_RETURN(1);
+	      DBUG_RETURN(1);
     }
     length= (ulong) (net->write_pos - net->buff);
     /* TODO: Look into avoding the following memdup */
-    if (!(param_data= my_memdup((byte *) net->buff, length, MYF(0))))
+    if (!(param_data= my_memdup( net->buff, length, MYF(0))))
     {
       set_stmt_error(stmt, CR_OUT_OF_MEMORY);
       DBUG_RETURN(1);
     }
     net->write_pos= net->buff;			/* Reset for net_write() */
     result= execute(stmt, param_data, length);
+    stmt->send_types_to_server=0;
     my_free(param_data, MYF(MY_WME));
     DBUG_RETURN(result);
   }
@@ -3774,15 +4052,19 @@ my_bool STDCALL mysql_bind_param(MYSQL_STMT *stmt, MYSQL_BIND * bind)
 	      param->param_number);
       DBUG_RETURN(1);
     }
+    
     /*
       If param->length is not given, change it to point to bind_length.
       This way we can always use *param->length to get the length of data
     */
     if (!param->length)
       param->length= &param->bind_length;
-
+      
     /* Setup data copy functions for the different supported types */
     switch (param->buffer_type) {
+    case MYSQL_TYPE_NULL:
+      param->is_null=1;
+      break;
     case MYSQL_TYPE_TINY:
       param->bind_length= 1;
       param->store_param_func= store_param_tinyint;
@@ -3804,12 +4086,13 @@ my_bool STDCALL mysql_bind_param(MYSQL_STMT *stmt, MYSQL_BIND * bind)
       param->store_param_func= store_param_float;
       break;
     case MYSQL_TYPE_DOUBLE:
-      param->bind_length= 4;
+      param->bind_length= 8;
       param->store_param_func= store_param_double;
       break;
     case MYSQL_TYPE_TINY_BLOB:
     case MYSQL_TYPE_MEDIUM_BLOB:
     case MYSQL_TYPE_LONG_BLOB:
+    case MYSQL_TYPE_BLOB:
     case MYSQL_TYPE_VAR_STRING:
     case MYSQL_TYPE_STRING:
       param->bind_length= param->buffer_length;
@@ -3822,7 +4105,8 @@ my_bool STDCALL mysql_bind_param(MYSQL_STMT *stmt, MYSQL_BIND * bind)
     }
   }
   /* We have to send/resendtype information to MySQL */
-  stmt->types_supplied= 0;
+  stmt->send_types_to_server= 1;
+  stmt->param_buffers= 1;
   DBUG_RETURN(0);
 }
 
@@ -3896,6 +4180,73 @@ mysql_send_long_data(MYSQL_STMT *stmt, uint param_number,
   Fetch-bind related implementations
 *********************************************************************/
 
+/****************************************************************************
+  Functions to fetch data to application buffers
+
+  All functions has the following characteristics:
+
+  SYNOPSIS
+    fetch_result_xxx()
+    param   MySQL bind param
+    row     Row value
+
+  RETURN VALUES
+    0	ok
+    1	Error	(Can't alloc net->buffer)
+****************************************************************************/
+
+
+static void fetch_result_tinyint(MYSQL_BIND *param, uchar **row)
+{
+  *param->buffer= (uchar) **row;
+  *row++;
+}
+
+static void fetch_result_short(MYSQL_BIND *param, uchar **row)
+{
+  short value= *(short *)row;
+  int2store(param->buffer, value); 
+  *row+=2;
+}
+
+static void fetch_result_int32(MYSQL_BIND *param, uchar **row)
+{
+  int32 value= *(int32 *)row;
+  int4store(param->buffer, value);
+  *row+=4;
+}
+
+static void fetch_result_int64(MYSQL_BIND *param, uchar **row)
+{
+  longlong value= *(longlong *)row;
+  int8store(param->buffer, value);
+  *row+=8;
+}
+
+static void fetch_result_float(MYSQL_BIND *param, uchar **row)
+{
+  float value;
+  float4get(value,*row);
+  float4store(param->buffer, *row);
+  *row+=4;
+}
+
+static void fetch_result_double(MYSQL_BIND *param, uchar **row)
+{
+  double value;
+  float8get(value,*row);
+  float8store(param->buffer, value);
+  *row+=8;
+}
+
+static void fetch_result_str(MYSQL_BIND *param, uchar **row)
+{
+  ulong length= net_field_length(row);
+  memcpy(param->buffer, (char *)*row, length);
+  *param->length= length;
+  *row+=length;
+}
+
 /*
   Setup the bind buffers for resultset processing
 */
@@ -3907,40 +4258,80 @@ my_bool STDCALL mysql_bind_result(MYSQL_STMT *stmt, MYSQL_BIND *bind)
   DBUG_ENTER("mysql_bind_result");
   DBUG_ASSERT(stmt != 0);
 
-#ifdef EXTRA_CHECK_ARGUMENTS
+#ifdef CHECK_EXTRA_ARGUMENTS
   if (!bind)
   {
     set_stmt_error(stmt, CR_NULL_POINTER);
     DBUG_RETURN(1);
   }
 #endif
-  bind_count= stmt->result->field_count;
+  bind_count= stmt->field_count;
   memcpy((char*) stmt->bind, (char*) bind,
 	 sizeof(MYSQL_BIND)*bind_count);
 
   for (param= stmt->bind, end= param+bind_count; param < end ; param++)
   {
-    /* TODO:  Set up convert functions like in mysql_bind_param */
+    /* Setup data copy functions for the different supported types */
+    switch (param->buffer_type) {
+    case MYSQL_TYPE_TINY:
+      param->bind_length= 1;
+      param->fetch_result= fetch_result_tinyint;
+      break;
+    case MYSQL_TYPE_SHORT:
+      param->bind_length= 2;
+      param->fetch_result= fetch_result_short;
+      break;
+    case MYSQL_TYPE_LONG:
+      param->bind_length= 4;
+      param->fetch_result= fetch_result_int32;
+      break;
+    case MYSQL_TYPE_LONGLONG:
+      param->bind_length= 8;
+      param->fetch_result= fetch_result_int64;
+      break;
+    case MYSQL_TYPE_FLOAT:
+      param->bind_length= 4;
+      param->fetch_result= fetch_result_float;
+      break;
+    case MYSQL_TYPE_DOUBLE:
+      param->bind_length= 8;
+      param->fetch_result= fetch_result_double;
+      break;
+    case MYSQL_TYPE_TINY_BLOB:
+    case MYSQL_TYPE_MEDIUM_BLOB:
+    case MYSQL_TYPE_LONG_BLOB:
+    case MYSQL_TYPE_VAR_STRING:
+    case MYSQL_TYPE_STRING:
+      param->length= &param->buffer_length;
+      param->fetch_result= fetch_result_str;
+      break;
+    default:
+      sprintf(stmt->last_error, ER(stmt->last_errno= CR_UNSUPPORTED_PARAM_TYPE),
+	      param->buffer_type, param->param_number);
+      DBUG_RETURN(1);
+    }                                    
+    if (!param->length)
+      param->length= &param->bind_length;
   }
+  stmt->res_buffers= 1;
   DBUG_RETURN(0);
 }
 
-
 /*
   Fetch row data to bind buffers
 */
 
 static my_bool
-my_fetch_row(MYSQL_STMT *stmt, MYSQL_RES *result, const byte *row)
+stmt_fetch_row(MYSQL_STMT *stmt, uchar **row)
 {
   MYSQL_BIND  *bind, *end;
-  uchar *null_ptr= (uchar*) row, bit;
-
-  result->row_count++;
-  row+= (result->field_count+7)/8;
-  /* Copy complete row to application buffers */
+  uchar *null_ptr= (uchar*) *row, bit;
+  
+  *row+= (stmt->field_count+7)/8;  
   bit=1;
-  for (bind= stmt->bind, end= (MYSQL_BIND *) bind + result->field_count;
+  
+  /* Copy complete row to application buffers */
+  for (bind= stmt->bind, end= (MYSQL_BIND *) bind + stmt->field_count;
        bind < end;
        bind++)
   {
@@ -3949,7 +4340,7 @@ my_fetch_row(MYSQL_STMT *stmt, MYSQL_RES *result, const byte *row)
     else
     {
       bind->is_null= 0;
-      row= (byte*) (*bind->fetch_result)(bind, (char*) row);
+      (*bind->fetch_result)(bind, row);
     }
     if (! (bit<<=1) & 255)
     {
@@ -3960,12 +4351,9 @@ my_fetch_row(MYSQL_STMT *stmt, MYSQL_RES *result, const byte *row)
   return 0;
 }
 
-
-static int
-read_binary_data(MYSQL *mysql)
-{
-  ulong pkt_len;
-  if ((pkt_len= net_safe_read(mysql)) == packet_error)
+static int read_binary_data(MYSQL *mysql)
+{  
+  if (packet_error == net_safe_read(mysql))
     return -1;
   if (mysql->net.read_pos[0])
     return 1;				/* End of data */
@@ -3979,57 +4367,30 @@ read_binary_data(MYSQL *mysql)
 
 int STDCALL mysql_fetch(MYSQL_STMT *stmt)
 {
-  MYSQL_RES *result;
+  MYSQL *mysql= stmt->mysql;
   DBUG_ENTER("mysql_fetch");
 
-  result= stmt->result;
-  if (!result)
-    DBUG_RETURN(MYSQL_NO_DATA);
-
-  if (!result->data)
+  if (stmt->res_buffers)
   {
-    MYSQL *mysql= stmt->mysql;
-    if (!result->eof)
+    int res;
+    if (!(res= read_binary_data(mysql)))
     {
-      int res;
-      if (!(res= read_binary_data(result->handle)))
-	DBUG_RETURN((int) my_fetch_row(stmt, result,
-				       (byte*) mysql->net.read_pos+1));
-      DBUG_PRINT("info", ("end of data"));
-      result->eof= 1;
-      result->handle->status= MYSQL_STATUS_READY;
-
-      /* Don't clear handle in mysql_free_results */
-      result->handle= 0;
-      if (res < 0)				/* Network error */
-      {
-	set_stmt_errmsg(stmt,(char *)mysql->net.last_error,
-			mysql->net.last_errno);
-	DBUG_RETURN(MYSQL_STATUS_ERROR);
-      }
+      if (stmt->res_buffers)
+	      DBUG_RETURN((int) stmt_fetch_row(stmt,(uchar **) &mysql->net.read_pos+1));
+      DBUG_RETURN(0);
     }
-    DBUG_RETURN(MYSQL_NO_DATA); /* no more data */
-  }
-  {
-    /*
-      For prepared statements, the row data is a string of binary bytes,
-      not a set of string pointers as for normal statements
-      It's however convenient to use the data pointer also for prepared
-      statements.
-    */
-    MYSQL_ROW values;
-    if (!result->data_cursor)
+    DBUG_PRINT("info", ("end of data"));    
+    mysql->status= MYSQL_STATUS_READY;
+    
+    if (res < 0)				/* Network error */
     {
-      DBUG_PRINT("info", ("end of data"));
-      result->current_row= (MYSQL_ROW) NULL;
-      DBUG_RETURN(MYSQL_NO_DATA);
+	   set_stmt_errmsg(stmt,(char *)mysql->net.last_error,
+		                mysql->net.last_errno);
+	   DBUG_RETURN(MYSQL_STATUS_ERROR);
     }
-    values= result->data_cursor->data;
-    result->data_cursor= result->data_cursor->next;
-
-    DBUG_RETURN((int) my_fetch_row(stmt,result, (byte*) values));
+    DBUG_RETURN(MYSQL_NO_DATA); /* no more data */
   }
-  DBUG_RETURN(0);
+  DBUG_RETURN(0); //?? do we need to set MYSQL_STATUS_READY ?
 }
 
 
@@ -4038,29 +4399,42 @@ int STDCALL mysql_fetch(MYSQL_STMT *stmt)
 *********************************************************************/
 
 /*
-  Close the statement handle by freeing all resources
-*/
+  Close the statement handle by freeing all alloced resources
 
-my_bool STDCALL mysql_stmt_close(MYSQL_STMT *stmt)
+  SYNOPSIS
+    mysql_stmt_close()
+    stmt	       Statement handle
+    skip_list    Flag to indicate delete from list or not
+  RETURN VALUES
+    0	ok
+    1	error
+*/
+static my_bool stmt_close(MYSQL_STMT *stmt, my_bool skip_list)
 {
   my_bool error=0;
   DBUG_ENTER("mysql_stmt_close");
 
-  if (stmt->state)
+  DBUG_ASSERT(stmt != 0);
+  if (stmt->state == MY_ST_PREPARE || stmt->state == MY_ST_EXECUTE)
   {
     char buff[4];
     int4store(buff, stmt->stmt_id);
-    error= simple_command(stmt->mysql, COM_CLOSE_STMT, buff, 4, 0);
+    error= simple_command(stmt->mysql, COM_CLOSE_STMT, buff, 4, 1);
   }
-
+  mysql_free_result(stmt->result);
   free_root(&stmt->mem_root, MYF(0));
   my_free((gptr) stmt->query, MYF(MY_WME | MY_ALLOW_ZERO_PTR));
-  my_free((gptr) stmt->bind, MY_ALLOW_ZERO_PTR);
-  my_free((gptr) stmt->params, MY_ALLOW_ZERO_PTR);
+  if (!skip_list)
+    stmt->mysql->stmts= list_delete(stmt->mysql->stmts, &stmt->list);
   my_free((gptr) stmt, MYF(MY_WME));
   DBUG_RETURN(error);
 }
 
+my_bool STDCALL mysql_stmt_close(MYSQL_STMT *stmt)
+{
+  return stmt_close(stmt, 0);
+}
+
 /*
   Return statement error code
 */
diff --git a/libmysql/libmysql.def b/libmysql/libmysql.def
index a7fb4d378e517b02d5473434118a00ef18ef1d03..0d6504676657ed155d06c832543bb4da7e30dd99 100644
--- a/libmysql/libmysql.def
+++ b/libmysql/libmysql.def
@@ -102,8 +102,24 @@ EXPORTS
 	mysql_add_slave
 	mysql_warning_count
 	mysql_warnings
-	
-	
+	mysql_prepare
+        mysql_execute
+	mysql_param_count
+        mysql_bind_param
+        mysql_bind_result
+        mysql_prepare_result
+        mysql_stmt_close
+        mysql_stmt_error
+        mysql_stmt_errno
+        mysql_fetch
+        mysql_send_long_data
+        mysql_multi_query
+        mysql_next_result
+        mysql_commit
+        mysql_rollback
+        mysql_autocommit
+  
+  
 	
 	
 	
diff --git a/libmysql/password.c b/libmysql/password.c
index 9b154603b98a83b170c1f5a2639ec09d56f5a9b5..1c2c55892152f18c73f5f457c41dd1a23e07c19f 100644
--- a/libmysql/password.c
+++ b/libmysql/password.c
@@ -91,7 +91,7 @@ void make_scrambled_password(char *to,const char *password)
   sprintf(to,"%08lx%08lx",hash_res[0],hash_res[1]);
 }
 
-static inline uint char_val(char X)
+static inline unsigned int char_val(char X)
 {
   return (uint) (X >= '0' && X <= '9' ? X-'0' :
 		 X >= 'A' && X <= 'Z' ? X-'A'+10 :
diff --git a/libmysql_r/Makefile.am b/libmysql_r/Makefile.am
index e01fc7634a1df320833be81991e2e6b3782fff28..265e31fafdb206e3f6654a3d2629f34ccf70fe22 100644
--- a/libmysql_r/Makefile.am
+++ b/libmysql_r/Makefile.am
@@ -21,8 +21,7 @@ target = libmysqlclient_r.la
 target_defs = -DDONT_USE_RAID @LIB_EXTRA_CCFLAGS@
 ## LIBS = @LIBS@
 
-INCLUDES =	@MT_INCLUDES@ -I$(srcdir)/../include -I../include \
-		-I$(srcdir)/.. -I$(top_srcdir) -I.. $(openssl_includes)
+INCLUDES =	@MT_INCLUDES@ -I$(top_srcdir)/include $(openssl_includes)
 
 ## automake barfs if you don't use $(srcdir) or $(top_srcdir) in include
 include $(top_srcdir)/libmysql/Makefile.shared
diff --git a/libmysqld/Makefile.am b/libmysqld/Makefile.am
index 022a589e304b34ad6afdbb8592f409bed5a657da..18469422e39dde7f9576b792563650e781be62a6 100644
--- a/libmysqld/Makefile.am
+++ b/libmysqld/Makefile.am
@@ -25,9 +25,8 @@ DEFS =			-DEMBEDDED_LIBRARY -DMYSQL_SERVER \
 			-DDEFAULT_MYSQL_HOME="\"$(MYSQLBASEdir)\"" \
 			-DDATADIR="\"$(MYSQLDATAdir)\"" \
 			-DSHAREDIR="\"$(MYSQLSHAREdir)\""
-INCLUDES=		@MT_INCLUDES@ @bdb_includes@ -I$(srcdir)/../include \
-			-I../include -I$(srcdir)/.. -I$(top_srcdir) -I.. \
-			-I../sql -I../regex
+INCLUDES=		@MT_INCLUDES@ @bdb_includes@ -I$(top_srcdir)/include \
+			-I$(top_srcdir)/sql -I$(top_srcdir)/regex
 
 noinst_LIBRARIES =	libmysqld_int.a
 pkglib_LIBRARIES =	libmysqld.a
diff --git a/libmysqld/lib_sql.cc b/libmysqld/lib_sql.cc
index 09681fa3a63af2258ab283c8809f2f712d212ea2..4726cbb44a75bf8f510592793980348398cc9480 100644
--- a/libmysqld/lib_sql.cc
+++ b/libmysqld/lib_sql.cc
@@ -506,13 +506,13 @@ int STDCALL mysql_server_init(int argc, char **argv, char **groups)
     exit(1);
   }
   opt_noacl = 1;				// No permissions
-  if (acl_init(opt_noacl))
+  if (acl_init((THD*) 0,opt_noacl))
   {
     mysql_server_end();
     return 1;
   }
   if (!opt_noacl)
-    (void) grant_init();
+    (void) grant_init((THD*) 0);
   init_max_user_conn();
   init_update_queries();
 
diff --git a/libmysqld/libmysqld.c b/libmysqld/libmysqld.c
index 6328a205a7bdbec0898ebcc9206c798bedb095d1..059ed184f13cc759766ba91b1d1632965cd2dc7e 100644
--- a/libmysqld/libmysqld.c
+++ b/libmysqld/libmysqld.c
@@ -49,6 +49,10 @@
 static my_bool	mysql_client_init=0;
 uint		mysql_port=0;
 my_string	mysql_unix_port=0;
+const char *sql_protocol_names_lib[] =
+{ "TCP", "SOCKET", "PIPE", "MEMORY",NullS };
+TYPELIB sql_protocol_typelib = {array_elements(sql_protocol_names_lib)-1,"",
+			   sql_protocol_names_lib};
 
 #define CLIENT_CAPABILITIES	(CLIENT_LONG_PASSWORD | CLIENT_LONG_FLAG | CLIENT_TRANSACTIONS | CLIENT_PROTOCOL_41)
 
@@ -433,11 +437,15 @@ mysql_free_result(MYSQL_RES *result)
 ****************************************************************************/
 
 static const char *default_options[]=
-{"port","socket","compress","password","pipe", "timeout", "user",
- "init-command", "host", "database", "debug", "return-found-rows",
- "ssl_key" ,"ssl_cert" ,"ssl_ca" ,"ssl_capath",
- "character-set-dir", "default-character-set",
- NullS
+{
+  "port","socket","compress","password","pipe", "timeout", "user",
+  "init-command", "host", "database", "debug", "return-found-rows",
+  "ssl-key" ,"ssl-cert" ,"ssl-ca" ,"ssl-capath",
+  "character-sets-dir", "default-character-set", "interactive-timeout",
+  "connect-timeout", "local-infile", "disable-local-infile",
+  "replication-probe", "enable-reads-from-master", "repl-parse-query",
+  "ssl-cipher","protocol", "shared_memory_base_name",
+  NullS
 };
 
 static TYPELIB option_types={array_elements(default_options)-1,
@@ -471,6 +479,9 @@ static void mysql_read_default_options(struct st_mysql_options *options,
 	  opt_arg=end+1;
 	  *end=0;				/* Remove '=' */
 	}
+	/* Change all '_' in variable name to '-' */
+	for (end= *option ; *(end= strcend(end,'_')) ; )
+	  *end= '-';
 	switch (find_type(*option+2,&option_types,2)) {
 	case 1:				/* port */
 	  if (opt_arg)
@@ -494,8 +505,9 @@ static void mysql_read_default_options(struct st_mysql_options *options,
 	  }
 	  break;
 	case 5:				/* pipe */
-	  options->named_pipe=1;	/* Force named pipe */
+          options->protocol = MYSQL_PROTOCOL_PIPE;
 	  break;
+	case 20:			/* connect_timeout */
 	case 6:				/* timeout */
 	  if (opt_arg)
 	    options->connect_timeout=atoi(opt_arg);
@@ -538,6 +550,7 @@ static void mysql_read_default_options(struct st_mysql_options *options,
 	case 14:
 	case 15:
 	case 16:
+	case 26:
 	  break;
 	case 17:			/* charset-lib */
 	  my_free(options->charset_dir,MYF(MY_ALLOW_ZERO_PTR));
@@ -547,6 +560,15 @@ static void mysql_read_default_options(struct st_mysql_options *options,
 	  my_free(options->charset_name,MYF(MY_ALLOW_ZERO_PTR));
           options->charset_name = my_strdup(opt_arg, MYF(MY_WME));
 	  break;
+	case 19:				/* Interactive-timeout */
+	case 21:				/* client_local_files */
+	case 22:
+	case 23:				/* Replication options */
+	case 24:
+	case 25:
+	case 27:				/* Protocol */
+	case 28:				/* Shared memory */
+	  break;
 	default:
 	  DBUG_PRINT("warning",("unknown option: %s",option[0]));
 	}
@@ -1789,7 +1811,13 @@ mysql_options(MYSQL *mysql,enum mysql_option option, const char *arg)
     mysql->options.compress=1;			/* Remember for connect */
     break;
   case MYSQL_OPT_NAMED_PIPE:
-    mysql->options.named_pipe=1;		/* Force named pipe */
+    mysql->options.protocol=MYSQL_PROTOCOL_PIPE; /* Force named pipe */
+    break;
+  case MYSQL_OPT_LOCAL_INFILE:			/* Allow LOAD DATA LOCAL ?*/
+    if (!arg || test(*(uint*) arg))
+      mysql->options.client_flag|= CLIENT_LOCAL_FILES;
+    else
+      mysql->options.client_flag&= ~CLIENT_LOCAL_FILES;
     break;
   case MYSQL_INIT_COMMAND:
     my_free(mysql->options.init_command,MYF(MY_ALLOW_ZERO_PTR));
@@ -1811,6 +1839,11 @@ mysql_options(MYSQL *mysql,enum mysql_option option, const char *arg)
     my_free(mysql->options.charset_name,MYF(MY_ALLOW_ZERO_PTR));
     mysql->options.charset_name=my_strdup(arg,MYF(MY_WME));
     break;
+  case MYSQL_OPT_PROTOCOL:
+    mysql->options.protocol= *(uint*) arg;
+    break;
+  case MYSQL_SHARED_MEMORY_BASE_NAME:
+    break;
   default:
     DBUG_RETURN(-1);
   }
diff --git a/merge/Makefile.am b/merge/Makefile.am
index 78441e84fac0bae148c15c66b47c1161200ec61a..25e15e9c6ec05f3308a829396dd88370ecf795ef 100644
--- a/merge/Makefile.am
+++ b/merge/Makefile.am
@@ -14,7 +14,7 @@
 # along with this program; if not, write to the Free Software
 # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
 
-INCLUDES =		@MT_INCLUDES@ -I$(srcdir)/../include -I../include
+INCLUDES =		@MT_INCLUDES@ -I$(top_srcdir)/include
 pkglib_LIBRARIES =	libmerge.a
 noinst_HEADERS =	mrg_def.h
 libmerge_a_SOURCES =	mrg_open.c mrg_extra.c mrg_info.c mrg_locking.c \
diff --git a/myisam/Makefile.am b/myisam/Makefile.am
index 1dbce5727f02967e13e594f3e42fb23a461f6dc4..f8225868d9618dcb7b42df4e1fdd322e5c203b9e 100644
--- a/myisam/Makefile.am
+++ b/myisam/Makefile.am
@@ -17,7 +17,7 @@
 EXTRA_DIST =		mi_test_all.sh mi_test_all.res
 pkgdata_DATA =		mi_test_all mi_test_all.res
 
-INCLUDES =		@MT_INCLUDES@ -I$(srcdir)/../include -I../include
+INCLUDES =		@MT_INCLUDES@ -I$(top_srcdir)/include
 LDADD =			@CLIENT_EXTRA_LDFLAGS@ libmyisam.a ../mysys/libmysys.a \
 			../dbug/libdbug.a ../strings/libmystrings.a
 pkglib_LIBRARIES =	libmyisam.a
diff --git a/myisam/ft_boolean_search.c b/myisam/ft_boolean_search.c
index 2b9b6cedcf6b10a7913de0ebc71a2e1367e5255e..6749de06ee2095cbcd6cecef3652425814dfdcce 100644
--- a/myisam/ft_boolean_search.c
+++ b/myisam/ft_boolean_search.c
@@ -119,8 +119,8 @@ static int FTB_WORD_cmp(my_off_t *v, FTB_WORD *a, FTB_WORD *b)
 static int FTB_WORD_cmp_list(CHARSET_INFO *cs, FTB_WORD **a, FTB_WORD **b)
 {
   /* ORDER BY word DESC, ndepth DESC */
-  int i= mi_compare_text(cs, (*b)->word+1,(*b)->len-1,
-                             (*a)->word+1,(*a)->len-1,0);
+  int i= mi_compare_text(cs, (uchar*) (*b)->word+1,(*b)->len-1,
+                             (uchar*) (*a)->word+1,(*a)->len-1,0);
   if (!i)
     i=CMP_NUM((*b)->ndepth,(*a)->ndepth);
   return i;
@@ -255,7 +255,7 @@ static void _ftb_init_index_search(FT_INFO *ftb)
       r= mi_compare_text(ftb->charset,
                          info->lastkey + (ftbw->flags&FTB_FLAG_TRUNC),
                          ftbw->len     - (ftbw->flags&FTB_FLAG_TRUNC),
-                         ftbw->word    + (ftbw->flags&FTB_FLAG_TRUNC),
+                         (uchar*) ftbw->word    + (ftbw->flags&FTB_FLAG_TRUNC),
                          ftbw->len     - (ftbw->flags&FTB_FLAG_TRUNC),
                          0);
     }
@@ -348,9 +348,9 @@ static int _ftb_strstr(const byte *s0, const byte *e0,
     if (s0 >= e0)
       return 0;
     p=s1+1;
-    while (s0 < e0 && p < e1 && cs->to_upper[(uint) (uchar) *s0++] ==
-	   cs->to_upper[(uint) (uchar) *p++])
-      /* no-op */;
+    while (s0 < e0 && p < e1 && cs->to_upper[(uint) (uchar) *s0] ==
+	   cs->to_upper[(uint) (uchar) *p])
+      s0++, p++;
     if (p >= e1)
       return 1;
   }
@@ -473,7 +473,7 @@ int ft_boolean_read_next(FT_INFO *ftb, char *record)
         r= mi_compare_text(ftb->charset,
                            info->lastkey + (ftbw->flags&FTB_FLAG_TRUNC),
                            ftbw->len     - (ftbw->flags&FTB_FLAG_TRUNC),
-                           ftbw->word    + (ftbw->flags&FTB_FLAG_TRUNC),
+                           (uchar*) ftbw->word + (ftbw->flags&FTB_FLAG_TRUNC),
                            ftbw->len     - (ftbw->flags&FTB_FLAG_TRUNC),
                            0);
       }
@@ -578,7 +578,7 @@ float ft_boolean_find_relevance(FT_INFO *ftb, byte *record, uint length)
       for (a=0, b=ftb->queue.elements, c=(a+b)/2; b-a>1; c=(a+b)/2)
       {
         ftbw=ftb->list[c];
-        if (mi_compare_text(ftb->charset, word.pos, word.len,
+        if (mi_compare_text(ftb->charset, (uchar*) word.pos, word.len,
                             (uchar*) ftbw->word+1, ftbw->len-1,
                             (my_bool) (ftbw->flags&FTB_FLAG_TRUNC)) >0)
           b=c;
@@ -588,7 +588,7 @@ float ft_boolean_find_relevance(FT_INFO *ftb, byte *record, uint length)
       for (; c>=0; c--)
       {
         ftbw=ftb->list[c];
-        if (mi_compare_text(ftb->charset, word.pos,word.len,
+        if (mi_compare_text(ftb->charset, (uchar*) word.pos, word.len,
                             (uchar*) ftbw->word+1,ftbw->len-1,
                             (my_bool) (ftbw->flags&FTB_FLAG_TRUNC)))
           break;
diff --git a/myisam/ft_nlq_search.c b/myisam/ft_nlq_search.c
index 7225896c69ee3cffa4a2999946671de9882cd633..f9c276de32fb0100ea3026f2d906c625cb01d015 100644
--- a/myisam/ft_nlq_search.c
+++ b/myisam/ft_nlq_search.c
@@ -155,7 +155,8 @@ static int walk_and_match(FT_WORD *word, uint32 count, ALL_IN_ONE *aio)
   if (doc_cnt)
   {
     word->weight*=GWS_IN_USE;
-    if (word->weight < 0) word->weight=0;
+    if (word->weight < 0)
+      word->weight=0;
 
   }
   DBUG_RETURN(0);
diff --git a/myisam/ft_parser.c b/myisam/ft_parser.c
index 29a48352cd6eeb44c22157b4e3754e3d2a614cb8..358706a8ffa705f1a2672cb66f27fef6a6125237 100644
--- a/myisam/ft_parser.c
+++ b/myisam/ft_parser.c
@@ -111,7 +111,7 @@ FT_WORD * ft_linearize(TREE *wtree)
 #else
 #define misc_word_char(X)	((X)=='\'' || (X)=='-')
 #endif
-#define word_char(s,X)		(true_word_char(s,X) || misc_word_char(s,X))
+#define word_char(s,X)		(true_word_char(s,X) || misc_word_char(X))
 
 
 /* returns:
@@ -132,8 +132,8 @@ byte ft_get_word(byte **start, byte *end, FT_WORD *word, FTB_PARAM *param)
   {
     for (;doc<end;doc++)
     {
-      /* 
-        BAR TODO: discuss with Serge how to remove 
+      /*
+        BAR TODO: discuss with Serge how to remove
         default_charset_info correctly
       */
       if (true_word_char(default_charset_info,*doc)) break;
diff --git a/myisam/mi_dynrec.c b/myisam/mi_dynrec.c
index 60e6fc0519a5d93d08db80d2885f6081a7cb4234..d33aa2718b76a606a3d38b27121f4ac7c9c57f83 100644
--- a/myisam/mi_dynrec.c
+++ b/myisam/mi_dynrec.c
@@ -157,6 +157,7 @@ static int _mi_find_writepos(MI_INFO *info,
 			     ulong *length)   /* length of block at filepos */
 {
   MI_BLOCK_INFO block_info;
+  ulong tmp;
   DBUG_ENTER("_mi_find_writepos");
 
   if (info->s->state.dellink != HA_OFFSET_ERROR)
@@ -182,21 +183,22 @@ static int _mi_find_writepos(MI_INFO *info,
   {
     /* No deleted blocks;  Allocate a new block */
     *filepos=info->state->data_file_length;
-    if ((*length=reclength+3 + test(reclength >= (65520-3))) <
+    if ((tmp=reclength+3 + test(reclength >= (65520-3))) <
 	info->s->base.min_block_length)
-      *length=info->s->base.min_block_length;
+      tmp= info->s->base.min_block_length;
     else
-      *length= ((*length+MI_DYN_ALIGN_SIZE-1) &
-		(~ (ulong) (MI_DYN_ALIGN_SIZE-1)));
+      tmp= ((tmp+MI_DYN_ALIGN_SIZE-1) &
+	    (~ (ulong) (MI_DYN_ALIGN_SIZE-1)));
     if (info->state->data_file_length >
-	(info->s->base.max_data_file_length- *length))
+	(info->s->base.max_data_file_length - tmp))
     {
       my_errno=HA_ERR_RECORD_FILE_FULL;
       DBUG_RETURN(-1);
     }
-    if (*length > MI_MAX_BLOCK_LENGTH)
-      *length=MI_MAX_BLOCK_LENGTH;
-    info->state->data_file_length+= *length;
+    if (tmp > MI_MAX_BLOCK_LENGTH)
+      tmp=MI_MAX_BLOCK_LENGTH;
+    *length= tmp;
+    info->state->data_file_length+= tmp;
     info->s->state.split++;
     info->update|=HA_STATE_WRITE_AT_END;
   }
diff --git a/myisam/mi_open.c b/myisam/mi_open.c
index e4e70f649a4b564c3300d2f179e8ff199f3fd2a4..8f0da612c3a107fa57378c8164c5e56142f357a3 100644
--- a/myisam/mi_open.c
+++ b/myisam/mi_open.c
@@ -583,7 +583,8 @@ byte *mi_alloc_rec_buff(MI_INFO *info, ulong length, byte **buf)
 
     /* to simplify initial init of info->rec_buf in mi_open and mi_extra */
     if (length == (ulong) -1)
-      length= max(info->s->base.pack_reclength,info->s->base.max_key_length);
+      length= max(info->s->base.pack_reclength+info->s->base.pack_bits,
+                  info->s->base.max_key_length);
 
     extra= ((info->s->options & HA_OPTION_PACK_RECORD) ?
 	    ALIGN_SIZE(MI_MAX_DYN_BLOCK_HEADER)+MI_SPLIT_LENGTH+
diff --git a/myisam/mi_page.c b/myisam/mi_page.c
index 064e9239e733e12194f20f682870732a2370964b..1d40980e309129418dd4ef03a82da9dfd658415e 100644
--- a/myisam/mi_page.c
+++ b/myisam/mi_page.c
@@ -66,7 +66,9 @@ int _mi_write_keypage(register MI_INFO *info, register MI_KEYDEF *keyinfo,
       page+keyinfo->block_length > info->state->key_file_length ||
       (page & (MI_MIN_KEY_BLOCK_LENGTH-1)))
   {
-    DBUG_PRINT("error",("Trying to write inside key status region: %lu",
+    DBUG_PRINT("error",("Trying to write inside key status region: key_start: %lu  length: %lu  page: %lu",
+			(long) info->s->base.keystart,
+			(long) info->state->key_file_length,
 			(long) page));
     my_errno=EINVAL;
     return(-1);
diff --git a/myisam/mi_rkey.c b/myisam/mi_rkey.c
index cefb7a74dd1754d96dc46695f91dd2ebcd16d86d..4a3c76809e88b2f5cd8697cf30fceb4b77ce4a56 100644
--- a/myisam/mi_rkey.c
+++ b/myisam/mi_rkey.c
@@ -38,7 +38,15 @@ int mi_rkey(MI_INFO *info, byte *buf, int inx, const byte *key, uint key_len,
   info->update&= (HA_STATE_CHANGED | HA_STATE_ROW_CHANGED);
   info->last_key_func=search_flag;
 
-  if (!info->use_packed_key)
+  if (info->once_flags & USE_PACKED_KEYS)
+  {
+    /* key is already packed! */
+    key_buff=info->lastkey+info->s->base.max_key_length;
+    info->last_rkey_length=pack_key_length=key_len;
+    bmove(key_buff,key,key_len);
+    info->once_flags&= ~USE_PACKED_KEYS;
+  }
+  else
   {
     if (key_len == 0)
       key_len=USE_WHOLE_KEY;
@@ -48,13 +56,6 @@ int mi_rkey(MI_INFO *info, byte *buf, int inx, const byte *key, uint key_len,
     DBUG_EXECUTE("key",_mi_print_key(DBUG_FILE,share->keyinfo[inx].seg,
 				     key_buff,pack_key_length););
   }
-  else
-  {
-    /* key is already packed! */
-    key_buff=info->lastkey+info->s->base.max_key_length;
-    info->last_rkey_length=pack_key_length=key_len;
-    bmove(key_buff,key,key_len);
-  }
 
   if (fast_mi_readinfo(info))
     goto err;
diff --git a/myisam/mi_rrnd.c b/myisam/mi_rrnd.c
index f8009441cfffcea2a0321745dad3ff95459be9fb..29f686b0456c237a7c7bb83e44d130933436799b 100644
--- a/myisam/mi_rrnd.c
+++ b/myisam/mi_rrnd.c
@@ -46,7 +46,10 @@ int mi_rrnd(MI_INFO *info, byte *buf, register my_off_t filepos)
       filepos= info->nextpos;
   }
 
-  info->lastinx= -1;				/* Can't forward or backward */
+  if (info->once_flags & RRND_PRESERVE_LASTINX)
+    info->once_flags&= ~RRND_PRESERVE_LASTINX;
+  else
+    info->lastinx= -1;                          /* Can't forward or backward */
   /* Init all but update-flag */
   info->update&= (HA_STATE_CHANGED | HA_STATE_ROW_CHANGED);
 
diff --git a/myisam/mi_write.c b/myisam/mi_write.c
index 5d22ebfe5b5b8901b95f15f593d5f8400b635195..58f9ebdb735fbc2a570abd3c79a4b82ecb012075 100644
--- a/myisam/mi_write.c
+++ b/myisam/mi_write.c
@@ -845,8 +845,9 @@ int _mi_init_bulk_insert(MI_INFO *info, ulong cache_size)
     {
       params->info=info;
       params->keynr=i;
+      /* Only allocate a 16'th of the buffer at a time */
       init_tree(&info->bulk_insert[i],
-                cache_size / num_keys / 4 + 10,
+                cache_size / num_keys / 16 + 10,
 		cache_size / num_keys, 0,
 		(qsort_cmp2)keys_compare, 0,
 		(tree_element_free) keys_free, (void *)params++);
diff --git a/myisam/myisamchk.c b/myisam/myisamchk.c
index ca4e430d49b75a2f006f7d9525a69f2d5f3d8fea..281cb90d9bf04e8d06faaf2ac311d3dfc531ada1 100644
--- a/myisam/myisamchk.c
+++ b/myisam/myisamchk.c
@@ -134,6 +134,7 @@ int main(int argc, char **argv)
 	   llstr(check_param.total_deleted,buff2));
   }
   free_defaults(default_argv);
+  free_tmpdir(&myisamchk_tmpdir);
   ft_free_stopwords();
   my_end(check_param.testflag & T_INFO ? MY_CHECK_ERROR | MY_GIVE_INFO : MY_CHECK_ERROR);
   exit(error);
@@ -1638,7 +1639,7 @@ static int sort_record_index(MI_SORT_PARAM *sort_param,MI_INFO *info,
 
 volatile bool *killed_ptr(MI_CHECK *param)
 {
-  return (bool *)(param->thd); /* always NULL */
+  return (bool *)(& param->thd); /* always NULL */
 }
 
 	/* print warnings and errors */
diff --git a/myisam/myisamdef.h b/myisam/myisamdef.h
index 6499021861eee7de364b0494fcd231c72dd84e38..c63f4a2856242dd5c59fceb4c692b0062842d3cb 100644
--- a/myisam/myisamdef.h
+++ b/myisam/myisamdef.h
@@ -267,7 +267,7 @@ struct st_myisam_info {
   my_bool quick_mode;
   my_bool page_changed;		/* If info->buff can't be used for rnext */
   my_bool buff_used;		/* If info->buff has to be reread for rnext */
-  my_bool use_packed_key;		/* For MYISAMMRG */
+  my_bool once_flags;           /* For MYISAMMRG */
 #ifdef THREAD
   THR_LOCK_DATA lock;
 #endif
@@ -288,6 +288,10 @@ struct st_myisam_info {
 #define WRITEINFO_UPDATE_KEYFILE	1
 #define WRITEINFO_NO_UNLOCK		2
 
+        /* once_flags */
+#define USE_PACKED_KEYS         1
+#define RRND_PRESERVE_LASTINX   2
+
 	/* bits in state.changed */
 
 #define STATE_CHANGED		1
diff --git a/myisam/sort.c b/myisam/sort.c
index 0e69e41ed5cd61db28125071c83673a1bd9040b2..50618e43991bd9e94536a1488f500e555758bf23 100644
--- a/myisam/sort.c
+++ b/myisam/sort.c
@@ -488,7 +488,7 @@ int thr_write_keys(MI_SORT_PARAM *sort_param)
           printf("Key %d  - Merging %u keys\n",sinfo->key+1, sinfo->keys);
         if (merge_many_buff(sinfo, keys, (uchar **)mergebuf,
 			    dynamic_element(&sinfo->buffpek, 0, BUFFPEK *),
-			    &maxbuffer, &sinfo->tempfile))
+			    (int*) &maxbuffer, &sinfo->tempfile))
         {
           got_error=1;
           continue;
diff --git a/myisammrg/Makefile.am b/myisammrg/Makefile.am
index 299b1a20d6ed6b95cb8c8ca00a95f0cc1e991dd9..b5b1260385b2d3815f1b3238140792a2bb4f698b 100644
--- a/myisammrg/Makefile.am
+++ b/myisammrg/Makefile.am
@@ -14,14 +14,15 @@
 # along with this program; if not, write to the Free Software
 # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
 
-INCLUDES =		@MT_INCLUDES@ -I$(srcdir)/../include -I../include
+INCLUDES =		@MT_INCLUDES@ -I$(top_srcdir)/include
 pkglib_LIBRARIES =	libmyisammrg.a
 noinst_HEADERS =	myrg_def.h
 libmyisammrg_a_SOURCES = myrg_open.c myrg_extra.c myrg_info.c myrg_locking.c \
 			myrg_rrnd.c myrg_update.c myrg_delete.c myrg_rsame.c \
 			myrg_panic.c myrg_close.c myrg_create.c myrg_static.c \
 			myrg_rkey.c myrg_rfirst.c myrg_rlast.c myrg_rnext.c \
-			myrg_rprev.c myrg_queue.c myrg_write.c
+			myrg_rprev.c myrg_queue.c myrg_write.c myrg_range.c \
+			myrg_rnext_same.c
 
 # Don't update the files from bitkeeper
 %::SCCS/s.%
diff --git a/myisammrg/myrg_range.c b/myisammrg/myrg_range.c
new file mode 100644
index 0000000000000000000000000000000000000000..7644ae40c7bae07787a5459c016224a76eb634cd
--- /dev/null
+++ b/myisammrg/myrg_range.c
@@ -0,0 +1,41 @@
+/* Copyright (C) 2000 MySQL AB & MySQL Finland AB & TCX DataKonsult AB
+
+   This program is free software; you can redistribute it and/or modify
+   it under the terms of the GNU General Public License as published by
+   the Free Software Foundation; either version 2 of the License, or
+   (at your option) any later version.
+
+   This program is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+   GNU General Public License for more details.
+
+   You should have received a copy of the GNU General Public License
+   along with this program; if not, write to the Free Software
+   Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA */
+
+#include "myrg_def.h"
+
+ha_rows myrg_records_in_range(MYRG_INFO *info, int inx, const byte *start_key,
+                              uint start_key_len,
+                              enum ha_rkey_function start_search_flag,
+                              const byte *end_key, uint end_key_len,
+                              enum ha_rkey_function end_search_flag)
+{
+  ha_rows records=0, res;
+  MYRG_TABLE *table;
+
+  for (table=info->open_tables ; table != info->end_table ; table++)
+  {
+    res=mi_records_in_range(table->table, inx,
+                start_key, start_key_len, start_search_flag,
+                  end_key,   end_key_len,   end_search_flag);
+    if (res == HA_POS_ERROR)
+      return HA_POS_ERROR; 
+    if (records > HA_POS_ERROR - res)
+      return HA_POS_ERROR-1;
+    records+=res;
+  }
+  return records;
+}
+
diff --git a/myisammrg/myrg_rkey.c b/myisammrg/myrg_rkey.c
index ba042352a51dd9de358cbe56a9201b5171aef1c4..c0cef5a4eca0efd6627f1cef4b928d7f2a60dd8e 100644
--- a/myisammrg/myrg_rkey.c
+++ b/myisammrg/myrg_rkey.c
@@ -62,9 +62,8 @@ int myrg_rkey(MYRG_INFO *info,byte *record,int inx, const byte *key,
     }
     else
     {
-      mi->use_packed_key=1;
+      mi->once_flags|= USE_PACKED_KEYS;
       err=mi_rkey(mi,0,inx,key_buff,pack_key_length,search_flag);
-      mi->use_packed_key=0;
     }
     info->last_used_table=table+1;
 
@@ -83,5 +82,6 @@ int myrg_rkey(MYRG_INFO *info,byte *record,int inx, const byte *key,
     return HA_ERR_KEY_NOT_FOUND;
 
   mi=(info->current_table=(MYRG_TABLE *)queue_top(&(info->by_key)))->table;
+  mi->once_flags|= RRND_PRESERVE_LASTINX;
   return mi_rrnd(mi,record,mi->lastpos);
 }
diff --git a/myisammrg/myrg_rnext_same.c b/myisammrg/myrg_rnext_same.c
new file mode 100644
index 0000000000000000000000000000000000000000..b569459b77d8aa900c152b8ff0278857426debfe
--- /dev/null
+++ b/myisammrg/myrg_rnext_same.c
@@ -0,0 +1,40 @@
+/* Copyright (C) 2000 MySQL AB & MySQL Finland AB & TCX DataKonsult AB
+
+   This program is free software; you can redistribute it and/or modify
+   it under the terms of the GNU General Public License as published by
+   the Free Software Foundation; either version 2 of the License, or
+   (at your option) any later version.
+
+   This program is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+   GNU General Public License for more details.
+
+   You should have received a copy of the GNU General Public License
+   along with this program; if not, write to the Free Software
+   Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA */
+
+#include "myrg_def.h"
+
+int myrg_rnext_same(MYRG_INFO *info, byte *buf)
+{
+  uint err;
+  MI_INFO *mi;
+
+  if (!info->current_table)
+    return (HA_ERR_KEY_NOT_FOUND);
+
+  err=mi_rnext_same(info->current_table->table,buf);
+  if (err == HA_ERR_END_OF_FILE)
+  {
+    queue_remove(&(info->by_key),0);
+    if (!info->by_key.elements)
+      return HA_ERR_END_OF_FILE;
+
+    mi=(info->current_table=(MYRG_TABLE *)queue_top(&(info->by_key)))->table;
+    mi->once_flags|= RRND_PRESERVE_LASTINX;
+    return mi_rrnd(mi,buf,mi->lastpos);
+  }
+  return err;
+}
+
diff --git a/mysql-test/mysql-test-run.sh b/mysql-test/mysql-test-run.sh
index cf9b6653c5a60a349ebb8325924357907b9cd355..d585243c6bc0a6212fc010d45d926f375c3defc0 100644
--- a/mysql-test/mysql-test-run.sh
+++ b/mysql-test/mysql-test-run.sh
@@ -56,6 +56,7 @@ sleep_until_file_deleted ()
       sleep $SLEEP_TIME_AFTER_RESTART
       return
     fi
+    sleep 1
     loop=`expr $loop - 1`
   done
 }
@@ -314,6 +315,17 @@ while test $# -gt 0; do
       DO_DDD=1
       USE_RUNNING_SERVER=""
       ;;
+    --valgrind)
+      VALGRIND="valgrind --alignment=8 --leak-check=yes"
+      EXTRA_MASTER_MYSQLD_OPT="$EXTRA_MASTER_MYSQLD_OPT --skip-safemalloc"
+      EXTRA_SLAVE_MYSQLD_OPT="$EXTRA_SLAVE_MYSQLD_OPT --skip-safemalloc"
+      SLEEP_TIME_AFTER_RESTART=120
+      SLEEP_TIME_FOR_DELETE=120
+      ;;
+    --valgrind-options=*)
+      TMP=`$ECHO "$1" | $SED -e "s;--valgrind-options=;;"`
+      VALGRIND="$VALGRIND $TMP"
+      ;;
     --skip-*)
       EXTRA_MASTER_MYSQLD_OPT="$EXTRA_MASTER_MYSQLD_OPT $1"
       EXTRA_SLAVE_MYSQLD_OPT="$EXTRA_SLAVE_MYSQLD_OPT $1"
@@ -374,6 +386,7 @@ fi
 [ -d $MYSQL_TEST_DIR/var ] || mkdir $MYSQL_TEST_DIR/var
 [ -d $MYSQL_TEST_DIR/var/tmp ] || mkdir $MYSQL_TEST_DIR/var/tmp
 [ -d $MYSQL_TEST_DIR/var/run ] || mkdir $MYSQL_TEST_DIR/var/run
+[ -d $MYSQL_TEST_DIR/var/log ] || mkdir $MYSQL_TEST_DIR/var/log
 
 if test ${COLUMNS:-0} -lt 80 ; then COLUMNS=80 ; fi
 E=`$EXPR $COLUMNS - 8`
@@ -382,7 +395,7 @@ DASH72=`$ECHO '-----------------------------------------------------------------
 # on source dist, we pick up freshly build executables
 # on binary, use what is installed
 if [ x$SOURCE_DIST = x1 ] ; then
- MYSQLD="$BASEDIR/sql/mysqld"
+ MYSQLD="$VALGRIND $BASEDIR/sql/mysqld"
  if [ -f "$BASEDIR/client/.libs/lt-mysqltest" ] ; then
    MYSQL_TEST="$BASEDIR/client/.libs/lt-mysqltest"
  elif [ -f "$BASEDIR/client/.libs/mysqltest" ] ; then
@@ -405,9 +418,9 @@ if [ x$SOURCE_DIST = x1 ] ; then
 else
  if test -x "$BASEDIR/libexec/mysqld"
  then
-   MYSQLD="$BASEDIR/libexec/mysqld"
+   MYSQLD="$VALGRIND $BASEDIR/libexec/mysqld"
  else
-   MYSQLD="$BASEDIR/bin/mysqld"
+   MYSQLD="$VALGRIND $BASEDIR/bin/mysqld"
  fi
  MYSQL_TEST="$BASEDIR/bin/mysqltest"
  MYSQLADMIN="$BASEDIR/bin/mysqladmin"
@@ -459,8 +472,8 @@ fi
 
 
 MYSQL_TEST_ARGS="--no-defaults --socket=$MASTER_MYSOCK --database=$DB \
- --user=$DBUSER --password=$DBPASSWD --silent -v \
- --tmpdir=$MYSQL_TMP_DIR"
+ --user=$DBUSER --password=$DBPASSWD --silent -v --skip-safemalloc \
+ --tmpdir=$MYSQL_TMP_DIR --port=$MASTER_MYPORT"
 MYSQL_TEST_BIN=$MYSQL_TEST
 MYSQL_TEST="$MYSQL_TEST $MYSQL_TEST_ARGS"
 GDB_CLIENT_INIT=$MYSQL_TMP_DIR/gdbinit.client
@@ -706,7 +719,7 @@ manager_launch()
   ident=$1
   shift
   if [ $USE_MANAGER = 0 ] ; then
-    $@  >$CUR_MYERR 2>&1  &
+    $@  >> $CUR_MYERR 2>&1  &
     sleep 2 #hack
     return
   fi
@@ -1052,6 +1065,8 @@ run_testcase ()
  slave_init_script=$TESTDIR/$tname-slave.sh
  slave_master_info_file=$TESTDIR/$tname-slave-master-info.opt
  echo $tname > $CURRENT_TEST
+ echo "CURRENT_TEST: $tname" >> $SLAVE_MYERR
+ echo "CURRENT_TEST: $tname" >> $MASTER_MYERR
  SKIP_SLAVE=`$EXPR \( $tname : rpl \) = 0`
  if [ $USE_MANAGER = 1 ] ; then
   many_slaves=`$EXPR \( $tname : rpl_failsafe \) != 0`
diff --git a/mysql-test/r/bdb-deadlock.result b/mysql-test/r/bdb-deadlock.result
index 74798a34a53d06808658c264e40778aff3a3329a..55b3d3ea2a56406e72e56be3722133477b11c257 100644
--- a/mysql-test/r/bdb-deadlock.result
+++ b/mysql-test/r/bdb-deadlock.result
@@ -9,23 +9,23 @@ set autocommit=0;
 update t2 set x = 1 where id = 0;
 select x from t1 where id = 0;
 select x from t2 where id = 0;
-commit;
 Deadlock found when trying to get lock; Try restarting transaction
 commit;
 x
 1
+commit;
 select * from t1;
+id	x
+0	1
 select * from t2;
 id	x
 0	1
 commit;
+select * from t1;
 id	x
 0	1
-select * from t1;
 select * from t2;
 id	x
 0	1
 commit;
-id	x
-0	1
 drop table t1,t2;
diff --git a/mysql-test/r/bdb.result b/mysql-test/r/bdb.result
index 0abf48041d621bd9b9a8a7ea463e4e47b1f05f67..ef4dfc307bfea7ccb1589955a29344a1578eff84 100644
--- a/mysql-test/r/bdb.result
+++ b/mysql-test/r/bdb.result
@@ -133,20 +133,20 @@ id	parent_id	level
 1202	107	2
 1204	107	2
 update ignore t1 set id=1023 where id=1010;
-select * from t1 where parent_id=102;
+select * from t1 where parent_id=102 order by parent_id,id;
 id	parent_id	level
 1008	102	2
-1015	102	2
 1010	102	2
+1015	102	2
 explain select level from t1 where level=1;
 id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
-1	SIMPLE	t1	ref	level	level	1	const	1	where used; Using index
+1	SIMPLE	t1	ref	level	level	1	const	1	Using where; Using index
 explain select level,id from t1 where level=1;
 id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
-1	SIMPLE	t1	ref	level	level	1	const	1	where used; Using index
+1	SIMPLE	t1	ref	level	level	1	const	1	Using where; Using index
 explain select level,id,parent_id from t1 where level=1;
 id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
-1	SIMPLE	t1	ref	level	level	1	const	1	where used
+1	SIMPLE	t1	ref	level	level	1	const	1	Using where
 select level,id from t1 where level=1;
 level	id
 1	1002
@@ -203,7 +203,7 @@ a
 2
 check table t1;
 Table	Op	Msg_type	Msg_text
-test.t1	check	error	The handler for the table doesn't support check/repair
+test.t1	check	error	The handler for the table doesn't support check
 drop table t1;
 create table t1 (a int,b varchar(20)) type=bdb;
 insert into t1 values (1,""), (2,"testing");
@@ -625,7 +625,7 @@ id	parent_id	level
 1016	102	2
 explain select level from t1 where level=1;
 id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
-1	SIMPLE	t1	ref	level	level	1	const	1	where used; Using index
+1	SIMPLE	t1	ref	level	level	1	const	1	Using where; Using index
 select level,id from t1 where level=1;
 level	id
 1	1004
diff --git a/mysql-test/r/bdb_cache.result b/mysql-test/r/bdb_cache.result
new file mode 100644
index 0000000000000000000000000000000000000000..e5c6923162ad2f6463fc2a73a2bca689d2e9f14d
--- /dev/null
+++ b/mysql-test/r/bdb_cache.result
@@ -0,0 +1,100 @@
+drop table if exists t1, t2, t3;
+flush status;
+set autocommit=0;
+create table t1 (a int not null) type=bdb;
+insert into t1 values (1),(2),(3);
+select * from t1;
+a
+1
+2
+3
+show status like "Qcache_queries_in_cache";
+Variable_name	Value
+Qcache_queries_in_cache	0
+drop table t1;
+commit;
+set autocommit=1;
+begin;
+create table t1 (a int not null) type=bdb;
+insert into t1 values (1),(2),(3);
+select * from t1;
+a
+1
+2
+3
+show status like "Qcache_queries_in_cache";
+Variable_name	Value
+Qcache_queries_in_cache	0
+drop table t1;
+commit;
+create table t1 (a int not null) type=bdb;
+create table t2 (a int not null) type=bdb;
+create table t3 (a int not null) type=bdb;
+insert into t1 values (1),(2);
+insert into t2 values (1),(2);
+insert into t3 values (1),(2);
+select * from t1;
+a
+1
+2
+select * from t2;
+a
+1
+2
+select * from t3;
+a
+1
+2
+show status like "Qcache_queries_in_cache";
+Variable_name	Value
+Qcache_queries_in_cache	3
+show status like "Qcache_hits";
+Variable_name	Value
+Qcache_hits	0
+begin;
+select * from t1;
+a
+1
+2
+select * from t2;
+a
+1
+2
+select * from t3;
+a
+1
+2
+show status like "Qcache_queries_in_cache";
+Variable_name	Value
+Qcache_queries_in_cache	3
+show status like "Qcache_hits";
+Variable_name	Value
+Qcache_hits	0
+insert into t1 values (3);
+insert into t2 values (3);
+insert into t1 values (4);
+select * from t1;
+a
+1
+2
+3
+4
+select * from t2;
+a
+1
+2
+3
+select * from t3;
+a
+1
+2
+show status like "Qcache_queries_in_cache";
+Variable_name	Value
+Qcache_queries_in_cache	3
+show status like "Qcache_hits";
+Variable_name	Value
+Qcache_hits	0
+commit;
+show status like "Qcache_queries_in_cache";
+Variable_name	Value
+Qcache_queries_in_cache	1
diff --git a/mysql-test/r/bigint.result b/mysql-test/r/bigint.result
index f666c5311b8ee3ac01045189dfe864333c6e71fd..6afa74d20e2af17563989186238253776afc5c4e 100644
--- a/mysql-test/r/bigint.result
+++ b/mysql-test/r/bigint.result
@@ -52,24 +52,3 @@ select min(big),max(big),max(big)-1 from t1 group by a;
 min(big)	max(big)	max(big)-1
 -1	9223372036854775807	9223372036854775806
 drop table t1;
-select CAST(1-2 AS UNSIGNED);
-CAST(1-2 AS UNSIGNED)
-18446744073709551615
-select CAST(CAST(1-2 AS UNSIGNED) AS SIGNED INTEGER);
-CAST(CAST(1-2 AS UNSIGNED) AS SIGNED INTEGER)
--1
-select CONVERT('-1',UNSIGNED);
-CONVERT('-1',UNSIGNED)
-18446744073709551615
-select cast(-5 as unsigned) | 1, cast(-5 as unsigned) & -1;
-cast(-5 as unsigned) | 1	cast(-5 as unsigned) & -1
-18446744073709551611	18446744073709551611
-select cast(-5 as unsigned) -1, cast(-5 as unsigned) + 1;
-cast(-5 as unsigned) -1	cast(-5 as unsigned) + 1
-18446744073709551610	18446744073709551612
-select ~5, cast(~5 as signed);
-~5	cast(~5 as signed)
-18446744073709551610	-6
-select cast(5 as unsigned) -6.0;
-cast(5 as unsigned) -6.0
--1.0
diff --git a/mysql-test/r/bool.result b/mysql-test/r/bool.result
new file mode 100644
index 0000000000000000000000000000000000000000..cb82c6baa0f50b1643121c84bec59cebeb083c49
--- /dev/null
+++ b/mysql-test/r/bool.result
@@ -0,0 +1,74 @@
+DROP TABLE IF EXISTS t1;
+SELECT IF(NULL AND 1, 1, 2), IF(1 AND NULL, 1, 2);
+IF(NULL AND 1, 1, 2)	IF(1 AND NULL, 1, 2)
+2	2
+SELECT NULL AND 1, 1 AND NULL, 0 AND NULL, NULL and 0;
+NULL AND 1	1 AND NULL	0 AND NULL	NULL and 0
+NULL	NULL	0	0
+create table t1 (a int);
+insert into t1 values (0),(1),(NULL);
+SELECT * FROM t1 WHERE IF(a AND 1, 0, 1);
+a
+0
+NULL
+SELECT * FROM t1 WHERE IF(1 AND a, 0, 1);
+a
+0
+NULL
+SELECT * FROM t1 where NOT(a AND 1);
+a
+0
+SELECT * FROM t1 where NOT(1 AND a);
+a
+0
+SELECT * FROM t1 where (a AND 1)=0;
+a
+0
+SELECT * FROM t1 where (1 AND a)=0;
+a
+0
+SELECT * FROM t1 where (1 AND a)=1;
+a
+1
+SELECT * FROM t1 where (1 AND a) IS NULL;
+a
+NULL
+SET @a=0, @b=0;
+SELECT * FROM t1 WHERE NULL AND (@a:=@a+1);
+a
+SELECT * FROM t1 WHERE NOT(a>=0 AND NULL AND (@b:=@b+1));
+a
+SELECT * FROM t1 WHERE a=2 OR (NULL AND (@a:=@a+1));
+a
+SELECT * FROM t1 WHERE NOT(a=2 OR (NULL AND (@b:=@b+1)));
+a
+SELECT @a, @b;
+@a	@b
+0	6
+DROP TABLE t1;
+drop table if exists t;
+create table t(a int, b int);
+insert into t values(null, null), (0, null), (1, null), (null, 0), (null, 1), (0, 0), (0, 1), (1, 0), (1, 1);
+select ifnull(A, 'N') as A, ifnull(B, 'N') as B, ifnull(not A, 'N') as nA, ifnull(not B, 'N') as nB, ifnull(A and B, 'N') as AB, ifnull(not (A and B), 'N') as `n(AB)`, ifnull((not A or not B), 'N') as nAonB, ifnull(A or B, 'N') as AoB, ifnull(not(A or B), 'N') as `n(AoB)`, ifnull(not A and not B, 'N') as nAnB from t;
+A	B	nA	nB	AB	n(AB)	nAonB	AoB	n(AoB)	nAnB
+N	N	N	N	N	N	N	N	N	N
+0	N	1	N	0	1	1	N	N	N
+1	N	0	N	N	N	N	1	0	0
+N	0	N	1	0	1	1	N	N	N
+N	1	N	0	N	N	N	1	0	0
+0	0	1	1	0	1	1	0	1	1
+0	1	1	0	0	1	1	1	0	0
+1	0	0	1	0	1	1	1	0	0
+1	1	0	0	1	0	0	1	0	0
+select ifnull(A=1, 'N') as A, ifnull(B=1, 'N') as B, ifnull(not (A=1), 'N') as nA, ifnull(not (B=1), 'N') as nB, ifnull((A=1) and (B=1), 'N') as AB, ifnull(not ((A=1) and (B=1)), 'N') as `n(AB)`, ifnull((not (A=1) or not (B=1)), 'N') as nAonB, ifnull((A=1) or (B=1), 'N') as AoB, ifnull(not((A=1) or (B=1)), 'N') as `n(AoB)`, ifnull(not (A=1) and not (B=1), 'N') as nAnB from t;
+A	B	nA	nB	AB	n(AB)	nAonB	AoB	n(AoB)	nAnB
+N	N	N	N	N	N	N	N	N	N
+0	N	1	N	0	1	1	N	N	N
+1	N	0	N	N	N	N	1	0	0
+N	0	N	1	0	1	1	N	N	N
+N	1	N	0	N	N	N	1	0	0
+0	0	1	1	0	1	1	0	1	1
+0	1	1	0	0	1	1	1	0	0
+1	0	0	1	0	1	1	1	0	0
+1	1	0	0	1	0	0	1	0	0
+drop table t;
diff --git a/mysql-test/r/cast.result b/mysql-test/r/cast.result
new file mode 100644
index 0000000000000000000000000000000000000000..572b32c171c224685bfe5425b540f7992c06ed1c
--- /dev/null
+++ b/mysql-test/r/cast.result
@@ -0,0 +1,39 @@
+select CAST(1-2 AS UNSIGNED);
+CAST(1-2 AS UNSIGNED)
+18446744073709551615
+select CAST(CAST(1-2 AS UNSIGNED) AS SIGNED INTEGER);
+CAST(CAST(1-2 AS UNSIGNED) AS SIGNED INTEGER)
+-1
+select CONVERT('-1',UNSIGNED);
+CONVERT('-1',UNSIGNED)
+18446744073709551615
+select cast(-5 as unsigned) | 1, cast(-5 as unsigned) & -1;
+cast(-5 as unsigned) | 1	cast(-5 as unsigned) & -1
+18446744073709551611	18446744073709551611
+select cast(-5 as unsigned) -1, cast(-5 as unsigned) + 1;
+cast(-5 as unsigned) -1	cast(-5 as unsigned) + 1
+18446744073709551610	18446744073709551612
+select ~5, cast(~5 as signed);
+~5	cast(~5 as signed)
+18446744073709551610	-6
+select cast(5 as unsigned) -6.0;
+cast(5 as unsigned) -6.0
+-1.0
+select cast("A" as binary) = "a", cast(BINARY "a" as CHAR) = "A";
+cast("A" as binary) = "a"	cast(BINARY "a" as CHAR) = "A"
+0	1
+select cast("2001-1-1" as DATE), cast("2001-1-1" as DATETIME);
+cast("2001-1-1" as DATE)	cast("2001-1-1" as DATETIME)
+2001-1-1	2001-1-1
+select cast("1:2:3" as TIME);
+cast("1:2:3" as TIME)
+1:2:3
+select cast("2001-1-1" as date) = "2001-01-01";
+cast("2001-1-1" as date) = "2001-01-01"
+0
+select cast("2001-1-1" as datetime) = "2001-01-01 00:00:00";
+cast("2001-1-1" as datetime) = "2001-01-01 00:00:00"
+0
+select cast("1:2:3" as TIME) = "1:02:03";
+cast("1:2:3" as TIME) = "1:02:03"
+0
diff --git a/mysql-test/r/compare.result b/mysql-test/r/compare.result
index 10f149e7a9b6aa8a00847c86a5570cb8fd386a8f..3ad3465fac05b2883a67adfc3e956a34f322c8e6 100644
--- a/mysql-test/r/compare.result
+++ b/mysql-test/r/compare.result
@@ -3,7 +3,7 @@ CREATE TABLE t1 (id CHAR(12) not null, PRIMARY KEY (id));
 insert into t1 values ('000000000001'),('000000000002');
 explain select * from t1 where id=000000000001;
 id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
-1	SIMPLE	t1	index	PRIMARY	PRIMARY	12	NULL	2	where used; Using index
+1	SIMPLE	t1	index	PRIMARY	PRIMARY	12	NULL	2	Using where; Using index
 select * from t1 where id=000000000001;
 id
 000000000001
diff --git a/mysql-test/r/constraints.result b/mysql-test/r/constraints.result
new file mode 100644
index 0000000000000000000000000000000000000000..3b41e291e0fb0662517a87406921fc587325cd58
--- /dev/null
+++ b/mysql-test/r/constraints.result
@@ -0,0 +1,16 @@
+drop table if exists t1;
+create table t1 (a int check (a>0));
+insert into t1 values (1);
+insert into t1 values (0);
+drop table t1;
+create table t1 (a int ,b int, check a>b);
+insert into t1 values (1,0);
+insert into t1 values (0,1);
+drop table t1;
+create table t1 (a int ,b int, constraint abc check (a>b));
+insert into t1 values (1,0);
+insert into t1 values (0,1);
+drop table t1;
+create table t1 (a int null);
+insert into t1 values (1),(NULL);
+drop table t1;
diff --git a/mysql-test/r/create.result b/mysql-test/r/create.result
index cc1780a12d05fcf47b284cd572109dd9dfa17e46..0be0d624fca502598e741a25f6ed0b9b8a5e4ce7 100644
--- a/mysql-test/r/create.result
+++ b/mysql-test/r/create.result
@@ -62,7 +62,7 @@ insert into t1 (b) values ("hello"),("my"),("world");
 create table t2 (key (b)) select * from t1;
 explain select * from t2 where b="world";
 id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
-1	SIMPLE	t2	ref	B	B	21	const	1	where used
+1	SIMPLE	t2	ref	B	B	21	const	1	Using where
 select * from t2 where b="world";
 a	B
 3	world
@@ -158,3 +158,6 @@ select * from t1;
 if('2002'='2002','Y','N')
 Y
 drop table if exists t1;
+create table t1 (a int, key(a));
+create table t2 (b int, foreign key(b) references t1(a), key(b));
+drop table if exists t1,t2;
diff --git a/mysql-test/r/derived.result b/mysql-test/r/derived.result
index d3fbd5571563386cf5d19fe46b0841c08abf9978..b397c2f7635663400e55757d0ed01f54e957825b 100644
--- a/mysql-test/r/derived.result
+++ b/mysql-test/r/derived.result
@@ -17,6 +17,19 @@ select t1.a,t4.y from t1,(select t2.a as y from t2,(select t3.b from t3 where t3
 a	y
 3	3
 3	3
+SELECT a FROM (SELECT 1 FROM (SELECT 1) HAVING a=1);
+Unknown column 'a' in 'having clause'
+SELECT a,b as a FROM (SELECT '1' as a,'2' as b) HAVING a=1;
+Column: 'a' in having clause is ambiguous
+SELECT a,2 as a FROM (SELECT '1' as a) HAVING a=2;
+a	a
+1	2
+SELECT a,2 as a FROM (SELECT '1' as a) HAVING a=1;
+a	a
+SELECT 1 FROM (SELECT 1) WHERE a=2;
+Unknown column 'a' in 'where clause'
+SELECT (SELECT 1) as a FROM (SELECT 1 FROM t1  HAVING a=1);
+Unknown column 'a' in 'having clause'
 drop table if exists  t1.t2,t3;
 select * from (select 1);
 1
@@ -24,3 +37,34 @@ select * from (select 1);
 select a from (select 1 as a);
 a
 1
+select 1 from (select 1);
+1
+1
+drop table if exists t1;
+create table t1(a int not null, t char(8), index(a));
+SELECT * FROM (SELECT * FROM t1) ORDER BY a  ASC LIMIT 0,20;
+a	t
+1	1
+2	2
+3	3
+4	4
+5	5
+6	6
+7	7
+8	8
+9	9
+10	10
+11	11
+12	12
+13	13
+14	14
+15	15
+16	16
+17	17
+18	18
+19	19
+20	20
+drop table if exists  t1;
+SELECT * FROM (SELECT (SELECT * FROM (SELECT 1 as a)));
+(SELECT * FROM (SELECT 1 as a))
+1
diff --git a/mysql-test/r/distinct.result b/mysql-test/r/distinct.result
index 057e0308313c25c9c78453ccbabd0e103c4f5773..fec5ece8ddfb4279a8f9263d41b2311cacf41097 100644
--- a/mysql-test/r/distinct.result
+++ b/mysql-test/r/distinct.result
@@ -175,7 +175,7 @@ explain SELECT distinct t3.a FROM t3,t2,t1 WHERE t3.a=t1.b AND t1.a=t2.a;
 id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
 1	SIMPLE	t3	index	a	a	5	NULL	6	Using index; Using temporary
 1	SIMPLE	t2	index	a	a	4	NULL	5	Using index; Distinct
-1	SIMPLE	t1	eq_ref	PRIMARY	PRIMARY	4	t2.a	1	where used; Distinct
+1	SIMPLE	t1	eq_ref	PRIMARY	PRIMARY	4	t2.a	1	Using where; Distinct
 SELECT distinct t3.a FROM t3,t2,t1 WHERE t3.a=t1.b AND t1.a=t2.a;
 a
 1
@@ -190,7 +190,7 @@ insert into t3 select * from t4;
 explain select distinct t1.a from t1,t3 where t1.a=t3.a;
 id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
 1	SIMPLE	t1	index	PRIMARY	PRIMARY	4	NULL	2	Using index; Using temporary
-1	SIMPLE	t3	ref	a	a	5	t1.a	10	where used; Using index; Distinct
+1	SIMPLE	t3	ref	a	a	5	t1.a	10	Using where; Using index; Distinct
 select distinct t1.a from t1,t3 where t1.a=t3.a;
 a
 1
@@ -278,10 +278,10 @@ id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
 1	SIMPLE	t1	index	id	id	4	NULL	2	Using index; Using temporary
 1	SIMPLE	t2	index	id	id	8	NULL	1	Using index; Distinct
 1	SIMPLE	t3	index	id	id	8	NULL	1	Using index; Distinct
-1	SIMPLE	j_lj_t2	index	id	id	4	NULL	2	where used; Using index; Distinct
-1	SIMPLE	t2_lj	index	id	id	8	NULL	1	where used; Using index; Distinct
-1	SIMPLE	j_lj_t3	index	id	id	4	NULL	2	where used; Using index; Distinct
-1	SIMPLE	t3_lj	index	id	id	8	NULL	1	where used; Using index; Distinct
+1	SIMPLE	j_lj_t2	index	id	id	4	NULL	2	Using where; Using index; Distinct
+1	SIMPLE	t2_lj	index	id	id	8	NULL	1	Using where; Using index; Distinct
+1	SIMPLE	j_lj_t3	index	id	id	4	NULL	2	Using where; Using index; Distinct
+1	SIMPLE	t3_lj	index	id	id	8	NULL	1	Using where; Using index; Distinct
 SELECT DISTINCT
 t1.id
 from
diff --git a/mysql-test/r/explain.result b/mysql-test/r/explain.result
index 0d97aeaf5316d85a98d403c04c8a2ec6158fe645..dafed9a7d413055fffc9d8527eac490c79a2e9cf 100644
--- a/mysql-test/r/explain.result
+++ b/mysql-test/r/explain.result
@@ -10,13 +10,13 @@ id	str
 3	foo
 explain select * from t1 where str is null;
 id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
-1	SIMPLE	t1	ref	str	str	11	const	1	where used
+1	SIMPLE	t1	ref	str	str	11	const	1	Using where
 explain select * from t1 where str="foo";
 id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
 1	SIMPLE	t1	const	str	str	11	const	1	
 explain select * from t1 ignore key (str) where str="foo";
 id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
-1	SIMPLE	t1	ALL	NULL	NULL	NULL	NULL	4	where used
+1	SIMPLE	t1	ALL	NULL	NULL	NULL	NULL	4	Using where
 explain select * from t1 use key (str,str) where str="foo";
 id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
 1	SIMPLE	t1	const	str	str	11	const	1	
diff --git a/mysql-test/r/fulltext.result b/mysql-test/r/fulltext.result
index ea6327320171d6dcc46abb295b8abcacf4153877..a991981bf2120609f620abad21b79b2bd2d1c97c 100644
--- a/mysql-test/r/fulltext.result
+++ b/mysql-test/r/fulltext.result
@@ -85,6 +85,9 @@ Full-text search in MySQL	implements vector space model
 select * from t1 where MATCH a,b AGAINST ('"text search" +"now support"' IN BOOLEAN MODE);
 a	b
 MySQL has now support	for full-text search
+select * from t1 where MATCH a,b AGAINST ('"text i"' IN BOOLEAN MODE);
+a	b
+Full-text indexes	are called collections
 select * from t1 where MATCH a AGAINST ("search" IN BOOLEAN MODE);
 a	b
 Full-text search in MySQL	implements vector space model
diff --git a/mysql-test/r/func_system.result b/mysql-test/r/func_system.result
index 5ea4ed5e4e0347260c4c90de19662def53720215..83c2ad6e02099a58435933308d92fb1b6b6ddb26 100644
--- a/mysql-test/r/func_system.result
+++ b/mysql-test/r/func_system.result
@@ -4,3 +4,6 @@ test	1
 select version()>="3.23.29";
 version()>="3.23.29"
 1
+select TRUE,FALSE,NULL;
+TRUE	FALSE	NULL
+1	0	NULL
diff --git a/mysql-test/r/func_test.result b/mysql-test/r/func_test.result
index 8cfae44b9ddbf6fb5924875bb1a47a658e648fb7..9fcf03db838cfd19750e01d1b28b567ba128c4a9 100644
--- a/mysql-test/r/func_test.result
+++ b/mysql-test/r/func_test.result
@@ -46,6 +46,9 @@ select 3 ^ 11, 1 ^ 1, 1 ^ 0, 1 ^ NULL, NULL ^ 1;
 select 1 XOR 1, 1 XOR 0, 0 XOR 1, 0 XOR 0, NULL XOR 1, 1 XOR NULL, 0 XOR NULL;
 1 XOR 1	1 XOR 0	0 XOR 1	0 XOR 0	NULL XOR 1	1 XOR NULL	0 XOR NULL
 0	1	1	0	NULL	NULL	NULL
+select 10 % 7, 10 mod 7, 10 div 3;
+10 % 7	10 mod 7	10 div 3
+3	3	3
 select 5 between 0 and 10 between 0 and 1,(5 between 0 and 10) between 0 and 1;
 5 between 0 and 10 between 0 and 1	(5 between 0 and 10) between 0 and 1
 0	1
diff --git a/mysql-test/r/func_time.result b/mysql-test/r/func_time.result
index 5433194c71968e39ebc67869bd84726a4a535d5a..2941352c7762b8be7616bc8c4e87c0ed1d090629 100644
--- a/mysql-test/r/func_time.result
+++ b/mysql-test/r/func_time.result
@@ -1,4 +1,4 @@
-drop table if exists t1,t2;
+drop table if exists t1,t2,t3;
 select from_days(to_days("960101")),to_days(960201)-to_days("19960101"),to_days(date_add(curdate(), interval 1 day))-to_days(curdate()),weekday("1997-11-29");
 from_days(to_days("960101"))	to_days(960201)-to_days("19960101")	to_days(date_add(curdate(), interval 1 day))-to_days(curdate())	weekday("1997-11-29")
 1996-01-01	31	1	5
@@ -24,6 +24,12 @@ now()-curdate()*1000000-curtime()
 select strcmp(current_timestamp(),concat(current_date()," ",current_time()));
 strcmp(current_timestamp(),concat(current_date()," ",current_time()))
 0
+select strcmp(localtime(),concat(current_date()," ",current_time()));
+strcmp(localtime(),concat(current_date()," ",current_time()))
+0
+select strcmp(localtimestamp(),concat(current_date()," ",current_time()));
+strcmp(localtimestamp(),concat(current_date()," ",current_time()))
+0
 select date_format("1997-01-02 03:04:05", "%M %W %D %Y %y %m %d %h %i %s %w");
 date_format("1997-01-02 03:04:05", "%M %W %D %Y %y %m %d %h %i %s %w")
 January Thursday 2nd 1997 97 01 02 03 04 05 4
@@ -84,6 +90,12 @@ select yearweek("2000-01-01",1) as '2000', yearweek("2001-01-01",1) as '2001', y
 select yearweek("2000-01-06",1) as '2000', yearweek("2001-01-06",1) as '2001', yearweek("2002-01-06",1) as '2002',yearweek("2003-01-06",1) as '2003', yearweek("2004-01-06",1) as '2004', yearweek("2005-01-06",1) as '2005', yearweek("2006-01-06",1) as '2006';
 2000	2001	2002	2003	2004	2005	2006
 200001	200101	200201	200302	200402	200501	200601
+select week(19981231,2), week(19981231,3), week(20000101,2), week(20000101,3);
+week(19981231,2)	week(19981231,3)	week(20000101,2)	week(20000101,3)
+52	53	52	52
+select week(20001231,2),week(20001231,3);
+week(20001231,2)	week(20001231,3)
+1	52
 select date_format('1998-12-31','%x-%v'),date_format('1999-01-01','%x-%v');
 date_format('1998-12-31','%x-%v')	date_format('1999-01-01','%x-%v')
 1998-53	1998-53
@@ -372,3 +384,19 @@ select extract(MONTH FROM "0000-00-00"),extract(MONTH FROM d),extract(MONTH FROM
 extract(MONTH FROM "0000-00-00")	extract(MONTH FROM d)	extract(MONTH FROM dt)	extract(MONTH FROM t)	extract(MONTH FROM c)
 0	0	0	0	0
 drop table t1;
+CREATE TABLE t1 ( start datetime default NULL);
+INSERT INTO t1 VALUES ('2002-10-21 00:00:00'),('2002-10-28 00:00:00'),('2002-11-04 00:00:00');
+CREATE TABLE t2 ( ctime1 timestamp(14) NOT NULL, ctime2 timestamp(14) NOT NULL);
+INSERT INTO t2 VALUES (20021029165106,20021105164731);
+CREATE TABLE t3 (ctime1 char(19) NOT NULL, ctime2 char(19) NOT NULL);
+INSERT INTO t3 VALUES ("2002-10-29 16:51:06","2002-11-05 16:47:31");
+select * from t1, t2 where t1.start between t2.ctime1 and t2.ctime2;
+start	ctime1	ctime2
+2002-11-04 00:00:00	20021029165106	20021105164731
+select * from t1, t2 where t1.start >= t2.ctime1 and t1.start <= t2.ctime2;
+start	ctime1	ctime2
+2002-11-04 00:00:00	20021029165106	20021105164731
+select * from t1, t3 where t1.start between t3.ctime1 and t3.ctime2;
+start	ctime1	ctime2
+2002-11-04 00:00:00	2002-10-29 16:51:06	2002-11-05 16:47:31
+drop table t1,t2,t3;
diff --git a/mysql-test/r/group_by.result b/mysql-test/r/group_by.result
index 449d7bcb818045faca30f7a41616a2b7468e5475..ead9935f824ad3b88f20ce228f362dea0bc7ae66 100644
--- a/mysql-test/r/group_by.result
+++ b/mysql-test/r/group_by.result
@@ -1,4 +1,6 @@
-drop table if exists t1,t2;
+SELECT 1 FROM (SELECT 1) GROUP BY SUM(1);
+Invalid use of group function
+drop table if exists t1,t2,t3;
 CREATE TABLE t1 (
 spID int(10) unsigned,
 userID int(10) unsigned,
@@ -234,10 +236,10 @@ userid	count(*)
 1	2
 explain select spid,count(*) from t1 where spid between 1 and 2 group by spid desc;
 id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
-1	SIMPLE	t1	range	spID	spID	5	NULL	2	where used; Using index
+1	SIMPLE	t1	range	spID	spID	5	NULL	2	Using where; Using index
 explain select spid,count(*) from t1 where spid between 1 and 2 group by spid;
 id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
-1	SIMPLE	t1	range	spID	spID	5	NULL	2	where used; Using index
+1	SIMPLE	t1	range	spID	spID	5	NULL	2	Using where; Using index
 select spid,count(*) from t1 where spid between 1 and 2 group by spid;
 spid	count(*)
 1	1
@@ -417,3 +419,38 @@ xID	xID1	Level
 3	134	***
 4	185	****
 drop table t1;
+CREATE TABLE t1 (
+pid int(11) unsigned NOT NULL default '0',
+c1id int(11) unsigned default NULL,
+c2id int(11) unsigned default NULL,
+value int(11) unsigned NOT NULL default '0',
+UNIQUE KEY pid2 (pid,c1id,c2id),
+UNIQUE KEY pid (pid,value)
+) TYPE=MyISAM;
+INSERT INTO t1 VALUES (1, 1, NULL, 1),(1, 2, NULL, 2),(1, NULL, 3, 3),(1, 4, NULL, 4),(1, 5, NULL, 5);
+CREATE TABLE t2 (
+id int(11) unsigned NOT NULL default '0',
+active enum('Yes','No') NOT NULL default 'Yes',
+PRIMARY KEY  (id)
+) TYPE=MyISAM;
+INSERT INTO t2 VALUES (1, 'Yes'),(2, 'No'),(4, 'Yes'),(5, 'No');
+CREATE TABLE t3 (
+id int(11) unsigned NOT NULL default '0',
+active enum('Yes','No') NOT NULL default 'Yes',
+PRIMARY KEY  (id)
+);
+INSERT INTO t3 VALUES (3, 'Yes');
+select * from t1 AS m LEFT JOIN t2 AS c1 ON m.c1id = 
+c1.id AND c1.active = 'Yes' LEFT JOIN t3 AS c2 ON m.c2id = c2.id AND 
+c2.active = 'Yes' WHERE m.pid=1  AND (c1.id IS NOT NULL OR c2.id IS NOT NULL);
+pid	c1id	c2id	value	id	active	id	active
+1	1	NULL	1	1	Yes	NULL	NULL
+1	NULL	3	3	NULL	NULL	3	Yes
+1	4	NULL	4	4	Yes	NULL	NULL
+select max(value) from t1 AS m LEFT JOIN t2 AS c1 ON 
+m.c1id = c1.id AND c1.active = 'Yes' LEFT JOIN t3 AS c2 ON m.c2id = 
+c2.id AND c2.active = 'Yes' WHERE m.pid=1  AND (c1.id IS NOT NULL OR c2.id IS 
+NOT NULL);
+max(value)
+4
+drop table t1,t2,t3;
diff --git a/mysql-test/r/heap.result b/mysql-test/r/heap.result
index 8fe87cdda8b228eb45351849d3888bd7ad298542..ffd62ceabb6ce7b90b9bd7cf3d963445651cd592 100644
--- a/mysql-test/r/heap.result
+++ b/mysql-test/r/heap.result
@@ -66,7 +66,7 @@ a
 alter table t1 type=myisam;
 explain select * from t1 where a in (869751,736494,226312,802616);
 id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
-1	SIMPLE	t1	range	uniq_id	uniq_id	4	NULL	4	where used; Using index
+1	SIMPLE	t1	range	uniq_id	uniq_id	4	NULL	4	Using where; Using index
 drop table t1;
 create table t1 (x int not null, y int not null, key x (x), unique y (y))
 type=heap;
@@ -159,17 +159,17 @@ create table t1 (btn char(10) not null, key(btn)) type=heap;
 insert into t1 values ("hello"),("hello"),("hello"),("hello"),("hello"),("a"),("b"),("c"),("d"),("e"),("f"),("g"),("h"),("i");
 explain select * from t1 where btn like "q%";
 id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
-1	SIMPLE	t1	ALL	btn	NULL	NULL	NULL	14	where used
+1	SIMPLE	t1	ALL	btn	NULL	NULL	NULL	14	Using where
 select * from t1 where btn like "q%";
 btn
 alter table t1 add column new_col char(1) not null, add key (btn,new_col), drop key btn;
 update t1 set new_col=btn;
 explain select * from t1 where btn="a";
 id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
-1	SIMPLE	t1	ALL	btn	NULL	NULL	NULL	14	where used
+1	SIMPLE	t1	ALL	btn	NULL	NULL	NULL	14	Using where
 explain select * from t1 where btn="a" and new_col="a";
 id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
-1	SIMPLE	t1	ref	btn	btn	11	const,const	10	where used
+1	SIMPLE	t1	ref	btn	btn	11	const,const	10	Using where
 drop table t1;
 CREATE TABLE t1 (
 a int default NULL,
@@ -182,7 +182,7 @@ SELECT * FROM t1 WHERE a=NULL;
 a	b
 explain SELECT * FROM t1 WHERE a IS NULL;
 id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
-1	SIMPLE	t1	ref	a	a	5	const	10	where used
+1	SIMPLE	t1	ref	a	a	5	const	10	Using where
 SELECT * FROM t1 WHERE a<=>NULL;
 a	b
 NULL	99
@@ -190,7 +190,7 @@ SELECT * FROM t1 WHERE b=NULL;
 a	b
 explain SELECT * FROM t1 WHERE b IS NULL;
 id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
-1	SIMPLE	t1	ref	b	b	5	const	1	where used
+1	SIMPLE	t1	ref	b	b	5	const	1	Using where
 SELECT * FROM t1 WHERE b<=>NULL;
 a	b
 99	NULL
diff --git a/mysql-test/r/heap_btree.result b/mysql-test/r/heap_btree.result
index 12d07bf6660954f0c78e4372e9dd28f6fa0c30a1..bf24f78321fbde27f1736d6e950822f08629c12f 100644
--- a/mysql-test/r/heap_btree.result
+++ b/mysql-test/r/heap_btree.result
@@ -66,14 +66,14 @@ a
 alter table t1 type=myisam;
 explain select * from t1 where a in (869751,736494,226312,802616);
 id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
-1	SIMPLE	t1	range	uniq_id	uniq_id	4	NULL	4	where used; Using index
+1	SIMPLE	t1	range	uniq_id	uniq_id	4	NULL	4	Using where; Using index
 drop table t1;
 create table t1 (x int not null, y int not null, key x  using BTREE (x,y), unique y  using BTREE (y))
 type=heap;
 insert into t1 values (1,1),(2,2),(1,3),(2,4),(2,5),(2,6);
 explain select * from t1 where x=1;
 id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
-1	SIMPLE	t1	ref	x	x	4	const	1	where used
+1	SIMPLE	t1	ref	x	x	4	const	1	Using where
 select * from t1 where x=1;
 x	y
 1	1
@@ -124,17 +124,17 @@ a	b
 1	6
 explain select * from tx where a=x order by a,b;
 id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
-x	SIMPLE	tx	ref	a	a	x	const	x	where used
+x	SIMPLE	tx	ref	a	a	x	const	x	Using where
 explain select * from tx where a=x order by b;
 id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
-x	SIMPLE	tx	ref	a	a	x	const	x	where used
+x	SIMPLE	tx	ref	a	a	x	const	x	Using where
 select * from t1 where b=1;
 a	b
 1	1
 1	1
 explain select * from tx where b=x;
 id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
-x	SIMPLE	tx	ref	b	b	x	const	x	where used
+x	SIMPLE	tx	ref	b	b	x	const	x	Using where
 drop table t1;
 create table t1 (id int unsigned not null, primary key  using BTREE (id)) type=HEAP;
 insert into t1 values(1);
@@ -175,17 +175,17 @@ create table t1 (btn char(10) not null, key using BTREE (btn)) type=heap;
 insert into t1 values ("hello"),("hello"),("hello"),("hello"),("hello"),("a"),("b"),("c"),("d"),("e"),("f"),("g"),("h"),("i");
 explain select * from t1 where btn like "q%";
 id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
-1	SIMPLE	t1	ALL	btn	NULL	NULL	NULL	14	where used
+1	SIMPLE	t1	ALL	btn	NULL	NULL	NULL	14	Using where
 select * from t1 where btn like "q%";
 btn
 alter table t1 add column new_col char(1) not null, add key using BTREE (btn,new_col), drop key btn;
 update t1 set new_col=btn;
 explain select * from t1 where btn="a";
 id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
-1	SIMPLE	t1	ref	btn	btn	10	const	1	where used
+1	SIMPLE	t1	ref	btn	btn	10	const	1	Using where
 explain select * from t1 where btn="a" and new_col="a";
 id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
-1	SIMPLE	t1	ref	btn	btn	11	const,const	1	where used
+1	SIMPLE	t1	ref	btn	btn	11	const,const	1	Using where
 drop table t1;
 CREATE TABLE t1 (
 a int default NULL,
@@ -198,7 +198,7 @@ SELECT * FROM t1 WHERE a=NULL;
 a	b
 explain SELECT * FROM t1 WHERE a IS NULL;
 id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
-1	SIMPLE	t1	ref	a	a	5	const	1	where used
+1	SIMPLE	t1	ref	a	a	5	const	1	Using where
 SELECT * FROM t1 WHERE a<=>NULL;
 a	b
 NULL	99
@@ -206,13 +206,27 @@ SELECT * FROM t1 WHERE b=NULL;
 a	b
 explain SELECT * FROM t1 WHERE b IS NULL;
 id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
-1	SIMPLE	t1	ref	b	b	5	const	1	where used
+1	SIMPLE	t1	ref	b	b	5	const	1	Using where
 SELECT * FROM t1 WHERE b<=>NULL;
 a	b
 99	NULL
 INSERT INTO t1 VALUES (1,3);
 Duplicate entry '3' for key 1
 DROP TABLE t1;
+CREATE TABLE t1 (a int, b int, c int, key using BTREE (a, b, c)) type=heap;
+INSERT INTO t1 VALUES (1, NULL, NULL), (1, 1, NULL), (1, NULL, 1);
+SELECT * FROM t1 WHERE a=1 and b IS NULL;
+a	b	c
+1	NULL	NULL
+1	NULL	1
+SELECT * FROM t1 WHERE a=1 and c IS NULL;
+a	b	c
+1	NULL	NULL
+1	1	NULL
+SELECT * FROM t1 WHERE a=1 and b IS NULL and c IS NULL;
+a	b	c
+1	NULL	NULL
+DROP TABLE t1;
 CREATE TABLE t1 (a int not null, primary key using BTREE (a)) type=heap;
 INSERT into t1 values (1),(2),(3),(4),(5),(6),(7),(8),(9),(10),(11);
 DELETE from t1 where a < 100;
diff --git a/mysql-test/r/heap_hash.result b/mysql-test/r/heap_hash.result
index 43a86069d3d0c7f4ffa66b9a7687b16f645aa38b..3c2baa645f7b58b9aef84d11ef99909cb6cfd663 100644
--- a/mysql-test/r/heap_hash.result
+++ b/mysql-test/r/heap_hash.result
@@ -66,7 +66,7 @@ a
 alter table t1 type=myisam;
 explain select * from t1 where a in (869751,736494,226312,802616);
 id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
-1	SIMPLE	t1	range	uniq_id	uniq_id	4	NULL	4	where used; Using index
+1	SIMPLE	t1	range	uniq_id	uniq_id	4	NULL	4	Using where; Using index
 drop table t1;
 create table t1 (x int not null, y int not null, key x  using HASH (x), unique y  using HASH (y))
 type=heap;
@@ -159,17 +159,17 @@ create table t1 (btn char(10) not null, key using HASH (btn)) type=heap;
 insert into t1 values ("hello"),("hello"),("hello"),("hello"),("hello"),("a"),("b"),("c"),("d"),("e"),("f"),("g"),("h"),("i");
 explain select * from t1 where btn like "q%";
 id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
-1	SIMPLE	t1	ALL	btn	NULL	NULL	NULL	14	where used
+1	SIMPLE	t1	ALL	btn	NULL	NULL	NULL	14	Using where
 select * from t1 where btn like "q%";
 btn
 alter table t1 add column new_col char(1) not null, add key using HASH (btn,new_col), drop key btn;
 update t1 set new_col=btn;
 explain select * from t1 where btn="a";
 id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
-1	SIMPLE	t1	ALL	btn	NULL	NULL	NULL	14	where used
+1	SIMPLE	t1	ALL	btn	NULL	NULL	NULL	14	Using where
 explain select * from t1 where btn="a" and new_col="a";
 id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
-1	SIMPLE	t1	ref	btn	btn	11	const,const	10	where used
+1	SIMPLE	t1	ref	btn	btn	11	const,const	10	Using where
 drop table t1;
 CREATE TABLE t1 (
 a int default NULL,
@@ -182,7 +182,7 @@ SELECT * FROM t1 WHERE a=NULL;
 a	b
 explain SELECT * FROM t1 WHERE a IS NULL;
 id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
-1	SIMPLE	t1	ref	a	a	5	const	10	where used
+1	SIMPLE	t1	ref	a	a	5	const	10	Using where
 SELECT * FROM t1 WHERE a<=>NULL;
 a	b
 NULL	99
@@ -190,7 +190,7 @@ SELECT * FROM t1 WHERE b=NULL;
 a	b
 explain SELECT * FROM t1 WHERE b IS NULL;
 id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
-1	SIMPLE	t1	ref	b	b	5	const	1	where used
+1	SIMPLE	t1	ref	b	b	5	const	1	Using where
 SELECT * FROM t1 WHERE b<=>NULL;
 a	b
 99	NULL
diff --git a/mysql-test/r/innodb-deadlock.result b/mysql-test/r/innodb-deadlock.result
new file mode 100644
index 0000000000000000000000000000000000000000..db7155f14fbc71cb93a4b2fd5789102a46b4e9f8
--- /dev/null
+++ b/mysql-test/r/innodb-deadlock.result
@@ -0,0 +1,97 @@
+drop table if exists t1;
+create table t1 (id integer, x integer) type=INNODB;
+insert into t1 values(0, 0);
+set autocommit=0;
+SELECT * from t1 where id = 0 FOR UPDATE;
+id	x
+0	0
+set autocommit=0;
+update t1 set x=2 where id = 0;
+update t1 set x=1 where id = 0;
+select * from t1;
+id	x
+0	1
+commit;
+commit;
+select * from t1;
+id	x
+0	2
+commit;
+drop table t1;
+drop table if exists t1, t2;
+create table t1 (id integer, x integer) type=INNODB;
+create table t2 (b integer, a integer) type=INNODB;
+insert into t1 values(0, 0), (300, 300);
+insert into t2 values(0, 10), (1, 20), (2, 30);
+commit;
+set autocommit=0;
+select * from t2;
+b	a
+0	10
+1	20
+2	30
+update t2 set a=100 where b=(SELECT x from t1 where id = b FOR UPDATE);
+select * from t2;
+b	a
+0	100
+1	20
+2	30
+select * from t1;
+id	x
+0	0
+300	300
+set autocommit=0;
+update t1 set x=2 where id = 0;
+update t1 set x=1 where id = 0;
+select * from t1;
+id	x
+0	1
+300	300
+commit;
+commit;
+select * from t1;
+id	x
+0	2
+300	300
+commit;
+drop table t1, t2;
+create table t1 (id integer, x integer) type=INNODB;
+create table t2 (b integer, a integer) type=INNODB;
+insert into t1 values(0, 0), (300, 300);
+insert into t2 values(0, 0), (1, 20), (2, 30);
+commit;
+select a,b from t2 UNION SELECT id, x from t1 FOR UPDATE;
+a	b
+0	0
+20	1
+30	2
+300	300
+select * from t2;
+b	a
+0	0
+1	20
+2	30
+select * from t1;
+id	x
+0	0
+300	300
+update t2 set a=2 where b = 0;
+select * from t2;
+b	a
+0	2
+1	20
+2	30
+update t1 set x=2 where id = 0;
+update t1 set x=1 where id = 0;
+select * from t1;
+id	x
+0	1
+300	300
+commit;
+commit;
+select * from t1;
+id	x
+0	2
+300	300
+commit;
+drop table t1, t2;
diff --git a/mysql-test/r/innodb.result b/mysql-test/r/innodb.result
index 8f1397995777f09bb985b8283fa377aa317c3504..81064143872b1d39586b8a2e6c22e15eddd286ae 100644
--- a/mysql-test/r/innodb.result
+++ b/mysql-test/r/innodb.result
@@ -140,13 +140,13 @@ id	parent_id	level
 1015	102	2
 explain select level from t1 where level=1;
 id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
-1	SIMPLE	t1	ref	level	level	1	const	12	where used; Using index
+1	SIMPLE	t1	ref	level	level	1	const	12	Using where; Using index
 explain select level,id from t1 where level=1;
 id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
-1	SIMPLE	t1	ref	level	level	1	const	12	where used; Using index
+1	SIMPLE	t1	ref	level	level	1	const	12	Using where; Using index
 explain select level,id,parent_id from t1 where level=1;
 id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
-1	SIMPLE	t1	ref	level	level	1	const	12	where used
+1	SIMPLE	t1	ref	level	level	1	const	12	Using where
 select level,id from t1 where level=1;
 level	id
 1	1002
@@ -165,7 +165,7 @@ level	id	parent_id
 1	1007	101
 optimize table t1;
 Table	Op	Msg_type	Msg_text
-test.t1	optimize	error	The handler for the table doesn't support check/repair
+test.t1	optimize	error	The handler for the table doesn't support optimize
 show keys from t1;
 Table	Non_unique	Key_name	Seq_in_index	Column_name	Collation	Cardinality	Sub_part	Packed	Null	Index_type	Comment
 t1	0	PRIMARY	1	id	A	87	NULL	NULL		BTREE	
@@ -189,7 +189,7 @@ create table t1 (a int) type=innodb;
 insert into t1 values (1), (2);
 optimize table t1;
 Table	Op	Msg_type	Msg_text
-test.t1	optimize	error	The handler for the table doesn't support check/repair
+test.t1	optimize	error	The handler for the table doesn't support optimize
 delete from t1 where a = 1;
 select * from t1;
 a
@@ -208,7 +208,7 @@ create index skr on t1 (a);
 insert into t1 values (3,""), (4,"testing");
 analyze table t1;
 Table	Op	Msg_type	Msg_text
-test.t1	analyze	error	The handler for the table doesn't support check/repair
+test.t1	analyze	error	The handler for the table doesn't support analyze
 show keys from t1;
 Table	Non_unique	Key_name	Seq_in_index	Column_name	Collation	Cardinality	Sub_part	Packed	Null	Index_type	Comment
 t1	1	skr	1	a	A	3	NULL	NULL	YES	BTREE	
@@ -597,7 +597,7 @@ id	parent_id	level
 1016	102	2
 explain select level from t1 where level=1;
 id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
-1	SIMPLE	t1	ref	level	level	1	const	6	where used; Using index
+1	SIMPLE	t1	ref	level	level	1	const	6	Using where; Using index
 select level,id from t1 where level=1;
 level	id
 1	1004
@@ -724,7 +724,7 @@ world	2
 hello	1
 optimize table t1;
 Table	Op	Msg_type	Msg_text
-test.t1	optimize	error	The handler for the table doesn't support check/repair
+test.t1	optimize	error	The handler for the table doesn't support optimize
 show keys from t1;
 Table	Non_unique	Key_name	Seq_in_index	Column_name	Collation	Cardinality	Sub_part	Packed	Null	Index_type	Comment
 t1	0	PRIMARY	1	a	A	2	NULL	NULL		BTREE	
@@ -759,7 +759,7 @@ create table t1 (a int  primary key,b int, c int, d int, e int, f int, g int, h
 insert into t1 values (1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1);
 explain select * from t1 where a > 0 and a < 50;
 id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
-1	SIMPLE	t1	range	PRIMARY	PRIMARY	4	NULL	1	where used
+1	SIMPLE	t1	range	PRIMARY	PRIMARY	4	NULL	1	Using where
 drop table t1;
 create table t1 (id int NOT NULL,id2 int NOT NULL,id3 int NOT NULL,dummy1 char(30),primary key (id,id2),index index_id3 (id3)) type=innodb;
 insert into t1 values (0,0,0,'ABCDEFGHIJ'),(2,2,2,'BCDEFGHIJK'),(1,1,1,'CDEFGHIJKL');
@@ -988,7 +988,7 @@ BEGIN;
 SET SESSION TRANSACTION ISOLATION LEVEL SERIALIZABLE;
 SELECT @@tx_isolation,@@global.tx_isolation;
 @@tx_isolation	@@global.tx_isolation
-SERIALIZABLE	READ-COMMITTED
+SERIALIZABLE	REPEATABLE-READ
 insert into t1 (code, name) values (1, 'Tim'), (1, 'Monty'), (2, 'David');
 select id, code, name from t1 order by id;
 id	code	name
diff --git a/mysql-test/r/innodb_cache.result b/mysql-test/r/innodb_cache.result
index eaa030046daaab5b90d1d560f732d611f0c92589..47abcb45fe5f0ea0670ee7b922a07879100be0e3 100644
--- a/mysql-test/r/innodb_cache.result
+++ b/mysql-test/r/innodb_cache.result
@@ -98,3 +98,13 @@ commit;
 show status like "Qcache_queries_in_cache";
 Variable_name	Value
 Qcache_queries_in_cache	1
+drop table if exists t1;
+CREATE TABLE t1 (id int(11) NOT NULL auto_increment, PRIMARY KEY  (id)) TYPE=InnoDB;
+select count(*) from t1;
+count(*)
+0
+insert into t1 (id) values (0);
+select count(*) from t1;
+count(*)
+1
+drop table t1;
diff --git a/mysql-test/r/isam.result b/mysql-test/r/isam.result
index 5cb218dc4ce3a4e39c3553bccb9136de2534814f..e8f7898f1eb46a83ac2eab28015ad3ef1e93f98b 100644
--- a/mysql-test/r/isam.result
+++ b/mysql-test/r/isam.result
@@ -47,14 +47,14 @@ test.t1	optimize	status	OK
 check table t1,t2;
 Table	Op	Msg_type	Msg_text
 test.t1	check	status	OK
-test.t2	check	error	The handler for the table doesn't support check/repair
+test.t2	check	error	The handler for the table doesn't support check
 repair table t1,t2;
 Table	Op	Msg_type	Msg_text
 test.t1	repair	status	OK
-test.t2	repair	error	The handler for the table doesn't support check/repair
+test.t2	repair	error	The handler for the table doesn't support repair
 check table t2,t1;
 Table	Op	Msg_type	Msg_text
-test.t2	check	error	The handler for the table doesn't support check/repair
+test.t2	check	error	The handler for the table doesn't support check
 test.t1	check	status	OK
 lock tables t1 write;
 check table t2,t1;
diff --git a/mysql-test/r/join_outer.result b/mysql-test/r/join_outer.result
index 9c44792724b5b1e9611442d5806a83093373dc15..700b73d3eca73cd672f8c7743bcb56e6ce10ef2d 100644
--- a/mysql-test/r/join_outer.result
+++ b/mysql-test/r/join_outer.result
@@ -95,7 +95,7 @@ id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
 explain select t1.*,t2.* from t1 left join t2 on t1.a=t2.a where isnull(t2.a)=1;
 id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
 1	SIMPLE	t1	ALL	NULL	NULL	NULL	NULL	7	
-1	SIMPLE	t2	eq_ref	PRIMARY	PRIMARY	8	t1.a	1	where used
+1	SIMPLE	t2	eq_ref	PRIMARY	PRIMARY	8	t1.a	1	Using where
 select t1.*,t2.*,t3.a from t1 left join t2 on (t1.a=t2.a) left join t1 as t3 on (t2.a=t3.a);
 grp	a	c	id	a	c	d	a
 1	1	a	1	1	a	1	1
@@ -313,11 +313,11 @@ Lilliana Angelovska	NULL	NULL
 explain select t1.name, t2.name, t2.id from t1 left join t2 on (t1.id = t2.owner) where t2.id is null;
 id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
 1	SIMPLE	t1	ALL	NULL	NULL	NULL	NULL	3	
-1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	3	where used; Not exists
+1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	3	Using where; Not exists
 explain select t1.name, t2.name, t2.id from t1 left join t2 on (t1.id = t2.owner) where t2.name is null;
 id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
 1	SIMPLE	t1	ALL	NULL	NULL	NULL	NULL	3	
-1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	3	where used
+1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	3	Using where
 select count(*) from t1 left join t2 on (t1.id = t2.owner);
 count(*)
 4
@@ -333,11 +333,11 @@ Lilliana Angelovska	NULL	NULL
 explain select t1.name, t2.name, t2.id from t2 right join t1 on (t1.id = t2.owner) where t2.id is null;
 id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
 1	SIMPLE	t1	ALL	NULL	NULL	NULL	NULL	3	
-1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	3	where used; Not exists
+1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	3	Using where; Not exists
 explain select t1.name, t2.name, t2.id from t2 right join t1 on (t1.id = t2.owner) where t2.name is null;
 id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
 1	SIMPLE	t1	ALL	NULL	NULL	NULL	NULL	3	
-1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	3	where used
+1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	3	Using where
 select count(*) from t2 right join t1 on (t1.id = t2.owner);
 count(*)
 4
@@ -620,7 +620,7 @@ INSERT INTO t2 VALUES (1,1);
 explain SELECT * from t1 left join t2 on t1.id=t2.id where t2.id IS NULL;
 id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
 1	SIMPLE	t1	ALL	NULL	NULL	NULL	NULL	2	
-1	SIMPLE	t2	index	id	id	8	NULL	1	where used; Using index; Not exists
+1	SIMPLE	t2	index	id	id	8	NULL	1	Using where; Using index; Not exists
 SELECT * from t1 left join t2 on t1.id=t2.id where t2.id IS NULL;
 id	name	id	idx
 2	no	NULL	NULL
@@ -640,7 +640,7 @@ insert into t2 values (10,1),(20,2),(30,3);
 explain select * from t2 left join t1 on t1.fooID = t2.fooID and t1.fooID = 30;
 id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
 1	SIMPLE	t2	index	NULL	PRIMARY	4	NULL	3	Using index
-1	SIMPLE	t1	eq_ref	PRIMARY	PRIMARY	2	const	1	where used; Using index
+1	SIMPLE	t1	eq_ref	PRIMARY	PRIMARY	2	const	1	Using where; Using index
 select * from t2 left join t1 on t1.fooID = t2.fooID and t1.fooID = 30;
 fooID	barID	fooID
 10	1	NULL
diff --git a/mysql-test/r/key_diff.result b/mysql-test/r/key_diff.result
index bdeff4f60d8f84d2c9e8d7d805041e1e72b42a65..8097186bde13c4c998210ed2428e1fcffefd574e 100644
--- a/mysql-test/r/key_diff.result
+++ b/mysql-test/r/key_diff.result
@@ -36,7 +36,7 @@ a	a	a	a
 explain select t1.*,t2.* from t1,t1 as t2 where t1.A=t2.B;
 id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
 1	SIMPLE	t1	ALL	a	NULL	NULL	NULL	5	
-1	SIMPLE	t2	ALL	b	NULL	NULL	NULL	5	where used
+1	SIMPLE	t2	ALL	b	NULL	NULL	NULL	5	Using where
 select t1.*,t2.* from t1,t1 as t2 where t1.A=t2.B order by binary t1.a,t2.a;
 a	b	a	b
 A	B	a	a
diff --git a/mysql-test/r/merge.result b/mysql-test/r/merge.result
index 27ce8e1d91540e9b5cd6a07753518ec924359fa1..cd78ac791c4b3bb8313e8a542670c04a7554b8e5 100644
--- a/mysql-test/r/merge.result
+++ b/mysql-test/r/merge.result
@@ -35,10 +35,10 @@ insert into t1 select NULL,message from t2;
 create table t3 (a int not null, b char(20), key(a)) type=MERGE UNION=(test.t1,test.t2);
 explain select * from t3 where a < 10;
 id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
-1	SIMPLE	t3	range	a	a	4	NULL	10	where used
+1	SIMPLE	t3	range	a	a	4	NULL	18	Using where
 explain select * from t3 where a > 10 and a < 20;
 id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
-1	SIMPLE	t3	range	a	a	4	NULL	10	where used
+1	SIMPLE	t3	range	a	a	4	NULL	16	Using where
 select * from t3 where a = 10;
 a	b
 10	Testing
@@ -541,3 +541,58 @@ select max(b) from t1 where a = 2;
 max(b)
 1
 drop table if exists t,t1,t2;
+drop table if exists t1, t2, t3, t4, t5, t6;
+create table t1 (a int not null);
+create table t2 (a int not null);
+insert into t1 values (1);
+insert into t2 values (2);
+create temporary table t3 (a int not null) TYPE=MERGE UNION=(t1,t2);
+select * from t3;
+a
+1
+2
+create temporary table t4 (a int not null);
+create temporary table t5 (a int not null);
+insert into t4 values (1);
+insert into t5 values (2);
+create temporary table t6 (a int not null) TYPE=MERGE UNION=(t4,t5);
+select * from t6;
+a
+1
+2
+drop table if exists t1, t2, t3, t4, t5, t6;
+DROP TABLE IF EXISTS t1, t2;
+CREATE TABLE t1 (
+fileset_id tinyint(3) unsigned NOT NULL default '0',
+file_code varchar(32) NOT NULL default '',
+fileset_root_id tinyint(3) unsigned NOT NULL default '0',
+PRIMARY KEY  (fileset_id,file_code),
+KEY files (fileset_id,fileset_root_id)
+) TYPE=MyISAM;
+INSERT INTO t1 VALUES (2, '0000000111', 1), (2, '0000000112', 1), (2, '0000000113', 1),
+(2, '0000000114', 1), (2, '0000000115', 1), (2, '0000000116', 1), (2, '0000000117', 1),
+(2, '0000000118', 1), (2, '0000000119', 1), (2, '0000000120', 1);
+CREATE TABLE t2 (
+fileset_id tinyint(3) unsigned NOT NULL default '0',
+file_code varchar(32) NOT NULL default '',
+fileset_root_id tinyint(3) unsigned NOT NULL default '0',
+PRIMARY KEY  (fileset_id,file_code),
+KEY files (fileset_id,fileset_root_id)
+) TYPE=MRG_MyISAM UNION=(t1);
+EXPLAIN SELECT * FROM t2 IGNORE INDEX (files) WHERE fileset_id = 2
+AND file_code BETWEEN '0000000115' AND '0000000120' LIMIT 1;
+id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
+1	SIMPLE	t2	range	PRIMARY	PRIMARY	33	NULL	5	Using where
+EXPLAIN SELECT * FROM t2 WHERE fileset_id = 2
+AND file_code BETWEEN '0000000115' AND '0000000120' LIMIT 1;
+id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
+1	SIMPLE	t2	range	PRIMARY,files	PRIMARY	33	NULL	5	Using where
+EXPLAIN SELECT * FROM t1 WHERE fileset_id = 2
+AND file_code BETWEEN '0000000115' AND '0000000120' LIMIT 1;
+id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
+1	SIMPLE	t1	range	PRIMARY,files	PRIMARY	33	NULL	5	Using where
+EXPLAIN SELECT * FROM t2 WHERE fileset_id = 2
+AND file_code = '0000000115' LIMIT 1;
+id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
+1	SIMPLE	t2	const	PRIMARY,files	PRIMARY	33	const,const	1	
+DROP TABLE IF EXISTS t1, t2;
diff --git a/mysql-test/r/multi_update.result b/mysql-test/r/multi_update.result
index 9dff4fba825d94c8a5e1b4fb02c69c47439f720f..ce3f7e90f6b03fda6262d55a28220ce42e433229 100644
--- a/mysql-test/r/multi_update.result
+++ b/mysql-test/r/multi_update.result
@@ -150,4 +150,29 @@ n	n
 delete  t1,t2 from t2 left outer join t1  using (n);
 select * from t2 left outer join t1  using (n);
 n	n
-drop table if exists t1,t2 ;
+drop table t1,t2 ;
+create table t1 (n int(10) not null primary key, d int(10));
+create table t2 (n int(10) not null primary key, d int(10));
+insert into t1 values(1,1);
+insert into t2 values(1,10),(2,20);
+LOCK TABLES t1 write, t2 read;
+DELETE t1.*, t2.* FROM t1,t2 where t1.n=t2.n;
+Table 't2' was locked with a READ lock and can't be updated
+UPDATE t1,t2 SET t1.d=t2.d,t2.d=30 WHERE t1.n=t2.n;
+Table 't2' was locked with a READ lock and can't be updated
+UPDATE t1,t2 SET t1.d=t2.d WHERE t1.n=t2.n;
+Table 't2' was locked with a READ lock and can't be updated
+unlock tables;
+LOCK TABLES t1 write, t2 write;
+UPDATE t1,t2 SET t1.d=t2.d WHERE t1.n=t2.n;
+select * from t1;
+n	d
+1	10
+DELETE t1.*, t2.* FROM t1,t2 where t1.n=t2.n;
+select * from t1;
+n	d
+select * from t2;
+n	d
+2	20
+unlock tables;
+drop table t1,t2;
diff --git a/mysql-test/r/myisam.result b/mysql-test/r/myisam.result
index 29818f28c45ad8d12bd4839a80676aa40f2d0cf0..6b9c3a5330565dff6b1ebbe888116483b3810322 100644
--- a/mysql-test/r/myisam.result
+++ b/mysql-test/r/myisam.result
@@ -75,6 +75,218 @@ explain select a,b,c from t1;
 id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
 1	SIMPLE	t1	ALL	NULL	NULL	NULL	NULL	4	
 drop table t1;
+CREATE TABLE t1 (a INT);
+INSERT INTO  t1 VALUES (1), (2), (3);
+LOCK TABLES t1 WRITE;
+INSERT INTO  t1 VALUES (1), (2), (3);
+OPTIMIZE TABLE t1;
+Table	Op	Msg_type	Msg_text
+test.t1	optimize	status	OK
+DROP TABLE t1;
+drop table if exists t1;
+create table t1 ( t1 char(255), key(t1(250)));
+insert t1 values ('137513751375137513751375137513751375137569516951695169516951695169516951695169');
+insert t1 values ('178417841784178417841784178417841784178403420342034203420342034203420342034203');
+insert t1 values ('213872387238723872387238723872387238723867376737673767376737673767376737673767');
+insert t1 values ('242624262426242624262426242624262426242607890789078907890789078907890789078907');
+insert t1 values ('256025602560256025602560256025602560256011701170117011701170117011701170117011');
+insert t1 values ('276027602760276027602760276027602760276001610161016101610161016101610161016101');
+insert t1 values ('281528152815281528152815281528152815281564956495649564956495649564956495649564');
+insert t1 values ('292129212921292129212921292129212921292102100210021002100210021002100210021002');
+insert t1 values ('380638063806380638063806380638063806380634483448344834483448344834483448344834');
+insert t1 values ('411641164116411641164116411641164116411616301630163016301630163016301630163016');
+insert t1 values ('420842084208420842084208420842084208420899889988998899889988998899889988998899');
+insert t1 values ('438443844384438443844384438443844384438482448244824482448244824482448244824482');
+insert t1 values ('443244324432443244324432443244324432443239613961396139613961396139613961396139');
+insert t1 values ('485448544854485448544854485448544854485477847784778477847784778477847784778477');
+insert t1 values ('494549454945494549454945494549454945494555275527552755275527552755275527552755');
+insert t1 values ('538647864786478647864786478647864786478688918891889188918891889188918891889188');
+insert t1 values ('565556555655565556555655565556555655565554845484548454845484548454845484548454');
+insert t1 values ('607860786078607860786078607860786078607856665666566656665666566656665666566656');
+insert t1 values ('640164016401640164016401640164016401640141274127412741274127412741274127412741');
+insert t1 values ('719471947194719471947194719471947194719478717871787178717871787178717871787178');
+insert t1 values ('742574257425742574257425742574257425742549604960496049604960496049604960496049');
+insert t1 values ('887088708870887088708870887088708870887035963596359635963596359635963596359635');
+insert t1 values ('917791779177917791779177917791779177917773857385738573857385738573857385738573');
+insert t1 values ('933293329332933293329332933293329332933278987898789878987898789878987898789878');
+insert t1 values ('963896389638963896389638963896389638963877807780778077807780778077807780778077');
+delete from t1 where t1>'2';
+insert t1 values ('70'), ('84'), ('60'), ('20'), ('76'), ('89'), ('49'), ('50'),
+('88'), ('61'), ('42'), ('98'), ('39'), ('30'), ('25'), ('66'), ('61'), ('48'),
+('80'), ('84'), ('98'), ('19'), ('91'), ('42'), ('47');
+optimize table t1;
+Table	Op	Msg_type	Msg_text
+test.t1	optimize	status	OK
+check table t1;
+Table	Op	Msg_type	Msg_text
+test.t1	check	status	OK
+drop table t1;
+drop table if exists t1;
+create table t1 (i1 int, i2 int, i3 int, i4 int, i5 int, i6 int, i7 int, i8
+int, i9 int, i10 int, i11 int, i12 int, i13 int, i14 int, i15 int, i16 int, i17
+int, i18 int, i19 int, i20 int, i21 int, i22 int, i23 int, i24 int, i25 int,
+i26 int, i27 int, i28 int, i29 int, i30 int, i31 int, i32 int, i33 int, i34
+int, i35 int, i36 int, i37 int, i38 int, i39 int, i40 int, i41 int, i42 int,
+i43 int, i44 int, i45 int, i46 int, i47 int, i48 int, i49 int, i50 int, i51
+int, i52 int, i53 int, i54 int, i55 int, i56 int, i57 int, i58 int, i59 int,
+i60 int, i61 int, i62 int, i63 int, i64 int, i65 int, i66 int, i67 int, i68
+int, i69 int, i70 int, i71 int, i72 int, i73 int, i74 int, i75 int, i76 int,
+i77 int, i78 int, i79 int, i80 int, i81 int, i82 int, i83 int, i84 int, i85
+int, i86 int, i87 int, i88 int, i89 int, i90 int, i91 int, i92 int, i93 int,
+i94 int, i95 int, i96 int, i97 int, i98 int, i99 int, i100 int, i101 int, i102
+int, i103 int, i104 int, i105 int, i106 int, i107 int, i108 int, i109 int, i110
+int, i111 int, i112 int, i113 int, i114 int, i115 int, i116 int, i117 int, i118
+int, i119 int, i120 int, i121 int, i122 int, i123 int, i124 int, i125 int, i126
+int, i127 int, i128 int, i129 int, i130 int, i131 int, i132 int, i133 int, i134
+int, i135 int, i136 int, i137 int, i138 int, i139 int, i140 int, i141 int, i142
+int, i143 int, i144 int, i145 int, i146 int, i147 int, i148 int, i149 int, i150
+int, i151 int, i152 int, i153 int, i154 int, i155 int, i156 int, i157 int, i158
+int, i159 int, i160 int, i161 int, i162 int, i163 int, i164 int, i165 int, i166
+int, i167 int, i168 int, i169 int, i170 int, i171 int, i172 int, i173 int, i174
+int, i175 int, i176 int, i177 int, i178 int, i179 int, i180 int, i181 int, i182
+int, i183 int, i184 int, i185 int, i186 int, i187 int, i188 int, i189 int, i190
+int, i191 int, i192 int, i193 int, i194 int, i195 int, i196 int, i197 int, i198
+int, i199 int, i200 int, i201 int, i202 int, i203 int, i204 int, i205 int, i206
+int, i207 int, i208 int, i209 int, i210 int, i211 int, i212 int, i213 int, i214
+int, i215 int, i216 int, i217 int, i218 int, i219 int, i220 int, i221 int, i222
+int, i223 int, i224 int, i225 int, i226 int, i227 int, i228 int, i229 int, i230
+int, i231 int, i232 int, i233 int, i234 int, i235 int, i236 int, i237 int, i238
+int, i239 int, i240 int, i241 int, i242 int, i243 int, i244 int, i245 int, i246
+int, i247 int, i248 int, i249 int, i250 int, i251 int, i252 int, i253 int, i254
+int, i255 int, i256 int, i257 int, i258 int, i259 int, i260 int, i261 int, i262
+int, i263 int, i264 int, i265 int, i266 int, i267 int, i268 int, i269 int, i270
+int, i271 int, i272 int, i273 int, i274 int, i275 int, i276 int, i277 int, i278
+int, i279 int, i280 int, i281 int, i282 int, i283 int, i284 int, i285 int, i286
+int, i287 int, i288 int, i289 int, i290 int, i291 int, i292 int, i293 int, i294
+int, i295 int, i296 int, i297 int, i298 int, i299 int, i300 int, i301 int, i302
+int, i303 int, i304 int, i305 int, i306 int, i307 int, i308 int, i309 int, i310
+int, i311 int, i312 int, i313 int, i314 int, i315 int, i316 int, i317 int, i318
+int, i319 int, i320 int, i321 int, i322 int, i323 int, i324 int, i325 int, i326
+int, i327 int, i328 int, i329 int, i330 int, i331 int, i332 int, i333 int, i334
+int, i335 int, i336 int, i337 int, i338 int, i339 int, i340 int, i341 int, i342
+int, i343 int, i344 int, i345 int, i346 int, i347 int, i348 int, i349 int, i350
+int, i351 int, i352 int, i353 int, i354 int, i355 int, i356 int, i357 int, i358
+int, i359 int, i360 int, i361 int, i362 int, i363 int, i364 int, i365 int, i366
+int, i367 int, i368 int, i369 int, i370 int, i371 int, i372 int, i373 int, i374
+int, i375 int, i376 int, i377 int, i378 int, i379 int, i380 int, i381 int, i382
+int, i383 int, i384 int, i385 int, i386 int, i387 int, i388 int, i389 int, i390
+int, i391 int, i392 int, i393 int, i394 int, i395 int, i396 int, i397 int, i398
+int, i399 int, i400 int, i401 int, i402 int, i403 int, i404 int, i405 int, i406
+int, i407 int, i408 int, i409 int, i410 int, i411 int, i412 int, i413 int, i414
+int, i415 int, i416 int, i417 int, i418 int, i419 int, i420 int, i421 int, i422
+int, i423 int, i424 int, i425 int, i426 int, i427 int, i428 int, i429 int, i430
+int, i431 int, i432 int, i433 int, i434 int, i435 int, i436 int, i437 int, i438
+int, i439 int, i440 int, i441 int, i442 int, i443 int, i444 int, i445 int, i446
+int, i447 int, i448 int, i449 int, i450 int, i451 int, i452 int, i453 int, i454
+int, i455 int, i456 int, i457 int, i458 int, i459 int, i460 int, i461 int, i462
+int, i463 int, i464 int, i465 int, i466 int, i467 int, i468 int, i469 int, i470
+int, i471 int, i472 int, i473 int, i474 int, i475 int, i476 int, i477 int, i478
+int, i479 int, i480 int, i481 int, i482 int, i483 int, i484 int, i485 int, i486
+int, i487 int, i488 int, i489 int, i490 int, i491 int, i492 int, i493 int, i494
+int, i495 int, i496 int, i497 int, i498 int, i499 int, i500 int, i501 int, i502
+int, i503 int, i504 int, i505 int, i506 int, i507 int, i508 int, i509 int, i510
+int, i511 int, i512 int, i513 int, i514 int, i515 int, i516 int, i517 int, i518
+int, i519 int, i520 int, i521 int, i522 int, i523 int, i524 int, i525 int, i526
+int, i527 int, i528 int, i529 int, i530 int, i531 int, i532 int, i533 int, i534
+int, i535 int, i536 int, i537 int, i538 int, i539 int, i540 int, i541 int, i542
+int, i543 int, i544 int, i545 int, i546 int, i547 int, i548 int, i549 int, i550
+int, i551 int, i552 int, i553 int, i554 int, i555 int, i556 int, i557 int, i558
+int, i559 int, i560 int, i561 int, i562 int, i563 int, i564 int, i565 int, i566
+int, i567 int, i568 int, i569 int, i570 int, i571 int, i572 int, i573 int, i574
+int, i575 int, i576 int, i577 int, i578 int, i579 int, i580 int, i581 int, i582
+int, i583 int, i584 int, i585 int, i586 int, i587 int, i588 int, i589 int, i590
+int, i591 int, i592 int, i593 int, i594 int, i595 int, i596 int, i597 int, i598
+int, i599 int, i600 int, i601 int, i602 int, i603 int, i604 int, i605 int, i606
+int, i607 int, i608 int, i609 int, i610 int, i611 int, i612 int, i613 int, i614
+int, i615 int, i616 int, i617 int, i618 int, i619 int, i620 int, i621 int, i622
+int, i623 int, i624 int, i625 int, i626 int, i627 int, i628 int, i629 int, i630
+int, i631 int, i632 int, i633 int, i634 int, i635 int, i636 int, i637 int, i638
+int, i639 int, i640 int, i641 int, i642 int, i643 int, i644 int, i645 int, i646
+int, i647 int, i648 int, i649 int, i650 int, i651 int, i652 int, i653 int, i654
+int, i655 int, i656 int, i657 int, i658 int, i659 int, i660 int, i661 int, i662
+int, i663 int, i664 int, i665 int, i666 int, i667 int, i668 int, i669 int, i670
+int, i671 int, i672 int, i673 int, i674 int, i675 int, i676 int, i677 int, i678
+int, i679 int, i680 int, i681 int, i682 int, i683 int, i684 int, i685 int, i686
+int, i687 int, i688 int, i689 int, i690 int, i691 int, i692 int, i693 int, i694
+int, i695 int, i696 int, i697 int, i698 int, i699 int, i700 int, i701 int, i702
+int, i703 int, i704 int, i705 int, i706 int, i707 int, i708 int, i709 int, i710
+int, i711 int, i712 int, i713 int, i714 int, i715 int, i716 int, i717 int, i718
+int, i719 int, i720 int, i721 int, i722 int, i723 int, i724 int, i725 int, i726
+int, i727 int, i728 int, i729 int, i730 int, i731 int, i732 int, i733 int, i734
+int, i735 int, i736 int, i737 int, i738 int, i739 int, i740 int, i741 int, i742
+int, i743 int, i744 int, i745 int, i746 int, i747 int, i748 int, i749 int, i750
+int, i751 int, i752 int, i753 int, i754 int, i755 int, i756 int, i757 int, i758
+int, i759 int, i760 int, i761 int, i762 int, i763 int, i764 int, i765 int, i766
+int, i767 int, i768 int, i769 int, i770 int, i771 int, i772 int, i773 int, i774
+int, i775 int, i776 int, i777 int, i778 int, i779 int, i780 int, i781 int, i782
+int, i783 int, i784 int, i785 int, i786 int, i787 int, i788 int, i789 int, i790
+int, i791 int, i792 int, i793 int, i794 int, i795 int, i796 int, i797 int, i798
+int, i799 int, i800 int, i801 int, i802 int, i803 int, i804 int, i805 int, i806
+int, i807 int, i808 int, i809 int, i810 int, i811 int, i812 int, i813 int, i814
+int, i815 int, i816 int, i817 int, i818 int, i819 int, i820 int, i821 int, i822
+int, i823 int, i824 int, i825 int, i826 int, i827 int, i828 int, i829 int, i830
+int, i831 int, i832 int, i833 int, i834 int, i835 int, i836 int, i837 int, i838
+int, i839 int, i840 int, i841 int, i842 int, i843 int, i844 int, i845 int, i846
+int, i847 int, i848 int, i849 int, i850 int, i851 int, i852 int, i853 int, i854
+int, i855 int, i856 int, i857 int, i858 int, i859 int, i860 int, i861 int, i862
+int, i863 int, i864 int, i865 int, i866 int, i867 int, i868 int, i869 int, i870
+int, i871 int, i872 int, i873 int, i874 int, i875 int, i876 int, i877 int, i878
+int, i879 int, i880 int, i881 int, i882 int, i883 int, i884 int, i885 int, i886
+int, i887 int, i888 int, i889 int, i890 int, i891 int, i892 int, i893 int, i894
+int, i895 int, i896 int, i897 int, i898 int, i899 int, i900 int, i901 int, i902
+int, i903 int, i904 int, i905 int, i906 int, i907 int, i908 int, i909 int, i910
+int, i911 int, i912 int, i913 int, i914 int, i915 int, i916 int, i917 int, i918
+int, i919 int, i920 int, i921 int, i922 int, i923 int, i924 int, i925 int, i926
+int, i927 int, i928 int, i929 int, i930 int, i931 int, i932 int, i933 int, i934
+int, i935 int, i936 int, i937 int, i938 int, i939 int, i940 int, i941 int, i942
+int, i943 int, i944 int, i945 int, i946 int, i947 int, i948 int, i949 int, i950
+int, i951 int, i952 int, i953 int, i954 int, i955 int, i956 int, i957 int, i958
+int, i959 int, i960 int, i961 int, i962 int, i963 int, i964 int, i965 int, i966
+int, i967 int, i968 int, i969 int, i970 int, i971 int, i972 int, i973 int, i974
+int, i975 int, i976 int, i977 int, i978 int, i979 int, i980 int, i981 int, i982
+int, i983 int, i984 int, i985 int, i986 int, i987 int, i988 int, i989 int, i990
+int, i991 int, i992 int, i993 int, i994 int, i995 int, i996 int, i997 int, i998
+int, i999 int, i1000 int) row_format=dynamic;
+insert into t1 values (1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
+1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
+1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
+1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
+1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
+1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
+1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
+1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
+1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
+1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
+1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
+1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
+1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
+1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
+1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
+1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
+1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
+1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
+1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
+1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
+1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
+1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
+1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
+1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
+1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
+1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
+1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
+1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
+1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
+1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
+1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
+1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
+1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
+1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
+1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
+1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
+1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
+1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
+1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1);
+drop table if exists t1;
 CREATE TABLE `t1` (
 `post_id` mediumint(8) unsigned NOT NULL auto_increment,
 `topic_id` mediumint(8) unsigned NOT NULL default '0',
@@ -100,14 +312,6 @@ CHECK TABLE t1;
 Table	Op	Msg_type	Msg_text
 test.t1	check	status	OK
 drop table t1;
-CREATE TABLE t1 (a INT);
-INSERT INTO  t1 VALUES (1), (2), (3);
-LOCK TABLES t1 WRITE;
-INSERT INTO  t1 VALUES (1), (2), (3);
-OPTIMIZE TABLE t1;
-Table	Op	Msg_type	Msg_text
-test.t1	optimize	status	OK
-DROP TABLE t1;
 CREATE TABLE t1 (a varchar(255), b varchar(255), c varchar(255), KEY t1 (a, b, c));
 Specified key was too long. Max key length is 500
 CREATE TABLE t1 (a varchar(255), b varchar(255), c varchar(255));
diff --git a/mysql-test/r/null.result b/mysql-test/r/null.result
index e6e3b7155a37d112ca0e31547e7715de2407b8c1..07724a56025f59e2ed2f4ce12b0b8d7455770e5e 100644
--- a/mysql-test/r/null.result
+++ b/mysql-test/r/null.result
@@ -30,7 +30,7 @@ SELECT (NULL OR NULL) IS NULL;
 1
 select NULL AND 0, 0 and NULL;
 NULL AND 0	0 and NULL
-NULL	0
+0	0
 select inet_ntoa(null),inet_aton(null),inet_aton("122.256"),inet_aton("122.226."),inet_aton("");
 inet_ntoa(null)	inet_aton(null)	inet_aton("122.256")	inet_aton("122.226.")	inet_aton("")
 NULL	NULL	NULL	NULL	NULL
diff --git a/mysql-test/r/null_key.result b/mysql-test/r/null_key.result
index cbc8b913f452da4d47accc6c6a21d199ff9dcb22..484437959a054538e4341f275921e09cbafb0433 100644
--- a/mysql-test/r/null_key.result
+++ b/mysql-test/r/null_key.result
@@ -3,37 +3,37 @@ create table t1 (a int, b int not null,unique key (a,b),index(b)) type=myisam;
 insert ignore into t1 values (1,1),(2,2),(3,3),(4,4),(5,5),(6,6),(null,7),(9,9),(8,8),(7,7),(null,9),(null,9),(6,6);
 explain select * from t1 where a is null;
 id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
-1	SIMPLE	t1	ref	a	a	5	const	3	where used; Using index
+1	SIMPLE	t1	ref	a	a	5	const	3	Using where; Using index
 explain select * from t1 where a is null and b = 2;
 id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
-1	SIMPLE	t1	ref	a,b	a	9	const,const	1	where used; Using index
+1	SIMPLE	t1	ref	a,b	a	9	const,const	1	Using where; Using index
 explain select * from t1 where a is null and b = 7;
 id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
-1	SIMPLE	t1	ref	a,b	a	9	const,const	1	where used; Using index
+1	SIMPLE	t1	ref	a,b	a	9	const,const	1	Using where; Using index
 explain select * from t1 where a=2 and b = 2;
 id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
 1	SIMPLE	t1	const	a,b	a	9	const,const	1	
 explain select * from t1 where a<=>b limit 2;
 id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
-1	SIMPLE	t1	index	NULL	a	9	NULL	12	where used; Using index
+1	SIMPLE	t1	index	NULL	a	9	NULL	12	Using where; Using index
 explain select * from t1 where (a is null or a > 0 and a < 3) and b < 5 limit 3;
 id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
-1	SIMPLE	t1	range	a,b	a	9	NULL	3	where used; Using index
+1	SIMPLE	t1	range	a,b	a	9	NULL	3	Using where; Using index
 explain select * from t1 where (a is null or a = 7) and b=7;
 id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
-1	SIMPLE	t1	ref	a,b	b	4	const	2	where used
+1	SIMPLE	t1	ref	a,b	b	4	const	2	Using where
 explain select * from t1 where (a is null and b>a) or a is null and b=7 limit 2;
 id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
-1	SIMPLE	t1	ref	a,b	a	5	const	3	where used; Using index
+1	SIMPLE	t1	ref	a,b	a	5	const	3	Using where; Using index
 explain select * from t1 where a is null and b=9 or a is null and b=7 limit 3;
 id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
-1	SIMPLE	t1	range	a,b	a	9	NULL	2	where used; Using index
+1	SIMPLE	t1	range	a,b	a	9	NULL	2	Using where; Using index
 explain select * from t1 where a > 1 and a < 3 limit 1;
 id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
-1	SIMPLE	t1	range	a	a	5	NULL	1	where used; Using index
+1	SIMPLE	t1	range	a	a	5	NULL	1	Using where; Using index
 explain select * from t1 where a > 8 and a < 9;
 id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
-1	SIMPLE	t1	range	a	a	5	NULL	1	where used; Using index
+1	SIMPLE	t1	range	a	a	5	NULL	1	Using where; Using index
 select * from t1 where a is null;
 a	b
 NULL	7
@@ -66,43 +66,43 @@ NULL	9
 alter table t1 modify b blob not null, add c int not null, drop key a, add unique key (a,b(20),c), drop key b, add key (b(10));
 explain select * from t1 where a is null and b = 2;
 id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
-1	SIMPLE	t1	ref	a,b	a	5	const	3	where used
+1	SIMPLE	t1	ref	a,b	a	5	const	3	Using where
 explain select * from t1 where a is null and b = 2 and c=0;
 id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
-1	SIMPLE	t1	ref	a,b	a	5	const	3	where used
+1	SIMPLE	t1	ref	a,b	a	5	const	3	Using where
 explain select * from t1 where a is null and b = 7 and c=0;
 id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
-1	SIMPLE	t1	ref	a,b	a	5	const	3	where used
+1	SIMPLE	t1	ref	a,b	a	5	const	3	Using where
 explain select * from t1 where a=2 and b = 2;
 id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
-1	SIMPLE	t1	ref	a,b	a	5	const	1	where used
+1	SIMPLE	t1	ref	a,b	a	5	const	1	Using where
 explain select * from t1 where a<=>b limit 2;
 id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
-1	SIMPLE	t1	ALL	NULL	NULL	NULL	NULL	12	where used
+1	SIMPLE	t1	ALL	NULL	NULL	NULL	NULL	12	Using where
 explain select * from t1 where (a is null or a > 0 and a < 3) and b < 5 and c=0 limit 3;
 id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
-1	SIMPLE	t1	range	a,b	a	5	NULL	5	where used
+1	SIMPLE	t1	range	a,b	a	5	NULL	5	Using where
 explain select * from t1 where (a is null or a = 7) and b=7 and c=0;
 id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
-1	SIMPLE	t1	range	a,b	a	5	NULL	4	where used
+1	SIMPLE	t1	range	a,b	a	5	NULL	4	Using where
 explain select * from t1 where (a is null and b>a) or a is null and b=7 limit 2;
 id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
-1	SIMPLE	t1	ref	a,b	a	5	const	3	where used
+1	SIMPLE	t1	ref	a,b	a	5	const	3	Using where
 explain select * from t1 where a is null and b=9 or a is null and b=7 limit 3;
 id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
-1	SIMPLE	t1	ref	a,b	a	5	const	3	where used
+1	SIMPLE	t1	ref	a,b	a	5	const	3	Using where
 explain select * from t1 where a > 1 and a < 3 limit 1;
 id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
-1	SIMPLE	t1	range	a	a	5	NULL	1	where used
+1	SIMPLE	t1	range	a	a	5	NULL	1	Using where
 explain select * from t1 where a is null and b=7 or a > 1 and a < 3 limit 1;
 id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
-1	SIMPLE	t1	range	a,b	a	5	NULL	4	where used
+1	SIMPLE	t1	range	a,b	a	5	NULL	4	Using where
 explain select * from t1 where a > 8 and a < 9;
 id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
-1	SIMPLE	t1	range	a	a	5	NULL	1	where used
+1	SIMPLE	t1	range	a	a	5	NULL	1	Using where
 explain select * from t1 where b like "6%";
 id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
-1	SIMPLE	t1	range	b	b	12	NULL	1	where used
+1	SIMPLE	t1	range	b	b	12	NULL	1	Using where
 select * from t1 where a is null;
 a	b	c
 NULL	7	0
@@ -152,7 +152,7 @@ INSERT INTO t1 VALUES (1,NULL),(2,NULL),(3,1),(4,2),(5,NULL),(6,NULL),(7,3),(8,4
 INSERT INTO t2 VALUES (1,NULL),(2,NULL),(3,1),(4,2),(5,NULL),(6,NULL),(7,3),(8,4),(9,NULL),(10,NULL);
 explain select id from t1 where uniq_id is null;
 id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
-1	SIMPLE	t1	ref	idx1	idx1	5	const	1	where used
+1	SIMPLE	t1	ref	idx1	idx1	5	const	1	Using where
 explain select id from t1 where uniq_id =1;
 id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
 1	SIMPLE	t1	const	idx1	idx1	5	const	1	
@@ -228,3 +228,36 @@ alter table t1 add key id (id);
 select * from t1, t2 where t1.id = t2.id;
 id	id
 drop table t1,t2;
+create table t1 (
+id  integer,
+id2 integer not null,
+index (id),
+index (id2)
+);
+insert into t1 values(null,null),(1,1);
+select * from t1;
+id	id2
+NULL	0
+1	1
+select * from t1 where id <=> null;
+id	id2
+NULL	0
+select * from t1 where id <=> null or id > 0;
+id	id2
+NULL	0
+1	1
+select * from t1 where id is null or id > 0;
+id	id2
+NULL	0
+1	1
+select * from t1 where id2 <=> null or id2 > 0;
+id	id2
+1	1
+select * from t1 where id2 is null or id2 > 0;
+id	id2
+1	1
+delete from t1 where id <=> NULL;
+select * from t1;
+id	id2
+1	1
+drop table t1;
diff --git a/mysql-test/r/order_by.result b/mysql-test/r/order_by.result
index 64e2c9f5240fffc5edd94ebdf266976ab77c753c..5645961a17834b4656c472f0a79fecc2bdf7e688 100644
--- a/mysql-test/r/order_by.result
+++ b/mysql-test/r/order_by.result
@@ -264,13 +264,13 @@ create table t1 (a int not null, b int, c varchar(10), key (a, b, c));
 insert into t1 values (1, NULL, NULL), (1, NULL, 'b'), (1, 1, NULL), (1, 1, 'b'), (1, 1, 'b'), (2, 1, 'a'), (2, 1, 'b'), (2, 2, 'a'), (2, 2, 'b'), (2, 3, 'c'),(1,3,'b');
 explain select * from t1 where (a = 1 and b is null and c = 'b') or (a > 2) order by a desc;
 id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
-1	SIMPLE	t1	range	a	a	20	NULL	2	where used; Using index
+1	SIMPLE	t1	range	a	a	20	NULL	2	Using where; Using index
 select * from t1 where (a = 1 and b is null and c = 'b') or (a > 2) order by a desc;
 a	b	c
 1	NULL	b
 explain select * from t1 where a >= 1 and a < 3 order by a desc;
 id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
-1	SIMPLE	t1	range	a	a	4	NULL	10	where used; Using index
+1	SIMPLE	t1	range	a	a	4	NULL	10	Using where; Using index
 select * from t1 where a >= 1 and a < 3 order by a desc;
 a	b	c
 2	3	c
@@ -286,7 +286,7 @@ a	b	c
 1	NULL	NULL
 explain select * from t1 where a = 1 order by a desc, b desc;
 id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
-1	SIMPLE	t1	ref	a	a	4	const	5	where used; Using index
+1	SIMPLE	t1	ref	a	a	4	const	5	Using where; Using index
 select * from t1 where a = 1 order by a desc, b desc;
 a	b	c
 1	3	b
@@ -297,30 +297,30 @@ a	b	c
 1	NULL	NULL
 explain select * from t1 where a = 1 and b is null order by a desc, b desc;
 id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
-1	SIMPLE	t1	ref	a	a	9	const,const	2	where used; Using index; Using filesort
+1	SIMPLE	t1	ref	a	a	9	const,const	2	Using where; Using index; Using filesort
 select * from t1 where a = 1 and b is null order by a desc, b desc;
 a	b	c
 1	NULL	NULL
 1	NULL	b
 explain select * from t1 where a >= 1 and a < 3 and b >0 order by a desc,b desc;
 id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
-1	SIMPLE	t1	range	a	a	9	NULL	8	where used; Using index; Using filesort
+1	SIMPLE	t1	range	a	a	9	NULL	8	Using where; Using index; Using filesort
 explain select * from t1 where a = 2 and b >0 order by a desc,b desc;
 id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
-1	SIMPLE	t1	range	a	a	9	NULL	5	where used; Using index
+1	SIMPLE	t1	range	a	a	9	NULL	5	Using where; Using index
 explain select * from t1 where a = 2 and b is null order by a desc,b desc;
 id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
-1	SIMPLE	t1	ref	a	a	9	const,const	1	where used; Using index; Using filesort
+1	SIMPLE	t1	ref	a	a	9	const,const	1	Using where; Using index; Using filesort
 explain select * from t1 where a = 2 and (b is null or b > 0) order by a
 desc,b desc;
 id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
-1	SIMPLE	t1	range	a	a	9	NULL	6	where used; Using index
+1	SIMPLE	t1	range	a	a	9	NULL	6	Using where; Using index
 explain select * from t1 where a = 2 and b > 0 order by a desc,b desc;
 id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
-1	SIMPLE	t1	range	a	a	9	NULL	5	where used; Using index
+1	SIMPLE	t1	range	a	a	9	NULL	5	Using where; Using index
 explain select * from t1 where a = 2 and b < 2 order by a desc,b desc;
 id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
-1	SIMPLE	t1	range	a	a	9	NULL	2	where used; Using index; Using filesort
+1	SIMPLE	t1	range	a	a	9	NULL	2	Using where; Using index; Using filesort
 alter table t1 modify b int not null, modify c varchar(10) not null;
 explain select * from t1 order by a, b, c;
 id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
@@ -356,14 +356,14 @@ a	b	c
 1	0	
 explain select * from t1 where (a = 1 and b = 1 and c = 'b') or (a > 2) order by a desc;
 id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
-1	SIMPLE	t1	range	a	a	18	NULL	3	where used; Using index
+1	SIMPLE	t1	range	a	a	18	NULL	3	Using where; Using index
 select * from t1 where (a = 1 and b = 1 and c = 'b') or (a > 2) order by a desc;
 a	b	c
 1	1	b
 1	1	b
 explain select * from t1 where a < 2 and b <= 1 order by a desc, b desc;
 id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
-1	SIMPLE	t1	range	a	a	4	NULL	6	where used; Using index
+1	SIMPLE	t1	range	a	a	4	NULL	6	Using where; Using index
 select * from t1 where a < 2 and b <= 1 order by a desc, b desc;
 a	b	c
 1	1	b
@@ -387,7 +387,7 @@ a	b	c
 1	1	
 explain select * from t1 where a between 1 and 3 and b <= 1 order by a desc, b desc;
 id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
-1	SIMPLE	t1	range	a	a	8	NULL	10	where used; Using index
+1	SIMPLE	t1	range	a	a	8	NULL	10	Using where; Using index
 select * from t1 where a between 1 and 3 and b <= 1 order by a desc, b desc;
 a	b	c
 2	1	b
@@ -399,7 +399,7 @@ a	b	c
 1	0	
 explain select * from t1 where a between 0 and 1 order by a desc, b desc;
 id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
-1	SIMPLE	t1	range	a	a	4	NULL	5	where used; Using index
+1	SIMPLE	t1	range	a	a	4	NULL	5	Using where; Using index
 select * from t1 where a between 0 and 1 order by a desc, b desc;
 a	b	c
 1	3	b
@@ -452,24 +452,24 @@ EXPLAIN select t1.gid, t2.sid, t3.uid from t3, t2, t1 where t2.gid = t1.gid and
 id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
 1	SIMPLE	t1	index	PRIMARY	PRIMARY	4	NULL	6	Using index
 1	SIMPLE	t2	eq_ref	PRIMARY,uid	PRIMARY	4	t1.gid	1	
-1	SIMPLE	t3	eq_ref	PRIMARY	PRIMARY	2	t2.uid	1	where used; Using index
+1	SIMPLE	t3	eq_ref	PRIMARY	PRIMARY	2	t2.uid	1	Using where; Using index
 EXPLAIN SELECT t1.gid, t3.uid from t1, t3 where t1.gid = t3.uid order by t1.gid,t3.skr;
 id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
 1	SIMPLE	t1	index	PRIMARY	PRIMARY	4	NULL	6	Using index
-1	SIMPLE	t3	eq_ref	PRIMARY	PRIMARY	2	t1.gid	1	where used
+1	SIMPLE	t3	eq_ref	PRIMARY	PRIMARY	2	t1.gid	1	Using where
 EXPLAIN SELECT t1.gid, t2.sid, t3.uid from t2, t1, t3 where t2.gid = t1.gid and t2.uid = t3.uid order by t3.uid, t1.gid;
 id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
 1	SIMPLE	t1	index	PRIMARY	PRIMARY	4	NULL	6	Using index; Using temporary; Using filesort
 1	SIMPLE	t2	eq_ref	PRIMARY,uid	PRIMARY	4	t1.gid	1	
-1	SIMPLE	t3	eq_ref	PRIMARY	PRIMARY	2	t2.uid	1	where used; Using index
+1	SIMPLE	t3	eq_ref	PRIMARY	PRIMARY	2	t2.uid	1	Using where; Using index
 EXPLAIN SELECT t1.gid, t3.uid from t1, t3 where t1.gid = t3.uid order by t3.skr,t1.gid;
 id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
 1	SIMPLE	t1	index	PRIMARY	PRIMARY	4	NULL	6	Using index; Using temporary; Using filesort
-1	SIMPLE	t3	eq_ref	PRIMARY	PRIMARY	2	t1.gid	1	where used
+1	SIMPLE	t3	eq_ref	PRIMARY	PRIMARY	2	t1.gid	1	Using where
 EXPLAIN SELECT t1.gid, t3.uid from t1, t3 where t1.skr = t3.uid order by t1.gid,t3.skr;
 id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
 1	SIMPLE	t1	ALL	NULL	NULL	NULL	NULL	6	Using temporary; Using filesort
-1	SIMPLE	t3	eq_ref	PRIMARY	PRIMARY	2	t1.skr	1	where used
+1	SIMPLE	t3	eq_ref	PRIMARY	PRIMARY	2	t1.skr	1	Using where
 drop table t1,t2,t3;
 CREATE TABLE t1 (
 `titre` char(80) NOT NULL default '',
diff --git a/mysql-test/r/query_cache.result b/mysql-test/r/query_cache.result
index a09f46081427c5e80cee3cf676395bd19d2faa9e..a37313a150a3cd60d8174796ccd76be9649c3ec4 100644
--- a/mysql-test/r/query_cache.result
+++ b/mysql-test/r/query_cache.result
@@ -320,6 +320,9 @@ insert into t1 select * from t2;
 show status like "Qcache_hits";
 Variable_name	Value
 Qcache_hits	4
+show status like "Qcache_lowmem_prunes";
+Variable_name	Value
+Qcache_lowmem_prunes	0
 select a as a1, a as a2 from t1;
 select a as a2, a as a3 from t1;
 select a as a3, a as a4 from t1;
@@ -330,6 +333,9 @@ Qcache_hits	4
 show status like "Qcache_queries_in_cache";
 Variable_name	Value
 Qcache_queries_in_cache	2
+show status like "Qcache_lowmem_prunes";
+Variable_name	Value
+Qcache_lowmem_prunes	2
 reset query cache;
 insert into t2 select * from t1;
 insert into t1 select * from t2;
diff --git a/mysql-test/r/rpl000007.result b/mysql-test/r/rpl000007.result
deleted file mode 100644
index 6889f6af2bc987082e646a73a46f8e44a1190559..0000000000000000000000000000000000000000
--- a/mysql-test/r/rpl000007.result
+++ /dev/null
@@ -1,20 +0,0 @@
-stop slave;
-drop table if exists t1,t2,t3,t4,t5,t6,t7,t8,t9;
-reset master;
-reset slave;
-drop table if exists t1,t2,t3,t4,t5,t6,t7,t8,t9;
-start slave;
-drop table if exists foo;
-create table foo (n int);
-insert into foo values(4);
-drop table if exists foo;
-create table foo (s char(20));
-load data infile '../../std_data/words.dat' into table foo;
-insert into foo values('five');
-drop table if exists bar;
-create table bar (m int);
-insert into bar values(15);
-select foo.n,bar.m from foo,bar;
-n	m
-4	15
-drop table if exists bar,foo;
diff --git a/mysql-test/r/rpl_log.result b/mysql-test/r/rpl_log.result
index a5850cbd1814acadc09e3207e89c196fcb842d60..ed54eb75f4bfa99f0ca54ff8d37de0656227c063 100644
--- a/mysql-test/r/rpl_log.result
+++ b/mysql-test/r/rpl_log.result
@@ -72,7 +72,7 @@ show binlog events in 'slave-bin.000001' from 4;
 Log_name	Pos	Event_type	Server_id	Orig_log_pos	Info
 slave-bin.000001	4	Start	2	4	Server ver: VERSION, Binlog ver: 3
 slave-bin.000001	79	Query	1	79	use `test`; create table t1(n int not null auto_increment primary key)
-slave-bin.000001	172	Intvar	1	200	INSERT_ID=1
+slave-bin.000001	172	Intvar	1	172	INSERT_ID=1
 slave-bin.000001	200	Query	1	200	use `test`; insert into t1 values (NULL)
 slave-bin.000001	263	Query	1	263	use `test`; drop table t1
 slave-bin.000001	311	Query	1	311	use `test`; create table t1 (word char(20) not null)
diff --git a/mysql-test/r/rpl_replicate_do.result b/mysql-test/r/rpl_replicate_do.result
new file mode 100644
index 0000000000000000000000000000000000000000..aabda54640ca0978f9d589384068e80fe124f9b1
--- /dev/null
+++ b/mysql-test/r/rpl_replicate_do.result
@@ -0,0 +1,28 @@
+stop slave;
+drop table if exists t1,t2,t3,t4,t5,t6,t7,t8,t9;
+reset master;
+reset slave;
+drop table if exists t1,t2,t3,t4,t5,t6,t7,t8,t9;
+start slave;
+drop table if exists t11;
+drop table if exists t11;
+create table t2 (n int);
+insert into t2 values(4);
+create table t2 (s char(20));
+load data infile '../../std_data/words.dat' into table t2;
+insert into t2 values('five');
+create table t1 (m int);
+insert into t1 values(15),(16),(17);
+update t1 set m=20 where m=16;
+delete from t1 where m=17;
+create table t11 select * from t1;
+select * from t1;
+m
+15
+20
+select * from t2;
+n
+4
+select * from t11;
+Table 'test.t11' doesn't exist
+drop table if exists t1,t2,t3,t11;
diff --git a/mysql-test/r/rpl_rotate_logs.result b/mysql-test/r/rpl_rotate_logs.result
index a5928edfaa349576308c7d50534c192b7d9d1cea..2582b875daa810983c8e524cb262a2571ae21560 100644
--- a/mysql-test/r/rpl_rotate_logs.result
+++ b/mysql-test/r/rpl_rotate_logs.result
@@ -1,3 +1,5 @@
+drop table if exists t1, t2, t3, t4;
+drop table if exists t1, t2, t3, t4;
 start slave;
 Could not initialize master info structure, check permisions on master.info
 start slave;
@@ -8,7 +10,6 @@ reset slave;
 change master to master_host='127.0.0.1',master_port=MASTER_PORT, master_user='root';
 reset master;
 start slave;
-drop table if exists t1, t2, t3, t4;
 create temporary table temp_table (a char(80) not null);
 insert into temp_table values ("testing temporary tables");
 create table t1 (s text);
diff --git a/mysql-test/r/select.result b/mysql-test/r/select.result
index 3a15e419fa58819040265de21ab14157ddcb762b..94c93dbc3dc226ca9776be99c03a5d28920e575a 100644
--- a/mysql-test/r/select.result
+++ b/mysql-test/r/select.result
@@ -1328,19 +1328,19 @@ select t2.fld3 from t2 where fld3 LIKE 'don_t_find_me_please%';
 fld3
 explain select t2.fld3 from t2 where fld3 = 'honeysuckle';
 id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
-1	SIMPLE	t2	ref	fld3	fld3	30	const	1	where used; Using index
+1	SIMPLE	t2	ref	fld3	fld3	30	const	1	Using where; Using index
 explain select fld3 from t2 ignore index (fld3) where fld3 = 'honeysuckle';
 id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
-1	SIMPLE	t2	index	NULL	fld3	30	NULL	1199	where used; Using index
+1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	1199	Using where
 explain select fld3 from t2 use index (fld1) where fld3 = 'honeysuckle';
 id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
-1	SIMPLE	t2	index	NULL	fld3	30	NULL	1199	where used; Using index
+1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	1199	Using where
 explain select fld3 from t2 use index (fld3) where fld3 = 'honeysuckle';
 id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
-1	SIMPLE	t2	ref	fld3	fld3	30	const	1	where used; Using index
+1	SIMPLE	t2	ref	fld3	fld3	30	const	1	Using where; Using index
 explain select fld3 from t2 use index (fld1,fld3) where fld3 = 'honeysuckle';
 id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
-1	SIMPLE	t2	ref	fld3	fld3	30	const	1	where used; Using index
+1	SIMPLE	t2	ref	fld3	fld3	30	const	1	Using where; Using index
 explain select fld3 from t2 ignore index (fld3,not_used);
 Key column 'not_used' doesn't exist in table
 explain select fld3 from t2 use index (not_used);
@@ -1351,7 +1351,7 @@ honeysuckle
 honoring
 explain select t2.fld3 from t2 where fld3 >= 'honeysuckle' and fld3 <= 'honoring' order by fld3;
 id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
-1	SIMPLE	t2	range	fld3	fld3	30	NULL	2	where used; Using index
+1	SIMPLE	t2	range	fld3	fld3	30	NULL	2	Using where; Using index
 select fld1,fld3 from t2 where fld3="Colombo" or fld3 = "nondecreasing" order by fld3;
 fld1	fld3
 148504	Colombo
@@ -1371,7 +1371,7 @@ fld1
 250502
 explain select fld1 from t2 where fld1=250501 or fld1="250502";
 id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
-1	SIMPLE	t2	range	fld1	fld1	4	NULL	2	where used; Using index
+1	SIMPLE	t2	range	fld1	fld1	4	NULL	2	Using where; Using index
 select fld1 from t2 where fld1=250501 or fld1=250502 or fld1 >= 250505 and fld1 <= 250601 or fld1 between 250501 and 250502;
 fld1
 250501
@@ -1380,7 +1380,7 @@ fld1
 250601
 explain select fld1 from t2 where fld1=250501 or fld1=250502 or fld1 >= 250505 and fld1 <= 250601 or fld1 between 250501 and 250502;
 id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
-1	SIMPLE	t2	range	fld1	fld1	4	NULL	4	where used; Using index
+1	SIMPLE	t2	range	fld1	fld1	4	NULL	4	Using where; Using index
 select fld1,fld3 from t2 where companynr = 37 and fld3 like 'f%';
 fld1	fld3
 218401	faithful
@@ -1807,8 +1807,8 @@ select distinct fld3 from t2,t3 where t2.companynr = 34 and t2.fld1=t3.t2nr orde
 fld3
 explain select t3.t2nr,fld3 from t2,t3 where t2.companynr = 34 and t2.fld1=t3.t2nr order by t3.t2nr,fld3;
 id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
-1	SIMPLE	t2	ALL	fld1	NULL	NULL	NULL	1199	where used; Using temporary; Using filesort
-1	SIMPLE	t3	eq_ref	PRIMARY	PRIMARY	4	t2.fld1	1	where used; Using index
+1	SIMPLE	t2	ALL	fld1	NULL	NULL	NULL	1199	Using where; Using temporary; Using filesort
+1	SIMPLE	t3	eq_ref	PRIMARY	PRIMARY	4	t2.fld1	1	Using where; Using index
 explain select * from t3 as t1,t3 where t1.period=t3.period order by t3.period;
 id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
 1	SIMPLE	t1	ALL	period	NULL	NULL	NULL	41810	Using temporary; Using filesort
@@ -2575,11 +2575,11 @@ companynr	companyname
 explain select t2.companynr,companyname from t2 left join t4 using (companynr) where t4.companynr is null;
 id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
 1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	1199	
-1	SIMPLE	t4	eq_ref	PRIMARY	PRIMARY	1	test.t2.companynr	1	where used; Not exists
+1	SIMPLE	t4	eq_ref	PRIMARY	PRIMARY	1	test.t2.companynr	1	Using where; Not exists
 explain select t2.companynr,companyname from t4 left join t2 using (companynr) where t2.companynr is null;
 id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
 1	SIMPLE	t4	ALL	NULL	NULL	NULL	NULL	12	
-1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	1199	where used; Not exists
+1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	1199	Using where; Not exists
 select distinct t2.companynr,t4.companynr from t2,t4 where t2.companynr=t4.companynr+1;
 companynr	companynr
 37	36
@@ -2587,7 +2587,7 @@ companynr	companynr
 explain select distinct t2.companynr,t4.companynr from t2,t4 where t2.companynr=t4.companynr+1;
 id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
 1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	1199	Using temporary
-1	SIMPLE	t4	index	NULL	PRIMARY	1	NULL	12	where used; Using index
+1	SIMPLE	t4	index	NULL	PRIMARY	1	NULL	12	Using where; Using index
 select t2.fld1,t2.companynr,fld3,period from t3,t2 where t2.fld1 = 38208 and t2.fld1=t3.t2nr and period = 1008 or t2.fld1 = 38008 and t2.fld1 =t3.t2nr and period = 1008;
 fld1	companynr	fld3	period
 038008	37	reporters	1008
diff --git a/mysql-test/r/select_found.result b/mysql-test/r/select_found.result
index 1c2cd7da894bf778633f9a001c3db73d0a5ef1a7..8500e244d083fc7ac9a493673f41cfbfc008c058 100644
--- a/mysql-test/r/select_found.result
+++ b/mysql-test/r/select_found.result
@@ -168,4 +168,24 @@ test2	2	2
 SELECT FOUND_ROWS();
 FOUND_ROWS()
 2
+SELECT SQL_CALC_FOUND_ROWS 1 FROM (SELECT 1) LIMIT 0;
+1
+SELECT FOUND_ROWS();
+FOUND_ROWS()
+1
+SELECT SQL_CALC_FOUND_ROWS * FROM t1 WHERE numeropost > 1  LIMIT 0;
+titre	numeropost	maxnumrep
+SELECT FOUND_ROWS();
+FOUND_ROWS()
+2
+SELECT SQL_CALC_FOUND_ROWS * FROM t1 LIMIT 0;
+titre	numeropost	maxnumrep
+SELECT FOUND_ROWS();
+FOUND_ROWS()
+3
+SELECT SQL_CALC_FOUND_ROWS * FROM t1 ORDER BY numeropost  LIMIT 0;
+titre	numeropost	maxnumrep
+SELECT FOUND_ROWS();
+FOUND_ROWS()
+3
 drop table t1;
diff --git a/mysql-test/r/subselect.result b/mysql-test/r/subselect.result
index cc907d33cc2d4b4323dbbdaf8e6aed710cd12f95..1b4289540300fd3a010f61e3e28e95c9fe98f0a0 100644
--- a/mysql-test/r/subselect.result
+++ b/mysql-test/r/subselect.result
@@ -8,7 +8,31 @@ SELECT (SELECT 1) UNION SELECT (SELECT 2);
 SELECT (SELECT (SELECT 0 UNION SELECT 0));
 (SELECT (SELECT 0 UNION SELECT 0))
 0
-drop table if exists t1,t2,t3,t4,t5,attend,clinic,inscrit;
+SELECT (SELECT 1 FROM (SELECT 1) HAVING a=1) as a;
+Reference 'a' not supported (forward reference in item list)
+SELECT (SELECT 1 FROM (SELECT 1) HAVING b=1) as a,(SELECT 1 FROM (SELECT 1) HAVING a=1) as b;
+Reference 'b' not supported (forward reference in item list)
+SELECT (SELECT 1),MAX(1) FROM (SELECT 1);
+(SELECT 1)	MAX(1)
+1	1
+SELECT (SELECT a) as a;
+Reference 'a' not supported (forward reference in item list)
+EXPLAIN SELECT 1 FROM (SELECT 1 as a) HAVING (SELECT a)=1;
+id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
+1	PRIMARY	<derived2>	system	NULL	NULL	NULL	NULL	1	
+3	DEPENDENT SUBSELECT								No tables used
+2	DERIVED								No tables used
+SELECT 1 FROM (SELECT 1 as a) HAVING (SELECT a)=1;
+1
+1
+SELECT (SELECT 1), a;
+Unknown column 'a' in 'field list'
+SELECT 1 as a FROM (SELECT 1) HAVING (SELECT a)=1;
+a
+1
+SELECT 1 FROM (SELECT (SELECT a));
+Unknown column 'a' in 'field list'
+drop table if exists t1,t2,t3,t4,t5,t6,t7,t8;
 create table t1 (a int);
 create table t2 (a int, b int);
 create table t3 (a int);
@@ -16,6 +40,8 @@ create table t4 (a int, b int);
 insert into t1 values (2);
 insert into t2 values (1,7),(2,7);
 insert into t4 values (4,8),(3,8),(5,9);
+select (select a from t1 where t1.a = a1) as a2, (select b from t2 where t2.b=a2) as a1;
+Reference 'a1' not supported (forward reference in item list)
 select (select a from t1 where t1.a=t2.a), a from t2;
 (select a from t1 where t1.a=t2.a)	a
 NULL	1
@@ -46,7 +72,7 @@ a	b
 1	7
 2	7
 3	8
-select * from t2 where t2.b=(select a from t3 order by 1 desc limit 1) 
+select * from t2 where t2.b=(select a from t3 order by 1 desc limit 1)
 union (select * from t4 where t4.b=(select max(t2.a)*4 from t2) order by a);
 a	b
 1	7
@@ -56,9 +82,9 @@ a	b
 explain select * from t2 where t2.b=(select a from t3 order by 1 desc limit 1) 
 union (select * from t4 where t4.b=(select max(t2.a)*4 from t2) order by a);
 id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
-1	PRIMARY	t2	ALL	NULL	NULL	NULL	NULL	2	where used
+1	PRIMARY	t2	ALL	NULL	NULL	NULL	NULL	2	Using where
 2	SUBSELECT	t3	ALL	NULL	NULL	NULL	NULL	3	Using filesort
-3	UNION	t4	ALL	NULL	NULL	NULL	NULL	3	where used; Using filesort
+3	UNION	t4	ALL	NULL	NULL	NULL	NULL	3	Using where; Using filesort
 4	SUBSELECT	t2	ALL	NULL	NULL	NULL	NULL	2	
 select (select a from t3 where a<t2.a*4 order by 1 desc limit 1), a from t2;
 (select a from t3 where a<t2.a*4 order by 1 desc limit 1)	a
@@ -71,9 +97,9 @@ select (select t3.a from t3 where a<8 order by 1 desc limit 1), a from
 explain select (select t3.a from t3 where a<8 order by 1 desc limit 1), a from 
 (select * from t2 where a>1) as tt;
 id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
-3	DERIVED	t2	ALL	NULL	NULL	NULL	NULL	2	where used
 1	PRIMARY	<derived3>	system	NULL	NULL	NULL	NULL	1	
-2	SUBSELECT	t3	ALL	NULL	NULL	NULL	NULL	3	where used; Using filesort
+3	DERIVED	t2	ALL	NULL	NULL	NULL	NULL	2	Using where
+2	SUBSELECT	t3	ALL	NULL	NULL	NULL	NULL	3	Using where; Using filesort
 select * from t1 where t1.a=(select t2.a from t2 where t2.b=(select max(a) from t3) order by 1 desc limit 1);
 a
 2
@@ -91,7 +117,7 @@ explain select b,(select avg(t2.a+(select min(t3.a) from t3 where t3.a >= t4.a))
 id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
 1	PRIMARY	t4	ALL	NULL	NULL	NULL	NULL	3	
 2	DEPENDENT SUBSELECT	t2	ALL	NULL	NULL	NULL	NULL	2	
-3	DEPENDENT SUBSELECT	t3	ALL	NULL	NULL	NULL	NULL	3	where used
+3	DEPENDENT SUBSELECT	t3	ALL	NULL	NULL	NULL	NULL	3	Using where
 select * from t3 where exists (select * from t2 where t2.b=t3.a);
 a
 7
@@ -166,15 +192,15 @@ NULL	1
 explain select (select a from t1 where t1.a=t2.a union select a from t5 where t5.a=t2.a), a from t2;
 id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
 1	PRIMARY	t2	ALL	NULL	NULL	NULL	NULL	2	
-2	DEPENDENT SUBSELECT	t1	system	NULL	NULL	NULL	NULL	1	where used
-3	DEPENDENT UNION	t5	ALL	NULL	NULL	NULL	NULL	2	where used
+2	DEPENDENT SUBSELECT	t1	system	NULL	NULL	NULL	NULL	1	Using where
+3	DEPENDENT UNION	t5	ALL	NULL	NULL	NULL	NULL	2	Using where
 select (select a from t1 where t1.a=t2.a union all select a from t5 where t5.a=t2.a), a from t2;
 Subselect returns more than 1 record
-create table attend (patient_uq int, clinic_uq int, index i1 (clinic_uq));
-create table clinic( uq int primary key, name char(25));
-insert into clinic values(1,"Oblastnaia bolnitsa"),(2,"Bolnitsa Krasnogo Kresta");
-insert into attend values (1,1),(1,2),(2,2),(1,3);
-select * from attend where exists (select * from clinic where uq = clinic_uq);
+create table t6 (patient_uq int, clinic_uq int, index i1 (clinic_uq));
+create table t7( uq int primary key, name char(25));
+insert into t7 values(1,"Oblastnaia bolnitsa"),(2,"Bolnitsa Krasnogo Kresta");
+insert into t6 values (1,1),(1,2),(2,2),(1,3);
+select * from t6 where exists (select * from t7 where uq = clinic_uq);
 patient_uq	clinic_uq
 1	1
 1	2
@@ -197,106 +223,274 @@ W	1
 SELECT * FROM t3 WHERE b = (SELECT MIN(b) FROM t3);
 a	b
 W	a
-drop table if exists inscrit;
-CREATE TABLE `inscrit` (
+drop table if exists t8;
+CREATE TABLE `t8` (
 `pseudo` varchar(35) character set latin1 NOT NULL default '',
 `email` varchar(60) character set latin1 NOT NULL default '',
 PRIMARY KEY  (`pseudo`),
 UNIQUE KEY `email` (`email`)
 ) TYPE=MyISAM CHARSET=latin1 ROW_FORMAT=DYNAMIC;
-INSERT INTO inscrit (pseudo,email) VALUES ('joce','test');
-INSERT INTO inscrit (pseudo,email) VALUES ('joce1','test1');
-INSERT INTO inscrit (pseudo,email) VALUES ('2joce1','2test1');
-EXPLAIN SELECT pseudo,(SELECT email FROM inscrit WHERE pseudo=(SELECT pseudo FROM inscrit WHERE pseudo='joce')) FROM inscrit WHERE pseudo=(SELECT pseudo FROM inscrit WHERE pseudo='joce');
+INSERT INTO t8 (pseudo,email) VALUES ('joce','test');
+INSERT INTO t8 (pseudo,email) VALUES ('joce1','test1');
+INSERT INTO t8 (pseudo,email) VALUES ('2joce1','2test1');
+EXPLAIN SELECT pseudo,(SELECT email FROM t8 WHERE pseudo=(SELECT pseudo FROM t8 WHERE pseudo='joce')) FROM t8 WHERE pseudo=(SELECT pseudo FROM t8 WHERE pseudo='joce');
 id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
-1	PRIMARY	inscrit	const	PRIMARY	PRIMARY	35	const	1	
-4	SUBSELECT	inscrit	const	PRIMARY	PRIMARY	35	const	1	
-2	SUBSELECT	inscrit	const	PRIMARY	PRIMARY	35	const	1	
-3	SUBSELECT	inscrit	const	PRIMARY	PRIMARY	35	const	1	
-SELECT pseudo FROM inscrit WHERE pseudo=(SELECT pseudo,email FROM
-inscrit WHERE pseudo='joce');
+1	PRIMARY	t8	const	PRIMARY	PRIMARY	35	const	1	
+4	SUBSELECT	t8	const	PRIMARY	PRIMARY	35	const	1	
+2	SUBSELECT	t8	const	PRIMARY	PRIMARY	35	const	1	
+3	SUBSELECT	t8	const	PRIMARY	PRIMARY	35	const	1	
+SELECT pseudo FROM t8 WHERE pseudo=(SELECT pseudo,email FROM
+t8 WHERE pseudo='joce');
 Subselect returns more than 1 field
-SELECT pseudo FROM inscrit WHERE pseudo=(SELECT * FROM inscrit WHERE
+SELECT pseudo FROM t8 WHERE pseudo=(SELECT * FROM t8 WHERE
 pseudo='joce');
 Subselect returns more than 1 field
-SELECT pseudo FROM inscrit WHERE pseudo=(SELECT pseudo FROM inscrit WHERE pseudo='joce');
+SELECT pseudo FROM t8 WHERE pseudo=(SELECT pseudo FROM t8 WHERE pseudo='joce');
 pseudo
 joce
-SELECT pseudo FROM inscrit WHERE pseudo=(SELECT pseudo FROM inscrit WHERE pseudo LIKE '%joce%');
+SELECT pseudo FROM t8 WHERE pseudo=(SELECT pseudo FROM t8 WHERE pseudo LIKE '%joce%');
 Subselect returns more than 1 record
-drop table if exists t1,t2,t3,t4,t5,attend,clinic,inscrit;
-drop table if exists searchconthardwarefr3, forumconthardwarefr7;
-CREATE TABLE `searchconthardwarefr3` (
+drop table if exists t1,t2,t3,t4,t5,t6,t7,t8;
+CREATE TABLE `t1` (
 `topic` mediumint(8) unsigned NOT NULL default '0',
 `date` date NOT NULL default '0000-00-00',
 `pseudo` varchar(35) character set latin1 NOT NULL default '',
 PRIMARY KEY  (`pseudo`,`date`,`topic`),
 KEY `topic` (`topic`)
 ) TYPE=MyISAM ROW_FORMAT=DYNAMIC;
-INSERT INTO searchconthardwarefr3 (topic,date,pseudo) VALUES
+INSERT INTO t1 (topic,date,pseudo) VALUES
 ('43506','2002-10-02','joce'),('40143','2002-08-03','joce');
-EXPLAIN SELECT DISTINCT date FROM searchconthardwarefr3 WHERE date='2002-08-03';
+EXPLAIN SELECT DISTINCT date FROM t1 WHERE date='2002-08-03';
 id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
-1	SIMPLE	searchconthardwarefr3	index	NULL	PRIMARY	41	NULL	2	where used; Using index
-EXPLAIN SELECT (SELECT DISTINCT date FROM searchconthardwarefr3 WHERE date='2002-08-03');
+1	SIMPLE	t1	index	NULL	PRIMARY	41	NULL	2	Using where; Using index
+EXPLAIN SELECT (SELECT DISTINCT date FROM t1 WHERE date='2002-08-03');
 id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
 1	PRIMARY								No tables used
-2	SUBSELECT	searchconthardwarefr3	index	NULL	PRIMARY	41	NULL	2	where used; Using index
-SELECT DISTINCT date FROM searchconthardwarefr3 WHERE date='2002-08-03';
+2	SUBSELECT	t1	index	NULL	PRIMARY	41	NULL	2	Using where; Using index
+SELECT DISTINCT date FROM t1 WHERE date='2002-08-03';
 date
 2002-08-03
-SELECT (SELECT DISTINCT date FROM searchconthardwarefr3 WHERE date='2002-08-03');
-(SELECT DISTINCT date FROM searchconthardwarefr3 WHERE date='2002-08-03')
+SELECT (SELECT DISTINCT date FROM t1 WHERE date='2002-08-03');
+(SELECT DISTINCT date FROM t1 WHERE date='2002-08-03')
 2002-08-03
-SELECT 1 FROM searchconthardwarefr3 WHERE 1=(SELECT 1 UNION SELECT 1) UNION ALL SELECT 1;
+SELECT 1 FROM t1 WHERE 1=(SELECT 1 UNION SELECT 1) UNION ALL SELECT 1;
 1
 1
 1
 1
-SELECT 1 FROM searchconthardwarefr3 WHERE 1=(SELECT 1 UNION ALL SELECT 1) UNION SELECT 1;
+SELECT 1 FROM t1 WHERE 1=(SELECT 1 UNION ALL SELECT 1) UNION SELECT 1;
 Subselect returns more than 1 record
-EXPLAIN SELECT 1 FROM searchconthardwarefr3 WHERE 1=(SELECT 1 UNION SELECT 1);
+EXPLAIN SELECT 1 FROM t1 WHERE 1=(SELECT 1 UNION SELECT 1);
 id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
-1	PRIMARY	searchconthardwarefr3	index	NULL	topic	3	NULL	2	Using index
+1	PRIMARY	t1	index	NULL	topic	3	NULL	2	Using index
 2	SUBSELECT								No tables used
 3	UNION								No tables used
-SELECT 1 IN (SELECT 1 FROM searchconthardwarefr3 HAVING a);
+SELECT 1 IN (SELECT 1 FROM t1 HAVING a);
 Unknown column 'a' in 'having clause'
-SELECT * from searchconthardwarefr3 where topic IN (SELECT topic FROM searchconthardwarefr3 GROUP BY date);
+SELECT * from t1 where topic IN (SELECT topic FROM t1 GROUP BY date);
 topic	date	pseudo
 40143	2002-08-03	joce
 43506	2002-10-02	joce
-SELECT * from searchconthardwarefr3 where topic IN (SELECT topic FROM searchconthardwarefr3 GROUP BY date HAVING topic < 4100);
+SELECT * from t1 where topic IN (SELECT topic FROM t1 GROUP BY date HAVING topic < 4100);
 topic	date	pseudo
 43506	2002-10-02	joce
-SELECT * from searchconthardwarefr3 where topic IN (SELECT SUM(topic) FROM searchconthardwarefr3);
+SELECT * from t1 where topic IN (SELECT SUM(topic) FROM t1);
 topic	date	pseudo
-SELECT * from searchconthardwarefr3 where topic = any (SELECT topic FROM searchconthardwarefr3 GROUP BY date);
+SELECT * from t1 where topic = any (SELECT topic FROM st1 GROUP BY date);
 topic	date	pseudo
 40143	2002-08-03	joce
 43506	2002-10-02	joce
-SELECT * from searchconthardwarefr3 where topic = any (SELECT topic FROM searchconthardwarefr3 GROUP BY date HAVING topic < 4100);
+SELECT * from t1 where topic = any (SELECT topic FROM t1 GROUP BY date HAVING topic < 4100);
 topic	date	pseudo
 43506	2002-10-02	joce
-SELECT * from searchconthardwarefr3 where topic = any (SELECT SUM(topic) FROM searchconthardwarefr3);
+SELECT * from t1 where topic = any (SELECT SUM(topic) FROM t1);
 topic	date	pseudo
-SELECT * from searchconthardwarefr3 where topic = all (SELECT topic FROM searchconthardwarefr3 GROUP BY date);
+SELECT * from t1 where topic = all (SELECT topic FROM t1 GROUP BY date);
 topic	date	pseudo
-SELECT * from searchconthardwarefr3 where topic = all (SELECT topic FROM searchconthardwarefr3 GROUP BY date HAVING topic < 4100);
+SELECT * from t1 where topic = all (SELECT topic FROM t1 GROUP BY date HAVING topic < 4100);
 topic	date	pseudo
 40143	2002-08-03	joce
-SELECT * from searchconthardwarefr3 where topic = all (SELECT SUM(topic) FROM searchconthardwarefr3);
+SELECT * from t1 where topic = all (SELECT SUM(topic) FROM t1);
 topic	date	pseudo
-SELECT * from searchconthardwarefr3 where topic <> any (SELECT SUM(topic) FROM searchconthardwarefr3);
+SELECT * from t1 where topic <> any (SELECT SUM(topic) FROM t1);
 topic	date	pseudo
 40143	2002-08-03	joce
 43506	2002-10-02	joce
-CREATE TABLE `forumconthardwarefr7` (
+CREATE TABLE `t2` (
 `numeropost` mediumint(8) unsigned NOT NULL auto_increment,
 `maxnumrep` int(10) unsigned NOT NULL default '0',
 PRIMARY KEY  (`numeropost`),
 UNIQUE KEY `maxnumrep` (`maxnumrep`)) TYPE=MyISAM ROW_FORMAT=FIXED;
-INSERT INTO forumconthardwarefr7 (numeropost,maxnumrep) VALUES (40143,1),(43506,2);
-SELECT SQL_CALC_FOUND_ROWS numeropost,maxnumrep FROM forumconthardwarefr7 WHERE numeropost IN (SELECT topic FROM searchconthardwarefr3 WHERE pseudo='joce' AND date >= '2002-10-06') ORDER BY maxnumrep DESC LIMIT 0,20;
+INSERT INTO t1 (numeropost,maxnumrep) VALUES (40143,1),(43506,2);
+SELECT SQL_CALC_FOUND_ROWS numeropost,maxnumrep FROM t2 WHERE numeropost IN (SELECT topic FROM t1 WHERE pseudo='joce' AND date >= '2002-10-06') ORDER BY maxnumrep DESC LIMIT 0,20;
 numeropost	maxnumrep
-drop table searchconthardwarefr3, forumconthardwarefr7;
+drop table t1,t2;
+CREATE TABLE `t1` (
+`numeropost` mediumint(8) unsigned NOT NULL auto_increment,
+`maxnumrep` int(10) unsigned NOT NULL default '0',
+PRIMARY KEY  (`numeropost`),
+UNIQUE KEY `maxnumrep` (`maxnumrep`)
+) TYPE=MyISAM ROW_FORMAT=FIXED;
+INSERT INTO t1 (numeropost,maxnumrep) VALUES (40143,1),(43506,2);
+CREATE TABLE `t2` (
+`mot` varchar(30) NOT NULL default '',
+`topic` mediumint(8) unsigned NOT NULL default '0',
+`date` date NOT NULL default '0000-00-00',
+`pseudo` varchar(35) NOT NULL default '',
+PRIMARY KEY  (`mot`,`pseudo`,`date`,`topic`)
+) TYPE=MyISAM ROW_FORMAT=DYNAMIC;
+INSERT INTO t2 (mot,topic,date,pseudo) VALUES ('joce','40143','2002-10-22','joce'), ('joce','43506','2002-10-22','joce');
+select numeropost as a FROM t1 GROUP BY (SELECT 1 FROM t1 HAVING a=1);
+a
+40143
+SELECT numeropost,maxnumrep FROM t1 WHERE exists (SELECT 1 FROM t2 WHERE (mot='joce') AND date >= '2002-10-21' AND t1.numeropost = t2.topic) ORDER BY maxnumrep DESC LIMIT 0, 20;
+numeropost	maxnumrep
+43506	2
+40143	1
+SELECT (SELECT 1) as a FROM (SELECT 1 FROM t1 HAVING a=1);
+Unknown column 'a' in 'having clause'
+drop table t1, t2;
+drop table if exists t1;
+CREATE TABLE `t1` (
+`numeropost` mediumint(8) unsigned NOT NULL auto_increment,
+`maxnumrep` int(10) unsigned NOT NULL default '0',
+PRIMARY KEY  (`numeropost`),
+UNIQUE KEY `maxnumrep` (`maxnumrep`)
+) TYPE=MyISAM ROW_FORMAT=FIXED;
+INSERT INTO t1 (numeropost,maxnumrep) VALUES (1,0),(2,1);
+select numeropost as a FROM t1 GROUP BY (SELECT 1 FROM t1 HAVING a=1);
+Subselect returns more than 1 record
+select numeropost as a FROM t1 ORDER BY (SELECT 1 FROM t1 HAVING a=1);
+Subselect returns more than 1 record
+drop table t1;
+CREATE TABLE t1 (field char(1) NOT NULL DEFAULT 'b');
+INSERT INTO t1 VALUES ();
+SELECT field FROM t1 WHERE 1=(SELECT 1 UNION ALL SELECT 1 FROM (SELECT 1) HAVING field='b');
+Subselect returns more than 1 record
+drop table t1;
+CREATE TABLE `t1` (
+`numeropost` mediumint(8) unsigned NOT NULL default '0',
+`numreponse` int(10) unsigned NOT NULL auto_increment,
+`pseudo` varchar(35) NOT NULL default '',
+PRIMARY KEY  (`numeropost`,`numreponse`),
+UNIQUE KEY `numreponse` (`numreponse`),
+KEY `pseudo` (`pseudo`,`numeropost`)
+) TYPE=MyISAM;
+SELECT (SELECT numeropost FROM t1 HAVING numreponse=a),numreponse FROM (SELECT * FROM t1) as a;
+Reference 'numreponse' not supported (forward reference in item list)
+SELECT numreponse, (SELECT numeropost FROM t1 HAVING numreponse=a) FROM (SELECT * FROM t1) as a;
+Unknown column 'a' in 'having clause'
+SELECT numreponse, (SELECT numeropost FROM t1 HAVING numreponse=1) FROM (SELECT * FROM t1) as a;
+numreponse	(SELECT numeropost FROM t1 HAVING numreponse=1)
+INSERT INTO t1 (numeropost,numreponse,pseudo) VALUES (1,1,'joce'),(1,2,'joce'),(1,3,'test');
+EXPLAIN SELECT numreponse FROM t1 WHERE numeropost='1' AND numreponse=(SELECT 1 FROM t1 WHERE numeropost='1');
+Subselect returns more than 1 record
+EXPLAIN SELECT MAX(numreponse) FROM t1 WHERE numeropost='1';
+id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
+1	SIMPLE								Select tables optimized away
+EXPLAIN SELECT numreponse FROM t1 WHERE numeropost='1' AND numreponse=(SELECT MAX(numreponse) FROM t1 WHERE numeropost='1');
+id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
+1	PRIMARY	t1	const	PRIMARY,numreponse	PRIMARY	7	const,const	1	
+2	SUBSELECT								Select tables optimized away
+drop table t1;
+CREATE TABLE t1 (a int(1));
+INSERT INTO t1 VALUES (1);
+SELECT 1 FROM (SELECT a FROM t1) HAVING (SELECT a)=1;
+1
+1
+drop table t1;
+create table t1 (a int NOT NULL, b int, primary key (a));
+create table t2 (a int NOT NULL, b int, primary key (a));
+insert into t1 values (0, 10),(1, 11),(2, 12);
+insert into t2 values (1, 21),(2, 22),(3, 23);
+select * from t1;
+a	b
+0	10
+1	11
+2	12
+update t1 set b= (select b from t2 where t1.a = t2.a);
+select * from t1;
+a	b
+0	NULL
+1	21
+2	22
+drop table t1, t2;
+create table t1 (a int NOT NULL, b int, primary key (a));
+create table t2 (a int NOT NULL, b int, primary key (a));
+insert into t1 values (0, 10),(1, 11),(2, 12);
+insert into t2 values (1, 21),(2, 12),(3, 23);
+select * from t1;
+a	b
+0	10
+1	11
+2	12
+select * from t1 where b = (select b from t2 where t1.a = t2.a);
+a	b
+2	12
+delete from t1 where b = (select b from t2 where t1.a = t2.a);
+select * from t1;
+a	b
+0	10
+1	11
+drop table t1, t2;
+CREATE TABLE t1 (x int);
+create table t2 (a int);
+insert into t2 values (1);
+INSERT INTO t1 (x) VALUES ((SELECT a FROM t2));
+select * from t1;
+x
+1
+insert into t2 values (1);
+INSERT DELAYED INTO t1 (x) VALUES ((SELECT SUM(a) FROM t2));
+select * from t1;
+x
+1
+2
+INSERT INTO t1 (x) select (SELECT SUM(a)+1 FROM t2) FROM t2;
+select * from t1;
+x
+1
+2
+3
+3
+INSERT INTO t1 (x) select (SELECT SUM(x)+2 FROM t1) FROM t2;
+INSERT TABLE 't1' isn't allowed in FROM table list
+INSERT DELAYED INTO t1 (x) VALUES ((SELECT SUM(x) FROM t1));
+select * from t1;
+x
+1
+2
+3
+3
+9
+drop table t1, t2;
+CREATE TABLE t1 (x int not null, y int, primary key (x));
+create table t2 (a int);
+insert into t2 values (1);
+select * from t1;
+x	y
+replace into t1 (x, y) VALUES ((SELECT a FROM t2), (SELECT a+1 FROM t2));
+select * from t1;
+x	y
+1	2
+replace into t1 (x, y) VALUES ((SELECT a FROM t2), (SELECT a+2 FROM t2));
+select * from t1;
+x	y
+1	3
+replace DELAYED into t1 (x, y) VALUES ((SELECT a+3 FROM t2), (SELECT a FROM t2));
+select * from t1;
+x	y
+1	3
+4	1
+replace DELAYED into t1 (x, y) VALUES ((SELECT a+3 FROM t2), (SELECT a+1 FROM t2));
+select * from t1;
+x	y
+1	3
+4	2
+replace LOW_PRIORITY into t1 (x, y) VALUES ((SELECT a+1 FROM t2), (SELECT a FROM t2));
+select * from t1;
+x	y
+1	3
+4	2
+2	1
+drop table t1, t2;
diff --git a/mysql-test/r/temp_table.result b/mysql-test/r/temp_table.result
index 84a00bfea34de4d58a566c91d495efacac5bbefc..45f879e182b68d1c1be4b7ecf24005bfa63d8875 100644
--- a/mysql-test/r/temp_table.result
+++ b/mysql-test/r/temp_table.result
@@ -72,3 +72,25 @@ id	val	elt(two.val,'one','two')
 2	1	one
 4	2	two
 drop table t1,t2;
+drop table if exists t1;
+CREATE TABLE t1 (
+d datetime default NULL
+) TYPE=MyISAM;
+INSERT INTO t1 VALUES ('2002-10-24 14:50:32'),('2002-10-24 14:50:33'),('2002-10-24 14:50:34'),('2002-10-24 14:50:34'),('2002-10-24 14:50:34'),('2002-10-24 14:50:35'),('2002-10-24 14:50:35'),('2002-10-24 14:50:35'),('2002-10-24 14:50:35'),('2002-10-24 14:50:36'),('2002-10-24 14:50:36'),('2002-10-24 14:50:36'),('2002-10-24 14:50:36'),('2002-10-24 14:50:37'),('2002-10-24 14:50:37'),('2002-10-24 14:50:37'),('2002-10-24 14:50:37'),('2002-10-24 14:50:38'),('2002-10-24 14:50:38'),('2002-10-24 14:50:38'),('2002-10-24 14:50:39'),('2002-10-24 14:50:39'),('2002-10-24 14:50:39'),('2002-10-24 14:50:39'),('2002-10-24 14:50:40'),('2002-10-24 14:50:40'),('2002-10-24 14:50:40');
+flush status;
+select * from t1 group by d;
+d
+2002-10-24 14:50:32
+2002-10-24 14:50:33
+2002-10-24 14:50:34
+2002-10-24 14:50:35
+2002-10-24 14:50:36
+2002-10-24 14:50:37
+2002-10-24 14:50:38
+2002-10-24 14:50:39
+2002-10-24 14:50:40
+show status like "created_tmp%tables";
+Variable_name	Value
+Created_tmp_disk_tables	0
+Created_tmp_tables	1
+drop table t1;
diff --git a/mysql-test/r/type_blob.result b/mysql-test/r/type_blob.result
index c99d22c2889f070abc7e7d6959b95b21a2518b30..ba8d4f770f61430111d8358dfbbe4320fcde1ea6 100644
--- a/mysql-test/r/type_blob.result
+++ b/mysql-test/r/type_blob.result
@@ -1,4 +1,36 @@
 drop table if exists t1,t2,t3,t4,t5,t6,t7;
+CREATE TABLE t1 (a blob, b text, c blob(250), d text(70000), e text(70000000));
+show columns from t1;
+Field	Type	Null	Key	Default	Extra
+a	blob	YES		NULL	
+b	text character set latin1	YES		NULL	
+c	blob	YES		NULL	
+d	mediumtext character set latin1	YES		NULL	
+e	longtext character set latin1	YES		NULL	
+CREATE TABLE t2 (a char(257), b varchar(70000) binary, c varchar(70000000));
+Warnings:
+Warning	1244	Converting column 'a' from CHAR to TEXT
+Warning	1244	Converting column 'b' from CHAR to BLOB
+Warning	1244	Converting column 'c' from CHAR to TEXT
+show columns from t2;
+Field	Type	Null	Key	Default	Extra
+a	text character set latin1	YES		NULL	
+b	mediumblob	YES		NULL	
+c	longtext character set latin1	YES		NULL	
+create table t3 (a long, b long byte);
+show create TABLE t3;
+Table	Create Table
+t3	CREATE TABLE `t3` (
+  `a` mediumtext character set latin1,
+  `b` mediumblob
+) TYPE=MyISAM CHARSET=latin1
+drop table t1,t2,t3
+#;
+CREATE TABLE t1 (a char(257) default "hello");
+Too big column length for column 'a' (max = 255). Use BLOB instead
+CREATE TABLE t2 (a blob default "hello");
+BLOB column 'a' can't have a default value
+drop table if exists t1,t2;
 create table t1 (nr int(5) not null auto_increment,b blob,str char(10), primary key (nr));
 insert into t1 values (null,"a","A");
 insert into t1 values (null,"bbb","BBB");
diff --git a/mysql-test/r/type_datetime.result b/mysql-test/r/type_datetime.result
index 22cfd2ceefab5ddee0db7188f50223219e195a4f..1e58b8da42eff0b31906d0d4c1e568738172b546 100644
--- a/mysql-test/r/type_datetime.result
+++ b/mysql-test/r/type_datetime.result
@@ -76,5 +76,5 @@ date	numfacture	expedition
 0000-00-00 00:00:00	1212	0001-00-00 00:00:00
 EXPLAIN SELECT * FROM t1 WHERE expedition='0001-00-00 00:00:00';
 id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
-1	SIMPLE	t1	ref	expedition	expedition	8	const	1	where used
+1	SIMPLE	t1	ref	expedition	expedition	8	const	1	Using where
 drop table t1;
diff --git a/mysql-test/r/type_decimal.result b/mysql-test/r/type_decimal.result
index 6550e981f5e9dd701078e326287a437b1eaba6b1..0e60eefc9c77c1b67af8786b9cdd0d6e6c5fc539 100644
--- a/mysql-test/r/type_decimal.result
+++ b/mysql-test/r/type_decimal.result
@@ -346,3 +346,14 @@ a
 1234567890
 9999999999
 drop  table t1;
+create table t1(a decimal(10,0));
+insert into t1 values ("1e4294967295");
+select * from t1;
+a
+99999999999
+delete from t1;
+insert into t1 values("1e4294967297");
+select * from t1;
+a
+99999999999
+drop table t1;
diff --git a/mysql-test/r/user_var.result b/mysql-test/r/user_var.result
index 7421c04076680ffb1959b8de9aeae861bea32fbc..1b0b359c533873a8e04cb292719ea6696176bd48 100644
--- a/mysql-test/r/user_var.result
+++ b/mysql-test/r/user_var.result
@@ -19,14 +19,14 @@ i	@vv1:=if(sv1.i,1,0)	@vv2:=if(sv2.i,1,0)	@vv3:=if(sv3.i,1,0)	@vv1+@vv2+@vv3
 2	1	0	0	1
 explain select * from t1 where i=@vv1;
 id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
-1	SIMPLE	t1	ref	i	i	4	const	1	where used
+1	SIMPLE	t1	ref	i	i	4	const	1	Using where
 explain select * from t1 where @vv1:=@vv1+1 and i=@vv1;
 id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
-1	SIMPLE	t1	ALL	NULL	NULL	NULL	NULL	3	where used
+1	SIMPLE	t1	ALL	NULL	NULL	NULL	NULL	3	Using where
 explain select @vv1:=i from t1 where i=@vv1;
 id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
-1	SIMPLE	t1	index	NULL	i	4	NULL	3	where used; Using index
+1	SIMPLE	t1	index	NULL	i	4	NULL	3	Using where; Using index
 explain select * from t1 where i=@vv1;
 id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
-1	SIMPLE	t1	ref	i	i	4	const	1	where used
+1	SIMPLE	t1	ref	i	i	4	const	1	Using where
 drop table t1,t2;
diff --git a/mysql-test/r/variables.result b/mysql-test/r/variables.result
index f708ddd2ee790507687835516aee6686e29b3fb8..fbbf7fcb8f4e8fb529b60cb9b2a20510fedda8bc 100644
--- a/mysql-test/r/variables.result
+++ b/mysql-test/r/variables.result
@@ -48,9 +48,6 @@ set max_join_size=100;
 show variables like 'max_join_size';
 Variable_name	Value
 max_join_size	100
-show global variables like 'max_join_size';
-Variable_name	Value
-max_join_size	4294967295
 set GLOBAL max_join_size=2000;
 show global variables like 'max_join_size';
 Variable_name	Value
@@ -62,7 +59,7 @@ max_join_size	2000
 set GLOBAL max_join_size=DEFAULT;
 show global variables like 'max_join_size';
 Variable_name	Value
-max_join_size	4294967295
+max_join_size	18446744073709551615
 set @@max_join_size=1000, @@global.max_join_size=2000;
 select @@local.max_join_size, @@global.max_join_size;
 @@session.max_join_size	@@global.max_join_size
@@ -108,7 +105,6 @@ show global variables like 'table_type';
 Variable_name	Value
 table_type	INNODB
 set GLOBAL query_cache_size=100000;
-set GLOBAL safe_show_database=0;
 set myisam_max_sort_file_size=10000, GLOBAL myisam_max_sort_file_size=20000;
 show variables like 'myisam_max_sort_file_size';
 Variable_name	Value
@@ -171,6 +167,10 @@ convert_character_set	cp1251_koi8
 select @@timestamp>0;
 @@timestamp>0
 1
+set @@rand_seed1=10000000,@@rand_seed2=1000000;
+select ROUND(RAND(),5);
+ROUND(RAND(),5)
+0.02887
 set big_tables=OFFF;
 Variable 'big_tables' can't be set to the value of 'OFFF'
 set big_tables="OFFF";
@@ -276,7 +276,6 @@ set global query_cache_type=demand;
 set read_buffer_size=100;
 set read_rnd_buffer_size=100;
 set global rpl_recovery_rank=100;
-set global safe_show_database=1;
 set global server_id=100;
 set global slave_net_timeout=100;
 set global slow_launch_time=100;
diff --git a/mysql-test/t/bdb-deadlock.test b/mysql-test/t/bdb-deadlock.test
index 27fcb5c6149582699f99172770a1d0ef5cec0a01..5ecfe592ce4ed764d8c5fcd0aa640adbb28601df 100644
--- a/mysql-test/t/bdb-deadlock.test
+++ b/mysql-test/t/bdb-deadlock.test
@@ -35,9 +35,11 @@ select x from t2 where id = 0;
 
 connection con2;
 --error 1213
+reap;
 commit;
 
 connection con1;
+reap;
 commit;
 
 connection con2;
diff --git a/mysql-test/t/bdb.test b/mysql-test/t/bdb.test
index 0df93b5f220ef0a9466e73b61be940ad79602a59..608d4bf5042e0f5b817372bc036205c369c7efd1 100644
--- a/mysql-test/t/bdb.test
+++ b/mysql-test/t/bdb.test
@@ -39,7 +39,7 @@ select * from t1;
 update ignore t1 set id=id+1; # This will change all rows
 select * from t1;
 update ignore t1 set id=1023 where id=1010;
-select * from t1 where parent_id=102;
+select * from t1 where parent_id=102 order by parent_id,id;
 explain select level from t1 where level=1;
 explain select level,id from t1 where level=1;
 explain select level,id,parent_id from t1 where level=1;
diff --git a/mysql-test/t/bdb_cache-master.opt b/mysql-test/t/bdb_cache-master.opt
new file mode 100644
index 0000000000000000000000000000000000000000..5f0ebff98f65d549b065efee8015ff7c8b6865ae
--- /dev/null
+++ b/mysql-test/t/bdb_cache-master.opt
@@ -0,0 +1 @@
+--set-variable=query_cache_size=1M
diff --git a/mysql-test/t/bdb_cache.test b/mysql-test/t/bdb_cache.test
new file mode 100644
index 0000000000000000000000000000000000000000..aa5572886c5f9b71bd4a91544750711cf16e96f0
--- /dev/null
+++ b/mysql-test/t/bdb_cache.test
@@ -0,0 +1,50 @@
+-- source include/have_bdb.inc
+-- source include/have_query_cache.inc
+
+#
+# Without auto_commit.
+#
+drop table if exists t1, t2, t3;
+flush status;
+set autocommit=0;
+create table t1 (a int not null) type=bdb;
+insert into t1 values (1),(2),(3);
+select * from t1;
+show status like "Qcache_queries_in_cache";
+drop table t1;
+commit;
+set autocommit=1;
+begin;
+create table t1 (a int not null) type=bdb;
+insert into t1 values (1),(2),(3);
+select * from t1;
+show status like "Qcache_queries_in_cache";
+drop table t1;
+commit;
+create table t1 (a int not null) type=bdb;
+create table t2 (a int not null) type=bdb;
+create table t3 (a int not null) type=bdb;
+insert into t1 values (1),(2);
+insert into t2 values (1),(2);
+insert into t3 values (1),(2);
+select * from t1;
+select * from t2;
+select * from t3;
+show status like "Qcache_queries_in_cache";
+show status like "Qcache_hits";
+begin;
+select * from t1;
+select * from t2;
+select * from t3;
+show status like "Qcache_queries_in_cache";
+show status like "Qcache_hits";
+insert into t1 values (3);
+insert into t2 values (3);
+insert into t1 values (4);
+select * from t1;
+select * from t2;
+select * from t3;
+show status like "Qcache_queries_in_cache";
+show status like "Qcache_hits";
+commit;
+show status like "Qcache_queries_in_cache";
\ No newline at end of file
diff --git a/mysql-test/t/bigint.test b/mysql-test/t/bigint.test
index 15b35ac7c87c44936c97e958f2724b653412ff55..15c61c2c0dcc3a9a27cb4538d3a33f19ec767d20 100644
--- a/mysql-test/t/bigint.test
+++ b/mysql-test/t/bigint.test
@@ -35,11 +35,3 @@ alter table t1 modify big bigint not null;
 select min(big),max(big),max(big)-1 from t1;
 select min(big),max(big),max(big)-1 from t1 group by a;
 drop table t1;
-
-select CAST(1-2 AS UNSIGNED);
-select CAST(CAST(1-2 AS UNSIGNED) AS SIGNED INTEGER);
-select CONVERT('-1',UNSIGNED);
-select cast(-5 as unsigned) | 1, cast(-5 as unsigned) & -1;
-select cast(-5 as unsigned) -1, cast(-5 as unsigned) + 1;
-select ~5, cast(~5 as signed);
-select cast(5 as unsigned) -6.0;
diff --git a/mysql-test/t/bool.test b/mysql-test/t/bool.test
new file mode 100644
index 0000000000000000000000000000000000000000..10f97fefb73ac28a1a6fe2550d9f1c1e158a126a
--- /dev/null
+++ b/mysql-test/t/bool.test
@@ -0,0 +1,51 @@
+#
+# Test of boolean operations with NULL
+#
+
+DROP TABLE IF EXISTS t1;
+
+SELECT IF(NULL AND 1, 1, 2), IF(1 AND NULL, 1, 2);
+SELECT NULL AND 1, 1 AND NULL, 0 AND NULL, NULL and 0;
+
+create table t1 (a int);
+insert into t1 values (0),(1),(NULL);
+SELECT * FROM t1 WHERE IF(a AND 1, 0, 1);
+SELECT * FROM t1 WHERE IF(1 AND a, 0, 1);
+SELECT * FROM t1 where NOT(a AND 1);
+SELECT * FROM t1 where NOT(1 AND a);
+SELECT * FROM t1 where (a AND 1)=0;
+SELECT * FROM t1 where (1 AND a)=0;
+SELECT * FROM t1 where (1 AND a)=1;
+SELECT * FROM t1 where (1 AND a) IS NULL;
+
+# Verify that NULL optimisation works in AND clause:
+SET @a=0, @b=0;
+SELECT * FROM t1 WHERE NULL AND (@a:=@a+1);
+SELECT * FROM t1 WHERE NOT(a>=0 AND NULL AND (@b:=@b+1));
+SELECT * FROM t1 WHERE a=2 OR (NULL AND (@a:=@a+1));
+SELECT * FROM t1 WHERE NOT(a=2 OR (NULL AND (@b:=@b+1)));
+SELECT @a, @b;
+DROP TABLE t1;
+
+
+# Test boolean operators in select part
+# NULLs are represented as N for readability
+# Read nA as !A, AB as A && B, AoB as A || B
+# Result table makes ANSI happy
+
+drop table if exists t;
+create table t(a int, b int);
+insert into t values(null, null), (0, null), (1, null), (null, 0), (null, 1), (0, 0), (0, 1), (1, 0), (1, 1);
+
+# Below test is valid untill we have True/False implemented as 1/0
+# To comply to all rules it must show that:  n(AB) = nAonB,  n(AoB) = nAnB 
+
+select ifnull(A, 'N') as A, ifnull(B, 'N') as B, ifnull(not A, 'N') as nA, ifnull(not B, 'N') as nB, ifnull(A and B, 'N') as AB, ifnull(not (A and B), 'N') as `n(AB)`, ifnull((not A or not B), 'N') as nAonB, ifnull(A or B, 'N') as AoB, ifnull(not(A or B), 'N') as `n(AoB)`, ifnull(not A and not B, 'N') as nAnB from t;
+
+# This should work with any internal representation of True/False
+# Result must be same as above
+
+select ifnull(A=1, 'N') as A, ifnull(B=1, 'N') as B, ifnull(not (A=1), 'N') as nA, ifnull(not (B=1), 'N') as nB, ifnull((A=1) and (B=1), 'N') as AB, ifnull(not ((A=1) and (B=1)), 'N') as `n(AB)`, ifnull((not (A=1) or not (B=1)), 'N') as nAonB, ifnull((A=1) or (B=1), 'N') as AoB, ifnull(not((A=1) or (B=1)), 'N') as `n(AoB)`, ifnull(not (A=1) and not (B=1), 'N') as nAnB from t;
+
+
+drop table t; 
diff --git a/mysql-test/t/cast.test b/mysql-test/t/cast.test
new file mode 100644
index 0000000000000000000000000000000000000000..7a120ef50052942ae5057cf2a078c19fe89d5918
--- /dev/null
+++ b/mysql-test/t/cast.test
@@ -0,0 +1,22 @@
+#
+# Test of cast function
+#
+
+select CAST(1-2 AS UNSIGNED);
+select CAST(CAST(1-2 AS UNSIGNED) AS SIGNED INTEGER);
+select CONVERT('-1',UNSIGNED);
+select cast(-5 as unsigned) | 1, cast(-5 as unsigned) & -1;
+select cast(-5 as unsigned) -1, cast(-5 as unsigned) + 1;
+select ~5, cast(~5 as signed);
+select cast(5 as unsigned) -6.0;
+select cast("A" as binary) = "a", cast(BINARY "a" as CHAR) = "A";
+select cast("2001-1-1" as DATE), cast("2001-1-1" as DATETIME);
+select cast("1:2:3" as TIME);
+
+#
+# The following should be fixed in 4.1
+#
+
+select cast("2001-1-1" as date) = "2001-01-01";
+select cast("2001-1-1" as datetime) = "2001-01-01 00:00:00";
+select cast("1:2:3" as TIME) = "1:02:03";
diff --git a/mysql-test/t/constraints.test b/mysql-test/t/constraints.test
new file mode 100644
index 0000000000000000000000000000000000000000..8682cdc42a2539cca94b073b22ac13a9641e6441
--- /dev/null
+++ b/mysql-test/t/constraints.test
@@ -0,0 +1,21 @@
+#
+# Testing of constraints
+# Currently MySQL only ignores the syntax.
+#
+drop table if exists t1;
+
+create table t1 (a int check (a>0));
+insert into t1 values (1);
+insert into t1 values (0);
+drop table t1;
+create table t1 (a int ,b int, check a>b);
+insert into t1 values (1,0);
+insert into t1 values (0,1);
+drop table t1;
+create table t1 (a int ,b int, constraint abc check (a>b));
+insert into t1 values (1,0);
+insert into t1 values (0,1);
+drop table t1;
+create table t1 (a int null);
+insert into t1 values (1),(NULL);
+drop table t1;
diff --git a/mysql-test/t/create.test b/mysql-test/t/create.test
index 65be9683061fbcbd1a329966c0e554aaf0ffc3e4..3bad053875c2392a3f002306bb3ac6f8208d3acc 100644
--- a/mysql-test/t/create.test
+++ b/mysql-test/t/create.test
@@ -110,3 +110,6 @@ drop table t1;
 create table t1 select if('2002'='2002','Y','N');
 select * from t1;
 drop table if exists t1;
+create table t1 (a int, key(a));
+create table t2 (b int, foreign key(b) references t1(a), key(b));
+drop table if exists t1,t2;
diff --git a/mysql-test/t/derived.test b/mysql-test/t/derived.test
index 87910c2970620714f2d3b92b0ecf9759735248c1..c1d8af4074a28327065224637b5b2822fc31b23e 100644
--- a/mysql-test/t/derived.test
+++ b/mysql-test/t/derived.test
@@ -8,6 +8,30 @@ select t1.a,t3.a from t1,(select * from t2  where b='c') as t3  where t1.a = t3.
 CREATE TABLE t3 (a int not null, b char (10) not null);
 insert into t3 values (3,'f'),(4,'y'),(5,'z'),(6,'c');
 select t1.a,t4.y from t1,(select t2.a as y from t2,(select t3.b from t3 where t3.a>3) as t5  where t2.b=t5.b) as t4  where t1.a = t4.y;
+--error 1054
+SELECT a FROM (SELECT 1 FROM (SELECT 1) HAVING a=1);
+--error 1052
+SELECT a,b as a FROM (SELECT '1' as a,'2' as b) HAVING a=1;
+SELECT a,2 as a FROM (SELECT '1' as a) HAVING a=2;
+SELECT a,2 as a FROM (SELECT '1' as a) HAVING a=1;
+--error 1054
+SELECT 1 FROM (SELECT 1) WHERE a=2;
+--error 1054
+SELECT (SELECT 1) as a FROM (SELECT 1 FROM t1  HAVING a=1);
 drop table if exists  t1.t2,t3;
 select * from (select 1);
 select a from (select 1 as a);
+select 1 from (select 1);
+drop table if exists t1;
+create table t1(a int not null, t char(8), index(a));
+disable_query_log;
+let $1 = 10000;
+while ($1)
+ {
+  eval insert into t1 values ($1,'$1'); 
+  dec $1;
+ }
+enable_query_log;
+SELECT * FROM (SELECT * FROM t1) ORDER BY a  ASC LIMIT 0,20;
+drop table if exists  t1;
+SELECT * FROM (SELECT (SELECT * FROM (SELECT 1 as a)));
diff --git a/mysql-test/t/fulltext.test b/mysql-test/t/fulltext.test
index 6483045f4ed3c7c72b7731853f04732d10c3f4c2..5a64f2614aa1d143a87c955adaeabc94b1c65b52 100644
--- a/mysql-test/t/fulltext.test
+++ b/mysql-test/t/fulltext.test
@@ -40,6 +40,7 @@ select * from t1 where MATCH a,b AGAINST ('"Now sUPPort"' IN BOOLEAN MODE);
 select * from t1 where MATCH a,b AGAINST ('"text search"  "now support"' IN BOOLEAN MODE);
 select * from t1 where MATCH a,b AGAINST ('"text search" -"now support"' IN BOOLEAN MODE);
 select * from t1 where MATCH a,b AGAINST ('"text search" +"now support"' IN BOOLEAN MODE);
+select * from t1 where MATCH a,b AGAINST ('"text i"' IN BOOLEAN MODE);
 
 # boolean w/o index:
 
diff --git a/mysql-test/t/func_system.test b/mysql-test/t/func_system.test
index 052e0530cf6515f0f54edf32e792b7f660d9a103..c69526644f49b616e95f5dc9d83d1b91817bea4c 100644
--- a/mysql-test/t/func_system.test
+++ b/mysql-test/t/func_system.test
@@ -4,3 +4,4 @@
 
 select database(),user() like "%@%";
 select version()>="3.23.29";
+select TRUE,FALSE,NULL;
diff --git a/mysql-test/t/func_test.test b/mysql-test/t/func_test.test
index f5ad2e21c73495cdce4d8ef5431e35c50ab086c5..8810aefc20ff3b65c3121b61c343b208a1f8311a 100644
--- a/mysql-test/t/func_test.test
+++ b/mysql-test/t/func_test.test
@@ -17,6 +17,7 @@ select 2 in (3,2,5,9,5,1),"monty" in ("david","monty","allan"), 1.2 in (1.4,1.2,
 select -1.49 or -1.49,0.6 or 0.6;
 select 3 ^ 11, 1 ^ 1, 1 ^ 0, 1 ^ NULL, NULL ^ 1;
 select 1 XOR 1, 1 XOR 0, 0 XOR 1, 0 XOR 0, NULL XOR 1, 1 XOR NULL, 0 XOR NULL;
+select 10 % 7, 10 mod 7, 10 div 3;
 
 #
 # Wrong usage of functions
diff --git a/mysql-test/t/func_time.test b/mysql-test/t/func_time.test
index a052f5f2d9264d2b61a707d8d0b8ffa7bae52c20..dd589ff2e66b13de6ab42b58ea0eb8a8f02a6685 100644
--- a/mysql-test/t/func_time.test
+++ b/mysql-test/t/func_time.test
@@ -1,7 +1,7 @@
 #
 # time functions
 #
-drop table if exists t1,t2;
+drop table if exists t1,t2,t3;
 
 select from_days(to_days("960101")),to_days(960201)-to_days("19960101"),to_days(date_add(curdate(), interval 1 day))-to_days(curdate()),weekday("1997-11-29");
 select period_add("9602",-12),period_diff(199505,"9404") ;
@@ -12,6 +12,8 @@ select sec_to_time(9001),sec_to_time(9001)+0,time_to_sec("15:12:22"),
 select sec_to_time(time_to_sec('-838:59:59'));
 select now()-curdate()*1000000-curtime();
 select strcmp(current_timestamp(),concat(current_date()," ",current_time()));
+select strcmp(localtime(),concat(current_date()," ",current_time()));
+select strcmp(localtimestamp(),concat(current_date()," ",current_time()));
 select date_format("1997-01-02 03:04:05", "%M %W %D %Y %y %m %d %h %i %s %w");
 select date_format("1997-01-02", concat("%M %W %D ","%Y %y %m %d %h %i %s %w"));
 select dayofmonth("1997-01-02"),dayofmonth(19970323);
@@ -34,6 +36,9 @@ select yearweek("2000-01-01",0) as '2000', yearweek("2001-01-01",0) as '2001', y
 select yearweek("2000-01-06",0) as '2000', yearweek("2001-01-06",0) as '2001', yearweek("2002-01-06",0) as '2002',yearweek("2003-01-06",0) as '2003', yearweek("2004-01-06",0) as '2004', yearweek("2005-01-06",0) as '2005', yearweek("2006-01-06",0) as '2006';
 select yearweek("2000-01-01",1) as '2000', yearweek("2001-01-01",1) as '2001', yearweek("2002-01-01",1) as '2002',yearweek("2003-01-01",1) as '2003', yearweek("2004-01-01",1) as '2004', yearweek("2005-01-01",1) as '2005', yearweek("2006-01-01",1) as '2006';
 select yearweek("2000-01-06",1) as '2000', yearweek("2001-01-06",1) as '2001', yearweek("2002-01-06",1) as '2002',yearweek("2003-01-06",1) as '2003', yearweek("2004-01-06",1) as '2004', yearweek("2005-01-06",1) as '2005', yearweek("2006-01-06",1) as '2006';
+select week(19981231,2), week(19981231,3), week(20000101,2), week(20000101,3);
+select week(20001231,2),week(20001231,3);
+
 select date_format('1998-12-31','%x-%v'),date_format('1999-01-01','%x-%v');
 select date_format('1999-12-31','%x-%v'),date_format('2000-01-01','%x-%v');
 
@@ -160,3 +165,21 @@ select yearweek("0000-00-00"),yearweek(d),yearweek(dt),yearweek(t),yearweek(c) f
 select to_days("0000-00-00"),to_days(d),to_days(dt),to_days(t),to_days(c) from t1;
 select extract(MONTH FROM "0000-00-00"),extract(MONTH FROM d),extract(MONTH FROM dt),extract(MONTH FROM t),extract(MONTH FROM c) from t1;
 drop table t1;
+
+
+#
+# Test problem with TIMESTAMP and BETWEEN
+#
+
+CREATE TABLE t1 ( start datetime default NULL);
+INSERT INTO t1 VALUES ('2002-10-21 00:00:00'),('2002-10-28 00:00:00'),('2002-11-04 00:00:00');
+CREATE TABLE t2 ( ctime1 timestamp(14) NOT NULL, ctime2 timestamp(14) NOT NULL);
+INSERT INTO t2 VALUES (20021029165106,20021105164731);
+CREATE TABLE t3 (ctime1 char(19) NOT NULL, ctime2 char(19) NOT NULL);
+INSERT INTO t3 VALUES ("2002-10-29 16:51:06","2002-11-05 16:47:31");
+
+# The following statement should be fixed to return a row in 4.1
+select * from t1, t2 where t1.start between t2.ctime1 and t2.ctime2;
+select * from t1, t2 where t1.start >= t2.ctime1 and t1.start <= t2.ctime2;
+select * from t1, t3 where t1.start between t3.ctime1 and t3.ctime2;
+drop table t1,t2,t3;
diff --git a/mysql-test/t/group_by.test b/mysql-test/t/group_by.test
index 072a1830f57733d73503597f50db12e4bc65c252..0f30fbd4cc6d3a4aa3d1f7e6f9357d2659e7c37e 100644
--- a/mysql-test/t/group_by.test
+++ b/mysql-test/t/group_by.test
@@ -1,8 +1,10 @@
+-- error 1111
+SELECT 1 FROM (SELECT 1) GROUP BY SUM(1);
 #
 # Test of group (Failed for Lars Hoss <lh@pbm.de>)
 #
 
-drop table if exists t1,t2;
+drop table if exists t1,t2,t3;
 CREATE TABLE t1 (
   spID int(10) unsigned,
   userID int(10) unsigned,
@@ -312,3 +314,42 @@ insert into t1 values (1,244,NULL),(2,243,NULL),(134,223,NULL),(185,186,NULL);
 select S.ID as xID, S.ID1 as xID1 from t1 as S left join t1 as yS  on S.ID1 between yS.ID1 and yS.ID2;
 select S.ID as xID, S.ID1 as xID1, repeat('*',count(distinct yS.ID)) as Level from t1 as S left join t1 as yS  on S.ID1 between yS.ID1 and yS.ID2 group by xID order by xID1;
 drop table t1;
+
+#
+# Problem with MAX and LEFT JOIN
+#
+
+CREATE TABLE t1 (
+  pid int(11) unsigned NOT NULL default '0',
+  c1id int(11) unsigned default NULL,
+  c2id int(11) unsigned default NULL,
+  value int(11) unsigned NOT NULL default '0',
+  UNIQUE KEY pid2 (pid,c1id,c2id),
+  UNIQUE KEY pid (pid,value)
+) TYPE=MyISAM;
+
+INSERT INTO t1 VALUES (1, 1, NULL, 1),(1, 2, NULL, 2),(1, NULL, 3, 3),(1, 4, NULL, 4),(1, 5, NULL, 5);
+
+CREATE TABLE t2 (
+  id int(11) unsigned NOT NULL default '0',
+  active enum('Yes','No') NOT NULL default 'Yes',
+  PRIMARY KEY  (id)
+) TYPE=MyISAM;
+
+INSERT INTO t2 VALUES (1, 'Yes'),(2, 'No'),(4, 'Yes'),(5, 'No');
+
+CREATE TABLE t3 (
+  id int(11) unsigned NOT NULL default '0',
+  active enum('Yes','No') NOT NULL default 'Yes',
+  PRIMARY KEY  (id)
+);
+INSERT INTO t3 VALUES (3, 'Yes');
+
+select * from t1 AS m LEFT JOIN t2 AS c1 ON m.c1id = 
+c1.id AND c1.active = 'Yes' LEFT JOIN t3 AS c2 ON m.c2id = c2.id AND 
+c2.active = 'Yes' WHERE m.pid=1  AND (c1.id IS NOT NULL OR c2.id IS NOT NULL);
+select max(value) from t1 AS m LEFT JOIN t2 AS c1 ON 
+m.c1id = c1.id AND c1.active = 'Yes' LEFT JOIN t3 AS c2 ON m.c2id = 
+c2.id AND c2.active = 'Yes' WHERE m.pid=1  AND (c1.id IS NOT NULL OR c2.id IS 
+NOT NULL);
+drop table t1,t2,t3;
diff --git a/mysql-test/t/heap_btree.test b/mysql-test/t/heap_btree.test
index 3dd22f2da034dd4270e2b28e3a167eb6d57e1bf0..5c0002fede48509d2f1b2045c9ff7ff5b20e62b2 100644
--- a/mysql-test/t/heap_btree.test
+++ b/mysql-test/t/heap_btree.test
@@ -137,6 +137,13 @@ SELECT * FROM t1 WHERE b<=>NULL;
 INSERT INTO t1 VALUES (1,3);
 DROP TABLE t1;
 
+CREATE TABLE t1 (a int, b int, c int, key using BTREE (a, b, c)) type=heap;
+INSERT INTO t1 VALUES (1, NULL, NULL), (1, 1, NULL), (1, NULL, 1);
+SELECT * FROM t1 WHERE a=1 and b IS NULL;
+SELECT * FROM t1 WHERE a=1 and c IS NULL;
+SELECT * FROM t1 WHERE a=1 and b IS NULL and c IS NULL;
+DROP TABLE t1;
+
 #
 # Test when deleting all rows
 #
diff --git a/mysql-test/t/innodb-deadlock.test b/mysql-test/t/innodb-deadlock.test
new file mode 100644
index 0000000000000000000000000000000000000000..2648d6cdf9c9a241707a733ddb1b9e5ee8841dc8
--- /dev/null
+++ b/mysql-test/t/innodb-deadlock.test
@@ -0,0 +1,111 @@
+-- source include/have_innodb.inc
+
+connect (con1,localhost,root,,);
+connect (con2,localhost,root,,);
+drop table if exists t1;
+
+#
+# Testing of FOR UPDATE
+#
+
+connection con1;
+create table t1 (id integer, x integer) type=INNODB;
+insert into t1 values(0, 0);
+set autocommit=0;
+SELECT * from t1 where id = 0 FOR UPDATE;
+
+connection con2;
+set autocommit=0;
+
+# The following query should hang because con1 is locking the page
+--send
+update t1 set x=2 where id = 0;
+--sleep 2;
+
+connection con1;
+update t1 set x=1 where id = 0;
+select * from t1;
+commit;
+
+connection con2;
+reap;
+commit;
+
+connection con1;
+select * from t1;
+commit;
+
+drop table t1;
+drop table if exists t1, t2;
+#
+# Testing of FOR UPDATE
+#
+
+connection con1;
+create table t1 (id integer, x integer) type=INNODB;
+create table t2 (b integer, a integer) type=INNODB;
+insert into t1 values(0, 0), (300, 300);
+insert into t2 values(0, 10), (1, 20), (2, 30);
+commit;
+set autocommit=0;
+select * from t2;
+update t2 set a=100 where b=(SELECT x from t1 where id = b FOR UPDATE);
+select * from t2;
+select * from t1;
+
+connection con2;
+set autocommit=0;
+
+# The following query should hang because con1 is locking the page
+--send
+update t1 set x=2 where id = 0;
+--sleep 2;
+
+connection con1;
+update t1 set x=1 where id = 0;
+select * from t1;
+commit;
+
+connection con2;
+reap;
+commit;
+
+connection con1;
+select * from t1;
+commit;
+
+drop table t1, t2;
+create table t1 (id integer, x integer) type=INNODB;
+create table t2 (b integer, a integer) type=INNODB;
+insert into t1 values(0, 0), (300, 300);
+insert into t2 values(0, 0), (1, 20), (2, 30);
+commit;
+
+connection con1;
+select a,b from t2 UNION SELECT id, x from t1 FOR UPDATE;
+select * from t2;
+select * from t1;
+
+connection con2;
+
+# The following query should hang because con1 is locking the page
+update t2 set a=2 where b = 0;
+select * from t2;
+--send
+update t1 set x=2 where id = 0;
+--sleep 2;
+
+connection con1;
+update t1 set x=1 where id = 0;
+select * from t1;
+commit;
+
+connection con2;
+reap;
+commit;
+
+connection con1;
+select * from t1;
+commit;
+
+drop table t1, t2;
diff --git a/mysql-test/t/innodb_cache.test b/mysql-test/t/innodb_cache.test
index 21d30420eaf825bd72b01a8a3c4589b1035d062b..9066a5f19ba2fb5d091f20854dfd9e51ce83b79d 100644
--- a/mysql-test/t/innodb_cache.test
+++ b/mysql-test/t/innodb_cache.test
@@ -47,4 +47,11 @@ select * from t3;
 show status like "Qcache_queries_in_cache";
 show status like "Qcache_hits";
 commit;
-show status like "Qcache_queries_in_cache";
\ No newline at end of file
+show status like "Qcache_queries_in_cache";
+
+drop table if exists t1;
+CREATE TABLE t1 (id int(11) NOT NULL auto_increment, PRIMARY KEY  (id)) TYPE=InnoDB;
+select count(*) from t1;
+insert into t1 (id) values (0);
+select count(*) from t1;
+drop table t1;
diff --git a/mysql-test/t/merge.test b/mysql-test/t/merge.test
index 86e787db0a357768cf90324f0ade7ae5ba4efc02..2199f50fb166d05ce11570a7155a3c97f3e91fb1 100644
--- a/mysql-test/t/merge.test
+++ b/mysql-test/t/merge.test
@@ -185,3 +185,55 @@ CREATE TABLE t (  a int(11) NOT NULL default '0',  b int(11) NOT NULL default '0
 select max(b) from t where a = 2;
 select max(b) from t1 where a = 2;
 drop table if exists t,t1,t2;
+
+#
+# temporary merge tables
+#
+drop table if exists t1, t2, t3, t4, t5, t6;
+create table t1 (a int not null);
+create table t2 (a int not null);
+insert into t1 values (1);
+insert into t2 values (2);
+create temporary table t3 (a int not null) TYPE=MERGE UNION=(t1,t2);
+select * from t3;
+create temporary table t4 (a int not null);
+create temporary table t5 (a int not null);
+insert into t4 values (1);
+insert into t5 values (2);
+create temporary table t6 (a int not null) TYPE=MERGE UNION=(t4,t5);
+select * from t6;
+drop table if exists t1, t2, t3, t4, t5, t6;
+
+#
+# testing merge::records_in_range and optimizer
+#
+
+DROP TABLE IF EXISTS t1, t2;
+CREATE TABLE t1 (
+  fileset_id tinyint(3) unsigned NOT NULL default '0',
+  file_code varchar(32) NOT NULL default '',
+  fileset_root_id tinyint(3) unsigned NOT NULL default '0',
+  PRIMARY KEY  (fileset_id,file_code),
+  KEY files (fileset_id,fileset_root_id)
+) TYPE=MyISAM;
+INSERT INTO t1 VALUES (2, '0000000111', 1), (2, '0000000112', 1), (2, '0000000113', 1),
+(2, '0000000114', 1), (2, '0000000115', 1), (2, '0000000116', 1), (2, '0000000117', 1),
+(2, '0000000118', 1), (2, '0000000119', 1), (2, '0000000120', 1);
+CREATE TABLE t2 (
+  fileset_id tinyint(3) unsigned NOT NULL default '0',
+  file_code varchar(32) NOT NULL default '',
+  fileset_root_id tinyint(3) unsigned NOT NULL default '0',
+  PRIMARY KEY  (fileset_id,file_code),
+  KEY files (fileset_id,fileset_root_id)
+) TYPE=MRG_MyISAM UNION=(t1);
+
+EXPLAIN SELECT * FROM t2 IGNORE INDEX (files) WHERE fileset_id = 2
+AND file_code BETWEEN '0000000115' AND '0000000120' LIMIT 1;
+EXPLAIN SELECT * FROM t2 WHERE fileset_id = 2
+AND file_code BETWEEN '0000000115' AND '0000000120' LIMIT 1;
+EXPLAIN SELECT * FROM t1 WHERE fileset_id = 2
+AND file_code BETWEEN '0000000115' AND '0000000120' LIMIT 1;
+EXPLAIN SELECT * FROM t2 WHERE fileset_id = 2
+AND file_code = '0000000115' LIMIT 1;
+DROP TABLE IF EXISTS t1, t2;
+
diff --git a/mysql-test/t/multi_update.test b/mysql-test/t/multi_update.test
index 7d855dd54ea6b4aaba32c35975b4a2693633e1a7..b3a51ff65bce2a21d517c7909a96593813996d0b 100644
--- a/mysql-test/t/multi_update.test
+++ b/mysql-test/t/multi_update.test
@@ -147,4 +147,30 @@ insert into t2 values (1),(2),(4),(8),(16),(32);
 select * from t2 left outer join t1  using (n);
 delete  t1,t2 from t2 left outer join t1  using (n);
 select * from t2 left outer join t1  using (n);
-drop table if exists t1,t2 ;
+drop table t1,t2 ;
+
+#
+# Test with locking
+#
+
+create table t1 (n int(10) not null primary key, d int(10));
+create table t2 (n int(10) not null primary key, d int(10));
+insert into t1 values(1,1);
+insert into t2 values(1,10),(2,20);
+LOCK TABLES t1 write, t2 read;
+--error 1099
+DELETE t1.*, t2.* FROM t1,t2 where t1.n=t2.n;
+--error 1099
+UPDATE t1,t2 SET t1.d=t2.d,t2.d=30 WHERE t1.n=t2.n;
+# The following should be fixed to not give an error
+--error 1099
+UPDATE t1,t2 SET t1.d=t2.d WHERE t1.n=t2.n;
+unlock tables;
+LOCK TABLES t1 write, t2 write;
+UPDATE t1,t2 SET t1.d=t2.d WHERE t1.n=t2.n;
+select * from t1;
+DELETE t1.*, t2.* FROM t1,t2 where t1.n=t2.n;
+select * from t1;
+select * from t2;
+unlock tables;
+drop table t1,t2;
diff --git a/mysql-test/t/myisam.test b/mysql-test/t/myisam.test
index c69b87f325a0839287914f091c729986bbf28c96..9c261ebf5bba930911c03e0721ae24c613fbdd43 100644
--- a/mysql-test/t/myisam.test
+++ b/mysql-test/t/myisam.test
@@ -67,6 +67,227 @@ explain select a,b from t1;
 explain select a,b,c from t1;
 drop table t1;
 
+#
+# Test of OPTIMIZE of locked and modified tables
+#
+CREATE TABLE t1 (a INT);
+INSERT INTO  t1 VALUES (1), (2), (3);
+LOCK TABLES t1 WRITE;
+INSERT INTO  t1 VALUES (1), (2), (3);
+OPTIMIZE TABLE t1;
+DROP TABLE t1;
+
+#
+# Test of optimize, when only mi_sort_index (but not mi_repair*) is done
+# in ha_myisam::repair, and index size is changed (decreased).
+#
+
+drop table if exists t1;
+create table t1 ( t1 char(255), key(t1(250)));
+insert t1 values ('137513751375137513751375137513751375137569516951695169516951695169516951695169');
+insert t1 values ('178417841784178417841784178417841784178403420342034203420342034203420342034203');
+insert t1 values ('213872387238723872387238723872387238723867376737673767376737673767376737673767');
+insert t1 values ('242624262426242624262426242624262426242607890789078907890789078907890789078907');
+insert t1 values ('256025602560256025602560256025602560256011701170117011701170117011701170117011');
+insert t1 values ('276027602760276027602760276027602760276001610161016101610161016101610161016101');
+insert t1 values ('281528152815281528152815281528152815281564956495649564956495649564956495649564');
+insert t1 values ('292129212921292129212921292129212921292102100210021002100210021002100210021002');
+insert t1 values ('380638063806380638063806380638063806380634483448344834483448344834483448344834');
+insert t1 values ('411641164116411641164116411641164116411616301630163016301630163016301630163016');
+insert t1 values ('420842084208420842084208420842084208420899889988998899889988998899889988998899');
+insert t1 values ('438443844384438443844384438443844384438482448244824482448244824482448244824482');
+insert t1 values ('443244324432443244324432443244324432443239613961396139613961396139613961396139');
+insert t1 values ('485448544854485448544854485448544854485477847784778477847784778477847784778477');
+insert t1 values ('494549454945494549454945494549454945494555275527552755275527552755275527552755');
+insert t1 values ('538647864786478647864786478647864786478688918891889188918891889188918891889188');
+insert t1 values ('565556555655565556555655565556555655565554845484548454845484548454845484548454');
+insert t1 values ('607860786078607860786078607860786078607856665666566656665666566656665666566656');
+insert t1 values ('640164016401640164016401640164016401640141274127412741274127412741274127412741');
+insert t1 values ('719471947194719471947194719471947194719478717871787178717871787178717871787178');
+insert t1 values ('742574257425742574257425742574257425742549604960496049604960496049604960496049');
+insert t1 values ('887088708870887088708870887088708870887035963596359635963596359635963596359635');
+insert t1 values ('917791779177917791779177917791779177917773857385738573857385738573857385738573');
+insert t1 values ('933293329332933293329332933293329332933278987898789878987898789878987898789878');
+insert t1 values ('963896389638963896389638963896389638963877807780778077807780778077807780778077');
+delete from t1 where t1>'2';
+insert t1 values ('70'), ('84'), ('60'), ('20'), ('76'), ('89'), ('49'), ('50'),
+('88'), ('61'), ('42'), ('98'), ('39'), ('30'), ('25'), ('66'), ('61'), ('48'),
+('80'), ('84'), ('98'), ('19'), ('91'), ('42'), ('47');
+optimize table t1;
+check table t1;
+drop table t1;
+
+#
+# test of myisam with huge number of packed fields
+#
+
+drop table if exists t1;
+create table t1 (i1 int, i2 int, i3 int, i4 int, i5 int, i6 int, i7 int, i8
+int, i9 int, i10 int, i11 int, i12 int, i13 int, i14 int, i15 int, i16 int, i17
+int, i18 int, i19 int, i20 int, i21 int, i22 int, i23 int, i24 int, i25 int,
+i26 int, i27 int, i28 int, i29 int, i30 int, i31 int, i32 int, i33 int, i34
+int, i35 int, i36 int, i37 int, i38 int, i39 int, i40 int, i41 int, i42 int,
+i43 int, i44 int, i45 int, i46 int, i47 int, i48 int, i49 int, i50 int, i51
+int, i52 int, i53 int, i54 int, i55 int, i56 int, i57 int, i58 int, i59 int,
+i60 int, i61 int, i62 int, i63 int, i64 int, i65 int, i66 int, i67 int, i68
+int, i69 int, i70 int, i71 int, i72 int, i73 int, i74 int, i75 int, i76 int,
+i77 int, i78 int, i79 int, i80 int, i81 int, i82 int, i83 int, i84 int, i85
+int, i86 int, i87 int, i88 int, i89 int, i90 int, i91 int, i92 int, i93 int,
+i94 int, i95 int, i96 int, i97 int, i98 int, i99 int, i100 int, i101 int, i102
+int, i103 int, i104 int, i105 int, i106 int, i107 int, i108 int, i109 int, i110
+int, i111 int, i112 int, i113 int, i114 int, i115 int, i116 int, i117 int, i118
+int, i119 int, i120 int, i121 int, i122 int, i123 int, i124 int, i125 int, i126
+int, i127 int, i128 int, i129 int, i130 int, i131 int, i132 int, i133 int, i134
+int, i135 int, i136 int, i137 int, i138 int, i139 int, i140 int, i141 int, i142
+int, i143 int, i144 int, i145 int, i146 int, i147 int, i148 int, i149 int, i150
+int, i151 int, i152 int, i153 int, i154 int, i155 int, i156 int, i157 int, i158
+int, i159 int, i160 int, i161 int, i162 int, i163 int, i164 int, i165 int, i166
+int, i167 int, i168 int, i169 int, i170 int, i171 int, i172 int, i173 int, i174
+int, i175 int, i176 int, i177 int, i178 int, i179 int, i180 int, i181 int, i182
+int, i183 int, i184 int, i185 int, i186 int, i187 int, i188 int, i189 int, i190
+int, i191 int, i192 int, i193 int, i194 int, i195 int, i196 int, i197 int, i198
+int, i199 int, i200 int, i201 int, i202 int, i203 int, i204 int, i205 int, i206
+int, i207 int, i208 int, i209 int, i210 int, i211 int, i212 int, i213 int, i214
+int, i215 int, i216 int, i217 int, i218 int, i219 int, i220 int, i221 int, i222
+int, i223 int, i224 int, i225 int, i226 int, i227 int, i228 int, i229 int, i230
+int, i231 int, i232 int, i233 int, i234 int, i235 int, i236 int, i237 int, i238
+int, i239 int, i240 int, i241 int, i242 int, i243 int, i244 int, i245 int, i246
+int, i247 int, i248 int, i249 int, i250 int, i251 int, i252 int, i253 int, i254
+int, i255 int, i256 int, i257 int, i258 int, i259 int, i260 int, i261 int, i262
+int, i263 int, i264 int, i265 int, i266 int, i267 int, i268 int, i269 int, i270
+int, i271 int, i272 int, i273 int, i274 int, i275 int, i276 int, i277 int, i278
+int, i279 int, i280 int, i281 int, i282 int, i283 int, i284 int, i285 int, i286
+int, i287 int, i288 int, i289 int, i290 int, i291 int, i292 int, i293 int, i294
+int, i295 int, i296 int, i297 int, i298 int, i299 int, i300 int, i301 int, i302
+int, i303 int, i304 int, i305 int, i306 int, i307 int, i308 int, i309 int, i310
+int, i311 int, i312 int, i313 int, i314 int, i315 int, i316 int, i317 int, i318
+int, i319 int, i320 int, i321 int, i322 int, i323 int, i324 int, i325 int, i326
+int, i327 int, i328 int, i329 int, i330 int, i331 int, i332 int, i333 int, i334
+int, i335 int, i336 int, i337 int, i338 int, i339 int, i340 int, i341 int, i342
+int, i343 int, i344 int, i345 int, i346 int, i347 int, i348 int, i349 int, i350
+int, i351 int, i352 int, i353 int, i354 int, i355 int, i356 int, i357 int, i358
+int, i359 int, i360 int, i361 int, i362 int, i363 int, i364 int, i365 int, i366
+int, i367 int, i368 int, i369 int, i370 int, i371 int, i372 int, i373 int, i374
+int, i375 int, i376 int, i377 int, i378 int, i379 int, i380 int, i381 int, i382
+int, i383 int, i384 int, i385 int, i386 int, i387 int, i388 int, i389 int, i390
+int, i391 int, i392 int, i393 int, i394 int, i395 int, i396 int, i397 int, i398
+int, i399 int, i400 int, i401 int, i402 int, i403 int, i404 int, i405 int, i406
+int, i407 int, i408 int, i409 int, i410 int, i411 int, i412 int, i413 int, i414
+int, i415 int, i416 int, i417 int, i418 int, i419 int, i420 int, i421 int, i422
+int, i423 int, i424 int, i425 int, i426 int, i427 int, i428 int, i429 int, i430
+int, i431 int, i432 int, i433 int, i434 int, i435 int, i436 int, i437 int, i438
+int, i439 int, i440 int, i441 int, i442 int, i443 int, i444 int, i445 int, i446
+int, i447 int, i448 int, i449 int, i450 int, i451 int, i452 int, i453 int, i454
+int, i455 int, i456 int, i457 int, i458 int, i459 int, i460 int, i461 int, i462
+int, i463 int, i464 int, i465 int, i466 int, i467 int, i468 int, i469 int, i470
+int, i471 int, i472 int, i473 int, i474 int, i475 int, i476 int, i477 int, i478
+int, i479 int, i480 int, i481 int, i482 int, i483 int, i484 int, i485 int, i486
+int, i487 int, i488 int, i489 int, i490 int, i491 int, i492 int, i493 int, i494
+int, i495 int, i496 int, i497 int, i498 int, i499 int, i500 int, i501 int, i502
+int, i503 int, i504 int, i505 int, i506 int, i507 int, i508 int, i509 int, i510
+int, i511 int, i512 int, i513 int, i514 int, i515 int, i516 int, i517 int, i518
+int, i519 int, i520 int, i521 int, i522 int, i523 int, i524 int, i525 int, i526
+int, i527 int, i528 int, i529 int, i530 int, i531 int, i532 int, i533 int, i534
+int, i535 int, i536 int, i537 int, i538 int, i539 int, i540 int, i541 int, i542
+int, i543 int, i544 int, i545 int, i546 int, i547 int, i548 int, i549 int, i550
+int, i551 int, i552 int, i553 int, i554 int, i555 int, i556 int, i557 int, i558
+int, i559 int, i560 int, i561 int, i562 int, i563 int, i564 int, i565 int, i566
+int, i567 int, i568 int, i569 int, i570 int, i571 int, i572 int, i573 int, i574
+int, i575 int, i576 int, i577 int, i578 int, i579 int, i580 int, i581 int, i582
+int, i583 int, i584 int, i585 int, i586 int, i587 int, i588 int, i589 int, i590
+int, i591 int, i592 int, i593 int, i594 int, i595 int, i596 int, i597 int, i598
+int, i599 int, i600 int, i601 int, i602 int, i603 int, i604 int, i605 int, i606
+int, i607 int, i608 int, i609 int, i610 int, i611 int, i612 int, i613 int, i614
+int, i615 int, i616 int, i617 int, i618 int, i619 int, i620 int, i621 int, i622
+int, i623 int, i624 int, i625 int, i626 int, i627 int, i628 int, i629 int, i630
+int, i631 int, i632 int, i633 int, i634 int, i635 int, i636 int, i637 int, i638
+int, i639 int, i640 int, i641 int, i642 int, i643 int, i644 int, i645 int, i646
+int, i647 int, i648 int, i649 int, i650 int, i651 int, i652 int, i653 int, i654
+int, i655 int, i656 int, i657 int, i658 int, i659 int, i660 int, i661 int, i662
+int, i663 int, i664 int, i665 int, i666 int, i667 int, i668 int, i669 int, i670
+int, i671 int, i672 int, i673 int, i674 int, i675 int, i676 int, i677 int, i678
+int, i679 int, i680 int, i681 int, i682 int, i683 int, i684 int, i685 int, i686
+int, i687 int, i688 int, i689 int, i690 int, i691 int, i692 int, i693 int, i694
+int, i695 int, i696 int, i697 int, i698 int, i699 int, i700 int, i701 int, i702
+int, i703 int, i704 int, i705 int, i706 int, i707 int, i708 int, i709 int, i710
+int, i711 int, i712 int, i713 int, i714 int, i715 int, i716 int, i717 int, i718
+int, i719 int, i720 int, i721 int, i722 int, i723 int, i724 int, i725 int, i726
+int, i727 int, i728 int, i729 int, i730 int, i731 int, i732 int, i733 int, i734
+int, i735 int, i736 int, i737 int, i738 int, i739 int, i740 int, i741 int, i742
+int, i743 int, i744 int, i745 int, i746 int, i747 int, i748 int, i749 int, i750
+int, i751 int, i752 int, i753 int, i754 int, i755 int, i756 int, i757 int, i758
+int, i759 int, i760 int, i761 int, i762 int, i763 int, i764 int, i765 int, i766
+int, i767 int, i768 int, i769 int, i770 int, i771 int, i772 int, i773 int, i774
+int, i775 int, i776 int, i777 int, i778 int, i779 int, i780 int, i781 int, i782
+int, i783 int, i784 int, i785 int, i786 int, i787 int, i788 int, i789 int, i790
+int, i791 int, i792 int, i793 int, i794 int, i795 int, i796 int, i797 int, i798
+int, i799 int, i800 int, i801 int, i802 int, i803 int, i804 int, i805 int, i806
+int, i807 int, i808 int, i809 int, i810 int, i811 int, i812 int, i813 int, i814
+int, i815 int, i816 int, i817 int, i818 int, i819 int, i820 int, i821 int, i822
+int, i823 int, i824 int, i825 int, i826 int, i827 int, i828 int, i829 int, i830
+int, i831 int, i832 int, i833 int, i834 int, i835 int, i836 int, i837 int, i838
+int, i839 int, i840 int, i841 int, i842 int, i843 int, i844 int, i845 int, i846
+int, i847 int, i848 int, i849 int, i850 int, i851 int, i852 int, i853 int, i854
+int, i855 int, i856 int, i857 int, i858 int, i859 int, i860 int, i861 int, i862
+int, i863 int, i864 int, i865 int, i866 int, i867 int, i868 int, i869 int, i870
+int, i871 int, i872 int, i873 int, i874 int, i875 int, i876 int, i877 int, i878
+int, i879 int, i880 int, i881 int, i882 int, i883 int, i884 int, i885 int, i886
+int, i887 int, i888 int, i889 int, i890 int, i891 int, i892 int, i893 int, i894
+int, i895 int, i896 int, i897 int, i898 int, i899 int, i900 int, i901 int, i902
+int, i903 int, i904 int, i905 int, i906 int, i907 int, i908 int, i909 int, i910
+int, i911 int, i912 int, i913 int, i914 int, i915 int, i916 int, i917 int, i918
+int, i919 int, i920 int, i921 int, i922 int, i923 int, i924 int, i925 int, i926
+int, i927 int, i928 int, i929 int, i930 int, i931 int, i932 int, i933 int, i934
+int, i935 int, i936 int, i937 int, i938 int, i939 int, i940 int, i941 int, i942
+int, i943 int, i944 int, i945 int, i946 int, i947 int, i948 int, i949 int, i950
+int, i951 int, i952 int, i953 int, i954 int, i955 int, i956 int, i957 int, i958
+int, i959 int, i960 int, i961 int, i962 int, i963 int, i964 int, i965 int, i966
+int, i967 int, i968 int, i969 int, i970 int, i971 int, i972 int, i973 int, i974
+int, i975 int, i976 int, i977 int, i978 int, i979 int, i980 int, i981 int, i982
+int, i983 int, i984 int, i985 int, i986 int, i987 int, i988 int, i989 int, i990
+int, i991 int, i992 int, i993 int, i994 int, i995 int, i996 int, i997 int, i998
+int, i999 int, i1000 int) row_format=dynamic;
+insert into t1 values (1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
+1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
+1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
+1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
+1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
+1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
+1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
+1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
+1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
+1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
+1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
+1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
+1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
+1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
+1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
+1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
+1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
+1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
+1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
+1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
+1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
+1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
+1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
+1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
+1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
+1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
+1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
+1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
+1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
+1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
+1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
+1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
+1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
+1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
+1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
+1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
+1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
+1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
+1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1);
+drop table if exists t1;
+
 #
 # Test of REPAIR that once failed
 #
@@ -94,16 +315,6 @@ REPAIR TABLE t1;
 CHECK TABLE t1;
 drop table t1;
 
-#
-# Test of OPTIMIZE of locked and modified tables
-#
-CREATE TABLE t1 (a INT);
-INSERT INTO  t1 VALUES (1), (2), (3);
-LOCK TABLES t1 WRITE;
-INSERT INTO  t1 VALUES (1), (2), (3);
-OPTIMIZE TABLE t1;
-DROP TABLE t1;
-
 #
 # Test of creating table with too long key
 #
@@ -114,3 +325,4 @@ CREATE TABLE t1 (a varchar(255), b varchar(255), c varchar(255));
 --error 1071
 ALTER TABLE t1 ADD INDEX t1 (a, b, c);   
 DROP TABLE t1;
+
diff --git a/mysql-test/t/null_key.test b/mysql-test/t/null_key.test
index 3ab8b993f43d8a57d5ab366e440c8b89eefddedd..b1cbd5cdfb09a72c2218c526d2fc46ba9b4731b5 100644
--- a/mysql-test/t/null_key.test
+++ b/mysql-test/t/null_key.test
@@ -135,3 +135,24 @@ select * from t1, t2 where t1.id = t2.id;
 alter table t1 add key id (id);
 select * from t1, t2 where t1.id = t2.id;
 drop table t1,t2;
+
+#
+# Check bug when doing <=> NULL on an indexed null field
+#
+
+create table t1 (
+  id  integer,
+  id2 integer not null,
+  index (id),
+  index (id2)
+);
+insert into t1 values(null,null),(1,1);
+select * from t1;
+select * from t1 where id <=> null;
+select * from t1 where id <=> null or id > 0;
+select * from t1 where id is null or id > 0;
+select * from t1 where id2 <=> null or id2 > 0;
+select * from t1 where id2 is null or id2 > 0;
+delete from t1 where id <=> NULL;
+select * from t1;
+drop table t1;
diff --git a/mysql-test/t/query_cache.test b/mysql-test/t/query_cache.test
index a0d2a34ee765766551646311763e2db68f4f85da..6c3f3d6ac5276e26d530e66bcfa1c1a437cf7da8 100644
--- a/mysql-test/t/query_cache.test
+++ b/mysql-test/t/query_cache.test
@@ -206,6 +206,7 @@ insert into t2 select * from t1; # 2584
 insert into t1 select * from t2; # 4181
 
 show status like "Qcache_hits";
+show status like "Qcache_lowmem_prunes";
 disable_result_log;
 select a as a1, a as a2 from t1;
 select a as a2, a as a3 from t1;
@@ -215,6 +216,7 @@ select a as a1, a as a2 from t1;
 enable_result_log;
 show status like "Qcache_hits";
 show status like "Qcache_queries_in_cache";
+show status like "Qcache_lowmem_prunes";
 reset query cache;
 #
 # Query bigger then query_cache_limit
diff --git a/mysql-test/t/rpl000007-slave.opt b/mysql-test/t/rpl000007-slave.opt
deleted file mode 100644
index 9ff99337d1ff26f854507f024c72f0fa9964c49f..0000000000000000000000000000000000000000
--- a/mysql-test/t/rpl000007-slave.opt
+++ /dev/null
@@ -1 +0,0 @@
---replicate-do-table=test.bar
diff --git a/mysql-test/t/rpl000007.test b/mysql-test/t/rpl000007.test
deleted file mode 100644
index 8ff1e1782cc80cff4bbc4f419efc55980d4fbbcd..0000000000000000000000000000000000000000
--- a/mysql-test/t/rpl000007.test
+++ /dev/null
@@ -1,24 +0,0 @@
-#this one assumes we are ignoring updates on table foo, but doing
-#the ones on bar
-source include/master-slave.inc;
-connection slave;
-drop table if exists foo;
-create table foo (n int);
-insert into foo values(4);
-connection master;
-drop table if exists foo;
-create table foo (s char(20));
-load data infile '../../std_data/words.dat' into table foo;
-insert into foo values('five');
-drop table if exists bar;
-create table bar (m int);
-insert into bar values(15);
-save_master_pos;
-connection slave;
-sync_with_master;
-select foo.n,bar.m from foo,bar;
-connection master;
-drop table if exists bar,foo;
-save_master_pos;
-connection slave;
-sync_with_master;
diff --git a/mysql-test/t/rpl_replicate_do-slave.opt b/mysql-test/t/rpl_replicate_do-slave.opt
new file mode 100644
index 0000000000000000000000000000000000000000..da3454742164a1ba7d982637d59fdfc754bc0956
--- /dev/null
+++ b/mysql-test/t/rpl_replicate_do-slave.opt
@@ -0,0 +1 @@
+--replicate-do-table=test.t1
diff --git a/mysql-test/t/rpl_replicate_do.test b/mysql-test/t/rpl_replicate_do.test
new file mode 100644
index 0000000000000000000000000000000000000000..0800062dc05951b16f943d0f22d85c062389bf18
--- /dev/null
+++ b/mysql-test/t/rpl_replicate_do.test
@@ -0,0 +1,30 @@
+# This test assumes we are ignoring updates on table t2, but doing
+# updates on t1
+
+source include/master-slave.inc;
+drop table if exists t11;
+connection slave;
+drop table if exists t11;
+create table t2 (n int);
+insert into t2 values(4);
+connection master;
+create table t2 (s char(20));
+load data infile '../../std_data/words.dat' into table t2;
+insert into t2 values('five');
+create table t1 (m int);
+insert into t1 values(15),(16),(17);
+update t1 set m=20 where m=16;
+delete from t1 where m=17;
+create table t11 select * from t1;
+save_master_pos;
+connection slave;
+sync_with_master;
+select * from t1;
+select * from t2;
+--error 1146
+select * from t11;
+connection master;
+drop table if exists t1,t2,t3,t11;
+save_master_pos;
+connection slave;
+sync_with_master;
diff --git a/mysql-test/t/rpl_rotate_logs.test b/mysql-test/t/rpl_rotate_logs.test
index f328e938f6186538b27f99573804cebf70057d83..c552936d93fd91c316026fe308a627a91bf26ab8 100644
--- a/mysql-test/t/rpl_rotate_logs.test
+++ b/mysql-test/t/rpl_rotate_logs.test
@@ -10,10 +10,12 @@
 # - Test creating a duplicate key error and recover from it
 #
 connect (master,localhost,root,,test,0,master.sock);
+drop table if exists t1, t2, t3, t4;
 connect (slave,localhost,root,,test,0,slave.sock);
 system cat /dev/null > var/slave-data/master.info;
 system chmod 000 var/slave-data/master.info;
 connection slave;
+drop table if exists t1, t2, t3, t4;
 --error 1201
 start slave;
 system chmod 600 var/slave-data/master.info;
@@ -31,8 +33,6 @@ connection slave;
 start slave;
 connection master;
 
-drop table if exists t1, t2, t3, t4;
-
 #
 # Test FLUSH LOGS
 #
diff --git a/mysql-test/t/select_found.test b/mysql-test/t/select_found.test
index 0a483c860cb9751b78557a72e415ce2006cf7261..316e78943441cca2a50634bc7b102b39c73a1e72 100644
--- a/mysql-test/t/select_found.test
+++ b/mysql-test/t/select_found.test
@@ -84,4 +84,12 @@ INSERT INTO t1 (titre,maxnumrep) VALUES
 ('test1','1'),('test2','2'),('test3','3');
 SELECT SQL_CALC_FOUND_ROWS titre,numeropost,maxnumrep FROM t1 WHERE numeropost IN (1,2) ORDER BY maxnumrep DESC LIMIT 0, 1;
 SELECT FOUND_ROWS();
+SELECT SQL_CALC_FOUND_ROWS 1 FROM (SELECT 1) LIMIT 0;
+SELECT FOUND_ROWS();
+SELECT SQL_CALC_FOUND_ROWS * FROM t1 WHERE numeropost > 1  LIMIT 0;
+SELECT FOUND_ROWS();
+SELECT SQL_CALC_FOUND_ROWS * FROM t1 LIMIT 0;
+SELECT FOUND_ROWS();
+SELECT SQL_CALC_FOUND_ROWS * FROM t1 ORDER BY numeropost  LIMIT 0;
+SELECT FOUND_ROWS();
 drop table t1;
diff --git a/mysql-test/t/subselect.test b/mysql-test/t/subselect.test
index 10e73a7f9716e93d2d8bbe8753c3d46d607f5c61..eeac0bbb81e0ad8a2b03ae42d7e5e37317c39ee4 100644
--- a/mysql-test/t/subselect.test
+++ b/mysql-test/t/subselect.test
@@ -1,7 +1,21 @@
 select (select 2);
 SELECT (SELECT 1) UNION SELECT (SELECT 2);
 SELECT (SELECT (SELECT 0 UNION SELECT 0));
-drop table if exists t1,t2,t3,t4,t5,attend,clinic,inscrit;
+-- error 1245
+SELECT (SELECT 1 FROM (SELECT 1) HAVING a=1) as a;
+-- error 1245
+SELECT (SELECT 1 FROM (SELECT 1) HAVING b=1) as a,(SELECT 1 FROM (SELECT 1) HAVING a=1) as b;
+SELECT (SELECT 1),MAX(1) FROM (SELECT 1);
+-- error 1245
+SELECT (SELECT a) as a;
+EXPLAIN SELECT 1 FROM (SELECT 1 as a) HAVING (SELECT a)=1;
+SELECT 1 FROM (SELECT 1 as a) HAVING (SELECT a)=1;
+-- error 1054
+SELECT (SELECT 1), a;
+SELECT 1 as a FROM (SELECT 1) HAVING (SELECT a)=1;
+-- error 1054
+SELECT 1 FROM (SELECT (SELECT a));
+drop table if exists t1,t2,t3,t4,t5,t6,t7,t8;
 create table t1 (a int);
 create table t2 (a int, b int);
 create table t3 (a int);
@@ -9,6 +23,8 @@ create table t4 (a int, b int);
 insert into t1 values (2);
 insert into t2 values (1,7),(2,7);
 insert into t4 values (4,8),(3,8),(5,9);
+-- error 1245
+select (select a from t1 where t1.a = a1) as a2, (select b from t2 where t2.b=a2) as a1;
 select (select a from t1 where t1.a=t2.a), a from t2;
 select (select a from t1 where t1.a=t2.b), a from t2;
 select (select a from t1), a from t2;
@@ -18,7 +34,7 @@ insert into t3 values (6),(7),(3);
 select * from t2 where t2.b=(select a from t3 order by 1 desc limit 1);
 select * from t2 where t2.b=(select a from t3 order by 1 desc limit 1) 
 union (select * from t4 order by a limit 2) limit 3;
-select * from t2 where t2.b=(select a from t3 order by 1 desc limit 1) 
+select * from t2 where t2.b=(select a from t3 order by 1 desc limit 1)
 union (select * from t4 where t4.b=(select max(t2.a)*4 from t2) order by a);
 explain select * from t2 where t2.b=(select a from t3 order by 1 desc limit 1) 
 union (select * from t4 where t4.b=(select max(t2.a)*4 from t2) order by a);
@@ -64,11 +80,11 @@ select (select a from t1 where t1.a=t2.a union select a from t5 where t5.a=t2.a)
 explain select (select a from t1 where t1.a=t2.a union select a from t5 where t5.a=t2.a), a from t2;
 -- error 1240
 select (select a from t1 where t1.a=t2.a union all select a from t5 where t5.a=t2.a), a from t2;
-create table attend (patient_uq int, clinic_uq int, index i1 (clinic_uq));
-create table clinic( uq int primary key, name char(25));
-insert into clinic values(1,"Oblastnaia bolnitsa"),(2,"Bolnitsa Krasnogo Kresta");
-insert into attend values (1,1),(1,2),(2,2),(1,3);
-select * from attend where exists (select * from clinic where uq = clinic_uq);
+create table t6 (patient_uq int, clinic_uq int, index i1 (clinic_uq));
+create table t7( uq int primary key, name char(25));
+insert into t7 values(1,"Oblastnaia bolnitsa"),(2,"Bolnitsa Krasnogo Kresta");
+insert into t6 values (1,1),(1,2),(2,2),(1,3);
+select * from t6 where exists (select * from t7 where uq = clinic_uq);
 
 # not unique fields
 -- error 1052
@@ -87,67 +103,199 @@ SELECT * FROM t1 WHERE b = (SELECT MIN(b) FROM t1);
 SELECT * FROM t2 WHERE b = (SELECT MIN(b) FROM t2);
 SELECT * FROM t3 WHERE b = (SELECT MIN(b) FROM t3);
 
-drop table if exists inscrit;
+drop table if exists t8;
 
-CREATE TABLE `inscrit` (
+CREATE TABLE `t8` (
   `pseudo` varchar(35) character set latin1 NOT NULL default '',
   `email` varchar(60) character set latin1 NOT NULL default '',
   PRIMARY KEY  (`pseudo`),
   UNIQUE KEY `email` (`email`)
 ) TYPE=MyISAM CHARSET=latin1 ROW_FORMAT=DYNAMIC;
 
-INSERT INTO inscrit (pseudo,email) VALUES ('joce','test');
-INSERT INTO inscrit (pseudo,email) VALUES ('joce1','test1');
-INSERT INTO inscrit (pseudo,email) VALUES ('2joce1','2test1');
-EXPLAIN SELECT pseudo,(SELECT email FROM inscrit WHERE pseudo=(SELECT pseudo FROM inscrit WHERE pseudo='joce')) FROM inscrit WHERE pseudo=(SELECT pseudo FROM inscrit WHERE pseudo='joce');
+INSERT INTO t8 (pseudo,email) VALUES ('joce','test');
+INSERT INTO t8 (pseudo,email) VALUES ('joce1','test1');
+INSERT INTO t8 (pseudo,email) VALUES ('2joce1','2test1');
+EXPLAIN SELECT pseudo,(SELECT email FROM t8 WHERE pseudo=(SELECT pseudo FROM t8 WHERE pseudo='joce')) FROM t8 WHERE pseudo=(SELECT pseudo FROM t8 WHERE pseudo='joce');
 -- error 1239
-SELECT pseudo FROM inscrit WHERE pseudo=(SELECT pseudo,email FROM
-inscrit WHERE pseudo='joce');
+SELECT pseudo FROM t8 WHERE pseudo=(SELECT pseudo,email FROM
+t8 WHERE pseudo='joce');
 -- error 1239
-SELECT pseudo FROM inscrit WHERE pseudo=(SELECT * FROM inscrit WHERE
+SELECT pseudo FROM t8 WHERE pseudo=(SELECT * FROM t8 WHERE
 pseudo='joce');
-SELECT pseudo FROM inscrit WHERE pseudo=(SELECT pseudo FROM inscrit WHERE pseudo='joce');
+SELECT pseudo FROM t8 WHERE pseudo=(SELECT pseudo FROM t8 WHERE pseudo='joce');
 -- error 1240
-SELECT pseudo FROM inscrit WHERE pseudo=(SELECT pseudo FROM inscrit WHERE pseudo LIKE '%joce%');
+SELECT pseudo FROM t8 WHERE pseudo=(SELECT pseudo FROM t8 WHERE pseudo LIKE '%joce%');
 
-drop table if exists t1,t2,t3,t4,t5,attend,clinic,inscrit;
+drop table if exists t1,t2,t3,t4,t5,t6,t7,t8;
 
-drop table if exists searchconthardwarefr3, forumconthardwarefr7;
-CREATE TABLE `searchconthardwarefr3` (
+#searchconthardwarefr3 forumconthardwarefr7
+CREATE TABLE `t1` (
   `topic` mediumint(8) unsigned NOT NULL default '0',
   `date` date NOT NULL default '0000-00-00',
   `pseudo` varchar(35) character set latin1 NOT NULL default '',
   PRIMARY KEY  (`pseudo`,`date`,`topic`),
   KEY `topic` (`topic`)
 ) TYPE=MyISAM ROW_FORMAT=DYNAMIC;
-INSERT INTO searchconthardwarefr3 (topic,date,pseudo) VALUES
+INSERT INTO t1 (topic,date,pseudo) VALUES
 ('43506','2002-10-02','joce'),('40143','2002-08-03','joce');
-EXPLAIN SELECT DISTINCT date FROM searchconthardwarefr3 WHERE date='2002-08-03';
-EXPLAIN SELECT (SELECT DISTINCT date FROM searchconthardwarefr3 WHERE date='2002-08-03');
-SELECT DISTINCT date FROM searchconthardwarefr3 WHERE date='2002-08-03';
-SELECT (SELECT DISTINCT date FROM searchconthardwarefr3 WHERE date='2002-08-03');
-SELECT 1 FROM searchconthardwarefr3 WHERE 1=(SELECT 1 UNION SELECT 1) UNION ALL SELECT 1;
+EXPLAIN SELECT DISTINCT date FROM t1 WHERE date='2002-08-03';
+EXPLAIN SELECT (SELECT DISTINCT date FROM t1 WHERE date='2002-08-03');
+SELECT DISTINCT date FROM t1 WHERE date='2002-08-03';
+SELECT (SELECT DISTINCT date FROM t1 WHERE date='2002-08-03');
+SELECT 1 FROM t1 WHERE 1=(SELECT 1 UNION SELECT 1) UNION ALL SELECT 1;
 -- error 1240
-SELECT 1 FROM searchconthardwarefr3 WHERE 1=(SELECT 1 UNION ALL SELECT 1) UNION SELECT 1;
-EXPLAIN SELECT 1 FROM searchconthardwarefr3 WHERE 1=(SELECT 1 UNION SELECT 1);
+SELECT 1 FROM t1 WHERE 1=(SELECT 1 UNION ALL SELECT 1) UNION SELECT 1;
+EXPLAIN SELECT 1 FROM t1 WHERE 1=(SELECT 1 UNION SELECT 1);
+drop table t1;
+
+#forumconthardwarefr7 searchconthardwarefr7
+CREATE TABLE `t1` (
+  `numeropost` mediumint(8) unsigned NOT NULL auto_increment,
+  `maxnumrep` int(10) unsigned NOT NULL default '0',
+  PRIMARY KEY  (`numeropost`),
+  UNIQUE KEY `maxnumrep` (`maxnumrep`)
+) TYPE=MyISAM ROW_FORMAT=FIXED;
+
+INSERT INTO t1 (numeropost,maxnumrep) VALUES (40143,1),(43506,2);
+
+CREATE TABLE `t2` (
+      `mot` varchar(30) NOT NULL default '',
+      `topic` mediumint(8) unsigned NOT NULL default '0',
+      `date` date NOT NULL default '0000-00-00',
+      `pseudo` varchar(35) NOT NULL default '',
+       PRIMARY KEY  (`mot`,`pseudo`,`date`,`topic`)
+    ) TYPE=MyISAM ROW_FORMAT=DYNAMIC;
+
+INSERT INTO t2 (mot,topic,date,pseudo) VALUES ('joce','40143','2002-10-22','joce'), ('joce','43506','2002-10-22','joce');
+select numeropost as a FROM t1 GROUP BY (SELECT 1 FROM t1 HAVING a=1);
+SELECT numeropost,maxnumrep FROM t1 WHERE exists (SELECT 1 FROM t2 WHERE (mot='joce') AND date >= '2002-10-21' AND t1.numeropost = t2.topic) ORDER BY maxnumrep DESC LIMIT 0, 20;
 -- error 1054
-SELECT 1 IN (SELECT 1 FROM searchconthardwarefr3 HAVING a);
-SELECT * from searchconthardwarefr3 where topic IN (SELECT topic FROM searchconthardwarefr3 GROUP BY date);
-SELECT * from searchconthardwarefr3 where topic IN (SELECT topic FROM searchconthardwarefr3 GROUP BY date HAVING topic < 4100);
-SELECT * from searchconthardwarefr3 where topic IN (SELECT SUM(topic) FROM searchconthardwarefr3);
-SELECT * from searchconthardwarefr3 where topic = any (SELECT topic FROM searchconthardwarefr3 GROUP BY date);
-SELECT * from searchconthardwarefr3 where topic = any (SELECT topic FROM searchconthardwarefr3 GROUP BY date HAVING topic < 4100);
-SELECT * from searchconthardwarefr3 where topic = any (SELECT SUM(topic) FROM searchconthardwarefr3);
-SELECT * from searchconthardwarefr3 where topic = all (SELECT topic FROM searchconthardwarefr3 GROUP BY date);
-SELECT * from searchconthardwarefr3 where topic = all (SELECT topic FROM searchconthardwarefr3 GROUP BY date HAVING topic < 4100);
-SELECT * from searchconthardwarefr3 where topic = all (SELECT SUM(topic) FROM searchconthardwarefr3);
-SELECT * from searchconthardwarefr3 where topic <> any (SELECT SUM(topic) FROM searchconthardwarefr3);
-CREATE TABLE `forumconthardwarefr7` (
+SELECT (SELECT 1) as a FROM (SELECT 1 FROM t1 HAVING a=1);
+drop table t1, t2;
+
+#forumconthardwarefr7
+drop table if exists t1;
+CREATE TABLE `t1` (
+  `numeropost` mediumint(8) unsigned NOT NULL auto_increment,
+  `maxnumrep` int(10) unsigned NOT NULL default '0',
+  PRIMARY KEY  (`numeropost`),
+  UNIQUE KEY `maxnumrep` (`maxnumrep`)
+) TYPE=MyISAM ROW_FORMAT=FIXED;
+
+INSERT INTO t1 (numeropost,maxnumrep) VALUES (1,0),(2,1);
+-- error 1240
+select numeropost as a FROM t1 GROUP BY (SELECT 1 FROM t1 HAVING a=1);
+-- error 1240
+select numeropost as a FROM t1 ORDER BY (SELECT 1 FROM t1 HAVING a=1);
+drop table t1;
+
+#iftest
+CREATE TABLE t1 (field char(1) NOT NULL DEFAULT 'b');
+INSERT INTO t1 VALUES ();
+-- error 1240
+SELECT field FROM t1 WHERE 1=(SELECT 1 UNION ALL SELECT 1 FROM (SELECT 1) HAVING field='b');
+drop table t1;
+
+# threadhardwarefr7
+CREATE TABLE `t1` (
+  `numeropost` mediumint(8) unsigned NOT NULL default '0',
+  `numreponse` int(10) unsigned NOT NULL auto_increment,
+  `pseudo` varchar(35) NOT NULL default '',
+  PRIMARY KEY  (`numeropost`,`numreponse`),
+  UNIQUE KEY `numreponse` (`numreponse`),
+  KEY `pseudo` (`pseudo`,`numeropost`)
+) TYPE=MyISAM;
+-- error 1245
+SELECT (SELECT numeropost FROM t1 HAVING numreponse=a),numreponse FROM (SELECT * FROM t1) as a;
+-- error 1054
+SELECT numreponse, (SELECT numeropost FROM t1 HAVING numreponse=a) FROM (SELECT * FROM t1) as a;
+SELECT numreponse, (SELECT numeropost FROM t1 HAVING numreponse=1) FROM (SELECT * FROM t1) as a;
+INSERT INTO t1 (numeropost,numreponse,pseudo) VALUES (1,1,'joce'),(1,2,'joce'),(1,3,'test');
+-- error 1240
+EXPLAIN SELECT numreponse FROM t1 WHERE numeropost='1' AND numreponse=(SELECT 1 FROM t1 WHERE numeropost='1');
+EXPLAIN SELECT MAX(numreponse) FROM t1 WHERE numeropost='1';
+EXPLAIN SELECT numreponse FROM t1 WHERE numeropost='1' AND numreponse=(SELECT MAX(numreponse) FROM t1 WHERE numeropost='1');
+SELECT 1 IN (SELECT 1 FROM t1 HAVING a);
+SELECT * from t1 where topic IN (SELECT topic FROM t1 GROUP BY date);
+SELECT * from t1 where topic IN (SELECT topic FROM t1 GROUP BY date HAVING topic < 4100);
+SELECT * from t1 where topic IN (SELECT SUM(topic) FROM t1);
+SELECT * from t1 where topic = any (SELECT topic FROM t1 GROUP BY date);
+SELECT * from t1 where topic = any (SELECT topic FROM t1 GROUP BY date HAVING topic < 4100);
+SELECT * from t1 where topic = any (SELECT SUM(topic) FROM t1);
+SELECT * from t1 where topic = all (SELECT topic FROM t1 GROUP BY date);
+SELECT * from t1 where topic = all (SELECT topic FROM t1 GROUP BY date HAVING topic < 4100);
+SELECT * from t1 where topic = all (SELECT SUM(topic) FROM t1);
+SELECT * from t1 where topic <> any (SELECT SUM(topic) FROM t1);
+CREATE TABLE `t2` (
   `numeropost` mediumint(8) unsigned NOT NULL auto_increment,
   `maxnumrep` int(10) unsigned NOT NULL default '0',
   PRIMARY KEY  (`numeropost`),
   UNIQUE KEY `maxnumrep` (`maxnumrep`)) TYPE=MyISAM ROW_FORMAT=FIXED;
 
-INSERT INTO forumconthardwarefr7 (numeropost,maxnumrep) VALUES (40143,1),(43506,2);
-SELECT SQL_CALC_FOUND_ROWS numeropost,maxnumrep FROM forumconthardwarefr7 WHERE numeropost IN (SELECT topic FROM searchconthardwarefr3 WHERE pseudo='joce' AND date >= '2002-10-06') ORDER BY maxnumrep DESC LIMIT 0,20;
-drop table searchconthardwarefr3, forumconthardwarefr7;
\ No newline at end of file
+INSERT INTO t2 (numeropost,maxnumrep) VALUES (40143,1),(43506,2);
+SELECT SQL_CALC_FOUND_ROWS numeropost,maxnumrep FROM t2 WHERE numeropost IN (SELECT topic FROM t1 WHERE pseudo='joce' AND date >= '2002-10-06') ORDER BY maxnumrep DESC LIMIT 0,20;
+drop table t1,t2;
+
+CREATE TABLE t1 (a int(1));
+INSERT INTO t1 VALUES (1);
+SELECT 1 FROM (SELECT a FROM t1) HAVING (SELECT a)=1;
+drop table t1;
+
+#update with subselects
+create table t1 (a int NOT NULL, b int, primary key (a));
+create table t2 (a int NOT NULL, b int, primary key (a));
+insert into t1 values (0, 10),(1, 11),(2, 12);
+insert into t2 values (1, 21),(2, 22),(3, 23);
+select * from t1;
+update t1 set b= (select b from t2 where t1.a = t2.a);
+select * from t1;
+drop table t1, t2;
+
+#delete with subselects
+create table t1 (a int NOT NULL, b int, primary key (a));
+create table t2 (a int NOT NULL, b int, primary key (a));
+insert into t1 values (0, 10),(1, 11),(2, 12);
+insert into t2 values (1, 21),(2, 12),(3, 23);
+select * from t1;
+select * from t1 where b = (select b from t2 where t1.a = t2.a);
+delete from t1 where b = (select b from t2 where t1.a = t2.a);
+select * from t1;
+drop table t1, t2;
+
+#insert with subselects
+CREATE TABLE t1 (x int);
+create table t2 (a int);
+insert into t2 values (1);
+INSERT INTO t1 (x) VALUES ((SELECT a FROM t2));
+select * from t1;
+insert into t2 values (1);
+INSERT DELAYED INTO t1 (x) VALUES ((SELECT SUM(a) FROM t2));
+-- sleep 1
+select * from t1;
+INSERT INTO t1 (x) select (SELECT SUM(a)+1 FROM t2) FROM t2;
+select * from t1;
+-- error 1093
+INSERT INTO t1 (x) select (SELECT SUM(x)+2 FROM t1) FROM t2;
+INSERT DELAYED INTO t1 (x) VALUES ((SELECT SUM(x) FROM t1));
+-- sleep 1
+select * from t1;
+drop table t1, t2;
+
+#replace with subselects
+CREATE TABLE t1 (x int not null, y int, primary key (x));
+create table t2 (a int);
+insert into t2 values (1);
+select * from t1;
+replace into t1 (x, y) VALUES ((SELECT a FROM t2), (SELECT a+1 FROM t2));
+select * from t1;
+replace into t1 (x, y) VALUES ((SELECT a FROM t2), (SELECT a+2 FROM t2));
+select * from t1;
+replace DELAYED into t1 (x, y) VALUES ((SELECT a+3 FROM t2), (SELECT a FROM t2));
+-- sleep 1
+select * from t1;
+replace DELAYED into t1 (x, y) VALUES ((SELECT a+3 FROM t2), (SELECT a+1 FROM t2));
+-- sleep 1
+select * from t1;
+replace LOW_PRIORITY into t1 (x, y) VALUES ((SELECT a+1 FROM t2), (SELECT a FROM t2));
+select * from t1;
+drop table t1, t2;
diff --git a/mysql-test/t/temp_table.test b/mysql-test/t/temp_table.test
index 3cf18bae9fe6d9ae9b639aacb0747be044c03e0c..10168cf13c71b168bfa1e77921c996375ce71e42 100644
--- a/mysql-test/t/temp_table.test
+++ b/mysql-test/t/temp_table.test
@@ -60,3 +60,21 @@ insert into t2 values (1,1),(2,1),(3,1),(4,2);
 # do a query using ELT, a join and an ORDER BY.
 select one.id, two.val, elt(two.val,'one','two') from t1 one, t2 two where two.id=one.id order by one.id;
 drop table t1,t2;
+
+#
+# In MySQL 4.0.4 doing a GROUP BY on a NULL column created a disk based
+# temporary table when a memory based one would be good enough.
+
+drop table if exists t1;
+
+CREATE TABLE t1 (
+  d datetime default NULL
+) TYPE=MyISAM;
+
+
+INSERT INTO t1 VALUES ('2002-10-24 14:50:32'),('2002-10-24 14:50:33'),('2002-10-24 14:50:34'),('2002-10-24 14:50:34'),('2002-10-24 14:50:34'),('2002-10-24 14:50:35'),('2002-10-24 14:50:35'),('2002-10-24 14:50:35'),('2002-10-24 14:50:35'),('2002-10-24 14:50:36'),('2002-10-24 14:50:36'),('2002-10-24 14:50:36'),('2002-10-24 14:50:36'),('2002-10-24 14:50:37'),('2002-10-24 14:50:37'),('2002-10-24 14:50:37'),('2002-10-24 14:50:37'),('2002-10-24 14:50:38'),('2002-10-24 14:50:38'),('2002-10-24 14:50:38'),('2002-10-24 14:50:39'),('2002-10-24 14:50:39'),('2002-10-24 14:50:39'),('2002-10-24 14:50:39'),('2002-10-24 14:50:40'),('2002-10-24 14:50:40'),('2002-10-24 14:50:40');
+
+flush status;
+select * from t1 group by d;
+show status like "created_tmp%tables";
+drop table t1;
diff --git a/mysql-test/t/type_blob.test b/mysql-test/t/type_blob.test
index 2b23617ec8b34588c713008c6d95959d4027ec0e..234daeabc2b2e067644000fb91dfee57fd98774b 100644
--- a/mysql-test/t/type_blob.test
+++ b/mysql-test/t/type_blob.test
@@ -1,8 +1,34 @@
+#
+# Basic cleanup
+#
+drop table if exists t1,t2,t3,t4,t5,t6,t7;
+
+#
+# Check syntax for creating BLOB/TEXT
+#
+
+CREATE TABLE t1 (a blob, b text, c blob(250), d text(70000), e text(70000000));
+show columns from t1;
+CREATE TABLE t2 (a char(257), b varchar(70000) binary, c varchar(70000000));
+show columns from t2;
+create table t3 (a long, b long byte);
+show create TABLE t3;
+drop table t1,t2,t3
+
+#
+# Check errors with blob
+#
+
+--error 1074
+CREATE TABLE t1 (a char(257) default "hello");
+--error 1101
+CREATE TABLE t2 (a blob default "hello");
+drop table if exists t1,t2;
+
 #
 # test of full join with blob
 #
 
-drop table if exists t1,t2,t3,t4,t5,t6,t7;
 create table t1 (nr int(5) not null auto_increment,b blob,str char(10), primary key (nr));
 insert into t1 values (null,"a","A");
 insert into t1 values (null,"bbb","BBB");
diff --git a/mysql-test/t/type_decimal.test b/mysql-test/t/type_decimal.test
index 9542053961134fe7d02cfa450b72ab38fc9c0830..7f73ec34e3a035f10264edd6ce1011c3d2de8500 100644
--- a/mysql-test/t/type_decimal.test
+++ b/mysql-test/t/type_decimal.test
@@ -220,3 +220,13 @@ create table t1 (a decimal unsigned zerofill);
 insert into t1 values (-99999999999999),(-1),('+1'),('01'),('+00000000000001'),('+1234567890'),(99999999999999);
 select * from t1;
 drop  table t1;
+
+#  Exponent overflow bug
+create table t1(a decimal(10,0));
+insert into t1 values ("1e4294967295");
+select * from t1;
+delete from t1;
+insert into t1 values("1e4294967297");
+select * from t1;
+drop table t1;
+
diff --git a/mysql-test/t/variables.test b/mysql-test/t/variables.test
index 7a1d01c2cb546d6cd4d7dfb2170c83305949d7f5..552777743f87c6fb8d74b326798de89a2f15d35c 100644
--- a/mysql-test/t/variables.test
+++ b/mysql-test/t/variables.test
@@ -34,7 +34,8 @@ drop table t1;
 
 set max_join_size=100;
 show variables like 'max_join_size';
-show global variables like 'max_join_size';
+# Removed, because it has different value with/without BIG_TABLES
+#show global variables like 'max_join_size';
 set GLOBAL max_join_size=2000;
 show global variables like 'max_join_size';
 set max_join_size=DEFAULT;
@@ -65,7 +66,6 @@ set table_type=MYISAM, table_type="HEAP", global table_type="INNODB";
 show local variables like 'table_type';
 show global variables like 'table_type';
 set GLOBAL query_cache_size=100000;
-set GLOBAL safe_show_database=0;
 
 set myisam_max_sort_file_size=10000, GLOBAL myisam_max_sort_file_size=20000;
 show variables like 'myisam_max_sort_file_size';
@@ -94,6 +94,10 @@ set global character set default, session character set default;
 show variables like "convert_character_set";
 select @@timestamp>0;
 
+set @@rand_seed1=10000000,@@rand_seed2=1000000;
+select ROUND(RAND(),5);
+
+
 # The following should give errors
 
 --error 1231
@@ -188,7 +192,6 @@ set global query_cache_type=demand;
 set read_buffer_size=100;
 set read_rnd_buffer_size=100;
 set global rpl_recovery_rank=100;
-set global safe_show_database=1;
 set global server_id=100;
 set global slave_net_timeout=100;
 set global slow_launch_time=100;
diff --git a/mysys/Makefile.am b/mysys/Makefile.am
index 5c0a531c37c6d39d89bca917c82714c84b12af03..330e1d6e59d1955391a19f7b637c1b5c27a6c557 100644
--- a/mysys/Makefile.am
+++ b/mysys/Makefile.am
@@ -17,7 +17,7 @@
 MYSQLDATAdir =		$(localstatedir)
 MYSQLSHAREdir =		$(pkgdatadir)
 MYSQLBASEdir=		$(prefix)
-INCLUDES =		@MT_INCLUDES@ -I$(srcdir)/../include -I../include -I.. -I$(srcdir)
+INCLUDES =		@MT_INCLUDES@ -I$(top_srcdir)/include -I$(srcdir)
 pkglib_LIBRARIES =	libmysys.a
 LDADD =			libmysys.a ../dbug/libdbug.a \
 			../strings/libmystrings.a
@@ -56,11 +56,10 @@ libmysys_a_SOURCES =	my_init.c my_getwd.c mf_getdate.c\
 EXTRA_DIST =		thr_alarm.c thr_lock.c my_pthread.c my_thr_init.c \
 			thr_mutex.c thr_rwlock.c
 libmysys_a_LIBADD =	@THREAD_LOBJECTS@
-# test_fn removed 980815 since it not upp to date test_dir
-noinst_PROGRAMS =	test_charset charset2html @THREAD_LPROGRAMS@
+noinst_PROGRAMS =	charset2html @THREAD_LPROGRAMS@
 # test_dir_DEPENDENCIES=	$(LIBRARIES)
 # testhash_DEPENDENCIES=	$(LIBRARIES)
-test_charset_DEPENDENCIES=	$(LIBRARIES)
+# test_charset_DEPENDENCIES=	$(LIBRARIES)
 charset2html_DEPENDENCIES=	$(LIBRARIES)
 EXTRA_PROGRAMS =	
 DEFS =			-DDEFAULT_BASEDIR=\"$(prefix)\" \
diff --git a/mysys/charset.c b/mysys/charset.c
index 9c977c7d145249faaf85c43b5bfcf75d0c075690..91bae04046b004c2ab731b03af33eb39a865dffa 100644
--- a/mysys/charset.c
+++ b/mysys/charset.c
@@ -376,6 +376,8 @@ static CHARSET_INFO *add_charset(CHARSET_INFO *cs, myf flags)
 	 sizeof(tmp_sort_order));
   memcpy((char*) cs->tab_to_uni, (char*) tmp_to_uni, sizeof(tmp_to_uni));
 
+  cs->like_range  = my_like_range_simple;
+  cs->wildcmp     = my_wildcmp_8bit;
   cs->strnncoll   = my_strnncoll_simple;
   cs->caseup_str  = my_caseup_str_8bit;
   cs->casedn_str  = my_casedn_str_8bit;
@@ -388,6 +390,12 @@ static CHARSET_INFO *add_charset(CHARSET_INFO *cs, myf flags)
   cs->wc_mb       = my_wc_mb_8bit;
   cs->hash_caseup = my_hash_caseup_simple;
   cs->hash_sort   = my_hash_sort_simple;
+  cs->snprintf	  = my_snprintf_8bit;
+  cs->strtol      = my_strtol_8bit;
+  cs->strtoul     = my_strtoul_8bit;
+  cs->strtoll     = my_strtoll_8bit;
+  cs->strtoull     = my_strtoull_8bit;
+  cs->mbmaxlen    = 1;
   
   set_max_sort_char(cs);
   create_fromuni(cs);
diff --git a/mysys/hash.c b/mysys/hash.c
index 2ef17be534153457a4a16e68ae6299521fc69a12..7707e7019c9c8c846cf76371ed2e096f48ce92f7 100644
--- a/mysys/hash.c
+++ b/mysys/hash.c
@@ -84,7 +84,12 @@ void hash_free(HASH *hash)
 
 	/* some helper functions */
 
-inline byte*
+/*
+  This function is char* instead of byte* as HPUX11 compiler can't
+  handle inline functions that are not defined as native types
+*/
+
+inline char*
 hash_key(HASH *hash,const byte *record,uint *length,my_bool first)
 {
   if (hash->get_key)
@@ -105,7 +110,7 @@ static uint hash_rec_mask(HASH *hash,HASH_LINK *pos,uint buffmax,
 			  uint maxlength)
 {
   uint length;
-  byte *key=hash_key(hash,pos->data,&length,0);
+  byte *key= (byte*) hash_key(hash,pos->data,&length,0);
   return hash_mask((*hash->calc_hashnr)(hash->charset,key,length),
   		   buffmax,maxlength);
 }
@@ -159,10 +164,10 @@ uint calc_hashnr(CHARSET_INFO *cs, const byte *key, uint len)
 #ifndef __SUNPRO_C				/* SUNPRO can't handle this */
 inline
 #endif
-uint rec_hashnr(HASH *hash,const byte *record)
+unsigned int rec_hashnr(HASH *hash,const byte *record)
 {
   uint length;
-  byte *key=hash_key(hash,record,&length,0);
+  byte *key= (byte*) hash_key(hash,record,&length,0);
   return (*hash->calc_hashnr)(hash->charset,key,length);
 }
 
@@ -249,7 +254,7 @@ static void movelink(HASH_LINK *array,uint find,uint next_link,uint newlink)
 static int hashcmp(HASH *hash,HASH_LINK *pos,const byte *key,uint length)
 {
   uint rec_keylength;
-  byte *rec_key=hash_key(hash,pos->data,&rec_keylength,1);
+  byte *rec_key= (byte*) hash_key(hash,pos->data,&rec_keylength,1);
   return (length && length != rec_keylength) ||
     (hash->flags & HASH_CASE_INSENSITIVE ?
      my_strncasecmp(hash->charset, rec_key,key,rec_keylength) :
diff --git a/mysys/mf_keycache.c b/mysys/mf_keycache.c
index 5a573bff0f73c466e1281bcb270c98dd0948a2f8..6a037f13f0513e7c1b33a03806135fe2c0784f79 100644
--- a/mysys/mf_keycache.c
+++ b/mysys/mf_keycache.c
@@ -595,13 +595,14 @@ static int flush_key_blocks_int(File file, enum flush_type type)
 	  count++;
       }
       /* Only allocate a new buffer if its bigger than the one we have */
-      if (count <= FLUSH_CACHE ||
-	  !(cache=(SEC_LINK**) my_malloc(sizeof(SEC_LINK*)*count,MYF(0))))
+      if (count > FLUSH_CACHE)
       {
-	cache=cache_buff;		/* Fall back to safe buffer */
-	count=FLUSH_CACHE;
+	if (!(cache=(SEC_LINK**) my_malloc(sizeof(SEC_LINK*)*count,MYF(0))))
+        {
+	  cache=cache_buff;		/* Fall back to safe buffer */
+	  count=FLUSH_CACHE;
+        }
       }
-      end=cache+count;
     }
 
     /* Go through the keys and write them to buffer to be flushed */
diff --git a/mysys/my_aes.c b/mysys/my_aes.c
index a3618e44b82cf40fce8653738a1b9e42ec46758e..16d326d7d1f3e6391e0708c71941b96adb42061b 100644
--- a/mysys/my_aes.c
+++ b/mysys/my_aes.c
@@ -60,19 +60,19 @@ static int my_aes_create_key(KEYINSTANCE *aes_key,
 			     enum encrypt_dir direction, const char *key,
 			     int key_length)
 {
-  char rkey[AES_KEY_LENGTH/8];	 /* The real key to be used for encryption */
-  char *rkey_end=rkey+AES_KEY_LENGTH/8; /* Real key boundary */
-  char *ptr;			/* Start of the real key*/
+  uint8 rkey[AES_KEY_LENGTH/8];	 /* The real key to be used for encryption */
+  uint8 *rkey_end=rkey+AES_KEY_LENGTH/8; /* Real key boundary */
+  uint8 *ptr;			/* Start of the real key*/
   const char *sptr;			/* Start of the working key */
   const char *key_end=key+key_length;	/* Working key boundary*/
 
-  bzero(rkey,AES_KEY_LENGTH/8);      /* Set initial key  */
+  bzero((char*) rkey,AES_KEY_LENGTH/8);      /* Set initial key  */
 
   for (ptr= rkey, sptr= key; sptr < key_end; ptr++,sptr++)
   {
     if (ptr == rkey_end)
       ptr= rkey;  /*  Just loop over tmp_key until we used all key */
-    *ptr^= *sptr;
+    *ptr^= (uint8) *sptr;
   }
 #ifdef AES_USE_KEY_BITS
   /*
@@ -128,7 +128,7 @@ int my_aes_encrypt(const char* source, int source_length, char* dest,
 		   const char* key, int key_length)
 {
   KEYINSTANCE aes_key;
-  char block[AES_BLOCK_SIZE];	/* 128 bit block used for padding */
+  uint8 block[AES_BLOCK_SIZE];	/* 128 bit block used for padding */
   int rc;			/* result codes */
   int num_blocks;		/* number of complete blocks */
   char pad_len;			/* pad size for the last block */
@@ -141,7 +141,8 @@ int my_aes_encrypt(const char* source, int source_length, char* dest,
 
   for (i = num_blocks; i > 0; i--)   /* Encode complete blocks */
   {
-    rijndaelEncrypt(aes_key.rk, aes_key.nr, source, dest);
+    rijndaelEncrypt(aes_key.rk, aes_key.nr, (const uint8*) source,
+		    (uint8*) dest);
     source+= AES_BLOCK_SIZE;
     dest+= AES_BLOCK_SIZE;
   }
@@ -150,7 +151,7 @@ int my_aes_encrypt(const char* source, int source_length, char* dest,
   pad_len = AES_BLOCK_SIZE - (source_length - AES_BLOCK_SIZE*num_blocks);
   memcpy(block, source, 16 - pad_len);
   bfill(block + AES_BLOCK_SIZE - pad_len, pad_len, pad_len);
-  rijndaelEncrypt(aes_key.rk, aes_key.nr, block, dest);
+  rijndaelEncrypt(aes_key.rk, aes_key.nr, block, (uint8*) dest);
   return AES_BLOCK_SIZE*(num_blocks + 1);
 }
 
@@ -175,7 +176,7 @@ int my_aes_decrypt(const char *source, int source_length, char *dest,
 		   const char *key, int key_length)
 {
   KEYINSTANCE aes_key;
-  char block[AES_BLOCK_SIZE];	/* 128 bit block used for padding */
+  uint8 block[AES_BLOCK_SIZE];	/* 128 bit block used for padding */
   int rc;			/* Result codes */
   int num_blocks;		/* Number of complete blocks */
   uint pad_len;			/* Pad size for the last block */
@@ -191,12 +192,13 @@ int my_aes_decrypt(const char *source, int source_length, char *dest,
 
   for (i = num_blocks-1; i > 0; i--)   /* Decode all but last blocks */
   {
-    rijndaelDecrypt(aes_key.rk, aes_key.nr, source, dest);
+    rijndaelDecrypt(aes_key.rk, aes_key.nr, (const uint8*) source,
+		    (uint8*) dest);
     source+= AES_BLOCK_SIZE;
     dest+= AES_BLOCK_SIZE;
   }
 
-  rijndaelDecrypt(aes_key.rk, aes_key.nr, source, block);
+  rijndaelDecrypt(aes_key.rk, aes_key.nr, (const uint8*) source, block);
   /* Use last char in the block as size */
   pad_len = (uint) (uchar) block[AES_BLOCK_SIZE-1];
 
diff --git a/mysys/my_alloc.c b/mysys/my_alloc.c
index f494cce8dbe32bb822c10bcd44c93ab22a19824a..1ab86476e415a163836031e33766c0cce7de2391 100644
--- a/mysys/my_alloc.c
+++ b/mysys/my_alloc.c
@@ -29,7 +29,7 @@ void init_alloc_root(MEM_ROOT *mem_root, uint block_size,
   mem_root->min_malloc= 32;
   mem_root->block_size= block_size-MALLOC_OVERHEAD-sizeof(USED_MEM)-8;
   mem_root->error_handler= 0;
-  mem_root->block_num= 0;
+  mem_root->block_num= 4;			/* We shift this with >>2 */
   mem_root->first_block_usage= 0;
 #if !(defined(HAVE_purify) && defined(EXTRA_DEBUG))
   if (pre_alloc_size)
@@ -69,10 +69,11 @@ gptr alloc_root(MEM_ROOT *mem_root,unsigned int Size)
   reg2 USED_MEM **prev;
 
   Size= ALIGN_SIZE(Size);
-  if ( (*(prev= &mem_root->free)) != NULL )
+  if ((*(prev= &mem_root->free)) != NULL)
   {
-    if( (*prev)->left < Size &&
-	mem_root->first_block_usage++ >= MAX_BLOCK_USAGE_BEFORE_DROP )
+    if ((*prev)->left < Size &&
+	mem_root->first_block_usage++ >= ALLOC_MAX_BLOCK_USAGE_BEFORE_DROP &&
+	(*prev)->left < ALLOC_MAX_BLOCK_TO_DROP)
     {
       next= *prev;
       *prev= next->next;			/* Remove block from list */
@@ -85,7 +86,7 @@ gptr alloc_root(MEM_ROOT *mem_root,unsigned int Size)
   }
   if (! next)
   {						/* Time to alloc new block */
-    block_size= mem_root->block_size*((mem_root->block_num>>2)+1);
+    block_size= mem_root->block_size * (mem_root->block_num >> 2);
     get_size= Size+ALIGN_SIZE(sizeof(USED_MEM));
     get_size= max(get_size, block_size);
 
@@ -177,10 +178,8 @@ void free_root(MEM_ROOT *root, myf MyFlags)
     root->free=root->pre_alloc;
     root->free->left=root->pre_alloc->size-ALIGN_SIZE(sizeof(USED_MEM));
     root->free->next=0;
-    root->block_num= 1;
   }
-  else
-    root->block_num= 0;
+  root->block_num= 4;
   root->first_block_usage= 0;
   DBUG_VOID_RETURN;
 }
diff --git a/mysys/my_append.c b/mysys/my_append.c
index 2e08b4b4c050c411b84e9bc9ae71174a89334022..dc5ed084bb3843ac8c4b884b4d3d12ca21276631 100644
--- a/mysys/my_append.c
+++ b/mysys/my_append.c
@@ -22,7 +22,7 @@
 #include <sys/utime.h>
 #elif defined(HAVE_UTIME_H)
 #include <utime.h>
-#elif !defined(HPUX)
+#elif !defined(HPUX10)
 struct utimbuf {
   time_t actime;
   time_t modtime;
diff --git a/mysys/my_copy.c b/mysys/my_copy.c
index 253608c53062e81a54b7a8edd2bff2a8076595a5..a899835ea62ff333988a8ab7232741b92f22b26b 100644
--- a/mysys/my_copy.c
+++ b/mysys/my_copy.c
@@ -22,7 +22,7 @@
 #include <sys/utime.h>
 #elif defined(HAVE_UTIME_H)
 #include <utime.h>
-#elif !defined(HPUX)
+#elif !defined(HPUX10)
 #include <time.h>
 struct utimbuf {
   time_t actime;
diff --git a/mysys/my_pthread.c b/mysys/my_pthread.c
index 54a5c71c695bbeada4e2957b30cafa2929430732..07e8ecec6acedab58aa6bb59dc3c767d511cf797 100644
--- a/mysys/my_pthread.c
+++ b/mysys/my_pthread.c
@@ -435,7 +435,7 @@ int my_pthread_cond_init(pthread_cond_t *mp, const pthread_condattr_t *attr)
   this has to be added here.
 ****************************************************************************/
 
-#if defined(HPUX) || defined(HAVE_BROKEN_PTHREAD_COND_TIMEDWAIT)
+#if defined(HPUX10) || defined(HAVE_BROKEN_PTHREAD_COND_TIMEDWAIT)
 
 int my_pthread_cond_timedwait(pthread_cond_t *cond, pthread_mutex_t *mutex,
 			      struct timespec *abstime)
diff --git a/mysys/my_redel.c b/mysys/my_redel.c
index 8474dab0d13b9134ef745552fc6ec22bc71552e1..b5a79d9454b342ce18868d990d8f6f2d8a02b904 100644
--- a/mysys/my_redel.c
+++ b/mysys/my_redel.c
@@ -23,7 +23,7 @@
 #include <sys/utime.h>
 #elif defined(HAVE_UTIME_H)
 #include <utime.h>
-#elif !defined(HPUX)
+#elif !defined(HPUX10)
 struct utimbuf {
   time_t actime;
   time_t modtime;
diff --git a/mysys/my_static.c b/mysys/my_static.c
index 1eb6220f1856836da3fade130fe27a417d3b2a2f..bbf7582a4546e9629d06314217d0352275e07e1a 100644
--- a/mysys/my_static.c
+++ b/mysys/my_static.c
@@ -60,7 +60,7 @@ USED_MEM* my_once_root_block=0;			/* pointer to first block */
 uint	  my_once_extra=ONCE_ALLOC_INIT;	/* Memory to alloc / block */
 
 	/* from my_tempnam */
-#ifndef HAVE_TEMPNAM
+#if !defined(HAVE_TEMPNAM) || defined(HPUX11)
 int _my_tempnam_used=0;
 #endif
 
diff --git a/mysys/my_static.h b/mysys/my_static.h
index 10b2e0fc2d224acdd4636ea9fa6c976ebb76912c..c1893f4074f3303a095340de18b9b6b1383d43fc 100644
--- a/mysys/my_static.h
+++ b/mysys/my_static.h
@@ -65,7 +65,7 @@ extern const char *soundex_map;
 extern USED_MEM* my_once_root_block;
 extern uint	 my_once_extra;
 
-#ifndef HAVE_TEMPNAM
+#if !defined(HAVE_TEMPNAM) || defined(HPUX11)
 extern int	_my_tempnam_used;
 #endif
 
diff --git a/mysys/my_tempnam.c b/mysys/my_tempnam.c
index 6c17aa5b16548c50f4ea382c0198654c03136f04..4fa2dd2abc42a92ef60e8a2bf4c94197709f352a 100644
--- a/mysys/my_tempnam.c
+++ b/mysys/my_tempnam.c
@@ -23,6 +23,12 @@
 
 #include "mysys_priv.h"
 #include <m_string.h>
+
+/* HPUX 11.0 doesn't allow us to change the environ pointer */
+#ifdef HPUX11
+#undef HAVE_TEMPNAM
+#endif
+
 #include "my_static.h"
 #include "mysys_err.h"
 
diff --git a/mysys/test_charset.c b/mysys/test_charset.c
index 47ed9062c050626c32eed1cb64084e8c87b13f26..d031007a1da1148f5b9bffdde4cadaea481987f9 100644
--- a/mysys/test_charset.c
+++ b/mysys/test_charset.c
@@ -46,7 +46,7 @@ static void _print_csinfo(CHARSET_INFO *cs)
          cs->strnxfrm,
          cs->like_range);
   printf("multi-byte: %3s (%d, %p, %p, %p)\n",
-         cs->mbmaxlen ? "yes" : "no",
+         cs->mbmaxlen > 1 ? "yes" : "no",
          cs->mbmaxlen,
          cs->ismbchar,
          cs->ismbhead,
diff --git a/mysys/thr_alarm.c b/mysys/thr_alarm.c
index d1343d4c2d3534deab571f3e1205bd0a7b07532c..ed468b5ef5072082921a0a4a9f7214afc43e8930 100644
--- a/mysys/thr_alarm.c
+++ b/mysys/thr_alarm.c
@@ -730,11 +730,11 @@ static pthread_cond_t COND_thread_count;
 static pthread_mutex_t LOCK_thread_count;
 static uint thread_count;
 
-#ifdef HPUX
+#ifdef HPUX10
 typedef int * fd_set_ptr;
 #else
 typedef fd_set * fd_set_ptr;
-#endif /* HPUX */
+#endif /* HPUX10 */
 
 static void *test_thread(void *arg)
 {
diff --git a/mysys/tree.c b/mysys/tree.c
index f72a49613126ab4277982a556afd83d8e5dec7d4..364b69921084b07c20f914acb2a6dc295ac570a3 100644
--- a/mysys/tree.c
+++ b/mysys/tree.c
@@ -53,7 +53,8 @@
 
 #define BLACK		1
 #define RED		0
-#define DEFAULT_ALLOC_SIZE (8192-MALLOC_OVERHEAD)
+#define DEFAULT_ALLOC_SIZE 8192
+#define DEFAULT_ALIGN_SIZE 8192
 
 static void delete_tree_element(TREE *,TREE_ELEMENT *);
 static int tree_walk_left_root_right(TREE *,TREE_ELEMENT *,
@@ -80,8 +81,9 @@ void init_tree(TREE *tree, uint default_alloc_size, uint memory_limit,
   DBUG_ENTER("init_tree");
   DBUG_PRINT("enter",("tree: %lx  size: %d",tree,size));
 
- if (!default_alloc_size)
-   default_alloc_size= DEFAULT_ALLOC_SIZE;
+  if (default_alloc_size < DEFAULT_ALLOC_SIZE)
+    default_alloc_size= DEFAULT_ALLOC_SIZE;
+  default_alloc_size= MY_ALIGN(default_alloc_size, DEFAULT_ALIGN_SIZE);
   bzero((gptr) &tree->null_element,sizeof(tree->null_element));
   tree->root= &tree->null_element;
   tree->compare=compare;
@@ -439,14 +441,14 @@ void *tree_search_next(TREE *tree, TREE_ELEMENT ***last_pos, int l_offs,
   Expected that tree is fully balanced
   (each path from root to leaf has the same length)
 */
-uint tree_record_pos(TREE *tree, const void *key, 
+ha_rows tree_record_pos(TREE *tree, const void *key, 
                      enum ha_rkey_function flag, void *custom_arg)
 {
   int cmp;
   TREE_ELEMENT *element= tree->root;
   double left= 1;
   double right= tree->elements_in_tree;
-  uint last_equal_pos= HA_POS_ERROR;
+  ha_rows last_equal_pos= HA_POS_ERROR;
 
   while (element != &tree->null_element)
   {
diff --git a/pstack/Makefile.am b/pstack/Makefile.am
index 863a52f4488adcd8bfd4e9a3571d919d10f87072..77f84d212cdf4036fb88f1b5f8315c036b297cd0 100644
--- a/pstack/Makefile.am
+++ b/pstack/Makefile.am
@@ -20,7 +20,7 @@
 #
 
 SUBDIRS =		aout
-INCLUDES =		-I$(srcdir)/../include -I../include
+INCLUDES =		-I$(top_srcdir)/include
 noinst_HEADERS =	bucomm.h debug.h ieee.h budbg.h demangle.h \
 			linuxthreads.h pstack.h pstacktrace.h
 SRC=			bucomm.c filemode.c linuxthreads.c rddbg.c \
diff --git a/readline/COPYING b/readline/COPYING
index a43ea2126fb6b114bff5f8e003ee118e045dacf1..1bf1526387846344944ce72e3f2341cdd61a9246 100644
--- a/readline/COPYING
+++ b/readline/COPYING
@@ -2,7 +2,7 @@
 		       Version 2, June 1991
 
  Copyright (C) 1989, 1991 Free Software Foundation, Inc.
-                          675 Mass Ave, Cambridge, MA 02139, USA
+                          59 Temple Place, Suite 330, Boston, MA 02111 USA
  Everyone is permitted to copy and distribute verbatim copies
  of this license document, but changing it is not allowed.
 
@@ -305,7 +305,7 @@ the "copyright" line and a pointer to where the full notice is found.
 
     You should have received a copy of the GNU General Public License
     along with this program; if not, write to the Free Software
-    Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+    Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
 
 Also add information on how to contact you by electronic and paper mail.
 
diff --git a/readline/INSTALL b/readline/INSTALL
index 95d84c820fb8382b4f2d9daa044f626739ba0254..adb27a9f222d08ffe3f95d5d2530dc9fdcf6bff1 100644
--- a/readline/INSTALL
+++ b/readline/INSTALL
@@ -1,73 +1,81 @@
 Basic Installation
 ==================
 
-   These are generic installation instructions.
-
-   The `configure' shell script attempts to guess correct values for
-various system-dependent variables used during compilation.  It uses
-those values to create a `Makefile' in each directory of the package.
-It may also create one or more `.h' files containing system-dependent
-definitions.  Finally, it creates a shell script `config.status' that
-you can run in the future to recreate the current configuration, a file
-`config.cache' that saves the results of its tests to speed up
-reconfiguring, and a file `config.log' containing compiler output
-(useful mainly for debugging `configure').
-
-   If you need to do unusual things to compile the package, please try
-to figure out how `configure' could check whether to do them, and mail
-diffs or instructions to the address given in the `README' so they can
-be considered for the next release.  If at some point `config.cache'
-contains results you don't want to keep, you may remove or edit it.
-
-   The file `configure.in' is used to create `configure' by a program
-called `autoconf'.  You only need `configure.in' if you want to change
-it or regenerate `configure' using a newer version of `autoconf'.
-
-The simplest way to compile this package is:
-
-  1. `cd' to the directory containing the package's source code and type
-     `./configure' to configure the package for your system.  If you're
+These are installation instructions for Readline-4.3.
+
+The simplest way to compile readline is:
+
+  1. `cd' to the directory containing the readline source code and type
+     `./configure' to configure readline for your system.  If you're
      using `csh' on an old version of System V, you might need to type
      `sh ./configure' instead to prevent `csh' from trying to execute
      `configure' itself.
 
-     Running `configure' takes awhile.  While running, it prints some
+     Running `configure' takes some time.  While running, it prints some
      messages telling which features it is checking for.
 
-  2. Type `make' to compile the package.
-
-  3. Optionally, type `make check' to run any self-tests that come with
-     the package.
+  2. Type `make' to compile readline and build the static readline
+     and history libraries.  If supported, the shared readline and history
+     libraries will be built also.  See below for instructions on compiling
+     the other parts of the distribution.  Typing `make everything' will
+     cause the static and shared libraries (if supported) and the example
+     programs to be built.
 
-  4. Type `make install' to install the programs and any data files and
-     documentation.
+  3. Type `make install' to install the static readline and history
+     libraries, the readline include files, the documentation, and, if
+     supported, the shared readline and history libraries.
 
-  5. You can remove the program binaries and object files from the
-     source code directory by typing `make clean'.  To also remove the
-     files that `configure' created (so you can compile the package for
+  4. You can remove the created libraries and object files from the
+     build directory by typing `make clean'.  To also remove the
+     files that `configure' created (so you can compile readline for
      a different kind of computer), type `make distclean'.  There is
      also a `make maintainer-clean' target, but that is intended mainly
-     for the package's developers.  If you use it, you may have to get
-     all sorts of other programs in order to regenerate files that came
-     with the distribution.
+     for the readline developers, and should be used with care.
+
+The `configure' shell script attempts to guess correct values for
+various system-dependent variables used during compilation.  It
+uses those values to create a `Makefile' in the build directory,
+and Makefiles in the `doc', `shlib', and `examples'
+subdirectories.  It also creates a `config.h' file containing
+system-dependent definitions.  Finally, it creates a shell script
+`config.status' that you can run in the future to recreate the
+current configuration, a file `config.cache' that saves the
+results of its tests to speed up reconfiguring, and a file
+`config.log' containing compiler output (useful mainly for
+debugging `configure'). 
+
+If you need to do unusual things to compile readline, please try
+to figure out how `configure' could check whether to do them, and
+mail diffs or instructions to <bug-readline@gnu.org> so they can
+be considered for the next release.  If at some point
+`config.cache' contains results you don't want to keep, you may
+remove or edit it. 
+
+The file `configure.in' is used to create `configure' by a
+program called `autoconf'.  You only need `configure.in' if you
+want to change it or regenerate `configure' using a newer version
+of `autoconf'.  The readline `configure.in' requires autoconf
+version 2.50 or newer. 
 
 Compilers and Options
 =====================
 
-   Some systems require unusual options for compilation or linking that
+Some systems require unusual options for compilation or linking that
 the `configure' script does not know about.  You can give `configure'
 initial values for variables by setting them in the environment.  Using
 a Bourne-compatible shell, you can do that on the command line like
 this:
+
      CC=c89 CFLAGS=-O2 LIBS=-lposix ./configure
 
 Or on systems that have the `env' program, you can do it like this:
+
      env CPPFLAGS=-I/usr/local/include LDFLAGS=-s ./configure
 
 Compiling For Multiple Architectures
 ====================================
 
-   You can compile the package for more than one kind of computer at the
+You can compile readline for more than one kind of computer at the
 same time, by placing the object files for each architecture in their
 own directory.  To do this, you must use a version of `make' that
 supports the `VPATH' variable, such as GNU `make'.  `cd' to the
@@ -75,80 +83,59 @@ directory where you want the object files and executables to go and run
 the `configure' script.  `configure' automatically checks for the
 source code in the directory that `configure' is in and in `..'.
 
-   If you have to use a `make' that does not supports the `VPATH'
-variable, you have to compile the package for one architecture at a time
-in the source code directory.  After you have installed the package for
-one architecture, use `make distclean' before reconfiguring for another
-architecture.
+If you have to use a `make' that does not supports the `VPATH'
+variable, you have to compile readline for one architecture at a
+time in the source code directory.  After you have installed
+readline for one architecture, use `make distclean' before
+reconfiguring for another architecture. 
 
 Installation Names
 ==================
 
-   By default, `make install' will install the package's files in
-`/usr/local/bin', `/usr/local/man', etc.  You can specify an
-installation prefix other than `/usr/local' by giving `configure' the
-option `--prefix=PATH'.
-
-   You can specify separate installation prefixes for
-architecture-specific files and architecture-independent files.  If you
-give `configure' the option `--exec-prefix=PATH', the package will use
-PATH as the prefix for installing programs and libraries.
-Documentation and other data files will still use the regular prefix.
-
-   If the package supports it, you can cause programs to be installed
-with an extra prefix or suffix on their names by giving `configure' the
-option `--program-prefix=PREFIX' or `--program-suffix=SUFFIX'.
-
-Optional Features
-=================
-
-   Some packages pay attention to `--enable-FEATURE' options to
-`configure', where FEATURE indicates an optional part of the package.
-They may also pay attention to `--with-PACKAGE' options, where PACKAGE
-is something like `gnu-as' or `x' (for the X Window System).  The
-`README' should mention any `--enable-' and `--with-' options that the
-package recognizes.
-
-   For packages that use the X Window System, `configure' can usually
-find the X include and library files automatically, but if it doesn't,
-you can use the `configure' options `--x-includes=DIR' and
-`--x-libraries=DIR' to specify their locations.
+By default, `make install' will install the readline libraries in
+`/usr/local/lib', the include files in
+`/usr/local/include/readline', the man pages in `/usr/local/man',
+and the info files in `/usr/local/info'.  You can specify an
+installation prefix other than `/usr/local' by giving `configure'
+the option `--prefix=PATH' or by supplying a value for the
+DESTDIR variable when running `make install'. 
+
+You can specify separate installation prefixes for
+architecture-specific files and architecture-independent files. 
+If you give `configure' the option `--exec-prefix=PATH', the
+readline Makefiles will use PATH as the prefix for installing the
+libraries.  Documentation and other data files will still use the
+regular prefix. 
 
 Specifying the System Type
 ==========================
 
-   There may be some features `configure' can not figure out
-automatically, but needs to determine by the type of host the package
-will run on.  Usually `configure' can figure that out, but if it prints
-a message saying it can not guess the host type, give it the
-`--host=TYPE' option.  TYPE can either be a short name for the system
-type, such as `sun4', or a canonical name with three fields:
-     CPU-COMPANY-SYSTEM
-
-See the file `config.sub' for the possible values of each field.  If
-`config.sub' isn't included in this package, then this package doesn't
-need to know the host type.
+There may be some features `configure' can not figure out
+automatically, but need to determine by the type of host readline
+will run on.  Usually `configure' can figure that out, but if it
+prints a message saying it can not guess the host type, give it
+the `--host=TYPE' option.  TYPE can either be a short name for
+the system type, such as `sun4', or a canonical name with three
+fields: CPU-COMPANY-SYSTEM (e.g., i386-unknown-freebsd4.2). 
 
-   If you are building compiler tools for cross-compiling, you can also
-use the `--target=TYPE' option to select the type of system they will
-produce code for and the `--build=TYPE' option to select the type of
-system on which you are compiling the package.
+See the file `config.sub' for the possible values of each field.
 
 Sharing Defaults
 ================
 
-   If you want to set default values for `configure' scripts to share,
+If you want to set default values for `configure' scripts to share,
 you can create a site shell script called `config.site' that gives
 default values for variables like `CC', `cache_file', and `prefix'.
 `configure' looks for `PREFIX/share/config.site' if it exists, then
 `PREFIX/etc/config.site' if it exists.  Or, you can set the
 `CONFIG_SITE' environment variable to the location of the site script.
-A warning: not all `configure' scripts look for a site script.
+A warning: the readline `configure' looks for a site script, but not
+all `configure' scripts do.
 
 Operation Controls
 ==================
 
-   `configure' recognizes the following options to control how it
+`configure' recognizes the following options to control how it
 operates.
 
 `--cache-file=FILE'
@@ -174,3 +161,113 @@ operates.
 
 `configure' also accepts some other, not widely useful, options.
 
+Optional Features
+=================
+
+The readline `configure' recognizes a single `--with-PACKAGE' option:
+
+`--with-curses'
+    This tells readline that it can find the termcap library functions
+    (tgetent, et al.) in the curses library, rather than a separate
+    termcap library.  Readline uses the termcap functions, but does not
+    link with the termcap or curses library itself, allowing applications
+    which link with readline the to choose an appropriate library.
+    This option tells readline to link the example programs with the
+    curses library rather than libtermcap.
+
+`configure' also recognizes two `--enable-FEATURE' options:
+
+`--enable-shared'
+    Build the shared libraries by default on supported platforms.  The
+    default is `yes'.
+
+`--enable-static'
+    Build the static libraries by default.  The default is `yes'.
+ 
+Shared Libraries
+================
+
+There is support for building shared versions of the readline and
+history libraries.  The configure script creates a Makefile in
+the `shlib' subdirectory, and typing `make shared' will cause
+shared versions of the readline and history libraries to be built
+on supported platforms.
+
+If `configure' is given the `--enable-shared' option, it will attempt
+to build the shared libraries by default on supported platforms.
+
+Configure calls the script support/shobj-conf to test whether or
+not shared library creation is supported and to generate the values
+of variables that are substituted into shlib/Makefile.  If you
+try to build shared libraries on an unsupported platform, `make'
+will display a message asking you to update support/shobj-conf for
+your platform.
+
+If you need to update support/shobj-conf, you will need to create
+a `stanza' for your operating system and compiler.  The script uses
+the value of host_os and ${CC} as determined by configure.  For
+instance, FreeBSD 4.2 with any version of gcc is identified as
+`freebsd4.2-gcc*'.
+
+In the stanza for your operating system-compiler pair, you will need to
+define several variables.  They are:
+
+SHOBJ_CC	The C compiler used to compile source files into shareable
+		object files.  This is normally set to the value of ${CC}
+		by configure, and should not need to be changed.
+
+SHOBJ_CFLAGS	Flags to pass to the C compiler ($SHOBJ_CC) to create
+		position-independent code.  If you are using gcc, this
+		should probably be set to `-fpic'.
+
+SHOBJ_LD	The link editor to be used to create the shared library from
+		the object files created by $SHOBJ_CC.  If you are using
+		gcc, a value of `gcc' will probably work.
+
+SHOBJ_LDFLAGS	Flags to pass to SHOBJ_LD to enable shared object creation.
+		If you are using gcc, `-shared' may be all that is necessary.
+		These should be the flags needed for generic shared object
+		creation.
+
+SHLIB_XLDFLAGS	Additional flags to pass to SHOBJ_LD for shared library
+		creation.  Many systems use the -R option to the link
+		editor to embed a path within the library for run-time
+		library searches.  A reasonable value for such systems would
+		be `-R$(libdir)'.
+
+SHLIB_LIBS	Any additional libraries that shared libraries should be
+		linked against when they are created.
+
+SHLIB_LIBSUFF	The suffix to add to `libreadline' and `libhistory' when
+		generating the filename of the shared library.  Many systems
+		use `so'; HP-UX uses `sl'.
+
+SHLIB_LIBVERSION The string to append to the filename to indicate the version
+		of the shared library.  It should begin with $(SHLIB_LIBSUFF),
+		and possibly include version information that allows the
+		run-time loader to load the version of the shared library
+		appropriate for a particular program.  Systems using shared
+		libraries similar to SunOS 4.x use major and minor library
+		version numbers; for those systems a value of
+		`$(SHLIB_LIBSUFF).$(SHLIB_MAJOR)$(SHLIB_MINOR)' is appropriate.
+		Systems based on System V Release 4 don't use minor version
+		numbers; use `$(SHLIB_LIBSUFF).$(SHLIB_MAJOR)' on those systems.
+		Other Unix versions use different schemes.
+
+SHLIB_STATUS	Set this to `supported' when you have defined the other
+		necessary variables.  Make uses this to determine whether
+		or not shared library creation should be attempted.  If
+		shared libraries are not supported, this will be set to
+		`unsupported'.
+
+You should look at the existing stanzas in support/shobj-conf for ideas.
+
+Once you have updated support/shobj-conf, re-run configure and type
+`make shared' or `make'.  The shared libraries will be created in the
+shlib subdirectory.
+
+If shared libraries are created, `make install' will install them. 
+You may install only the shared libraries by running `make
+install-shared' from the top-level build directory.  Running `make
+install' in the shlib subdirectory will also work.  If you don't want
+to install any created shared libraries, run `make install-static'. 
diff --git a/readline/Makefile.am b/readline/Makefile.am
index 37e97289e6b5d2e4309b2208d5968ad0840c969e..2fdb2e04bcd1ede58e717e0c514e13993b0edfe9 100644
--- a/readline/Makefile.am
+++ b/readline/Makefile.am
@@ -2,7 +2,7 @@
 # Makefile for the GNU readline library.
 # Copyright (C) 1994,1996,1997 Free Software Foundation, Inc.
 
-INCLUDES =		-I$(srcdir)/../include -I$(srcdir)/.. -I..
+INCLUDES =		-I$(top_srcdir)/include
 
 noinst_LIBRARIES =	libreadline.a
 
@@ -15,7 +15,7 @@ libreadline_a_SOURCES =	readline.c funmap.c keymaps.c \
 			callback.c terminal.c xmalloc.c \
 			history.c histsearch.c histexpand.c \
 			histfile.c nls.c search.c \
-			shell.c tilde.c 
+			shell.c tilde.c misc.c text.c mbutil.c
 
 pkginclude_HEADERS =	readline.h chardefs.h keymaps.h history.h tilde.h
 
diff --git a/readline/README b/readline/README
index 56565b2fb803adc49129f9709399c946069b5b55..7aa939452fbc983a1f777478899066f7a8e8f7aa 100644
--- a/readline/README
+++ b/readline/README
@@ -1,7 +1,7 @@
 Introduction
 ============
 
-This is the Gnu Readline library, version 4.0.
+This is the Gnu Readline library, version 4.3.
 
 The Readline library provides a set of functions for use by applications
 that allow users to edit command lines as they are typed in.  Both
@@ -16,8 +16,8 @@ may be used without Readline in applications which desire its
 capabilities.
 
 The Readline library is free software, distributed under the terms of
-the GNU Public License, version 2.  For more information, see the file
-COPYING.
+the [GNU] General Public License, version 2.  For more information, see
+the file COPYING.
 
 To build the library, try typing `./configure', then `make'.  The
 configuration process is automated, so no further intervention should
@@ -37,6 +37,9 @@ to customize and control the build process.
 The file rlconf.h contains C preprocessor defines that enable and disable
 certain Readline features.
 
+The special make target `everything' will build the static and shared
+libraries (if the target platform supports them) and the examples.
+
 Examples
 ========
 
@@ -54,6 +57,9 @@ a Makefile in the `shlib' subdirectory, and typing `make shared'
 will cause shared versions of the Readline and History libraries
 to be built on supported platforms.
 
+If `configure' is given the `--enable-shared' option, it will attempt
+to build the shared libraries by default on supported platforms.
+
 Configure calls the script support/shobj-conf to test whether or
 not shared library creation is supported and to generate the values
 of variables that are substituted into shlib/Makefile.  If you
@@ -64,8 +70,8 @@ your platform.
 If you need to update support/shobj-conf, you will need to create
 a `stanza' for your operating system and compiler.  The script uses
 the value of host_os and ${CC} as determined by configure.  For
-instance, FreeBSD 2.2.5 with any version of gcc is identified as
-`freebsd2.2.5-gcc*'.
+instance, FreeBSD 4.2 with any version of gcc is identified as
+`freebsd4.2-gcc*'.
 
 In the stanza for your operating system-compiler pair, you will need to
 define several variables.  They are:
@@ -122,18 +128,21 @@ Once you have updated support/shobj-conf, re-run configure and type
 `make shared'.  The shared libraries will be created in the shlib
 subdirectory.
 
-Since shared libraries are not created on all platforms, `make install'
-will not automatically install the shared libraries.  To install them,
-change the current directory to shlib and type `make install'.  Running
-`make install-shared' from the top-level build directory will also work.
+If shared libraries are created, `make install' will install them. 
+You may install only the shared libraries by running `make
+install-shared' from the top-level build directory.  Running `make
+install' in the shlib subdirectory will also work.  If you don't want
+to install any created shared libraries, run `make install-static'. 
 
 Documentation
 =============
 
-The documentation for the Readline and History libraries appears in the
-`doc' subdirectory.  There are two texinfo files and a Unix-style manual
-page describing the programming facilities available in the Readline
-library.  The texinfo files include both user and programmer's manuals.
+The documentation for the Readline and History libraries appears in
+the `doc' subdirectory.  There are three texinfo files and a
+Unix-style manual page describing the facilities available in the
+Readline library.  The texinfo files include both user and
+programmer's manuals.  HTML versions of the manuals appear in the
+`doc' subdirectory as well. 
 
 Reporting Bugs
 ==============
@@ -144,7 +153,7 @@ Bug reports for Readline should be sent to:
 
 When reporting a bug, please include the following information:
 
-        * the version number and release status of Readline (e.g., 4.0-release)
+        * the version number and release status of Readline (e.g., 4.2-release)
         * the machine and OS that it is running on
         * a list of the compilation flags or the contents of `config.h', if
           appropriate
diff --git a/readline/ansi_stdlib.h b/readline/ansi_stdlib.h
index 52339da5d333a3ec3e560cd380842f7f7cafca7d..db13cd234bdf216accbe666718f5e63dab4001cc 100644
--- a/readline/ansi_stdlib.h
+++ b/readline/ansi_stdlib.h
@@ -18,18 +18,31 @@
 
    You should have received a copy of the GNU General Public License along
    with Bash; see the file COPYING.  If not, write to the Free Software
-   Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. */
+   Foundation, 59 Temple Place, Suite 330, Boston, MA 02111 USA. */
 
 #if !defined (_STDLIB_H_)
 #define	_STDLIB_H_ 1
 
 /* String conversion functions. */
 extern int atoi ();
-extern long int atol ();
+
+extern double atof ();
+extern double strtod ();
 
 /* Memory allocation functions. */
-extern char *malloc ();
-extern char *realloc ();
+/* Generic pointer type. */
+#ifndef PTR_T
+
+#if defined (__STDC__)
+#  define PTR_T	void *
+#else
+#  define PTR_T char *
+#endif
+
+#endif /* PTR_T */
+
+extern PTR_T malloc ();
+extern PTR_T realloc ();
 extern void free ();
 
 /* Other miscellaneous functions. */
diff --git a/readline/bind.c b/readline/bind.c
index f122bdf4860d0472c344ea79e7bc76557ad686f3..7e8ca04e0d65d426f340cb8fb84054434fa8d82c 100644
--- a/readline/bind.c
+++ b/readline/bind.c
@@ -7,7 +7,7 @@
 
    The GNU Readline Library is free software; you can redistribute it
    and/or modify it under the terms of the GNU General Public License
-   as published by the Free Software Foundation; either version 1, or
+   as published by the Free Software Foundation; either version 2, or
    (at your option) any later version.
 
    The GNU Readline Library is distributed in the hope that it will be
@@ -18,7 +18,7 @@
    The GNU General Public License is often shipped with GNU software, and
    is generally kept in a file called COPYING or LICENSE.  If you do not
    have a copy of the license, write to the Free Software Foundation,
-   675 Mass Ave, Cambridge, MA 02139, USA. */
+   59 Temple Place, Suite 330, Boston, MA 02111 USA. */
 #define READLINE_LIBRARY
 
 #if defined (HAVE_CONFIG_H)
@@ -42,7 +42,6 @@
 #  include "ansi_stdlib.h"
 #endif /* HAVE_STDLIB_H */
 
-#include <signal.h>
 #include <errno.h>
 
 #if !defined (errno)
@@ -58,61 +57,27 @@ extern int errno;
 #include "readline.h"
 #include "history.h"
 
+#include "rlprivate.h"
+#include "rlshell.h"
+#include "xmalloc.h"
+
 #if !defined (strchr) && !defined (__STDC__)
 extern char *strchr (), *strrchr ();
 #endif /* !strchr && !__STDC__ */
 
-extern int _rl_horizontal_scroll_mode;
-extern int _rl_mark_modified_lines;
-extern int _rl_bell_preference;
-extern int _rl_meta_flag;
-extern int _rl_convert_meta_chars_to_ascii;
-extern int _rl_output_meta_chars;
-extern int _rl_complete_show_all;
-extern int _rl_complete_mark_directories;
-extern int _rl_print_completions_horizontally;
-extern int _rl_completion_case_fold;
-extern int _rl_enable_keypad;
-#if defined (PAREN_MATCHING)
-extern int rl_blink_matching_paren;
-#endif /* PAREN_MATCHING */
-#if defined (VISIBLE_STATS)
-extern int rl_visible_stats;
-#endif /* VISIBLE_STATS */
-extern int rl_complete_with_tilde_expansion;
-extern int rl_completion_query_items;
-extern int rl_inhibit_completion;
-extern char *_rl_comment_begin;
-extern unsigned char *_rl_isearch_terminators;
-
-extern int rl_explicit_arg;
-extern int rl_editing_mode;
-extern unsigned char _rl_parsing_conditionalized_out;
-extern Keymap _rl_keymap;
-
-extern char *possible_control_prefixes[], *possible_meta_prefixes[];
-
-/* Functions imported from funmap.c */
-extern char **rl_funmap_names ();
-extern int rl_add_funmap_entry ();
-
-/* Functions imported from util.c */
-extern char *_rl_strindex ();
-
-/* Functions imported from shell.c */
-extern char *get_env_value ();
-
 /* Variables exported by this file. */
 Keymap rl_binding_keymap;
 
-/* Forward declarations */
-void rl_set_keymap_from_edit_mode ();
+static char *_rl_read_file PARAMS((char *, size_t *));
+static void _rl_init_file_error PARAMS((const char *));
+static int _rl_read_init_file PARAMS((const char *, int));
+static int glean_key_from_name PARAMS((char *));
+static int substring_member_of_array PARAMS((char *, const char **));
 
-static int _rl_read_init_file (const char *filename, int include_level);
-static int glean_key_from_name ();
-static int substring_member_of_array ();
+static int currently_reading_init_file;
 
-extern char *xmalloc (), *xrealloc ();
+/* used only in this file */
+static int _rl_prefer_visible_bell = 1;
 
 /* **************************************************************** */
 /*								    */
@@ -120,13 +85,13 @@ extern char *xmalloc (), *xrealloc ();
 /*								    */
 /* **************************************************************** */
 
-/* rl_add_defun (char *name, Function *function, int key)
+/* rl_add_defun (char *name, rl_command_func_t *function, int key)
    Add NAME to the list of named functions.  Make FUNCTION be the function
    that gets called.  If KEY is not -1, then bind it. */
 int
 rl_add_defun (name, function, key)
-     char *name;
-     Function *function;
+     const char *name;
+     rl_command_func_t *function;
      int key;
 {
   if (key != -1)
@@ -139,7 +104,7 @@ rl_add_defun (name, function, key)
 int
 rl_bind_key (key, function)
      int key;
-     Function *function;
+     rl_command_func_t *function;
 {
   if (key < 0)
     return (key);
@@ -170,7 +135,7 @@ rl_bind_key (key, function)
 int
 rl_bind_key_in_map (key, function, map)
      int key;
-     Function *function;
+     rl_command_func_t *function;
      Keymap map;
 {
   int result;
@@ -189,7 +154,7 @@ int
 rl_unbind_key (key)
      int key;
 {
-  return (rl_bind_key (key, (Function *)NULL));
+  return (rl_bind_key (key, (rl_command_func_t *)NULL));
 }
 
 /* Make KEY do nothing in MAP.
@@ -199,13 +164,13 @@ rl_unbind_key_in_map (key, map)
      int key;
      Keymap map;
 {
-  return (rl_bind_key_in_map (key, (Function *)NULL, map));
+  return (rl_bind_key_in_map (key, (rl_command_func_t *)NULL, map));
 }
 
 /* Unbind all keys bound to FUNCTION in MAP. */
 int
 rl_unbind_function_in_map (func, map)
-     Function *func;
+     rl_command_func_t *func;
      Keymap map;
 {
   register int i, rval;
@@ -214,7 +179,7 @@ rl_unbind_function_in_map (func, map)
     {
       if (map[i].type == ISFUNC && map[i].function == func)
 	{
-	  map[i].function = (Function *)NULL;
+	  map[i].function = (rl_command_func_t *)NULL;
 	  rval = 1;
 	}
     }
@@ -223,10 +188,10 @@ rl_unbind_function_in_map (func, map)
 
 int
 rl_unbind_command_in_map (command, map)
-     char *command;
+     const char *command;
      Keymap map;
 {
-  Function *func;
+  rl_command_func_t *func;
 
   func = rl_named_function (command);
   if (func == 0)
@@ -239,8 +204,8 @@ rl_unbind_command_in_map (command, map)
    place to do bindings is in MAP. */
 int
 rl_set_key (keyseq, function, map)
-     char *keyseq;
-     Function *function;
+     const char *keyseq;
+     rl_command_func_t *function;
      Keymap map;
 {
   return (rl_generic_bind (ISFUNC, keyseq, (char *)function, map));
@@ -251,7 +216,7 @@ rl_set_key (keyseq, function, map)
    necessary.  The initial place to do bindings is in MAP. */
 int
 rl_macro_bind (keyseq, macro, map)
-     char *keyseq, *macro;
+     const char *keyseq, *macro;
      Keymap map;
 {
   char *macro_keys;
@@ -276,12 +241,16 @@ rl_macro_bind (keyseq, macro, map)
 int
 rl_generic_bind (type, keyseq, data, map)
      int type;
-     char *keyseq, *data;
+     const char *keyseq;
+     char *data;
      Keymap map;
 {
   char *keys;
   int keys_len;
   register int i;
+  KEYMAP_ENTRY k;
+
+  k.function = 0;
 
   /* If no keys to bind to, exit right away. */
   if (!keyseq || !*keyseq)
@@ -291,7 +260,7 @@ rl_generic_bind (type, keyseq, data, map)
       return -1;
     }
 
-  keys = xmalloc (1 + (2 * strlen (keyseq)));
+  keys = (char *)xmalloc (1 + (2 * strlen (keyseq)));
 
   /* Translate the ASCII representation of KEYSEQ into an array of
      characters.  Stuff the characters into KEYS, and the length of
@@ -305,7 +274,12 @@ rl_generic_bind (type, keyseq, data, map)
   /* Bind keys, making new keymaps as necessary. */
   for (i = 0; i < keys_len; i++)
     {
-      int ic = (int) ((unsigned char)keys[i]);
+      unsigned char uc = keys[i];
+      int ic;
+
+      ic = uc;
+      if (ic < 0 || ic >= KEYMAP_SIZE)
+	return -1;
 
       if (_rl_convert_meta_chars_to_ascii && META_CHAR (ic))
 	{
@@ -318,18 +292,40 @@ rl_generic_bind (type, keyseq, data, map)
 	{
 	  if (map[ic].type != ISKMAP)
 	    {
-	      if (map[ic].type == ISMACR)
-		free ((char *)map[ic].function);
+	      /* We allow subsequences of keys.  If a keymap is being
+		 created that will `shadow' an existing function or macro
+		 key binding, we save that keybinding into the ANYOTHERKEY
+		 index in the new map.  The dispatch code will look there
+		 to find the function to execute if the subsequence is not
+		 matched.  ANYOTHERKEY was chosen to be greater than
+		 UCHAR_MAX. */
+	      k = map[ic];
 
 	      map[ic].type = ISKMAP;
 	      map[ic].function = KEYMAP_TO_FUNCTION (rl_make_bare_keymap());
 	    }
 	  map = FUNCTION_TO_KEYMAP (map, ic);
+	  /* The dispatch code will return this function if no matching
+	     key sequence is found in the keymap.  This (with a little
+	     help from the dispatch code in readline.c) allows `a' to be
+	     mapped to something, `abc' to be mapped to something else,
+	     and the function bound  to `a' to be executed when the user
+	     types `abx', leaving `bx' in the input queue. */
+	  if (k.function /* && k.type == ISFUNC */)
+	    {
+	      map[ANYOTHERKEY] = k;
+	      k.function = 0;
+	    }
 	}
       else
 	{
 	  if (map[ic].type == ISMACR)
 	    free ((char *)map[ic].function);
+	  else if (map[ic].type == ISKMAP)
+	    {
+	      map = FUNCTION_TO_KEYMAP (map, ic);
+	      ic = ANYOTHERKEY;
+	    }
 
 	  map[ic].function = KEYMAP_TO_FUNCTION (data);
 	  map[ic].type = type;
@@ -346,7 +342,8 @@ rl_generic_bind (type, keyseq, data, map)
    non-zero if there was an error parsing SEQ. */
 int
 rl_translate_keyseq (seq, array, len)
-     char *seq, *array;
+     const char *seq;
+     char *array;
      int *len;
 {
   register int i, c, l, temp;
@@ -366,7 +363,7 @@ rl_translate_keyseq (seq, array, len)
 	      /* Handle special case of backwards define. */
 	      if (strncmp (&seq[i], "C-\\M-", 5) == 0)
 		{
-		  array[l++] = ESC;
+		  array[l++] = ESC;	/* ESC is meta-prefix */
 		  i += 5;
 		  array[l++] = CTRL (_rl_to_upper (seq[i]));
 		  if (seq[i] == '\0')
@@ -375,7 +372,7 @@ rl_translate_keyseq (seq, array, len)
 	      else if (c == 'M')
 		{
 		  i++;
-		  array[l++] = ESC;	/* XXX */
+		  array[l++] = ESC;	/* ESC is meta-prefix */
 		}
 	      else if (c == 'C')
 		{
@@ -428,16 +425,16 @@ rl_translate_keyseq (seq, array, len)
 	      for (temp = 2, c -= '0'; ISOCTAL (seq[i]) && temp--; i++)
 	        c = (c * 8) + OCTVALUE (seq[i]);
 	      i--;	/* auto-increment in for loop */
-	      array[l++] = c % (largest_char + 1);
+	      array[l++] = c & largest_char;
 	      break;
 	    case 'x':
 	      i++;
-	      for (temp = 3, c = 0; isxdigit (seq[i]) && temp--; i++)
+	      for (temp = 2, c = 0; ISXDIGIT ((unsigned char)seq[i]) && temp--; i++)
 	        c = (c * 16) + HEXVALUE (seq[i]);
-	      if (temp == 3)
+	      if (temp == 2)
 	        c = 'x';
 	      i--;	/* auto-increment in for loop */
-	      array[l++] = c % (largest_char + 1);
+	      array[l++] = c & largest_char;
 	      break;
 	    default:	/* backslashes before non-special chars just add the char */
 	      array[l++] = c;
@@ -507,7 +504,7 @@ _rl_untranslate_macro_value (seq)
   char *ret, *r, *s;
   int c;
 
-  r = ret = xmalloc (7 * strlen (seq) + 1);
+  r = ret = (char *)xmalloc (7 * strlen (seq) + 1);
   for (s = seq; *s; s++)
     {
       c = *s;
@@ -550,9 +547,9 @@ _rl_untranslate_macro_value (seq)
 /* Return a pointer to the function that STRING represents.
    If STRING doesn't have a matching function, then a NULL pointer
    is returned. */
-Function *
+rl_command_func_t *
 rl_named_function (string)
-     char *string;
+     const char *string;
 {
   register int i;
 
@@ -561,7 +558,7 @@ rl_named_function (string)
   for (i = 0; funmap[i]; i++)
     if (_rl_stricmp (funmap[i]->name, string) == 0)
       return (funmap[i]->function);
-  return ((Function *)NULL);
+  return ((rl_command_func_t *)NULL);
 }
 
 /* Return the function (or macro) definition which would be invoked via
@@ -569,8 +566,11 @@ rl_named_function (string)
    used.  TYPE, if non-NULL, is a pointer to an int which will receive the
    type of the object pointed to.  One of ISFUNC (function), ISKMAP (keymap),
    or ISMACR (macro). */
-Function *
-rl_function_of_keyseq (const char *keyseq, Keymap map, int *type)
+rl_command_func_t *
+rl_function_of_keyseq (keyseq, map, type)
+     const char *keyseq;
+     Keymap map;
+     int *type;
 {
   register int i;
 
@@ -579,7 +579,7 @@ rl_function_of_keyseq (const char *keyseq, Keymap map, int *type)
 
   for (i = 0; keyseq && keyseq[i]; i++)
     {
-      int ic = keyseq[i];
+      unsigned char ic = keyseq[i];
 
       if (META_CHAR (ic) && _rl_convert_meta_chars_to_ascii)
 	{
@@ -619,7 +619,7 @@ rl_function_of_keyseq (const char *keyseq, Keymap map, int *type)
 	  return (map[ic].function);
 	}
     }
-  return ((Function *) NULL);
+  return ((rl_command_func_t *) NULL);
 }
 
 /* The last key bindings file read. */
@@ -664,29 +664,26 @@ _rl_read_file (filename, sizep)
   i = read (file, buffer, file_size);
   close (file);
 
-#if 0
-  if (i < file_size)
-#else
   if (i < 0)
-#endif
     {
       free (buffer);
       return ((char *)NULL);
     }
 
-  buffer[file_size] = '\0';
+  buffer[i] = '\0';
   if (sizep)
-    *sizep = file_size;
+    *sizep = i;
+
   return (buffer);
 }
 
 /* Re-read the current keybindings file. */
 int
-rl_re_read_init_file (int count __attribute__((unused)),
-		      int ignore __attribute__((unused)))
+rl_re_read_init_file (count, ignore)
+     int count __attribute__((unused)), ignore __attribute__((unused));
 {
   int r;
-  r = rl_read_init_file ((char *)NULL);
+  r = rl_read_init_file ((const char *)NULL);
   rl_set_keymap_from_edit_mode ();
   return r;
 }
@@ -699,14 +696,15 @@ rl_re_read_init_file (int count __attribute__((unused)),
    If the file existed and could be opened and read, 0 is returned,
    otherwise errno is returned. */
 int
-rl_read_init_file (const char *filename)
+rl_read_init_file (filename)
+     const char *filename;
 {
   /* Default the filename. */
   if (filename == 0)
     {
       filename = last_readline_init_file;
       if (filename == 0)
-        filename = get_env_value ("INPUTRC");
+        filename = sh_get_env_value ("INPUTRC");
       if (filename == 0)
 	filename = DEFAULT_INPUTRC;
     }
@@ -714,11 +712,18 @@ rl_read_init_file (const char *filename)
   if (*filename == 0)
     filename = DEFAULT_INPUTRC;
 
+#if defined (__MSDOS__)
+  if (_rl_read_init_file (filename, 0) == 0)
+    return 0;
+  filename = "~/_inputrc";
+#endif
   return (_rl_read_init_file (filename, 0));
 }
 
 static int
-_rl_read_init_file (const char *filename, int include_level)
+_rl_read_init_file (filename, include_level)
+     const char *filename;
+     int include_level;
 {
   register int i;
   char *buffer, *openname, *line, *end;
@@ -733,13 +738,15 @@ _rl_read_init_file (const char *filename, int include_level)
 
   if (buffer == 0)
     return (errno);
-
+  
   if (include_level == 0 && filename != last_readline_init_file)
     {
       FREE (last_readline_init_file);
       last_readline_init_file = savestring (filename);
     }
 
+  currently_reading_init_file = 1;
+
   /* Loop over the lines in the file.  Lines that start with `#' are
      comments; all other lines are commands for readline initialization. */
   current_readline_init_lineno = 1;
@@ -750,6 +757,12 @@ _rl_read_init_file (const char *filename, int include_level)
       /* Find the end of this line. */
       for (i = 0; line + i != end && line[i] != '\n'; i++);
 
+#if defined (__CYGWIN__)
+      /* ``Be liberal in what you accept.'' */
+      if (line[i] == '\n' && line[i-1] == '\r')
+	line[i - 1] = '\0';
+#endif
+
       /* Mark end of line. */
       line[i] = '\0';
 
@@ -770,16 +783,19 @@ _rl_read_init_file (const char *filename, int include_level)
     }
 
   free (buffer);
+  currently_reading_init_file = 0;
   return (0);
 }
 
 static void
 _rl_init_file_error (msg)
-     char *msg;
+     const char *msg;
 {
-  fprintf (stderr, "readline: %s: line %d: %s\n", current_readline_init_file,
- 		   current_readline_init_lineno,
- 		   msg);
+  if (currently_reading_init_file)
+    fprintf (stderr, "readline: %s: line %d: %s\n", current_readline_init_file,
+		     current_readline_init_lineno, msg);
+  else
+    fprintf (stderr, "readline: %s\n", msg);
 }
 
 /* **************************************************************** */
@@ -788,6 +804,17 @@ _rl_init_file_error (msg)
 /*								    */
 /* **************************************************************** */
 
+typedef int _rl_parser_func_t PARAMS((char *));
+
+/* Things that mean `Control'. */
+const char *_rl_possible_control_prefixes[] = {
+  "Control-", "C-", "CTRL-", (const char *)NULL
+};
+
+const char *_rl_possible_meta_prefixes[] = {
+  "Meta", "M-", (const char *)NULL
+};
+
 /* Conditionals. */
 
 /* Calling programs set this to have their argv[0]. */
@@ -875,7 +902,7 @@ parser_if (args)
 /* Invert the current parser state if there is anything on the stack. */
 static int
 parser_else (args)
-char *args __attribute__((unused));
+     char *args __attribute__((unused));
 {
   register int i;
 
@@ -900,7 +927,7 @@ char *args __attribute__((unused));
    _rl_parsing_conditionalized_out from the stack. */
 static int
 parser_endif (args)
-char *args __attribute__((unused));
+     char *args __attribute__((unused));
 {
   if (if_stack_depth)
     _rl_parsing_conditionalized_out = if_stack[--if_stack_depth];
@@ -927,7 +954,7 @@ parser_include (args)
   e = strchr (args, '\n');
   if (e)
     *e = '\0';
-  r = _rl_read_init_file (args, old_include_level + 1);
+  r = _rl_read_init_file ((const char *)args, old_include_level + 1);
 
   current_readline_init_file = old_init_file;
   current_readline_init_lineno = old_line_number;
@@ -935,17 +962,17 @@ parser_include (args)
 
   return r;
 }
-
+  
 /* Associate textual names with actual functions. */
 static struct {
   const char *name;
-  Function *function;
+  _rl_parser_func_t *function;
 } parser_directives [] = {
   { "if", parser_if },
   { "endif", parser_endif },
   { "else", parser_else },
   { "include", parser_include },
-  { (char *)0x0, (Function *)0x0 }
+  { (char *)0x0, (_rl_parser_func_t *)0x0 }
 };
 
 /* Handle a parser directive.  STATEMENT is the line of the directive
@@ -1070,7 +1097,7 @@ rl_parse_and_bind (string)
       /* Make VAR point to start of variable name. */
       while (*var && whitespace (*var)) var++;
 
-      /* Make value point to start of value string. */
+      /* Make VALUE point to start of value string. */
       value = var;
       while (*value && !whitespace (*value)) value++;
       if (*value)
@@ -1140,7 +1167,7 @@ rl_parse_and_bind (string)
       char *seq;
       register int j, k, passc;
 
-      seq = xmalloc (1 + strlen (string));
+      seq = (char *)xmalloc (1 + strlen (string));
       for (j = 1, k = passc = 0; string[j]; j++)
 	{
 	  /* Allow backslash to quote characters, but leave them in place.
@@ -1189,23 +1216,23 @@ rl_parse_and_bind (string)
   key = glean_key_from_name (kname);
 
   /* Add in control and meta bits. */
-  if (substring_member_of_array (string, possible_control_prefixes))
+  if (substring_member_of_array (string, _rl_possible_control_prefixes))
     key = CTRL (_rl_to_upper (key));
 
-  if (substring_member_of_array (string, possible_meta_prefixes))
+  if (substring_member_of_array (string, _rl_possible_meta_prefixes))
     key = META (key);
 
   /* Temporary.  Handle old-style keyname with macro-binding. */
   if (*funname == '\'' || *funname == '"')
     {
-      unsigned char useq[2];
+      char useq[2];
       int fl = strlen (funname);
 
       useq[0] = key; useq[1] = '\0';
       if (fl && funname[fl - 1] == *funname)
 	funname[fl - 1] = '\0';
 
-      rl_macro_bind ((char*) useq, &funname[1], _rl_keymap);
+      rl_macro_bind (useq, &funname[1], _rl_keymap);
     }
 #if defined (PREFIX_META_HACK)
   /* Ugly, but working hack to keep prefix-meta around. */
@@ -1227,154 +1254,278 @@ rl_parse_and_bind (string)
    have one of two values; either "On" or 1 for truth, or "Off" or 0 for
    false. */
 
+#define V_SPECIAL	0x1
+
 static struct {
   const char *name;
   int *value;
+  int flags;
 } boolean_varlist [] = {
-#if defined (PAREN_MATCHING)
-  { "blink-matching-paren",	&rl_blink_matching_paren },
-#endif
-  { "completion-ignore-case",	&_rl_completion_case_fold },
-  { "convert-meta",		&_rl_convert_meta_chars_to_ascii },
-  { "disable-completion",	&rl_inhibit_completion },
-  { "enable-keypad",		&_rl_enable_keypad },
-  { "expand-tilde",		&rl_complete_with_tilde_expansion },
-  { "horizontal-scroll-mode",	&_rl_horizontal_scroll_mode },
-  { "input-meta",		&_rl_meta_flag },
-  { "mark-directories",		&_rl_complete_mark_directories },
-  { "mark-modified-lines",	&_rl_mark_modified_lines },
-  { "meta-flag",		&_rl_meta_flag },
-  { "output-meta",		&_rl_output_meta_chars },
-  { "print-completions-horizontally", &_rl_print_completions_horizontally },
-  { "show-all-if-ambiguous",	&_rl_complete_show_all },
+  { "blink-matching-paren",	&rl_blink_matching_paren,	V_SPECIAL },
+  { "byte-oriented",		&rl_byte_oriented,		0 },
+  { "completion-ignore-case",	&_rl_completion_case_fold,	0 },
+  { "convert-meta",		&_rl_convert_meta_chars_to_ascii, 0 },
+  { "disable-completion",	&rl_inhibit_completion,		0 },
+  { "enable-keypad",		&_rl_enable_keypad,		0 },
+  { "expand-tilde",		&rl_complete_with_tilde_expansion, 0 },
+  { "history-preserve-point",	&_rl_history_preserve_point,	0 },
+  { "horizontal-scroll-mode",	&_rl_horizontal_scroll_mode,	0 },
+  { "input-meta",		&_rl_meta_flag,			0 },
+  { "mark-directories",		&_rl_complete_mark_directories,	0 },
+  { "mark-modified-lines",	&_rl_mark_modified_lines,	0 },
+  { "mark-symlinked-directories", &_rl_complete_mark_symlink_dirs, 0 },
+  { "match-hidden-files",	&_rl_match_hidden_files,	0 },
+  { "meta-flag",		&_rl_meta_flag,			0 },
+  { "output-meta",		&_rl_output_meta_chars,		0 },
+  { "page-completions",		&_rl_page_completions,		0 },
+  { "prefer-visible-bell",	&_rl_prefer_visible_bell,	V_SPECIAL },
+  { "print-completions-horizontally", &_rl_print_completions_horizontally, 0 },
+  { "show-all-if-ambiguous",	&_rl_complete_show_all,		0 },
 #if defined (VISIBLE_STATS)
-  { "visible-stats",		&rl_visible_stats },
+  { "visible-stats",		&rl_visible_stats,		0 },
 #endif /* VISIBLE_STATS */
-  { (char *)NULL, (int *)NULL }
+  { (char *)NULL, (int *)NULL, 0 }
+};
+
+static int
+find_boolean_var (name)
+     const char *name;
+{
+  register int i;
+
+  for (i = 0; boolean_varlist[i].name; i++)
+    if (_rl_stricmp (name, boolean_varlist[i].name) == 0)
+      return i;
+  return -1;
+}
+
+/* Hooks for handling special boolean variables, where a
+   function needs to be called or another variable needs
+   to be changed when they're changed. */
+static void
+hack_special_boolean_var (i)
+     int i;
+{
+  const char *name;
+
+  name = boolean_varlist[i].name;
+
+  if (_rl_stricmp (name, "blink-matching-paren") == 0)
+    _rl_enable_paren_matching (rl_blink_matching_paren);
+  else if (_rl_stricmp (name, "prefer-visible-bell") == 0)
+    {
+      if (_rl_prefer_visible_bell)
+	_rl_bell_preference = VISIBLE_BELL;
+      else
+	_rl_bell_preference = AUDIBLE_BELL;
+    }
+}
+
+typedef int _rl_sv_func_t PARAMS((const char *));
+
+/* These *must* correspond to the array indices for the appropriate
+   string variable.  (Though they're not used right now.) */
+#define V_BELLSTYLE	0
+#define V_COMBEGIN	1
+#define V_EDITMODE	2
+#define V_ISRCHTERM	3
+#define V_KEYMAP	4
+
+#define	V_STRING	1
+#define V_INT		2
+
+/* Forward declarations */
+static int sv_bell_style PARAMS((const char *));
+static int sv_combegin PARAMS((const char *));
+static int sv_compquery PARAMS((const char *));
+static int sv_editmode PARAMS((const char *));
+static int sv_isrchterm PARAMS((const char *));
+static int sv_keymap PARAMS((const char *));
+
+static struct {
+  const char *name;
+  int flags;
+  _rl_sv_func_t *set_func;
+} string_varlist[] = {
+  { "bell-style",	V_STRING,	sv_bell_style },
+  { "comment-begin",	V_STRING,	sv_combegin },
+  { "completion-query-items", V_INT,	sv_compquery },
+  { "editing-mode",	V_STRING,	sv_editmode },
+  { "isearch-terminators", V_STRING,	sv_isrchterm },
+  { "keymap",		V_STRING,	sv_keymap },
+  { (char *)NULL,	0, 0 }
 };
 
+static int
+find_string_var (name)
+     const char *name;
+{
+  register int i;
+
+  for (i = 0; string_varlist[i].name; i++)
+    if (_rl_stricmp (name, string_varlist[i].name) == 0)
+      return i;
+  return -1;
+}
+
+/* A boolean value that can appear in a `set variable' command is true if
+   the value is null or empty, `on' (case-insenstive), or "1".  Any other
+   values result in 0 (false). */
+static int
+bool_to_int (value)
+     char *value;
+{
+  return (value == 0 || *value == '\0' ||
+		(_rl_stricmp (value, "on") == 0) ||
+		(value[0] == '1' && value[1] == '\0'));
+}
+
 int
 rl_variable_bind (name, value)
-     char *name, *value;
+     const char *name, *value;
 {
   register int i;
+  int	v;
 
   /* Check for simple variables first. */
-  for (i = 0; boolean_varlist[i].name; i++)
+  i = find_boolean_var (name);
+  if (i >= 0)
     {
-      if (_rl_stricmp (name, boolean_varlist[i].name) == 0)
-	{
-	  /* A variable is TRUE if the "value" is "on", "1" or "". */
-	  *boolean_varlist[i].value = *value == 0 ||
-	  			      _rl_stricmp (value, "on") == 0 ||
-				      (value[0] == '1' && value[1] == '\0');
-	  return 0;
-	}
+      *boolean_varlist[i].value = bool_to_int (value);
+      if (boolean_varlist[i].flags & V_SPECIAL)
+	hack_special_boolean_var (i);
+      return 0;
     }
 
-  /* Not a boolean variable, so check for specials. */
+  i = find_string_var (name);
+
+  /* For the time being, unknown variable names or string names without a
+     handler function are simply ignored. */
+  if (i < 0 || string_varlist[i].set_func == 0)
+    return 0;
 
-  /* Editing mode change? */
-  if (_rl_stricmp (name, "editing-mode") == 0)
+  v = (*string_varlist[i].set_func) (value);
+  return v;
+}
+
+static int
+sv_editmode (value)
+     const char *value;
+{
+  if (_rl_strnicmp (value, "vi", 2) == 0)
     {
-      if (_rl_strnicmp (value, "vi", 2) == 0)
-	{
 #if defined (VI_MODE)
-	  _rl_keymap = vi_insertion_keymap;
-	  rl_editing_mode = vi_mode;
+      _rl_keymap = vi_insertion_keymap;
+      rl_editing_mode = vi_mode;
 #endif /* VI_MODE */
-	}
-      else if (_rl_strnicmp (value, "emacs", 5) == 0)
-	{
-	  _rl_keymap = emacs_standard_keymap;
-	  rl_editing_mode = emacs_mode;
-	}
+      return 0;
     }
-
-  /* Comment string change? */
-  else if (_rl_stricmp (name, "comment-begin") == 0)
+  else if (_rl_strnicmp (value, "emacs", 5) == 0)
     {
-      if (*value)
-	{
-	  if (_rl_comment_begin)
-	    free (_rl_comment_begin);
-
-	  _rl_comment_begin = savestring (value);
-	}
+      _rl_keymap = emacs_standard_keymap;
+      rl_editing_mode = emacs_mode;
+      return 0;
     }
-  else if (_rl_stricmp (name, "completion-query-items") == 0)
+  return 1;
+}
+
+static int
+sv_combegin (value)
+     const char *value;
+{
+  if (value && *value)
     {
-      int nval = 100;
-      if (*value)
-	{
-	  nval = atoi (value);
-	  if (nval < 0)
-	    nval = 0;
-	}
-      rl_completion_query_items = nval;
+      FREE (_rl_comment_begin);
+      _rl_comment_begin = savestring (value);
+      return 0;
     }
-  else if (_rl_stricmp (name, "keymap") == 0)
+  return 1;
+}
+
+static int
+sv_compquery (value)
+     const char *value;
+{
+  int nval = 100;
+
+  if (value && *value)
     {
-      Keymap kmap;
-      kmap = rl_get_keymap_by_name (value);
-      if (kmap)
-        rl_set_keymap (kmap);
+      nval = atoi (value);
+      if (nval < 0)
+	nval = 0;
     }
-  else if (_rl_stricmp (name, "bell-style") == 0)
+  rl_completion_query_items = nval;
+  return 0;
+}
+
+static int
+sv_keymap (value)
+     const char *value;
+{
+  Keymap kmap;
+
+  kmap = rl_get_keymap_by_name (value);
+  if (kmap)
     {
-      if (!*value)
-        _rl_bell_preference = AUDIBLE_BELL;
-      else
-        {
-          if (_rl_stricmp (value, "none") == 0 || _rl_stricmp (value, "off") == 0)
-            _rl_bell_preference = NO_BELL;
-          else if (_rl_stricmp (value, "audible") == 0 || _rl_stricmp (value, "on") == 0)
-            _rl_bell_preference = AUDIBLE_BELL;
-          else if (_rl_stricmp (value, "visible") == 0)
-            _rl_bell_preference = VISIBLE_BELL;
-        }
+      rl_set_keymap (kmap);
+      return 0;
     }
-  else if (_rl_stricmp (name, "prefer-visible-bell") == 0)
+  return 1;
+}
+
+static int
+sv_bell_style (value)
+     const char *value;
+{
+  if (value == 0 || *value == '\0')
+    _rl_bell_preference = AUDIBLE_BELL;
+  else if (_rl_stricmp (value, "none") == 0 || _rl_stricmp (value, "off") == 0)
+    _rl_bell_preference = NO_BELL;
+  else if (_rl_stricmp (value, "audible") == 0 || _rl_stricmp (value, "on") == 0)
+    _rl_bell_preference = AUDIBLE_BELL;
+  else if (_rl_stricmp (value, "visible") == 0)
+    _rl_bell_preference = VISIBLE_BELL;
+  else
+    return 1;
+  return 0;
+}
+
+static int
+sv_isrchterm (value)
+     const char *value;
+{
+  int beg, end, delim;
+  char *v;
+
+  if (value == 0)
+    return 1;
+
+  /* Isolate the value and translate it into a character string. */
+  v = savestring (value);
+  FREE (_rl_isearch_terminators);
+  if (v[0] == '"' || v[0] == '\'')
     {
-      /* Backwards compatibility. */
-      if (*value && (_rl_stricmp (value, "on") == 0 ||
-		     (*value == '1' && !value[1])))
-        _rl_bell_preference = VISIBLE_BELL;
-      else
-        _rl_bell_preference = AUDIBLE_BELL;
+      delim = v[0];
+      for (beg = end = 1; v[end] && v[end] != delim; end++)
+	;
     }
-  else if (_rl_stricmp (name, "isearch-terminators") == 0)
+  else
     {
-      /* Isolate the value and translate it into a character string. */
-      int beg, end;
-      char *v;
+      for (beg = end = 0; whitespace (v[end]) == 0; end++)
+	;
+    }
 
-      v = savestring (value);
-      FREE (_rl_isearch_terminators);
-      if (v[0] == '"' || v[0] == '\'')
-	{
-	  int delim = v[0];
-	  for (beg = end = 1; v[end] && v[end] != delim; end++)
-	    ;
-	}
-      else
-	{
-	  for (beg = end = 0; whitespace (v[end]) == 0; end++)
-	    ;
-	}
+  v[end] = '\0';
 
-      v[end] = '\0';
-      /* The value starts at v + beg.  Translate it into a character string. */
-      _rl_isearch_terminators = (unsigned char *)xmalloc (2 * strlen (v) + 1);
-      rl_translate_keyseq (v + beg, (char*) _rl_isearch_terminators, &end);
-      _rl_isearch_terminators[end] = '\0';
-      free (v);
-    }
+  /* The value starts at v + beg.  Translate it into a character string. */
+  _rl_isearch_terminators = (char *)xmalloc (2 * strlen (v) + 1);
+  rl_translate_keyseq (v + beg, _rl_isearch_terminators, &end);
+  _rl_isearch_terminators[end] = '\0';
 
-  /* For the time being, unknown variable names are simply ignored. */
+  free (v);
   return 0;
 }
-
+      
 /* Return the character which matches NAME.
    For example, `Space' returns ' '. */
 
@@ -1431,27 +1582,27 @@ static struct {
 
 Keymap
 rl_get_keymap_by_name (name)
-     char *name;
+     const char *name;
 {
   register int i;
 
   for (i = 0; keymap_names[i].name; i++)
-    if (strcmp (name, keymap_names[i].name) == 0)
+    if (_rl_stricmp (name, keymap_names[i].name) == 0)
       return (keymap_names[i].map);
   return ((Keymap) NULL);
 }
 
-const char *
+char *
 rl_get_keymap_name (map)
      Keymap map;
 {
   register int i;
   for (i = 0; keymap_names[i].name; i++)
     if (map == keymap_names[i].map)
-      return (keymap_names[i].name);
+      return ((char *)keymap_names[i].name);
   return ((char *)NULL);
 }
-
+  
 void
 rl_set_keymap (map)
      Keymap map;
@@ -1477,6 +1628,7 @@ rl_set_keymap_from_edit_mode ()
 #endif /* VI_MODE */
 }
 
+
 const char *
 rl_get_keymap_name_from_edit_mode ()
 {
@@ -1487,7 +1639,7 @@ rl_get_keymap_name_from_edit_mode ()
     return "vi";
 #endif /* VI_MODE */
   else
-    return "none";
+    return "nope";
 }
 
 /* **************************************************************** */
@@ -1506,7 +1658,7 @@ void
 rl_list_funmap_names ()
 {
   register int i;
-  char **funmap_names;
+  const char **funmap_names;
 
   funmap_names = rl_funmap_names ();
 
@@ -1533,17 +1685,18 @@ _rl_get_keyname (key)
      pairs for possible inclusion in an inputrc file, we don't want to
      do any special meta processing on KEY. */
 
-#if 0
+#if 1
+  /* XXX - Experimental */
   /* We might want to do this, but the old version of the code did not. */
 
   /* If this is an escape character, we don't want to do any more processing.
      Just add the special ESC key sequence and return. */
   if (c == ESC)
     {
-      keyseq[0] = '\\';
-      keyseq[1] = 'e';
-      keyseq[2] = '\0';
-      return keyseq;
+      keyname[0] = '\\';
+      keyname[1] = 'e';
+      keyname[2] = '\0';
+      return keyname;
     }
 #endif
 
@@ -1596,7 +1749,7 @@ _rl_get_keyname (key)
    sequences that are used to invoke FUNCTION in MAP. */
 char **
 rl_invoking_keyseqs_in_map (function, map)
-     Function *function;
+     rl_command_func_t *function;
      Keymap map;
 {
   register int key;
@@ -1625,7 +1778,7 @@ rl_invoking_keyseqs_in_map (function, map)
 	      if (result_index + 2 > result_size)
 	        {
 	          result_size += 10;
-		  result = (char **) xrealloc (result, result_size * sizeof (char *));
+		  result = (char **)xrealloc (result, result_size * sizeof (char *));
 	        }
 
 	      result[result_index++] = keyname;
@@ -1654,7 +1807,12 @@ rl_invoking_keyseqs_in_map (function, map)
 		char *keyname = (char *)xmalloc (6 + strlen (seqs[i]));
 
 		if (key == ESC)
+#if 0
 		  sprintf (keyname, "\\e");
+#else
+		/* XXX - experimental */
+		  sprintf (keyname, "\\M-");
+#endif
 		else if (CTRL_CHAR (key))
 		  sprintf (keyname, "\\C-%c", _rl_to_lower (UNCTRL (key)));
 		else if (key == RUBOUT)
@@ -1670,14 +1828,14 @@ rl_invoking_keyseqs_in_map (function, map)
 		    keyname[0] = (char) key;
 		    keyname[1] = '\0';
 		  }
-
+		
 		strcat (keyname, seqs[i]);
 		free (seqs[i]);
 
 		if (result_index + 2 > result_size)
 		  {
 		    result_size += 10;
-		    result = (char **) xrealloc (result, result_size * sizeof (char *));
+		    result = (char **)xrealloc (result, result_size * sizeof (char *));
 		  }
 
 		result[result_index++] = keyname;
@@ -1696,7 +1854,7 @@ rl_invoking_keyseqs_in_map (function, map)
    sequences that can be used to invoke FUNCTION using the current keymap. */
 char **
 rl_invoking_keyseqs (function)
-     Function *function;
+     rl_command_func_t *function;
 {
   return (rl_invoking_keyseqs_in_map (function, _rl_keymap));
 }
@@ -1709,8 +1867,8 @@ rl_function_dumper (print_readably)
      int print_readably;
 {
   register int i;
-  char **names;
-  char *name;
+  const char **names;
+  const char *name;
 
   names = rl_funmap_names ();
 
@@ -1718,7 +1876,7 @@ rl_function_dumper (print_readably)
 
   for (i = 0; (name = names[i]); i++)
     {
-      Function *function;
+      rl_command_func_t *function;
       char **invokers;
 
       function = rl_named_function (name);
@@ -1775,8 +1933,8 @@ rl_function_dumper (print_readably)
    rl_outstream.  If an explicit argument is given, then print
    the output in such a way that it can be read back in. */
 int
-rl_dump_functions (int count __attribute__((unused)),
-		   int key __attribute__((unused)))
+rl_dump_functions (count, key)
+     int count __attribute__((unused)), key __attribute__((unused));
 {
   if (rl_dispatching)
     fprintf (rl_outstream, "\r\n");
@@ -1801,11 +1959,8 @@ _rl_macro_dumper_internal (print_readably, map, prefix)
 	{
 	case ISMACR:
 	  keyname = _rl_get_keyname (key);
-#if 0
-	  out = (char *)map[key].function;
-#else
 	  out = _rl_untranslate_macro_value ((char *)map[key].function);
-#endif
+
 	  if (print_readably)
 	    fprintf (rl_outstream, "\"%s%s\": \"%s\"\n", prefix ? prefix : "",
 						         keyname,
@@ -1815,9 +1970,7 @@ _rl_macro_dumper_internal (print_readably, map, prefix)
 							keyname,
 							out ? out : "");
 	  free (keyname);
-#if 1
 	  free (out);
-#endif
 	  break;
 	case ISFUNC:
 	  break;
@@ -1825,7 +1978,7 @@ _rl_macro_dumper_internal (print_readably, map, prefix)
 	  prefix_len = prefix ? strlen (prefix) : 0;
 	  if (key == ESC)
 	    {
-	      keyname = xmalloc (3 + prefix_len);
+	      keyname = (char *)xmalloc (3 + prefix_len);
 	      if (prefix)
 		strcpy (keyname, prefix);
 	      keyname[prefix_len] = '\\';
@@ -1837,7 +1990,7 @@ _rl_macro_dumper_internal (print_readably, map, prefix)
 	      keyname = _rl_get_keyname (key);
 	      if (prefix)
 		{
-		  out = xmalloc (strlen (keyname) + prefix_len + 1);
+		  out = (char *)xmalloc (strlen (keyname) + prefix_len + 1);
 		  strcpy (out, prefix);
 		  strcpy (out + prefix_len, keyname);
 		  free (keyname);
@@ -1860,8 +2013,8 @@ rl_macro_dumper (print_readably)
 }
 
 int
-rl_dump_macros (int count __attribute__((unused)),
-		int key __attribute__((unused)))
+rl_dump_macros (count, key)
+     int count __attribute__((unused)), key __attribute__((unused));
 {
   if (rl_dispatching)
     fprintf (rl_outstream, "\r\n");
@@ -1907,7 +2060,7 @@ rl_variable_dumper (print_readably)
   if (print_readably)
     fprintf (rl_outstream, "set comment-begin %s\n", _rl_comment_begin ? _rl_comment_begin : RL_COMMENT_BEGIN_DEFAULT);
   else
-    fprintf (rl_outstream, "comment-begin is set to `%s'\n", _rl_comment_begin ? _rl_comment_begin : "");
+    fprintf (rl_outstream, "comment-begin is set to `%s'\n", _rl_comment_begin ? _rl_comment_begin : RL_COMMENT_BEGIN_DEFAULT);
 
   /* completion-query-items */
   if (print_readably)
@@ -1921,15 +2074,6 @@ rl_variable_dumper (print_readably)
   else
     fprintf (rl_outstream, "editing-mode is set to `%s'\n", (rl_editing_mode == emacs_mode) ? "emacs" : "vi");
 
-  /* keymap */
-  kname = rl_get_keymap_name (_rl_keymap);
-  if (kname == 0)
-    kname = rl_get_keymap_name_from_edit_mode ();
-  if (print_readably)
-    fprintf (rl_outstream, "set keymap %s\n", kname ? kname : "none");
-  else
-    fprintf (rl_outstream, "keymap is set to `%s'\n", kname ? kname : "none");
-
   /* isearch-terminators */
   if (_rl_isearch_terminators)
     {
@@ -1944,14 +2088,23 @@ rl_variable_dumper (print_readably)
 
       free (disp);
     }
+
+  /* keymap */
+  kname = rl_get_keymap_name (_rl_keymap);
+  if (kname == 0)
+    kname = rl_get_keymap_name_from_edit_mode ();
+  if (print_readably)
+    fprintf (rl_outstream, "set keymap %s\n", kname ? kname : "none");
+  else
+    fprintf (rl_outstream, "keymap is set to `%s'\n", kname ? kname : "none");
 }
 
 /* Print all of the current variables and their values to
    rl_outstream.  If an explicit argument is given, then print
    the output in such a way that it can be read back in. */
 int
-rl_dump_variables (int count __attribute__((unused)),
-		   int key __attribute__((unused)))
+rl_dump_variables (count, key)
+     int count __attribute__((unused)), key __attribute__((unused));
 {
   if (rl_dispatching)
     fprintf (rl_outstream, "\r\n");
@@ -1960,18 +2113,24 @@ rl_dump_variables (int count __attribute__((unused)),
   return (0);
 }
 
-/* Bind key sequence KEYSEQ to DEFAULT_FUNC if KEYSEQ is unbound. */
+/* Bind key sequence KEYSEQ to DEFAULT_FUNC if KEYSEQ is unbound.  Right
+   now, this is always used to attempt to bind the arrow keys, hence the
+   check for rl_vi_movement_mode. */
 void
 _rl_bind_if_unbound (keyseq, default_func)
-     char *keyseq;
-     Function *default_func;
+     const char *keyseq;
+     rl_command_func_t *default_func;
 {
-  Function *func;
+  rl_command_func_t *func;
 
   if (keyseq)
     {
       func = rl_function_of_keyseq (keyseq, _rl_keymap, (int *)NULL);
+#if defined (VI_MODE)
+      if (!func || func == rl_do_lowercase_version || func == rl_vi_movement_mode)
+#else
       if (!func || func == rl_do_lowercase_version)
+#endif
 	rl_set_key (keyseq, default_func, _rl_keymap);
     }
 }
@@ -1979,7 +2138,8 @@ _rl_bind_if_unbound (keyseq, default_func)
 /* Return non-zero if any members of ARRAY are a substring in STRING. */
 static int
 substring_member_of_array (string, array)
-     char *string, **array;
+     char *string;
+     const char **array;
 {
   while (*array)
     {
diff --git a/readline/callback.c b/readline/callback.c
index 200f3cc37f9e89d831acdd43aa2751a75e13c26b..a8f4323c929f467c905b4781e867c641908a1646 100644
--- a/readline/callback.c
+++ b/readline/callback.c
@@ -7,7 +7,7 @@
 
    The GNU Readline Library is free software; you can redistribute it
    and/or modify it under the terms of the GNU General Public License
-   as published by the Free Software Foundation; either version 1, or
+   as published by the Free Software Foundation; either version 2, or
    (at your option) any later version.
 
    The GNU Readline Library is distributed in the hope that it will be
@@ -18,7 +18,7 @@
    The GNU General Public License is often shipped with GNU software, and
    is generally kept in a file called COPYING or LICENSE.  If you do not
    have a copy of the license, write to the Free Software Foundation,
-   675 Mass Ave, Cambridge, MA 02139, USA. */
+   59 Temple Place, Suite 330, Boston, MA 02111 USA. */
 #define READLINE_LIBRARY
 
 #if defined (HAVE_CONFIG_H)
@@ -29,22 +29,20 @@
 
 #if defined (READLINE_CALLBACKS)
 
-#include <stdlib.h>
 #include <sys/types.h>
+
+#ifdef HAVE_STDLIB_H
+#  include <stdlib.h>
+#else
+#  include "ansi_stdlib.h"
+#endif
+
 #include <stdio.h>
 
 /* System-specific feature definitions and include files. */
 #include "rldefs.h"
 #include "readline.h"
-
-extern void readline_internal_setup ();
-extern char *readline_internal_teardown ();
-extern int readline_internal_char ();
-extern void _rl_init_line_state ();
-
-extern int _rl_meta_flag;
-extern char *rl_prompt;
-extern int rl_visible_prompt_length;
+#include "rlprivate.h"
 
 /* **************************************************************** */
 /*								    */
@@ -61,7 +59,7 @@ extern int rl_visible_prompt_length;
    text read in at each end of line.  The terminal is kept prepped and
    signals handled all the time, except during calls to the user's function. */
 
-VFunction *rl_linefunc;		/* user callback function */
+rl_vcpfunc_t *rl_linefunc;		/* user callback function */
 static int in_handler;		/* terminal_prepped and signals set? */
 
 /* Make sure the terminal is set up, initialize readline, and prompt. */
@@ -87,11 +85,10 @@ _rl_callback_newline ()
 /* Install a readline handler, set up the terminal, and issue the prompt. */
 void
 rl_callback_handler_install (prompt, linefunc)
-     char *prompt;
-     VFunction *linefunc;
+     const char *prompt;
+     rl_vcpfunc_t *linefunc;
 {
-  rl_prompt = prompt;
-  rl_visible_prompt_length = rl_prompt ? rl_expand_prompt (rl_prompt) : 0;
+  rl_set_prompt (prompt);
   rl_linefunc = linefunc;
   _rl_callback_newline ();
 }
@@ -111,24 +108,33 @@ rl_callback_read_char ()
 
   eof = readline_internal_char ();
 
-  if (rl_done)
+  /* We loop in case some function has pushed input back with rl_execute_next. */
+  for (;;)
     {
-      line = readline_internal_teardown (eof);
+      if (rl_done)
+	{
+	  line = readline_internal_teardown (eof);
 
-      (*rl_deprep_term_function) ();
+	  (*rl_deprep_term_function) ();
 #if defined (HANDLE_SIGNALS)
-      rl_clear_signals ();
+	  rl_clear_signals ();
 #endif
-      in_handler = 0;
-      (*rl_linefunc) (line);
-
-    /* If the user did not clear out the line, do it for him. */
-    if (rl_line_buffer[0])
-      _rl_init_line_state ();
-
-    /* Redisplay the prompt if readline_handler_{install,remove} not called. */
-      if (in_handler == 0 && rl_linefunc)
-	_rl_callback_newline ();
+	  in_handler = 0;
+	  (*rl_linefunc) (line);
+
+	  /* If the user did not clear out the line, do it for him. */
+	  if (rl_line_buffer[0])
+	    _rl_init_line_state ();
+
+	  /* Redisplay the prompt if readline_handler_{install,remove}
+	     not called. */
+	  if (in_handler == 0 && rl_linefunc)
+	    _rl_callback_newline ();
+	}
+      if (rl_pending_input)
+	eof = readline_internal_char ();
+      else
+        break;
     }
 }
 
diff --git a/readline/chardefs.h b/readline/chardefs.h
index 740f14b185b0e8fba0adfccc4a5e13d0eb67e343..a537be220b0bcb37ec05a46ebb1399adad23f31a 100644
--- a/readline/chardefs.h
+++ b/readline/chardefs.h
@@ -7,7 +7,7 @@
 
    The GNU Readline Library is free software; you can redistribute it
    and/or modify it under the terms of the GNU General Public License
-   as published by the Free Software Foundation; either version 1, or
+   as published by the Free Software Foundation; either version 2, or
    (at your option) any later version.
 
    The GNU Readline Library is distributed in the hope that it will be
@@ -18,21 +18,23 @@
    The GNU General Public License is often shipped with GNU software, and
    is generally kept in a file called COPYING or LICENSE.  If you do not
    have a copy of the license, write to the Free Software Foundation,
-   675 Mass Ave, Cambridge, MA 02139, USA. */
+   59 Temple Place, Suite 330, Boston, MA 02111 USA. */
 
 #ifndef _CHARDEFS_H_
 #define _CHARDEFS_H_
 
-#ifndef _m_ctype_h
 #include <ctype.h>
-#endif
 
 #if defined (HAVE_CONFIG_H)
 #  if defined (HAVE_STRING_H)
+#    if ! defined (STDC_HEADERS) && defined (HAVE_MEMORY_H)
+#      include <memory.h>
+#    endif
 #    include <string.h>
-#  else
-#    include <strings.h>
 #  endif /* HAVE_STRING_H */
+#  if defined (HAVE_STRINGS_H)
+#    include <strings.h>
+#  endif /* HAVE_STRINGS_H */
 #else
 #  include <string.h>
 #endif /* !HAVE_CONFIG_H */
@@ -42,7 +44,10 @@
 #endif
 
 #ifdef CTRL
-#undef CTRL
+#  undef CTRL
+#endif
+#ifdef UNCTRL
+#  undef UNCTRL
 #endif
 
 /* Some character stuff. */
@@ -53,7 +58,7 @@
 #define meta_character_bit 0x080	    /* x0000000, must be on. */
 #define largest_char 255		    /* Largest character value. */
 
-#define CTRL_CHAR(c) ((c) < control_character_threshold && (c) >= 0)
+#define CTRL_CHAR(c) ((c) < control_character_threshold && (((c) & 0x80) == 0))
 #define META_CHAR(c) ((c) > meta_character_threshold && (c) <= largest_char)
 
 #define CTRL(c) ((c) & control_character_mask)
@@ -62,32 +67,58 @@
 #define UNMETA(c) ((c) & (~meta_character_bit))
 #define UNCTRL(c) _rl_to_upper(((c)|control_character_bit))
 
-/* Old versions
-#define _rl_lowercase_p(c) (((c) > ('a' - 1) && (c) < ('z' + 1)))
-#define _rl_uppercase_p(c) (((c) > ('A' - 1) && (c) < ('Z' + 1)))
-#define _rl_digit_p(c)  ((c) >= '0' && (c) <= '9')
-*/
+#if defined STDC_HEADERS || (!defined (isascii) && !defined (HAVE_ISASCII))
+#  define IN_CTYPE_DOMAIN(c) 1
+#else
+#  define IN_CTYPE_DOMAIN(c) isascii(c)
+#endif
+
+#if !defined (isxdigit) && !defined (HAVE_ISXDIGIT)
+#  define isxdigit(c)   (isdigit((c)) || ((c) >= 'a' && (c) <= 'f') || ((c) >= 'A' && (c) <= 'F'))
+#endif
+
+#define NON_NEGATIVE(c)	((unsigned char)(c) == (c))
 
-#define _rl_lowercase_p(c) (islower(c))
-#define _rl_uppercase_p(c) (isupper(c))
-#define _rl_digit_p(x)  (isdigit (x))
+/* Some systems define these; we want our definitions. */
+#undef ISPRINT
 
-#define _rl_pure_alphabetic(c) (_rl_lowercase_p(c) || _rl_uppercase_p(c))
-#define ALPHABETIC(c)	(_rl_lowercase_p(c) || _rl_uppercase_p(c) || _rl_digit_p(c))
+#define ISALNUM(c)	(IN_CTYPE_DOMAIN (c) && isalnum (c))
+#define ISALPHA(c)	(IN_CTYPE_DOMAIN (c) && isalpha (c))
+#define ISDIGIT(c)	(IN_CTYPE_DOMAIN (c) && isdigit (c))
+#define ISLOWER(c)	(IN_CTYPE_DOMAIN (c) && islower (c))
+#define ISPRINT(c)	(IN_CTYPE_DOMAIN (c) && isprint (c))
+#define ISUPPER(c)	(IN_CTYPE_DOMAIN (c) && isupper (c))
+#define ISXDIGIT(c)	(IN_CTYPE_DOMAIN (c) && isxdigit (c))
 
-/* Old versions
-#  define _rl_to_upper(c) (_rl_lowercase_p(c) ? ((c) - 32) : (c))
-#  define _rl_to_lower(c) (_rl_uppercase_p(c) ? ((c) + 32) : (c))
-*/
+#define _rl_lowercase_p(c)	(NON_NEGATIVE(c) && ISLOWER(c))
+#define _rl_uppercase_p(c)	(NON_NEGATIVE(c) && ISUPPER(c))
+#define _rl_digit_p(c)		((c) >= '0' && (c) <= '9')
+
+#define _rl_pure_alphabetic(c)	(NON_NEGATIVE(c) && ISALPHA(c))
+#define ALPHABETIC(c)		(NON_NEGATIVE(c) && ISALNUM(c))
 
 #ifndef _rl_to_upper
-#  define _rl_to_upper(c) (islower(c) ? toupper(c) : (c))
-#  define _rl_to_lower(c) (isupper(c) ? tolower(c) : (c))
+#  define _rl_to_upper(c) (_rl_lowercase_p(c) ? toupper((unsigned char)c) : (c))
+#  define _rl_to_lower(c) (_rl_uppercase_p(c) ? tolower((unsigned char)c) : (c))
 #endif
 
 #ifndef _rl_digit_value
-#define _rl_digit_value(x) ((x) - '0')
+#  define _rl_digit_value(x) ((x) - '0')
+#endif
+
+#ifndef _rl_isident
+#  define _rl_isident(c) (ISALNUM(c) || (c) == '_')
+#endif
+
+#ifndef ISOCTAL
+#  define ISOCTAL(c)	((c) >= '0' && (c) <= '7')
 #endif
+#define OCTVALUE(c)	((c) - '0')
+
+#define HEXVALUE(c) \
+  (((c) >= 'a' && (c) <= 'f') \
+  	? (c)-'a'+10 \
+  	: (c) >= 'A' && (c) <= 'F' ? (c)-'A'+10 : (c)-'0')
 
 #ifndef NEWLINE
 #define NEWLINE '\n'
@@ -125,18 +156,4 @@
 #endif
 #define ESC CTRL('[')
 
-#ifndef ISOCTAL
-#define ISOCTAL(c)      ((c) >= '0' && (c) <= '7')
-#endif
-#define OCTVALUE(c)     ((c) - '0')
-
-#ifndef isxdigit
-#  define isxdigit(c)   (isdigit((c)) || ((c) >= 'a' && (c) <= 'f') || ((c) >= 'A' && (c) <= 'F'))
-#endif
-
-#define HEXVALUE(c) \
-  (((c) >= 'a' && (c) <= 'f') \
-  	? (c)-'a'+10 \
-  	: (c) >= 'A' && (c) <= 'F' ? (c)-'A'+10 : (c)-'0')
-
 #endif  /* _CHARDEFS_H_ */
diff --git a/readline/complete.c b/readline/complete.c
index 8810ca06d5f8db0124dd9d8547e036019afec313..693550c9945018a436d0f62174f6d53c6a3a24bf 100644
--- a/readline/complete.c
+++ b/readline/complete.c
@@ -7,7 +7,7 @@
 
    The GNU Readline Library is free software; you can redistribute it
    and/or modify it under the terms of the GNU General Public License
-   as published by the Free Software Foundation; either version 1, or
+   as published by the Free Software Foundation; either version 2, or
    (at your option) any later version.
 
    The GNU Readline Library is distributed in the hope that it will be
@@ -18,7 +18,7 @@
    The GNU General Public License is often shipped with GNU software, and
    is generally kept in a file called COPYING or LICENSE.  If you do not
    have a copy of the license, write to the Free Software Foundation,
-   675 Mass Ave, Cambridge, MA 02139, USA. */
+   59 Temple Place, Suite 330, Boston, MA 02111 USA. */
 #define READLINE_LIBRARY
 
 #if defined (HAVE_CONFIG_H)
@@ -49,41 +49,39 @@ extern int errno;
 #endif /* !errno */
 
 #include <pwd.h>
-#if !defined (HAVE_GETPW_DECLS)
-extern struct passwd *getpwent ();
-#endif /* USG && !HAVE_GETPW_DECLS */
-
-/* ISC systems don't define getpwent() if _POSIX_SOURCE is defined. */
-#if defined (isc386) && defined (_POSIX_SOURCE)
-#  if defined (__STDC__)
-extern struct passwd *getpwent (void);
-#  else
-extern struct passwd *getpwent ();
-#  endif /* !__STDC__ */
-#endif /* isc386 && _POSIX_SOURCE */
 
 #include "posixdir.h"
 #include "posixstat.h"
 
 /* System-specific feature definitions and include files. */
 #include "rldefs.h"
+#include "rlmbutil.h"
 
 /* Some standard library routines. */
 #include "readline.h"
+#include "xmalloc.h"
+#include "rlprivate.h"
 
-extern char *tilde_expand ();
-extern char *rl_copy_text ();
-extern void _rl_abort_internal ();
-extern int _rl_qsort_string_compare ();
-extern void _rl_replace_text ();
+#ifdef __STDC__
+typedef int QSFUNC (const void *, const void *);
+#else
+typedef int QSFUNC ();
+#endif
+
+#ifdef HAVE_LSTAT
+#  define LSTAT lstat
+#else
+#  define LSTAT stat
+#endif
 
-extern Function *rl_last_func;
-extern int rl_editing_mode;
-extern int screenwidth;
+/* Unix version of a hidden file.  Could be different on other systems. */
+#define HIDDEN_FILE(fname)	((fname)[0] == '.')
 
-extern void _rl_move_vert ();
-extern int _rl_vis_botlin;
-extern int rl_display_fixed;
+/* Most systems don't declare getpwent in <pwd.h> if _POSIX_SOURCE is
+   defined. */
+#if !defined (HAVE_GETPW_DECLS) || defined (_POSIX_SOURCE)
+extern struct passwd *getpwent PARAMS((void));
+#endif /* !HAVE_GETPW_DECLS || _POSIX_SOURCE */
 
 /* If non-zero, then this is the address of a function to call when
    completing a word would normally display the list of possible matches.
@@ -92,30 +90,34 @@ extern int rl_display_fixed;
    where MATCHES is the array of strings that matched, NUM_MATCHES is the
    number of strings in that array, and MAX_LENGTH is the length of the
    longest string in that array. */
-VFunction *rl_completion_display_matches_hook = (VFunction *)NULL;
-
-/* Forward declarations for functions defined and used in this file. */
-char *filename_completion_function (const char *text, int state);
-char **completion_matches ();
+rl_compdisp_func_t *rl_completion_display_matches_hook = (rl_compdisp_func_t *)NULL;
 
 #if defined (VISIBLE_STATS)
 #  if !defined (X_OK)
 #    define X_OK 1
 #  endif
-static int stat_char ();
+static int stat_char PARAMS((char *));
 #endif
 
-static char *rl_quote_filename ();
-static char *rl_strpbrk ();
+static char *rl_quote_filename PARAMS((char *, int, char *));
+
+static void set_completion_defaults PARAMS((int));
+static int get_y_or_n PARAMS((int));
+static int _rl_internal_pager PARAMS((int));
+static char *printable_part PARAMS((char *));
+static int print_filename PARAMS((char *, char *));
+
+static char **gen_completion_matches PARAMS((char *, int, int, rl_compentry_func_t *, int, int));
 
-static char **remove_duplicate_matches ();
-static void insert_match ();
-static int append_to_match ();
-static void insert_all_matches ();
-static void display_matches ();
-static int compute_lcd_of_matches ();
+static char **remove_duplicate_matches PARAMS((char **));
+static void insert_match PARAMS((char *, int, int, char *));
+static int append_to_match PARAMS((char *, int, int, int));
+static void insert_all_matches PARAMS((char **, int, char *));
+static void display_matches PARAMS((char **));
+static int compute_lcd_of_matches PARAMS((char **, int, const char *));
+static int postprocess_matches PARAMS((char ***, int));
 
-extern char *xmalloc (), *xrealloc ();
+static char *make_quoted_replacement PARAMS((char *, int, char *));
 
 /* **************************************************************** */
 /*								    */
@@ -131,12 +133,26 @@ int _rl_complete_show_all = 0;
 /* If non-zero, completed directory names have a slash appended. */
 int _rl_complete_mark_directories = 1;
 
+/* If non-zero, the symlinked directory completion behavior introduced in
+   readline-4.2a is disabled, and symlinks that point to directories have
+   a slash appended (subject to the value of _rl_complete_mark_directories).
+   This is user-settable via the mark-symlinked-directories variable. */
+int _rl_complete_mark_symlink_dirs = 0;
+
 /* If non-zero, completions are printed horizontally in alphabetical order,
    like `ls -x'. */
 int _rl_print_completions_horizontally;
 
 /* Non-zero means that case is not significant in filename completion. */
+#if defined (__MSDOS__) && !defined (__DJGPP__)
+int _rl_completion_case_fold = 1;
+#else
 int _rl_completion_case_fold;
+#endif
+
+/* If non-zero, don't match hidden files (filenames beginning with a `.' on
+   Unix) when doing filename completion. */
+int _rl_match_hidden_files = 1;
 
 /* Global variables available to applications using readline. */
 
@@ -150,15 +166,17 @@ int rl_visible_stats = 0;
 /* If non-zero, then this is the address of a function to call when
    completing on a directory name.  The function is called with
    the address of a string (the current directory name) as an arg. */
-Function *rl_directory_completion_hook = (Function *)NULL;
+rl_icppfunc_t *rl_directory_completion_hook = (rl_icppfunc_t *)NULL;
+
+rl_icppfunc_t *rl_directory_rewrite_hook = (rl_icppfunc_t *)NULL;
 
 /* Non-zero means readline completion functions perform tilde expansion. */
 int rl_complete_with_tilde_expansion = 0;
 
 /* Pointer to the generator function for completion_matches ().
-   NULL means to use filename_completion_function (), the default filename
+   NULL means to use rl_filename_completion_function (), the default filename
    completer. */
-Function *rl_completion_entry_function = (Function *)NULL;
+rl_compentry_func_t *rl_completion_entry_function = (rl_compentry_func_t *)NULL;
 
 /* Pointer to alternative function to create matches.
    Function is called with TEXT, START, and END.
@@ -167,7 +185,7 @@ Function *rl_completion_entry_function = (Function *)NULL;
    If this function exists and returns NULL then call the value of
    rl_completion_entry_function to try to match, otherwise use the
    array of strings returned. */
-CPPFunction *rl_attempted_completion_function = (CPPFunction *)NULL;
+rl_completion_func_t *rl_attempted_completion_function = (rl_completion_func_t *)NULL;
 
 /* Non-zero means to suppress normal filename completion after the
    user-specified completion function has been called. */
@@ -183,10 +201,12 @@ int rl_completion_type = 0;
    she is sure she wants to see them all. */
 int rl_completion_query_items = 100;
 
+int _rl_page_completions = 1;
+
 /* The basic list of characters that signal a break between words for the
    completer routine.  The contents of this variable is what breaks words
    in the shell, i.e. " \t\n\"\\'`@$><=" */
-const char *rl_basic_word_break_characters = " \t\n\"\\'`@$><=;|&{(";
+const char *rl_basic_word_break_characters = " \t\n\"\\'`@$><=;|&{("; /* }) */
 
 /* List of basic quoting characters. */
 const char *rl_basic_quote_characters = "\"'";
@@ -194,21 +214,21 @@ const char *rl_basic_quote_characters = "\"'";
 /* The list of characters that signal a break between words for
    rl_complete_internal.  The default list is the contents of
    rl_basic_word_break_characters.  */
-const char *rl_completer_word_break_characters = (char *)NULL;
+const char *rl_completer_word_break_characters = (const char *)NULL;
 
 /* List of characters which can be used to quote a substring of the line.
    Completion occurs on the entire substring, and within the substring
    rl_completer_word_break_characters are treated as any other character,
    unless they also appear within this list. */
-char *rl_completer_quote_characters = (char *)NULL;
+const char *rl_completer_quote_characters = (const char *)NULL;
 
 /* List of characters that should be quoted in filenames by the completer. */
-char *rl_filename_quote_characters = (char *)NULL;
+const char *rl_filename_quote_characters = (const char *)NULL;
 
 /* List of characters that are word break characters, but should be left
    in TEXT when it is passed to the completion function.  The shell uses
    this to help determine what kind of completing to do. */
-char *rl_special_prefixes = (char *)NULL;
+const char *rl_special_prefixes = (const char *)NULL;
 
 /* If non-zero, then disallow duplicates in the matches. */
 int rl_ignore_completion_duplicates = 1;
@@ -234,29 +254,45 @@ int rl_filename_quoting_desired = 1;
    the list of matches as required, but all elements of the array must be
    free()'d if they are deleted. The main intent of this function is
    to implement FIGNORE a la SunOS csh. */
-Function *rl_ignore_some_completions_function = (Function *)NULL;
+rl_compignore_func_t *rl_ignore_some_completions_function = (rl_compignore_func_t *)NULL;
 
 /* Set to a function to quote a filename in an application-specific fashion.
    Called with the text to quote, the type of match found (single or multiple)
    and a pointer to the quoting character to be used, which the function can
    reset if desired. */
-CPFunction *rl_filename_quoting_function = rl_quote_filename;
-
+rl_quote_func_t *rl_filename_quoting_function = rl_quote_filename;
+         
 /* Function to call to remove quoting characters from a filename.  Called
    before completion is attempted, so the embedded quotes do not interfere
    with matching names in the file system.  Readline doesn't do anything
    with this; it's set only by applications. */
-CPFunction *rl_filename_dequoting_function = (CPFunction *)NULL;
+rl_dequote_func_t *rl_filename_dequoting_function = (rl_dequote_func_t *)NULL;
 
 /* Function to call to decide whether or not a word break character is
    quoted.  If a character is quoted, it does not break words for the
    completer. */
-Function *rl_char_is_quoted_p = (Function *)NULL;
+rl_linebuf_func_t *rl_char_is_quoted_p = (rl_linebuf_func_t *)NULL;
+
+/* If non-zero, the completion functions don't append anything except a
+   possible closing quote.  This is set to 0 by rl_complete_internal and
+   may be changed by an application-specific completion function. */
+int rl_completion_suppress_append = 0;
 
 /* Character appended to completed words when at the end of the line.  The
    default is a space. */
 int rl_completion_append_character = ' ';
 
+/* If non-zero, a slash will be appended to completed filenames that are
+   symbolic links to directory names, subject to the value of the
+   mark-directories variable (which is user-settable).  This exists so
+   that application completion functions can override the user's preference
+   (set via the mark-symlinked-directories variable) if appropriate.
+   It's set to the value of _rl_complete_mark_symlink_dirs in
+   rl_complete_internal before any application-specific completion
+   function is called, so without that function doing anything, the user's
+   preferences are honored. */
+int rl_completion_mark_symlink_dirs;
+
 /* If non-zero, inhibit completion (temporarily). */
 int rl_inhibit_completion;
 
@@ -273,13 +309,13 @@ static int completion_changed_buffer;
 
 /* Complete the word at or before point.  You have supplied the function
    that does the initial simple matching selection algorithm (see
-   completion_matches ()).  The default is to do filename completion. */
+   rl_completion_matches ()).  The default is to do filename completion. */
 int
 rl_complete (ignore, invoking_key)
      int ignore, invoking_key;
 {
   if (rl_inhibit_completion)
-    return (rl_insert (ignore, invoking_key));
+    return (_rl_insert_char (ignore, invoking_key));
   else if (rl_last_func == rl_complete && !completion_changed_buffer)
     return (rl_complete_internal ('?'));
   else if (_rl_complete_show_all)
@@ -303,52 +339,90 @@ rl_insert_completions (ignore, invoking_key)
   return (rl_complete_internal ('*'));
 }
 
+/* Return the correct value to pass to rl_complete_internal performing
+   the same tests as rl_complete.  This allows consecutive calls to an
+   application's completion function to list possible completions and for
+   an application-specific completion function to honor the
+   show-all-if-ambiguous readline variable. */
+int
+rl_completion_mode (cfunc)
+     rl_command_func_t *cfunc;
+{
+  if (rl_last_func == cfunc && !completion_changed_buffer)
+    return '?';
+  else if (_rl_complete_show_all)
+    return '!';
+  else
+    return TAB;
+}
+
 /************************************/
 /*				    */
 /*    Completion utility functions  */
 /*				    */
 /************************************/
 
-/* Find the first occurrence in STRING1 of any character from STRING2.
-   Return a pointer to the character in STRING1. */
-static char *
-rl_strpbrk (string1, string2)
-     char *string1, *string2;
+/* Set default values for readline word completion.  These are the variables
+   that application completion functions can change or inspect. */
+static void
+set_completion_defaults (what_to_do)
+     int what_to_do;
 {
-  register char *scan;
+  /* Only the completion entry function can change these. */
+  rl_filename_completion_desired = 0;
+  rl_filename_quoting_desired = 1;
+  rl_completion_type = what_to_do;
+  rl_completion_suppress_append = 0;
 
-  for (; *string1; string1++)
-    {
-      for (scan = string2; *scan; scan++)
-	{
-	  if (*string1 == *scan)
-	    {
-	      return (string1);
-	    }
-	}
-    }
-  return ((char *)NULL);
+  /* The completion entry function may optionally change this. */
+  rl_completion_mark_symlink_dirs = _rl_complete_mark_symlink_dirs;
 }
 
 /* The user must press "y" or "n". Non-zero return means "y" pressed. */
 static int
-get_y_or_n ()
+get_y_or_n (for_pager)
+     int for_pager;
 {
   int c;
 
   for (;;)
     {
+      RL_SETSTATE(RL_STATE_MOREINPUT);
       c = rl_read_key ();
+      RL_UNSETSTATE(RL_STATE_MOREINPUT);
+
       if (c == 'y' || c == 'Y' || c == ' ')
 	return (1);
       if (c == 'n' || c == 'N' || c == RUBOUT)
 	return (0);
       if (c == ABORT_CHAR)
 	_rl_abort_internal ();
-      ding ();
+      if (for_pager && (c == NEWLINE || c == RETURN))
+	return (2);
+      if (for_pager && (c == 'q' || c == 'Q'))
+	return (0);
+      rl_ding ();
     }
 }
 
+static int
+_rl_internal_pager (lines)
+     int lines;
+{
+  int i;
+
+  fprintf (rl_outstream, "--More--");
+  fflush (rl_outstream);
+  i = get_y_or_n (1);
+  _rl_erase_entire_line ();
+  if (i == 0)
+    return -1;
+  else if (i == 2)
+    return (lines - 1);
+  else
+    return 0;
+}
+
 #if defined (VISIBLE_STATS)
 /* Return the character which best describes FILENAME.
      `@' for symbolic links
@@ -409,15 +483,41 @@ stat_char (filename)
 /* Return the portion of PATHNAME that should be output when listing
    possible completions.  If we are hacking filename completion, we
    are only interested in the basename, the portion following the
-   final slash.  Otherwise, we return what we were passed. */
+   final slash.  Otherwise, we return what we were passed.  Since
+   printing empty strings is not very informative, if we're doing
+   filename completion, and the basename is the empty string, we look
+   for the previous slash and return the portion following that.  If
+   there's no previous slash, we just return what we were passed. */
 static char *
 printable_part (pathname)
       char *pathname;
 {
-  char *temp;
+  char *temp, *x;
 
-  temp = rl_filename_completion_desired ? strrchr (pathname, '/') : (char *)NULL;
-  return (temp ? ++temp : pathname);
+  if (rl_filename_completion_desired == 0)	/* don't need to do anything */
+    return (pathname);
+
+  temp = strrchr (pathname, '/');
+#if defined (__MSDOS__)
+  if (temp == 0 && ISALPHA ((unsigned char)pathname[0]) && pathname[1] == ':')
+    temp = pathname + 1;
+#endif
+
+  if (temp == 0 || *temp == '\0')
+    return (pathname);
+  /* If the basename is NULL, we might have a pathname like '/usr/src/'.
+     Look for a previous slash and, if one is found, return the portion
+     following that slash.  If there's no previous slash, just return the
+     pathname we were passed. */
+  else if (temp[1] == '\0')
+    {
+      for (x = temp - 1; x > pathname; x--)
+        if (*x == '/')
+          break;
+      return ((*x == '/') ? x + 1 : pathname);
+    }
+  else
+    return ++temp;
 }
 
 /* Output TO_PRINT to rl_outstream.  If VISIBLE_STATS is defined and we
@@ -477,13 +577,18 @@ print_filename (to_print, full_pathname)
 	  c = to_print[-1];
 	  to_print[-1] = '\0';
 
-	  s = tilde_expand (full_pathname);
+	  /* If setting the last slash in full_pathname to a NUL results in
+	     full_pathname being the empty string, we are trying to complete
+	     files in the root directory.  If we pass a null string to the
+	     bash directory completion hook, for example, it will expand it
+	     to the current directory.  We just want the `/'. */
+	  s = tilde_expand (full_pathname && *full_pathname ? full_pathname : "/");
 	  if (rl_directory_completion_hook)
 	    (*rl_directory_completion_hook) (&s);
 
 	  slen = strlen (s);
 	  tlen = strlen (to_print);
-	  new_full_pathname = xmalloc (slen + tlen + 2);
+	  new_full_pathname = (char *)xmalloc (slen + tlen + 2);
 	  strcpy (new_full_pathname, s);
 	  new_full_pathname[slen] = '/';
 	  strcpy (new_full_pathname + slen + 1, to_print);
@@ -518,7 +623,7 @@ rl_quote_filename (s, rtype, qcp)
 {
   char *r;
 
-  r = xmalloc (strlen (s) + 2);
+  r = (char *)xmalloc (strlen (s) + 2);
   *r = *rl_completer_quote_characters;
   strcpy (r + 1, s);
   if (qcp)
@@ -529,7 +634,7 @@ rl_quote_filename (s, rtype, qcp)
 /* Find the bounds of the current word for completion purposes, and leave
    rl_point set to the end of the word.  This function skips quoted
    substrings (characters between matched pairs of characters in
-   rl_completer_quote_characters.  First we try to find an unclosed
+   rl_completer_quote_characters).  First we try to find an unclosed
    quoted substring on which to do matching.  If one is not found, we use
    the word break characters to find the boundaries of the current word.
    We call an application-specific function to decide whether or not a
@@ -541,8 +646,8 @@ rl_quote_filename (s, rtype, qcp)
    quote, or backslash) anywhere in the string.  DP, if non-null, is set to
    the value of the delimiter character that caused a word break. */
 
-static char
-find_completion_word (fp, dp)
+char
+_rl_find_completion_word (fp, dp)
      int *fp, *dp;
 {
   int scan, end, found_quote, delimiter, pass_next, isbrk;
@@ -566,7 +671,11 @@ find_completion_word (fp, dp)
 	      continue;
 	    }
 
-	  if (rl_line_buffer[scan] == '\\')
+	  /* Shell-like semantics for single quotes -- don't allow backslash
+	     to quote anything in single quotes, especially not the closing
+	     quote.  If you don't like this, take out the check on the value
+	     of quote_char. */
+	  if (quote_char != '\'' && rl_line_buffer[scan] == '\\')
 	    {
 	      pass_next = 1;
 	      found_quote |= RL_QF_BACKSLASH;
@@ -593,6 +702,8 @@ find_completion_word (fp, dp)
 		found_quote |= RL_QF_SINGLE_QUOTE;
 	      else if (quote_char == '"')
 		found_quote |= RL_QF_DOUBLE_QUOTE;
+	      else
+		found_quote |= RL_QF_OTHER_QUOTE;      
 	    }
 	}
     }
@@ -602,7 +713,11 @@ find_completion_word (fp, dp)
       /* We didn't find an unclosed quoted substring upon which to do
          completion, so use the word break characters to find the
          substring on which to complete. */
+#if defined (HANDLE_MULTIBYTE)
+      while (rl_point = _rl_find_prev_mbchar (rl_line_buffer, rl_point, MB_FIND_ANY))
+#else
       while (--rl_point)
+#endif
 	{
 	  scan = rl_line_buffer[rl_point];
 
@@ -627,25 +742,31 @@ find_completion_word (fp, dp)
   /* If there is an application-specific function to say whether or not
      a character is quoted and we found a quote character, let that
      function decide whether or not a character is a word break, even
-     if it is found in rl_completer_word_break_characters. */
-  if (rl_char_is_quoted_p)
-    isbrk = (found_quote == 0 ||
- 		(*rl_char_is_quoted_p) (rl_line_buffer, rl_point) == 0) &&
-	      strchr (rl_completer_word_break_characters, scan) != 0;
-  else
-    isbrk = strchr (rl_completer_word_break_characters, scan) != 0;
-
-  if (isbrk)
+     if it is found in rl_completer_word_break_characters.  Don't bother
+     if we're at the end of the line, though. */
+  if (scan)
     {
-      /* If the character that caused the word break was a quoting
-	 character, then remember it as the delimiter. */
-      if (rl_basic_quote_characters && strchr (rl_basic_quote_characters, scan) && (end - rl_point) > 1)
-	delimiter = scan;
-
-      /* If the character isn't needed to determine something special
-	 about what kind of completion to perform, then advance past it. */
-      if (rl_special_prefixes == 0 || strchr (rl_special_prefixes, scan) == 0)
-	rl_point++;
+      if (rl_char_is_quoted_p)
+	isbrk = (found_quote == 0 ||
+		(*rl_char_is_quoted_p) (rl_line_buffer, rl_point) == 0) &&
+		strchr (rl_completer_word_break_characters, scan) != 0;
+      else
+	isbrk = strchr (rl_completer_word_break_characters, scan) != 0;
+
+      if (isbrk)
+	{
+	  /* If the character that caused the word break was a quoting
+	     character, then remember it as the delimiter. */
+	  if (rl_basic_quote_characters &&
+	      strchr (rl_basic_quote_characters, scan) &&
+	      (end - rl_point) > 1)
+	    delimiter = scan;
+
+	  /* If the character isn't needed to determine something special
+	     about what kind of completion to perform, then advance past it. */
+	  if (rl_special_prefixes == 0 || strchr (rl_special_prefixes, scan) == 0)
+	    rl_point++;
+	}
     }
 
   if (fp)
@@ -660,7 +781,7 @@ static char **
 gen_completion_matches (text, start, end, our_func, found_quote, quote_char)
      char *text;
      int start, end;
-     Function *our_func;
+     rl_compentry_func_t *our_func;
      int found_quote, quote_char;
 {
   char **matches, *temp;
@@ -684,7 +805,7 @@ gen_completion_matches (text, start, end, our_func, found_quote, quote_char)
      filename dequoting function. */
   temp = (char *)NULL;
 
-  if (found_quote && our_func == (Function *)filename_completion_function &&
+  if (found_quote && our_func == rl_filename_completion_function &&
       rl_filename_dequoting_function)
     {
       /* delete single and double quotes */
@@ -692,7 +813,7 @@ gen_completion_matches (text, start, end, our_func, found_quote, quote_char)
       text = temp;	/* not freeing text is not a memory leak */
     }
 
-  matches = completion_matches (text, (CPFunction *)our_func);
+  matches = rl_completion_matches (text, our_func);
   FREE (temp);
   return matches;  
 }
@@ -715,7 +836,7 @@ remove_duplicate_matches (matches)
   /* Sort the array without matches[0], since we need it to
      stay in place no matter what. */
   if (i)
-    qsort (matches+1, i-1, sizeof (char *), _rl_qsort_string_compare);
+    qsort (matches+1, i-1, sizeof (char *), (QSFUNC *)_rl_qsort_string_compare);
 
   /* Remember the lowest common denominator for it may be unique. */
   lowest_common = savestring (matches[0]);
@@ -764,10 +885,15 @@ static int
 compute_lcd_of_matches (match_list, matches, text)
      char **match_list;
      int matches;
-     char *text;
+     const char *text;
 {
   register int i, c1, c2, si;
   int low;		/* Count of max-matched characters. */
+#if defined (HANDLE_MULTIBYTE)
+  int v;
+  mbstate_t ps1, ps2;
+  wchar_t wc1, wc2;
+#endif
 
   /* If only one match, just use that.  Otherwise, compare each
      member of the list with the next, finding out where they
@@ -781,12 +907,33 @@ compute_lcd_of_matches (match_list, matches, text)
 
   for (i = 1, low = 100000; i < matches; i++)
     {
+#if defined (HANDLE_MULTIBYTE)
+      if (MB_CUR_MAX > 1 && rl_byte_oriented == 0)
+	{
+	  memset (&ps1, 0, sizeof (mbstate_t));
+	  memset (&ps2, 0, sizeof (mbstate_t));
+	}
+#endif
       if (_rl_completion_case_fold)
 	{
 	  for (si = 0;
 	       (c1 = _rl_to_lower(match_list[i][si])) &&
 	       (c2 = _rl_to_lower(match_list[i + 1][si]));
 	       si++)
+#if defined (HANDLE_MULTIBYTE)
+	    if (MB_CUR_MAX > 1 && rl_byte_oriented == 0)
+	      {
+		v = mbrtowc (&wc1, match_list[i]+si, strlen (match_list[i]+si), &ps1);
+		mbrtowc (&wc2, match_list[i+1]+si, strlen (match_list[i+1]+si), &ps2);
+		wc1 = towlower (wc1);
+		wc2 = towlower (wc2);
+		if (wc1 != wc2)
+		  break;
+		else if (v > 1)
+		  si += v - 1;
+	      }
+	    else
+#endif
 	    if (c1 != c2)
 	      break;
 	}
@@ -796,6 +943,17 @@ compute_lcd_of_matches (match_list, matches, text)
 	       (c1 = match_list[i][si]) &&
 	       (c2 = match_list[i + 1][si]);
 	       si++)
+#if defined (HANDLE_MULTIBYTE)
+	    if (MB_CUR_MAX > 1 && rl_byte_oriented == 0)
+	      {
+		mbstate_t ps_back = ps1;
+		if (!_rl_compare_chars (match_list[i], si, &ps1, match_list[i+1], si, &ps2))
+		  break;
+		else if ((v = _rl_get_char_len (&match_list[i][si], &ps_back)) > 1)
+		  si += v - 1;
+	      }
+	    else
+#endif
 	    if (c1 != c2)
 	      break;
 	}
@@ -809,13 +967,42 @@ compute_lcd_of_matches (match_list, matches, text)
      value of matches[0]. */
   if (low == 0 && text && *text)
     {
-      match_list[0] = xmalloc (strlen (text) + 1);
+      match_list[0] = (char *)xmalloc (strlen (text) + 1);
       strcpy (match_list[0], text);
     }
   else
     {
-      match_list[0] = xmalloc (low + 1);
-      strncpy (match_list[0], match_list[1], low);
+      match_list[0] = (char *)xmalloc (low + 1);
+
+      /* XXX - this might need changes in the presence of multibyte chars */
+
+      /* If we are ignoring case, try to preserve the case of the string
+	 the user typed in the face of multiple matches differing in case. */
+      if (_rl_completion_case_fold)
+	{
+	  /* sort the list to get consistent answers. */
+	  qsort (match_list+1, matches, sizeof(char *), (QSFUNC *)_rl_qsort_string_compare);
+
+	  si = strlen (text);
+	  if (si <= low)
+	    {
+	      for (i = 1; i <= matches; i++)
+		if (strncmp (match_list[i], text, si) == 0)
+		  {
+		    strncpy (match_list[0], match_list[i], low);
+		    break;
+		  }
+	      /* no casematch, use first entry */
+	      if (i > matches)
+		strncpy (match_list[0], match_list[1], low);
+	    }
+	  else
+	    /* otherwise, just use the text the user typed. */
+	    strncpy (match_list[0], text, low);
+	}
+      else
+        strncpy (match_list[0], match_list[1], low);
+
       match_list[0][low] = '\0';
     }
 
@@ -832,6 +1019,9 @@ postprocess_matches (matchesp, matching_filenames)
 
   matches = *matchesp;
 
+  if (matches == 0)
+    return 0;
+
   /* It seems to me that in all the cases we handle we would like
      to ignore duplicate possiblilities.  Scan for the text to
      insert being identical to the other completions. */
@@ -884,17 +1074,17 @@ rl_display_match_list (matches, len, max)
      char **matches;
      int len, max;
 {
-  int count, limit, printed_len;
+  int count, limit, printed_len, lines;
   int i, j, k, l;
   char *temp;
 
   /* How many items of MAX length can we fit in the screen window? */
   max += 2;
-  limit = screenwidth / max;
-  if (limit != 1 && (limit * max == screenwidth))
+  limit = _rl_screenwidth / max;
+  if (limit != 1 && (limit * max == _rl_screenwidth))
     limit--;
 
-  /* Avoid a possible floating exception.  If max > screenwidth,
+  /* Avoid a possible floating exception.  If max > _rl_screenwidth,
      limit will be 0 and a divide-by-zero fault will result. */
   if (limit == 0)
     limit = 1;
@@ -908,10 +1098,11 @@ rl_display_match_list (matches, len, max)
 
   /* Sort the items if they are not already sorted. */
   if (rl_ignore_completion_duplicates == 0)
-    qsort (matches + 1, len, sizeof (char *), _rl_qsort_string_compare);
+    qsort (matches + 1, len, sizeof (char *), (QSFUNC *)_rl_qsort_string_compare);
 
-  crlf ();
+  rl_crlf ();
 
+  lines = 0;
   if (_rl_print_completions_horizontally == 0)
     {
       /* Print the sorted items, up-and-down alphabetically, like ls. */
@@ -932,7 +1123,14 @@ rl_display_match_list (matches, len, max)
 		}
 	      l += count;
 	    }
-	  crlf ();
+	  rl_crlf ();
+	  lines++;
+	  if (_rl_page_completions && lines >= (_rl_screenheight - 1) && i < count)
+	    {
+	      lines = _rl_internal_pager (lines);
+	      if (lines < 0)
+		return;
+	    }
 	}
     }
   else
@@ -946,13 +1144,22 @@ rl_display_match_list (matches, len, max)
 	  if (matches[i+1])
 	    {
 	      if (i && (limit > 1) && (i % limit) == 0)
-		crlf ();
+		{
+		  rl_crlf ();
+		  lines++;
+		  if (_rl_page_completions && lines >= _rl_screenheight - 1)
+		    {
+		      lines = _rl_internal_pager (lines);
+		      if (lines < 0)
+			return;
+		    }
+		}
 	      else
 		for (k = 0; k < max - printed_len; k++)
 		  putc (' ', rl_outstream);
 	    }
 	}
-      crlf ();
+      rl_crlf ();
     }
 }
 
@@ -981,9 +1188,9 @@ display_matches (matches)
   if (matches[1] == 0)
     {
       temp = printable_part (matches[0]);
-      crlf ();
+      rl_crlf ();
       print_filename (temp, matches[0]);
-      crlf ();
+      rl_crlf ();
 
       rl_forced_update_display ();
       rl_display_fixed = 1;
@@ -1010,17 +1217,17 @@ display_matches (matches)
       (*rl_completion_display_matches_hook) (matches, len, max);
       return;
     }
-
+	
   /* If there are many items, then ask the user if she really wants to
      see them all. */
   if (len >= rl_completion_query_items)
     {
-      crlf ();
+      rl_crlf ();
       fprintf (rl_outstream, "Display all %d possibilities? (y or n)", len);
       fflush (rl_outstream);
-      if (get_y_or_n () == 0)
+      if (get_y_or_n (0) == 0)
 	{
-	  crlf ();
+	  rl_crlf ();
 
 	  rl_forced_update_display ();
 	  rl_display_fixed = 1;
@@ -1068,7 +1275,7 @@ make_quoted_replacement (match, mtype, qc)
          This also checks whether the common prefix of several
 	 matches needs to be quoted. */
       should_quote = rl_filename_quote_characters
-			? (rl_strpbrk (match, rl_filename_quote_characters) != 0)
+			? (_rl_strpbrk (match, rl_filename_quote_characters) != 0)
 			: 0;
 
       do_replace = should_quote ? mtype : NO_MATCH;
@@ -1114,14 +1321,20 @@ insert_match (match, start, mtype, qc)
    just-inserted match.  If the user has specified that directories
    should be marked by a trailing `/', append one of those instead.  The
    default trailing character is a space.  Returns the number of characters
-   appended. */
+   appended.  If NONTRIVIAL_MATCH is set, we test for a symlink (if the OS
+   has them) and don't add a suffix for a symlink to a directory.  A
+   nontrivial match is one that actually adds to the word being completed.
+   The variable rl_completion_mark_symlink_dirs controls this behavior
+   (it's initially set to the what the user has chosen, indicated by the
+   value of _rl_complete_mark_symlink_dirs, but may be modified by an
+   application's completion function). */
 static int
-append_to_match (text, delimiter, quote_char)
+append_to_match (text, delimiter, quote_char, nontrivial_match)
      char *text;
-     int delimiter, quote_char;
+     int delimiter, quote_char, nontrivial_match;
 {
   char temp_string[4], *filename;
-  int temp_string_index;
+  int temp_string_index, s;
   struct stat finfo;
 
   temp_string_index = 0;
@@ -1130,7 +1343,7 @@ append_to_match (text, delimiter, quote_char)
 
   if (delimiter)
     temp_string[temp_string_index++] = delimiter;
-  else if (rl_completion_append_character)
+  else if (rl_completion_suppress_append == 0 && rl_completion_append_character)
     temp_string[temp_string_index++] = rl_completion_append_character;
 
   temp_string[temp_string_index++] = '\0';
@@ -1138,21 +1351,39 @@ append_to_match (text, delimiter, quote_char)
   if (rl_filename_completion_desired)
     {
       filename = tilde_expand (text);
-      if (stat (filename, &finfo) == 0 && S_ISDIR (finfo.st_mode))
+      s = (nontrivial_match && rl_completion_mark_symlink_dirs == 0)
+		? LSTAT (filename, &finfo)
+		: stat (filename, &finfo);
+      if (s == 0 && S_ISDIR (finfo.st_mode))
 	{
-	  if (_rl_complete_mark_directories && rl_line_buffer[rl_point] != '/')
-	    rl_insert_text ("/");
+	  if (_rl_complete_mark_directories)
+	    {
+	      /* This is clumsy.  Avoid putting in a double slash if point
+		 is at the end of the line and the previous character is a
+		 slash. */
+	      if (rl_point && rl_line_buffer[rl_point] == '\0' && rl_line_buffer[rl_point - 1] == '/')
+		;
+	      else if (rl_line_buffer[rl_point] != '/')
+		rl_insert_text ("/");
+	    }
 	}
+#ifdef S_ISLNK
+      /* Don't add anything if the filename is a symlink and resolves to a
+	 directory. */
+      else if (s == 0 && S_ISLNK (finfo.st_mode) &&
+	       stat (filename, &finfo) == 0 && S_ISDIR (finfo.st_mode))
+	;
+#endif
       else
 	{
-	  if (rl_point == rl_end)
+	  if (rl_point == rl_end && temp_string_index)
 	    rl_insert_text (temp_string);
 	}
       free (filename);
     }
   else
     {
-      if (rl_point == rl_end)
+      if (rl_point == rl_end && temp_string_index)
 	rl_insert_text (temp_string);
     }
 
@@ -1198,12 +1429,15 @@ insert_all_matches (matches, point, qc)
   rl_end_undo_group ();
 }
 
-static void
-free_match_list (matches)
+void
+_rl_free_match_list (matches)
      char **matches;
 {
   register int i;
 
+  if (matches == 0)
+    return;
+
   for (i = 0; matches[i]; i++)
     free (matches[i]);
   free (matches);
@@ -1221,20 +1455,19 @@ rl_complete_internal (what_to_do)
      int what_to_do;
 {
   char **matches;
-  Function *our_func;
-  int start, end, delimiter, found_quote, i;
+  rl_compentry_func_t *our_func;
+  int start, end, delimiter, found_quote, i, nontrivial_lcd;
   char *text, *saved_line_buffer;
   char quote_char;
 
-  /* Only the completion entry function can change these. */
-  rl_filename_completion_desired = 0;
-  rl_filename_quoting_desired = 1;
-  rl_completion_type = what_to_do;
+  RL_SETSTATE(RL_STATE_COMPLETING);
+
+  set_completion_defaults (what_to_do);
 
   saved_line_buffer = rl_line_buffer ? savestring (rl_line_buffer) : (char *)NULL;
   our_func = rl_completion_entry_function
 		? rl_completion_entry_function
-		: (Function *)filename_completion_function;
+		: rl_filename_completion_function;
 
   /* We now look backwards for the start of a filename/variable word. */
   end = rl_point;
@@ -1244,38 +1477,38 @@ rl_complete_internal (what_to_do)
   if (rl_point)
     /* This (possibly) changes rl_point.  If it returns a non-zero char,
        we know we have an open quote. */
-    quote_char = find_completion_word (&found_quote, &delimiter);
+    quote_char = _rl_find_completion_word (&found_quote, &delimiter);
 
   start = rl_point;
   rl_point = end;
 
   text = rl_copy_text (start, end);
   matches = gen_completion_matches (text, start, end, our_func, found_quote, quote_char);
+  /* nontrivial_lcd is set if the common prefix adds something to the word
+     being completed. */
+  nontrivial_lcd = matches && strcmp (text, matches[0]) != 0;
   free (text);
 
   if (matches == 0)
     {
-      ding ();
+      rl_ding ();
       FREE (saved_line_buffer);
+      completion_changed_buffer = 0;
+      RL_UNSETSTATE(RL_STATE_COMPLETING);
       return (0);
     }
 
-#if 0
-  /* If we are matching filenames, our_func will have been set to
-     filename_completion_function */
-  i = our_func == (Function *)filename_completion_function;
-#else
   /* If we are matching filenames, the attempted completion function will
      have set rl_filename_completion_desired to a non-zero value.  The basic
-     filename_completion_function does this. */
+     rl_filename_completion_function does this. */
   i = rl_filename_completion_desired;
-#endif
 
   if (postprocess_matches (&matches, i) == 0)
     {
-      ding ();
+      rl_ding ();
       FREE (saved_line_buffer);
       completion_changed_buffer = 0;
+      RL_UNSETSTATE(RL_STATE_COMPLETING);
       return (0);
     }
 
@@ -1303,10 +1536,10 @@ rl_complete_internal (what_to_do)
 	      break;
 	    }
 	  else if (rl_editing_mode != vi_mode)
-	    ding ();	/* There are other matches remaining. */
+	    rl_ding ();	/* There are other matches remaining. */
 	}
       else
-	append_to_match (matches[0], delimiter, quote_char);
+	append_to_match (matches[0], delimiter, quote_char, nontrivial_lcd);
 
       break;
 
@@ -1320,12 +1553,13 @@ rl_complete_internal (what_to_do)
 
     default:
       fprintf (stderr, "\r\nreadline: bad value %d for what_to_do in rl_complete\n", what_to_do);
-      ding ();
+      rl_ding ();
       FREE (saved_line_buffer);
+      RL_UNSETSTATE(RL_STATE_COMPLETING);
       return 1;
     }
 
-  free_match_list (matches);
+  _rl_free_match_list (matches);
 
   /* Check to see if the line has changed through all of this manipulation. */
   if (saved_line_buffer)
@@ -1334,6 +1568,7 @@ rl_complete_internal (what_to_do)
       free (saved_line_buffer);
     }
 
+  RL_UNSETSTATE(RL_STATE_COMPLETING);
   return 0;
 }
 
@@ -1356,7 +1591,9 @@ rl_complete_internal (what_to_do)
      when there are no more matches.
  */
 char **
-completion_matches (const char *text, CPFunction *entry_function)
+rl_completion_matches (text, entry_function)
+     const char *text;
+     rl_compentry_func_t *entry_function;
 {
   /* Number of slots in match_list. */
   int match_list_size;
@@ -1401,11 +1638,13 @@ completion_matches (const char *text, CPFunction *entry_function)
    TEXT contains a partial username preceded by a random
    character (usually `~').  */
 char *
-username_completion_function (const char *text, int state)
+rl_username_completion_function (text, state)
+     const char *text;
+     int state;
 {
-#if defined (__GO32__) || defined (__WIN__) || defined (__OPENNT)
+#if defined (__WIN32__) || defined (__OPENNT)
   return (char *)NULL;
-#else /* !__GO32__ */
+#else /* !__WIN32__ && !__OPENNT) */
   static char *username = (char *)NULL;
   static struct passwd *entry;
   static int namelen, first_char, first_char_loc;
@@ -1437,7 +1676,7 @@ username_completion_function (const char *text, int state)
     }
   else
     {
-      value = xmalloc (2 + strlen (entry->pw_name));
+      value = (char *)xmalloc (2 + strlen (entry->pw_name));
 
       *value = *text;
 
@@ -1448,7 +1687,7 @@ username_completion_function (const char *text, int state)
 
       return (value);
     }
-#endif /* !__GO32__ */
+#endif /* !__WIN32__ && !__OPENNT */
 }
 
 /* Okay, now we write the entry_function for filename completion.  In the
@@ -1456,7 +1695,9 @@ username_completion_function (const char *text, int state)
    because of all the pathnames that must be followed when looking up the
    completion for a command. */
 char *
-filename_completion_function (const char *text, int state)
+rl_filename_completion_function (text, state)
+     const char *text;
+     int state;
 {
   static DIR *directory = (DIR *)NULL;
   static char *filename = (char *)NULL;
@@ -1488,11 +1729,25 @@ filename_completion_function (const char *text, int state)
 
       temp = strrchr (dirname, '/');
 
+#if defined (__MSDOS__)
+      /* special hack for //X/... */
+      if (dirname[0] == '/' && dirname[1] == '/' && ISALPHA ((unsigned char)dirname[2]) && dirname[3] == '/')
+        temp = strrchr (dirname + 3, '/');
+#endif
+
       if (temp)
 	{
 	  strcpy (filename, ++temp);
 	  *temp = '\0';
 	}
+#if defined (__MSDOS__)
+      /* searches from current directory on the drive */
+      else if (ISALPHA ((unsigned char)dirname[0]) && dirname[1] == ':')
+        {
+          strcpy (filename, dirname + 2);
+          dirname[2] = '\0';
+        }
+#endif
       else
 	{
 	  dirname[0] = '.';
@@ -1511,6 +1766,9 @@ filename_completion_function (const char *text, int state)
 	  dirname = temp;
 	}
 
+      if (rl_directory_rewrite_hook)
+	(*rl_directory_rewrite_hook) (&dirname);
+
       if (rl_directory_completion_hook && (*rl_directory_completion_hook) (&dirname))
 	{
 	  free (users_dirname);
@@ -1534,10 +1792,14 @@ filename_completion_function (const char *text, int state)
   entry = (struct dirent *)NULL;
   while (directory && (entry = readdir (directory)))
     {
-      /* Special case for no filename.
-	 All entries except "." and ".." match. */
+      /* Special case for no filename.  If the user has disabled the
+         `match-hidden-files' variable, skip filenames beginning with `.'.
+	 All other entries except "." and ".." match. */
       if (filename_len == 0)
 	{
+	  if (_rl_match_hidden_files == 0 && HIDDEN_FILE (entry->d_name))
+	    continue;
+
 	  if (entry->d_name[0] != '.' ||
 	       (entry->d_name[1] &&
 		 (entry->d_name[1] != '.' || entry->d_name[2])))
@@ -1597,7 +1859,7 @@ filename_completion_function (const char *text, int state)
 	  if (rl_complete_with_tilde_expansion && *users_dirname == '~')
 	    {
 	      dirlen = strlen (dirname);
-	      temp = xmalloc (2 + dirlen + D_NAMLEN (entry));
+	      temp = (char *)xmalloc (2 + dirlen + D_NAMLEN (entry));
 	      strcpy (temp, dirname);
 	      /* Canonicalization cuts off any final slash present.  We
 		 may need to add it back. */
@@ -1610,8 +1872,11 @@ filename_completion_function (const char *text, int state)
 	  else
 	    {
 	      dirlen = strlen (users_dirname);
-	      temp = xmalloc (1 + dirlen + D_NAMLEN (entry));
+	      temp = (char *)xmalloc (2 + dirlen + D_NAMLEN (entry));
 	      strcpy (temp, users_dirname);
+	      /* Make sure that temp has a trailing slash here. */
+	      if (users_dirname[dirlen - 1] != '/')
+		temp[dirlen++] = '/';
 	    }
 
 	  strcpy (temp + dirlen, entry->d_name);
@@ -1633,9 +1898,10 @@ filename_completion_function (const char *text, int state)
    hit the end of the match list, we restore the original unmatched text,
    ring the bell, and reset the counter to zero. */
 int
-rl_menu_complete (int count, int ignore __attribute__((unused)))
+rl_menu_complete (count, ignore)
+     int count, ignore __attribute__((unused));
 {
-  Function *our_func;
+  rl_compentry_func_t *our_func;
   int matching_filenames, found_quote;
 
   static char *orig_text;
@@ -1653,23 +1919,17 @@ rl_menu_complete (int count, int ignore __attribute__((unused)))
       /* Clean up from previous call, if any. */
       FREE (orig_text);
       if (matches)
-	{
-	  for (match_list_index = 0; matches[match_list_index]; match_list_index++)
-	    free (matches[match_list_index]);
-	  free (matches);
-	}
+	_rl_free_match_list (matches);
 
       match_list_index = match_list_size = 0;
       matches = (char **)NULL;
 
       /* Only the completion entry function can change these. */
-      rl_filename_completion_desired = 0;
-      rl_filename_quoting_desired = 1;
-      rl_completion_type = '%';
+      set_completion_defaults ('%');
 
       our_func = rl_completion_entry_function
 			? rl_completion_entry_function
-			: (Function *)filename_completion_function;
+			: rl_filename_completion_function;
 
       /* We now look backwards for the start of a filename/variable word. */
       orig_end = rl_point;
@@ -1679,7 +1939,7 @@ rl_menu_complete (int count, int ignore __attribute__((unused)))
       if (rl_point)
 	/* This (possibly) changes rl_point.  If it returns a non-zero char,
 	   we know we have an open quote. */
-	quote_char = find_completion_word (&found_quote, &delimiter);
+	quote_char = _rl_find_completion_word (&found_quote, &delimiter);
 
       orig_start = rl_point;
       rl_point = orig_end;
@@ -1688,19 +1948,14 @@ rl_menu_complete (int count, int ignore __attribute__((unused)))
       matches = gen_completion_matches (orig_text, orig_start, orig_end,
 					our_func, found_quote, quote_char);
 
-#if 0
-      /* If we are matching filenames, our_func will have been set to
-	 filename_completion_function */
-      matching_filenames = our_func == (Function *)filename_completion_function;
-#else
       /* If we are matching filenames, the attempted completion function will
 	 have set rl_filename_completion_desired to a non-zero value.  The basic
-	 filename_completion_function does this. */
+	 rl_filename_completion_function does this. */
       matching_filenames = rl_filename_completion_desired;
-#endif
+
       if (matches == 0 || postprocess_matches (&matches, matching_filenames) == 0)
 	{
-    	  ding ();
+    	  rl_ding ();
 	  FREE (matches);
 	  matches = (char **)0;
 	  FREE (orig_text);
@@ -1721,7 +1976,7 @@ rl_menu_complete (int count, int ignore __attribute__((unused)))
 
   if (matches == 0 || match_list_size == 0) 
     {
-      ding ();
+      rl_ding ();
       FREE (matches);
       matches = (char **)0;
       completion_changed_buffer = 0;
@@ -1734,13 +1989,14 @@ rl_menu_complete (int count, int ignore __attribute__((unused)))
 
   if (match_list_index == 0 && match_list_size > 1)
     {
-      ding ();
+      rl_ding ();
       insert_match (orig_text, orig_start, MULT_MATCH, &quote_char);
     }
   else
     {
       insert_match (matches[match_list_index], orig_start, SINGLE_MATCH, &quote_char);
-      append_to_match (matches[match_list_index], delimiter, quote_char);
+      append_to_match (matches[match_list_index], delimiter, quote_char,
+		       strcmp (orig_text, matches[match_list_index]));
     }
 
   completion_changed_buffer = 1;
diff --git a/readline/configure b/readline/configure
index 454a177e35da06286fe4b5ff24636bae692975da..fc3769f50e8edcc0ec85886abfa05422be22f7e0 100755
--- a/readline/configure
+++ b/readline/configure
@@ -1,119 +1,158 @@
 #! /bin/sh
+# From configure.in for Readline 4.3, version 2.45, from autoconf version 2.52.
+# Guess values for system-dependent variables and create Makefiles.
+# Generated by Autoconf 2.52 for readline 4.3.
+#
+# Report bugs to <bug-readline@gnu.org>.
+#
+# Copyright 1992, 1993, 1994, 1995, 1996, 1998, 1999, 2000, 2001
+# Free Software Foundation, Inc.
+# This configure script is free software; the Free Software Foundation
+# gives unlimited permission to copy, distribute and modify it.
 
-# From configure.in for Readline 4.0, version 2.14, from autoconf version 2.12
-LIBVERSION=4.0
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
+# Avoid depending upon Character Ranges.
+as_cr_letters='abcdefghijklmnopqrstuvwxyz'
+as_cr_LETTERS='ABCDEFGHIJKLMNOPQRSTUVWXYZ'
+as_cr_Letters=$as_cr_letters$as_cr_LETTERS
+as_cr_digits='0123456789'
+as_cr_alnum=$as_cr_Letters$as_cr_digits
 
+# Sed expression to map a string onto a valid variable name.
+as_tr_sh="sed y%*+%pp%;s%[^_$as_cr_alnum]%_%g"
 
+# Sed expression to map a string onto a valid CPP name.
+as_tr_cpp="sed y%*$as_cr_letters%P$as_cr_LETTERS%;s%[^_$as_cr_alnum]%_%g"
 
+# Be Bourne compatible
+if test -n "${ZSH_VERSION+set}" && (emulate sh) >/dev/null 2>&1; then
+  emulate sh
+  NULLCMD=:
+elif test -n "${BASH_VERSION+set}" && (set -o posix) >/dev/null 2>&1; then
+  set -o posix
+fi
 
+# Name of the executable.
+as_me=`echo "$0" |sed 's,.*[\\/],,'`
 
+if expr a : '\(a\)' >/dev/null 2>&1; then
+  as_expr=expr
+else
+  as_expr=false
+fi
 
+rm -f conf$$ conf$$.exe conf$$.file
+echo >conf$$.file
+if ln -s conf$$.file conf$$ 2>/dev/null; then
+  # We could just check for DJGPP; but this test a) works b) is more generic
+  # and c) will remain valid once DJGPP supports symlinks (DJGPP 2.04).
+  if test -f conf$$.exe; then
+    # Don't use ln at all; we don't have any links
+    as_ln_s='cp -p'
+  else
+    as_ln_s='ln -s'
+  fi
+elif ln conf$$.file conf$$ 2>/dev/null; then
+  as_ln_s=ln
+else
+  as_ln_s='cp -p'
+fi
+rm -f conf$$ conf$$.exe conf$$.file
 
+as_executable_p="test -f"
 
+# Support unset when possible.
+if (FOO=FOO; unset FOO) >/dev/null 2>&1; then
+  as_unset=unset
+else
+  as_unset=false
+fi
 
+# NLS nuisances.
+$as_unset LANG || test "${LANG+set}" != set || { LANG=C; export LANG; }
+$as_unset LC_ALL || test "${LC_ALL+set}" != set || { LC_ALL=C; export LC_ALL; }
+$as_unset LC_TIME || test "${LC_TIME+set}" != set || { LC_TIME=C; export LC_TIME; }
+$as_unset LC_CTYPE || test "${LC_CTYPE+set}" != set || { LC_CTYPE=C; export LC_CTYPE; }
+$as_unset LANGUAGE || test "${LANGUAGE+set}" != set || { LANGUAGE=C; export LANGUAGE; }
+$as_unset LC_COLLATE || test "${LC_COLLATE+set}" != set || { LC_COLLATE=C; export LC_COLLATE; }
+$as_unset LC_NUMERIC || test "${LC_NUMERIC+set}" != set || { LC_NUMERIC=C; export LC_NUMERIC; }
+$as_unset LC_MESSAGES || test "${LC_MESSAGES+set}" != set || { LC_MESSAGES=C; export LC_MESSAGES; }
+
+# IFS
+# We need space, tab and new line, in precisely that order.
+as_nl='
+'
+IFS=" 	$as_nl"
+
+# CDPATH.
+$as_unset CDPATH || test "${CDPATH+set}" != set || { CDPATH=:; export CDPATH; }
+
+# Name of the host.
+# hostname on some systems (SVR3.2, Linux) returns a bogus exit status,
+# so uname gets run too.
+ac_hostname=`(hostname || uname -n) 2>/dev/null | sed 1q`
+
+exec 6>&1
 
-# Guess values for system-dependent variables and create Makefiles.
-# Generated automatically using autoconf version 2.12 
-# Copyright (C) 1992, 93, 94, 95, 96 Free Software Foundation, Inc.
 #
-# This configure script is free software; the Free Software Foundation
-# gives unlimited permission to copy, distribute and modify it.
-
-# Defaults:
-ac_help=
+# Initializations.
+#
 ac_default_prefix=/usr/local
-# Any additions from configure.in:
-ac_help="$ac_help
---with-curses               use the curses library instead of the termcap library"
+cross_compiling=no
+subdirs=
+MFLAGS= MAKEFLAGS=
+SHELL=${CONFIG_SHELL-/bin/sh}
+
+# Maximum number of lines to put in a shell here document.
+# This variable seems obsolete.  It should probably be removed, and
+# only ac_max_sed_lines should be used.
+: ${ac_max_here_lines=38}
+
+ac_unique_file="readline.h"
+# Factoring default headers for most tests.
+ac_includes_default="\
+#include <stdio.h>
+#if HAVE_SYS_TYPES_H
+# include <sys/types.h>
+#endif
+#if HAVE_SYS_STAT_H
+# include <sys/stat.h>
+#endif
+#if STDC_HEADERS
+# include <stdlib.h>
+# include <stddef.h>
+#else
+# if HAVE_STDLIB_H
+#  include <stdlib.h>
+# endif
+#endif
+#if HAVE_STRING_H
+# if !STDC_HEADERS && HAVE_MEMORY_H
+#  include <memory.h>
+# endif
+# include <string.h>
+#endif
+#if HAVE_STRINGS_H
+# include <strings.h>
+#endif
+#if HAVE_INTTYPES_H
+# include <inttypes.h>
+#else
+# if HAVE_STDINT_H
+#  include <stdint.h>
+# endif
+#endif
+#if HAVE_UNISTD_H
+# include <unistd.h>
+#endif"
 
 # Initialize some variables set by options.
+ac_init_help=
+ac_init_version=false
 # The variables have the same names as the options, with
 # dashes changed to underlines.
-build=NONE
-cache_file=./config.cache
+cache_file=/dev/null
 exec_prefix=NONE
-host=NONE
 no_create=
-nonopt=NONE
 no_recursion=
 prefix=NONE
 program_prefix=NONE
@@ -122,10 +161,15 @@ program_transform_name=s,x,x,
 silent=
 site=
 srcdir=
-target=NONE
 verbose=
 x_includes=NONE
 x_libraries=NONE
+
+# Installation directory options.
+# These are left unexpanded so users can "make install exec_prefix=/foo"
+# and all the variables that are supposed to be based on exec_prefix
+# by default will actually change.
+# Use braces instead of parens because sh, perl, etc. also accept them.
 bindir='${exec_prefix}/bin'
 sbindir='${exec_prefix}/sbin'
 libexecdir='${exec_prefix}/libexec'
@@ -139,16 +183,16 @@ oldincludedir='/usr/include'
 infodir='${prefix}/info'
 mandir='${prefix}/man'
 
-# Initialize some other variables.
-subdirs=
-MFLAGS= MAKEFLAGS=
-# Maximum number of lines to put in a shell here document.
-ac_max_here_lines=12
+# Identity of this package.
+PACKAGE_NAME='readline'
+PACKAGE_TARNAME='readline'
+PACKAGE_VERSION='4.3'
+PACKAGE_STRING='readline 4.3'
+PACKAGE_BUGREPORT='bug-readline@gnu.org'
 
 ac_prev=
 for ac_option
 do
-
   # If the previous option needs an argument, assign it.
   if test -n "$ac_prev"; then
     eval "$ac_prev=\$ac_option"
@@ -156,59 +200,59 @@ do
     continue
   fi
 
-  case "$ac_option" in
-  -*=*) ac_optarg=`echo "$ac_option" | sed 's/[-_a-zA-Z0-9]*=//'` ;;
-  *) ac_optarg= ;;
-  esac
+  ac_optarg=`expr "x$ac_option" : 'x[^=]*=\(.*\)'`
 
   # Accept the important Cygnus configure options, so we can diagnose typos.
 
-  case "$ac_option" in
+  case $ac_option in
 
   -bindir | --bindir | --bindi | --bind | --bin | --bi)
     ac_prev=bindir ;;
   -bindir=* | --bindir=* | --bindi=* | --bind=* | --bin=* | --bi=*)
-    bindir="$ac_optarg" ;;
+    bindir=$ac_optarg ;;
 
   -build | --build | --buil | --bui | --bu)
-    ac_prev=build ;;
+    ac_prev=build_alias ;;
   -build=* | --build=* | --buil=* | --bui=* | --bu=*)
-    build="$ac_optarg" ;;
+    build_alias=$ac_optarg ;;
 
   -cache-file | --cache-file | --cache-fil | --cache-fi \
   | --cache-f | --cache- | --cache | --cach | --cac | --ca | --c)
     ac_prev=cache_file ;;
   -cache-file=* | --cache-file=* | --cache-fil=* | --cache-fi=* \
   | --cache-f=* | --cache-=* | --cache=* | --cach=* | --cac=* | --ca=* | --c=*)
-    cache_file="$ac_optarg" ;;
+    cache_file=$ac_optarg ;;
+
+  --config-cache | -C)
+    cache_file=config.cache ;;
 
   -datadir | --datadir | --datadi | --datad | --data | --dat | --da)
     ac_prev=datadir ;;
   -datadir=* | --datadir=* | --datadi=* | --datad=* | --data=* | --dat=* \
   | --da=*)
-    datadir="$ac_optarg" ;;
+    datadir=$ac_optarg ;;
 
   -disable-* | --disable-*)
-    ac_feature=`echo $ac_option|sed -e 's/-*disable-//'`
+    ac_feature=`expr "x$ac_option" : 'x-*disable-\(.*\)'`
     # Reject names that are not valid shell variable names.
-    if test -n "`echo $ac_feature| sed 's/[-a-zA-Z0-9_]//g'`"; then
-      { echo "configure: error: $ac_feature: invalid feature name" 1>&2; exit 1; }
-    fi
-    ac_feature=`echo $ac_feature| sed 's/-/_/g'`
-    eval "enable_${ac_feature}=no" ;;
+    expr "x$ac_feature" : ".*[^-_$as_cr_alnum]" >/dev/null &&
+      { echo "$as_me: error: invalid feature name: $ac_feature" >&2
+   { (exit 1); exit 1; }; }
+    ac_feature=`echo $ac_feature | sed 's/-/_/g'`
+    eval "enable_$ac_feature=no" ;;
 
   -enable-* | --enable-*)
-    ac_feature=`echo $ac_option|sed -e 's/-*enable-//' -e 's/=.*//'`
+    ac_feature=`expr "x$ac_option" : 'x-*enable-\([^=]*\)'`
     # Reject names that are not valid shell variable names.
-    if test -n "`echo $ac_feature| sed 's/[-_a-zA-Z0-9]//g'`"; then
-      { echo "configure: error: $ac_feature: invalid feature name" 1>&2; exit 1; }
-    fi
-    ac_feature=`echo $ac_feature| sed 's/-/_/g'`
-    case "$ac_option" in
-      *=*) ;;
+    expr "x$ac_feature" : ".*[^-_$as_cr_alnum]" >/dev/null &&
+      { echo "$as_me: error: invalid feature name: $ac_feature" >&2
+   { (exit 1); exit 1; }; }
+    ac_feature=`echo $ac_feature | sed 's/-/_/g'`
+    case $ac_option in
+      *=*) ac_optarg=`echo "$ac_optarg" | sed "s/'/'\\\\\\\\''/g"`;;
       *) ac_optarg=yes ;;
     esac
-    eval "enable_${ac_feature}='$ac_optarg'" ;;
+    eval "enable_$ac_feature='$ac_optarg'" ;;
 
   -exec-prefix | --exec_prefix | --exec-prefix | --exec-prefi \
   | --exec-pref | --exec-pre | --exec-pr | --exec-p | --exec- \
@@ -217,95 +261,47 @@ do
   -exec-prefix=* | --exec_prefix=* | --exec-prefix=* | --exec-prefi=* \
   | --exec-pref=* | --exec-pre=* | --exec-pr=* | --exec-p=* | --exec-=* \
   | --exec=* | --exe=* | --ex=*)
-    exec_prefix="$ac_optarg" ;;
+    exec_prefix=$ac_optarg ;;
 
   -gas | --gas | --ga | --g)
     # Obsolete; use --with-gas.
     with_gas=yes ;;
 
-  -help | --help | --hel | --he)
-    # Omit some internal or obsolete options to make the list less imposing.
-    # This message is too long to be a string in the A/UX 3.1 sh.
-    cat << EOF
-Usage: configure [options] [host]
-Options: [defaults in brackets after descriptions]
-Configuration:
-  --cache-file=FILE       cache test results in FILE
-  --help                  print this message
-  --no-create             do not create output files
-  --quiet, --silent       do not print \`checking...' messages
-  --version               print the version of autoconf that created configure
-Directory and file names:
-  --prefix=PREFIX         install architecture-independent files in PREFIX
-                          [$ac_default_prefix]
-  --exec-prefix=EPREFIX   install architecture-dependent files in EPREFIX
-                          [same as prefix]
-  --bindir=DIR            user executables in DIR [EPREFIX/bin]
-  --sbindir=DIR           system admin executables in DIR [EPREFIX/sbin]
-  --libexecdir=DIR        program executables in DIR [EPREFIX/libexec]
-  --datadir=DIR           read-only architecture-independent data in DIR
-                          [PREFIX/share]
-  --sysconfdir=DIR        read-only single-machine data in DIR [PREFIX/etc]
-  --sharedstatedir=DIR    modifiable architecture-independent data in DIR
-                          [PREFIX/com]
-  --localstatedir=DIR     modifiable single-machine data in DIR [PREFIX/var]
-  --libdir=DIR            object code libraries in DIR [EPREFIX/lib]
-  --includedir=DIR        C header files in DIR [PREFIX/include]
-  --oldincludedir=DIR     C header files for non-gcc in DIR [/usr/include]
-  --infodir=DIR           info documentation in DIR [PREFIX/info]
-  --mandir=DIR            man documentation in DIR [PREFIX/man]
-  --srcdir=DIR            find the sources in DIR [configure dir or ..]
-  --program-prefix=PREFIX prepend PREFIX to installed program names
-  --program-suffix=SUFFIX append SUFFIX to installed program names
-  --program-transform-name=PROGRAM
-                          run sed PROGRAM on installed program names
-EOF
-    cat << EOF
-Host type:
-  --build=BUILD           configure for building on BUILD [BUILD=HOST]
-  --host=HOST             configure for HOST [guessed]
-  --target=TARGET         configure for TARGET [TARGET=HOST]
-Features and packages:
-  --disable-FEATURE       do not include FEATURE (same as --enable-FEATURE=no)
-  --enable-FEATURE[=ARG]  include FEATURE [ARG=yes]
-  --with-PACKAGE[=ARG]    use PACKAGE [ARG=yes]
-  --without-PACKAGE       do not use PACKAGE (same as --with-PACKAGE=no)
-  --x-includes=DIR        X include files are in DIR
-  --x-libraries=DIR       X library files are in DIR
-EOF
-    if test -n "$ac_help"; then
-      echo "--enable and --with options recognized:$ac_help"
-    fi
-    exit 0 ;;
+  -help | --help | --hel | --he | -h)
+    ac_init_help=long ;;
+  -help=r* | --help=r* | --hel=r* | --he=r* | -hr*)
+    ac_init_help=recursive ;;
+  -help=s* | --help=s* | --hel=s* | --he=s* | -hs*)
+    ac_init_help=short ;;
 
   -host | --host | --hos | --ho)
-    ac_prev=host ;;
+    ac_prev=host_alias ;;
   -host=* | --host=* | --hos=* | --ho=*)
-    host="$ac_optarg" ;;
+    host_alias=$ac_optarg ;;
 
   -includedir | --includedir | --includedi | --included | --include \
   | --includ | --inclu | --incl | --inc)
     ac_prev=includedir ;;
   -includedir=* | --includedir=* | --includedi=* | --included=* | --include=* \
   | --includ=* | --inclu=* | --incl=* | --inc=*)
-    includedir="$ac_optarg" ;;
+    includedir=$ac_optarg ;;
 
   -infodir | --infodir | --infodi | --infod | --info | --inf)
     ac_prev=infodir ;;
   -infodir=* | --infodir=* | --infodi=* | --infod=* | --info=* | --inf=*)
-    infodir="$ac_optarg" ;;
+    infodir=$ac_optarg ;;
 
   -libdir | --libdir | --libdi | --libd)
     ac_prev=libdir ;;
   -libdir=* | --libdir=* | --libdi=* | --libd=*)
-    libdir="$ac_optarg" ;;
+    libdir=$ac_optarg ;;
 
   -libexecdir | --libexecdir | --libexecdi | --libexecd | --libexec \
   | --libexe | --libex | --libe)
     ac_prev=libexecdir ;;
   -libexecdir=* | --libexecdir=* | --libexecdi=* | --libexecd=* | --libexec=* \
   | --libexe=* | --libex=* | --libe=*)
-    libexecdir="$ac_optarg" ;;
+    libexecdir=$ac_optarg ;;
 
   -localstatedir | --localstatedir | --localstatedi | --localstated \
   | --localstate | --localstat | --localsta | --localst \
@@ -314,12 +310,12 @@ EOF
   -localstatedir=* | --localstatedir=* | --localstatedi=* | --localstated=* \
   | --localstate=* | --localstat=* | --localsta=* | --localst=* \
   | --locals=* | --local=* | --loca=* | --loc=* | --lo=*)
-    localstatedir="$ac_optarg" ;;
+    localstatedir=$ac_optarg ;;
 
   -mandir | --mandir | --mandi | --mand | --man | --ma | --m)
     ac_prev=mandir ;;
   -mandir=* | --mandir=* | --mandi=* | --mand=* | --man=* | --ma=* | --m=*)
-    mandir="$ac_optarg" ;;
+    mandir=$ac_optarg ;;
 
   -nfp | --nfp | --nf)
     # Obsolete; use --without-fp.
@@ -340,26 +336,26 @@ EOF
   -oldincludedir=* | --oldincludedir=* | --oldincludedi=* | --oldincluded=* \
   | --oldinclude=* | --oldinclud=* | --oldinclu=* | --oldincl=* | --oldinc=* \
   | --oldin=* | --oldi=* | --old=* | --ol=* | --o=*)
-    oldincludedir="$ac_optarg" ;;
+    oldincludedir=$ac_optarg ;;
 
   -prefix | --prefix | --prefi | --pref | --pre | --pr | --p)
     ac_prev=prefix ;;
   -prefix=* | --prefix=* | --prefi=* | --pref=* | --pre=* | --pr=* | --p=*)
-    prefix="$ac_optarg" ;;
+    prefix=$ac_optarg ;;
 
   -program-prefix | --program-prefix | --program-prefi | --program-pref \
   | --program-pre | --program-pr | --program-p)
     ac_prev=program_prefix ;;
   -program-prefix=* | --program-prefix=* | --program-prefi=* \
   | --program-pref=* | --program-pre=* | --program-pr=* | --program-p=*)
-    program_prefix="$ac_optarg" ;;
+    program_prefix=$ac_optarg ;;
 
   -program-suffix | --program-suffix | --program-suffi | --program-suff \
   | --program-suf | --program-su | --program-s)
     ac_prev=program_suffix ;;
   -program-suffix=* | --program-suffix=* | --program-suffi=* \
   | --program-suff=* | --program-suf=* | --program-su=* | --program-s=*)
-    program_suffix="$ac_optarg" ;;
+    program_suffix=$ac_optarg ;;
 
   -program-transform-name | --program-transform-name \
   | --program-transform-nam | --program-transform-na \
@@ -376,7 +372,7 @@ EOF
   | --program-transfo=* | --program-transf=* \
   | --program-trans=* | --program-tran=* \
   | --progr-tra=* | --program-tr=* | --program-t=*)
-    program_transform_name="$ac_optarg" ;;
+    program_transform_name=$ac_optarg ;;
 
   -q | -quiet | --quiet | --quie | --qui | --qu | --q \
   | -silent | --silent | --silen | --sile | --sil)
@@ -386,7 +382,7 @@ EOF
     ac_prev=sbindir ;;
   -sbindir=* | --sbindir=* | --sbindi=* | --sbind=* | --sbin=* \
   | --sbi=* | --sb=*)
-    sbindir="$ac_optarg" ;;
+    sbindir=$ac_optarg ;;
 
   -sharedstatedir | --sharedstatedir | --sharedstatedi \
   | --sharedstated | --sharedstate | --sharedstat | --sharedsta \
@@ -397,58 +393,57 @@ EOF
   | --sharedstated=* | --sharedstate=* | --sharedstat=* | --sharedsta=* \
   | --sharedst=* | --shareds=* | --shared=* | --share=* | --shar=* \
   | --sha=* | --sh=*)
-    sharedstatedir="$ac_optarg" ;;
+    sharedstatedir=$ac_optarg ;;
 
   -site | --site | --sit)
     ac_prev=site ;;
   -site=* | --site=* | --sit=*)
-    site="$ac_optarg" ;;
+    site=$ac_optarg ;;
 
   -srcdir | --srcdir | --srcdi | --srcd | --src | --sr)
     ac_prev=srcdir ;;
   -srcdir=* | --srcdir=* | --srcdi=* | --srcd=* | --src=* | --sr=*)
-    srcdir="$ac_optarg" ;;
+    srcdir=$ac_optarg ;;
 
   -sysconfdir | --sysconfdir | --sysconfdi | --sysconfd | --sysconf \
   | --syscon | --sysco | --sysc | --sys | --sy)
     ac_prev=sysconfdir ;;
   -sysconfdir=* | --sysconfdir=* | --sysconfdi=* | --sysconfd=* | --sysconf=* \
   | --syscon=* | --sysco=* | --sysc=* | --sys=* | --sy=*)
-    sysconfdir="$ac_optarg" ;;
+    sysconfdir=$ac_optarg ;;
 
   -target | --target | --targe | --targ | --tar | --ta | --t)
-    ac_prev=target ;;
+    ac_prev=target_alias ;;
   -target=* | --target=* | --targe=* | --targ=* | --tar=* | --ta=* | --t=*)
-    target="$ac_optarg" ;;
+    target_alias=$ac_optarg ;;
 
   -v | -verbose | --verbose | --verbos | --verbo | --verb)
     verbose=yes ;;
 
-  -version | --version | --versio | --versi | --vers)
-    echo "configure generated by autoconf version 2.12"
-    exit 0 ;;
+  -version | --version | --versio | --versi | --vers | -V)
+    ac_init_version=: ;;
 
   -with-* | --with-*)
-    ac_package=`echo $ac_option|sed -e 's/-*with-//' -e 's/=.*//'`
+    ac_package=`expr "x$ac_option" : 'x-*with-\([^=]*\)'`
     # Reject names that are not valid shell variable names.
-    if test -n "`echo $ac_package| sed 's/[-_a-zA-Z0-9]//g'`"; then
-      { echo "configure: error: $ac_package: invalid package name" 1>&2; exit 1; }
-    fi
+    expr "x$ac_package" : ".*[^-_$as_cr_alnum]" >/dev/null &&
+      { echo "$as_me: error: invalid package name: $ac_package" >&2
+   { (exit 1); exit 1; }; }
     ac_package=`echo $ac_package| sed 's/-/_/g'`
-    case "$ac_option" in
-      *=*) ;;
+    case $ac_option in
+      *=*) ac_optarg=`echo "$ac_optarg" | sed "s/'/'\\\\\\\\''/g"`;;
       *) ac_optarg=yes ;;
     esac
-    eval "with_${ac_package}='$ac_optarg'" ;;
+    eval "with_$ac_package='$ac_optarg'" ;;
 
   -without-* | --without-*)
-    ac_package=`echo $ac_option|sed -e 's/-*without-//'`
+    ac_package=`expr "x$ac_option" : 'x-*without-\(.*\)'`
     # Reject names that are not valid shell variable names.
-    if test -n "`echo $ac_package| sed 's/[-a-zA-Z0-9_]//g'`"; then
-      { echo "configure: error: $ac_package: invalid package name" 1>&2; exit 1; }
-    fi
-    ac_package=`echo $ac_package| sed 's/-/_/g'`
-    eval "with_${ac_package}=no" ;;
+    expr "x$ac_package" : ".*[^-_$as_cr_alnum]" >/dev/null &&
+      { echo "$as_me: error: invalid package name: $ac_package" >&2
+   { (exit 1); exit 1; }; }
+    ac_package=`echo $ac_package | sed 's/-/_/g'`
+    eval "with_$ac_package=no" ;;
 
   --x)
     # Obsolete; use --with-x.
@@ -459,98 +454,98 @@ EOF
     ac_prev=x_includes ;;
   -x-includes=* | --x-includes=* | --x-include=* | --x-includ=* | --x-inclu=* \
   | --x-incl=* | --x-inc=* | --x-in=* | --x-i=*)
-    x_includes="$ac_optarg" ;;
+    x_includes=$ac_optarg ;;
 
   -x-libraries | --x-libraries | --x-librarie | --x-librari \
   | --x-librar | --x-libra | --x-libr | --x-lib | --x-li | --x-l)
     ac_prev=x_libraries ;;
   -x-libraries=* | --x-libraries=* | --x-librarie=* | --x-librari=* \
   | --x-librar=* | --x-libra=* | --x-libr=* | --x-lib=* | --x-li=* | --x-l=*)
-    x_libraries="$ac_optarg" ;;
+    x_libraries=$ac_optarg ;;
 
-  -*) { echo "configure: error: $ac_option: invalid option; use --help to show usage" 1>&2; exit 1; }
+  -*) { echo "$as_me: error: unrecognized option: $ac_option
+Try \`$0 --help' for more information." >&2
+   { (exit 1); exit 1; }; }
     ;;
 
+  *=*)
+    ac_envvar=`expr "x$ac_option" : 'x\([^=]*\)='`
+    # Reject names that are not valid shell variable names.
+    expr "x$ac_envvar" : ".*[^_$as_cr_alnum]" >/dev/null &&
+      { echo "$as_me: error: invalid variable name: $ac_envvar" >&2
+   { (exit 1); exit 1; }; }
+    ac_optarg=`echo "$ac_optarg" | sed "s/'/'\\\\\\\\''/g"`
+    eval "$ac_envvar='$ac_optarg'"
+    export $ac_envvar ;;
+
   *)
-    if test -n "`echo $ac_option| sed 's/[-a-z0-9.]//g'`"; then
-      echo "configure: warning: $ac_option: invalid host type" 1>&2
-    fi
-    if test "x$nonopt" != xNONE; then
-      { echo "configure: error: can only configure for one host and one target at a time" 1>&2; exit 1; }
-    fi
-    nonopt="$ac_option"
+    # FIXME: should be removed in autoconf 3.0.
+    echo "$as_me: WARNING: you should use --build, --host, --target" >&2
+    expr "x$ac_option" : ".*[^-._$as_cr_alnum]" >/dev/null &&
+      echo "$as_me: WARNING: invalid host type: $ac_option" >&2
+    : ${build_alias=$ac_option} ${host_alias=$ac_option} ${target_alias=$ac_option}
     ;;
 
   esac
 done
 
 if test -n "$ac_prev"; then
-  { echo "configure: error: missing argument to --`echo $ac_prev | sed 's/_/-/g'`" 1>&2; exit 1; }
-fi
-
-trap 'rm -fr conftest* confdefs* core core.* *.core $ac_clean_files; exit 1' 1 2 15
-
-# File descriptor usage:
-# 0 standard input
-# 1 file creation
-# 2 errors and warnings
-# 3 some systems may open it to /dev/tty
-# 4 used on the Kubota Titan
-# 6 checking for... messages and results
-# 5 compiler messages saved in config.log
-if test "$silent" = yes; then
-  exec 6>/dev/null
-else
-  exec 6>&1
+  ac_option=--`echo $ac_prev | sed 's/_/-/g'`
+  { echo "$as_me: error: missing argument to $ac_option" >&2
+   { (exit 1); exit 1; }; }
 fi
-exec 5>./config.log
 
-echo "\
-This file contains any messages produced by compilers while
-running configure, to aid debugging if configure makes a mistake.
-" 1>&5
+# Be sure to have absolute paths.
+for ac_var in exec_prefix prefix
+do
+  eval ac_val=$`echo $ac_var`
+  case $ac_val in
+    [\\/$]* | ?:[\\/]* | NONE | '' ) ;;
+    *)  { echo "$as_me: error: expected an absolute path for --$ac_var: $ac_val" >&2
+   { (exit 1); exit 1; }; };;
+  esac
+done
 
-# Strip out --no-create and --no-recursion so they do not pile up.
-# Also quote any args containing shell metacharacters.
-ac_configure_args=
-for ac_arg
+# Be sure to have absolute paths.
+for ac_var in bindir sbindir libexecdir datadir sysconfdir sharedstatedir \
+              localstatedir libdir includedir oldincludedir infodir mandir
 do
-  case "$ac_arg" in
-  -no-create | --no-create | --no-creat | --no-crea | --no-cre \
-  | --no-cr | --no-c) ;;
-  -no-recursion | --no-recursion | --no-recursio | --no-recursi \
-  | --no-recurs | --no-recur | --no-recu | --no-rec | --no-re | --no-r) ;;
-  *" "*|*"	"*|*[\[\]\~\#\$\^\&\*\(\)\{\}\\\|\;\<\>\?]*)
-  ac_configure_args="$ac_configure_args '$ac_arg'" ;;
-  *) ac_configure_args="$ac_configure_args $ac_arg" ;;
+  eval ac_val=$`echo $ac_var`
+  case $ac_val in
+    [\\/$]* | ?:[\\/]* ) ;;
+    *)  { echo "$as_me: error: expected an absolute path for --$ac_var: $ac_val" >&2
+   { (exit 1); exit 1; }; };;
   esac
 done
 
-# NLS nuisances.
-# Only set these to C if already set.  These must not be set unconditionally
-# because not all systems understand e.g. LANG=C (notably SCO).
-# Fixing LC_MESSAGES prevents Solaris sh from translating var values in `set'!
-# Non-C LC_CTYPE values break the ctype check.
-if test "${LANG+set}"   = set; then LANG=C;   export LANG;   fi
-if test "${LC_ALL+set}" = set; then LC_ALL=C; export LC_ALL; fi
-if test "${LC_MESSAGES+set}" = set; then LC_MESSAGES=C; export LC_MESSAGES; fi
-if test "${LC_CTYPE+set}"    = set; then LC_CTYPE=C;    export LC_CTYPE;    fi
+# There might be people who depend on the old broken behavior: `$host'
+# used to hold the argument of --host etc.
+build=$build_alias
+host=$host_alias
+target=$target_alias
+
+# FIXME: should be removed in autoconf 3.0.
+if test "x$host_alias" != x; then
+  if test "x$build_alias" = x; then
+    cross_compiling=maybe
+    echo "$as_me: WARNING: If you wanted to set the --build type, don't use --host.
+    If a cross compiler is detected then cross compile mode will be used." >&2
+  elif test "x$build_alias" != "x$host_alias"; then
+    cross_compiling=yes
+  fi
+fi
 
-# confdefs.h avoids OS command line length limits that DEFS can exceed.
-rm -rf conftest* confdefs.h
-# AIX cpp loses on an empty file, so make sure it contains at least a newline.
-echo > confdefs.h
+ac_tool_prefix=
+test -n "$host_alias" && ac_tool_prefix=$host_alias-
 
-# A filename unique to this package, relative to the directory that
-# configure is in, which we can look for to find out if srcdir is correct.
-ac_unique_file=readline.h
+test "$silent" = yes && exec 6>/dev/null
 
 # Find the source files, if location was not specified.
 if test -z "$srcdir"; then
   ac_srcdir_defaulted=yes
   # Try the directory containing this script, then its parent.
   ac_prog=$0
-  ac_confdir=`echo $ac_prog|sed 's%/[^/][^/]*$%%'`
+  ac_confdir=`echo "$ac_prog" | sed 's%[\\/][^\\/][^\\/]*$%%'`
   test "x$ac_confdir" = "x$ac_prog" && ac_confdir=.
   srcdir=$ac_confdir
   if test ! -r $srcdir/$ac_unique_file; then
@@ -561,13 +556,316 @@ else
 fi
 if test ! -r $srcdir/$ac_unique_file; then
   if test "$ac_srcdir_defaulted" = yes; then
-    { echo "configure: error: can not find sources in $ac_confdir or .." 1>&2; exit 1; }
+    { echo "$as_me: error: cannot find sources in $ac_confdir or .." >&2
+   { (exit 1); exit 1; }; }
   else
-    { echo "configure: error: can not find sources in $srcdir" 1>&2; exit 1; }
+    { echo "$as_me: error: cannot find sources in $srcdir" >&2
+   { (exit 1); exit 1; }; }
   fi
 fi
-srcdir=`echo "${srcdir}" | sed 's%\([^/]\)/*$%\1%'`
+srcdir=`echo "$srcdir" | sed 's%\([^\\/]\)[\\/]*$%\1%'`
+ac_env_build_alias_set=${build_alias+set}
+ac_env_build_alias_value=$build_alias
+ac_cv_env_build_alias_set=${build_alias+set}
+ac_cv_env_build_alias_value=$build_alias
+ac_env_host_alias_set=${host_alias+set}
+ac_env_host_alias_value=$host_alias
+ac_cv_env_host_alias_set=${host_alias+set}
+ac_cv_env_host_alias_value=$host_alias
+ac_env_target_alias_set=${target_alias+set}
+ac_env_target_alias_value=$target_alias
+ac_cv_env_target_alias_set=${target_alias+set}
+ac_cv_env_target_alias_value=$target_alias
+ac_env_CC_set=${CC+set}
+ac_env_CC_value=$CC
+ac_cv_env_CC_set=${CC+set}
+ac_cv_env_CC_value=$CC
+ac_env_CFLAGS_set=${CFLAGS+set}
+ac_env_CFLAGS_value=$CFLAGS
+ac_cv_env_CFLAGS_set=${CFLAGS+set}
+ac_cv_env_CFLAGS_value=$CFLAGS
+ac_env_LDFLAGS_set=${LDFLAGS+set}
+ac_env_LDFLAGS_value=$LDFLAGS
+ac_cv_env_LDFLAGS_set=${LDFLAGS+set}
+ac_cv_env_LDFLAGS_value=$LDFLAGS
+ac_env_CPPFLAGS_set=${CPPFLAGS+set}
+ac_env_CPPFLAGS_value=$CPPFLAGS
+ac_cv_env_CPPFLAGS_set=${CPPFLAGS+set}
+ac_cv_env_CPPFLAGS_value=$CPPFLAGS
+ac_env_CPP_set=${CPP+set}
+ac_env_CPP_value=$CPP
+ac_cv_env_CPP_set=${CPP+set}
+ac_cv_env_CPP_value=$CPP
+
+#
+# Report the --help message.
+#
+if test "$ac_init_help" = "long"; then
+  # Omit some internal or obsolete options to make the list less imposing.
+  # This message is too long to be a string in the A/UX 3.1 sh.
+  cat <<EOF
+\`configure' configures readline 4.3 to adapt to many kinds of systems.
+
+Usage: $0 [OPTION]... [VAR=VALUE]...
+
+To assign environment variables (e.g., CC, CFLAGS...), specify them as
+VAR=VALUE.  See below for descriptions of some of the useful variables.
+
+Defaults for the options are specified in brackets.
+
+Configuration:
+  -h, --help              display this help and exit
+      --help=short        display options specific to this package
+      --help=recursive    display the short help of all the included packages
+  -V, --version           display version information and exit
+  -q, --quiet, --silent   do not print \`checking...' messages
+      --cache-file=FILE   cache test results in FILE [disabled]
+  -C, --config-cache      alias for \`--cache-file=config.cache'
+  -n, --no-create         do not create output files
+      --srcdir=DIR        find the sources in DIR [configure dir or \`..']
+
+EOF
+
+  cat <<EOF
+Installation directories:
+  --prefix=PREFIX         install architecture-independent files in PREFIX
+                          [$ac_default_prefix]
+  --exec-prefix=EPREFIX   install architecture-dependent files in EPREFIX
+                          [PREFIX]
+
+By default, \`make install' will install all the files in
+\`$ac_default_prefix/bin', \`$ac_default_prefix/lib' etc.  You can specify
+an installation prefix other than \`$ac_default_prefix' using \`--prefix',
+for instance \`--prefix=\$HOME'.
+
+For better control, use the options below.
+
+Fine tuning of the installation directories:
+  --bindir=DIR           user executables [EPREFIX/bin]
+  --sbindir=DIR          system admin executables [EPREFIX/sbin]
+  --libexecdir=DIR       program executables [EPREFIX/libexec]
+  --datadir=DIR          read-only architecture-independent data [PREFIX/share]
+  --sysconfdir=DIR       read-only single-machine data [PREFIX/etc]
+  --sharedstatedir=DIR   modifiable architecture-independent data [PREFIX/com]
+  --localstatedir=DIR    modifiable single-machine data [PREFIX/var]
+  --libdir=DIR           object code libraries [EPREFIX/lib]
+  --includedir=DIR       C header files [PREFIX/include]
+  --oldincludedir=DIR    C header files for non-gcc [/usr/include]
+  --infodir=DIR          info documentation [PREFIX/info]
+  --mandir=DIR           man documentation [PREFIX/man]
+EOF
+
+  cat <<\EOF
+
+System types:
+  --build=BUILD     configure for building on BUILD [guessed]
+  --host=HOST       build programs to run on HOST [BUILD]
+EOF
+fi
+
+if test -n "$ac_init_help"; then
+  case $ac_init_help in
+     short | recursive ) echo "Configuration of readline 4.3:";;
+   esac
+  cat <<\EOF
+
+Optional Features:
+  --disable-FEATURE       do not include FEATURE (same as --enable-FEATURE=no)
+  --enable-FEATURE[=ARG]  include FEATURE [ARG=yes]
+  --enable-shared         build shared libraries [default=YES]
+  --enable-static         build static libraries [default=YES]
+
+Optional Packages:
+  --with-PACKAGE[=ARG]    use PACKAGE [ARG=yes]
+  --without-PACKAGE       do not use PACKAGE (same as --with-PACKAGE=no)
+  --with-curses           use the curses library instead of the termcap
+                          library
+
+Some influential environment variables:
+  CC          C compiler command
+  CFLAGS      C compiler flags
+  LDFLAGS     linker flags, e.g. -L<lib dir> if you have libraries in a
+              nonstandard directory <lib dir>
+  CPPFLAGS    C/C++ preprocessor flags, e.g. -I<include dir> if you have
+              headers in a nonstandard directory <include dir>
+  CPP         C preprocessor
+
+Use these variables to override the choices made by `configure' or to help
+it to find libraries and programs with nonstandard names/locations.
+
+Report bugs to <bug-readline@gnu.org>.
+EOF
+fi
+
+if test "$ac_init_help" = "recursive"; then
+  # If there are subdirs, report their specific --help.
+  ac_popdir=`pwd`
+  for ac_subdir in : $ac_subdirs_all; do test "x$ac_subdir" = x: && continue
+    cd $ac_subdir
+    # A "../" for each directory in /$ac_subdir.
+    ac_dots=`echo $ac_subdir |
+             sed 's,^\./,,;s,[^/]$,&/,;s,[^/]*/,../,g'`
+
+    case $srcdir in
+    .) # No --srcdir option.  We are building in place.
+      ac_sub_srcdir=$srcdir ;;
+    [\\/]* | ?:[\\/]* ) # Absolute path.
+      ac_sub_srcdir=$srcdir/$ac_subdir ;;
+    *) # Relative path.
+      ac_sub_srcdir=$ac_dots$srcdir/$ac_subdir ;;
+    esac
+
+    # Check for guested configure; otherwise get Cygnus style configure.
+    if test -f $ac_sub_srcdir/configure.gnu; then
+      echo
+      $SHELL $ac_sub_srcdir/configure.gnu  --help=recursive
+    elif test -f $ac_sub_srcdir/configure; then
+      echo
+      $SHELL $ac_sub_srcdir/configure  --help=recursive
+    elif test -f $ac_sub_srcdir/configure.ac ||
+           test -f $ac_sub_srcdir/configure.in; then
+      echo
+      $ac_configure --help
+    else
+      echo "$as_me: WARNING: no configuration information is in $ac_subdir" >&2
+    fi
+    cd $ac_popdir
+  done
+fi
+
+test -n "$ac_init_help" && exit 0
+if $ac_init_version; then
+  cat <<\EOF
+readline configure 4.3
+generated by GNU Autoconf 2.52
+
+Copyright 1992, 1993, 1994, 1995, 1996, 1998, 1999, 2000, 2001
+Free Software Foundation, Inc.
+This configure script is free software; the Free Software Foundation
+gives unlimited permission to copy, distribute and modify it.
+EOF
+  exit 0
+fi
+exec 5>config.log
+cat >&5 <<EOF
+This file contains any messages produced by compilers while
+running configure, to aid debugging if configure makes a mistake.
+
+It was created by readline $as_me 4.3, which was
+generated by GNU Autoconf 2.52.  Invocation command line was
+
+  $ $0 $@
+
+EOF
+{
+cat <<_ASUNAME
+## ---------- ##
+## Platform.  ##
+## ---------- ##
+
+hostname = `(hostname || uname -n) 2>/dev/null | sed 1q`
+uname -m = `(uname -m) 2>/dev/null || echo unknown`
+uname -r = `(uname -r) 2>/dev/null || echo unknown`
+uname -s = `(uname -s) 2>/dev/null || echo unknown`
+uname -v = `(uname -v) 2>/dev/null || echo unknown`
+
+/usr/bin/uname -p = `(/usr/bin/uname -p) 2>/dev/null || echo unknown`
+/bin/uname -X     = `(/bin/uname -X) 2>/dev/null     || echo unknown`
+
+/bin/arch              = `(/bin/arch) 2>/dev/null              || echo unknown`
+/usr/bin/arch -k       = `(/usr/bin/arch -k) 2>/dev/null       || echo unknown`
+/usr/convex/getsysinfo = `(/usr/convex/getsysinfo) 2>/dev/null || echo unknown`
+hostinfo               = `(hostinfo) 2>/dev/null               || echo unknown`
+/bin/machine           = `(/bin/machine) 2>/dev/null           || echo unknown`
+/usr/bin/oslevel       = `(/usr/bin/oslevel) 2>/dev/null       || echo unknown`
+/bin/universe          = `(/bin/universe) 2>/dev/null          || echo unknown`
+
+PATH = $PATH
+
+_ASUNAME
+} >&5
+
+cat >&5 <<EOF
+## ------------ ##
+## Core tests.  ##
+## ------------ ##
+
+EOF
+
+# Keep a trace of the command line.
+# Strip out --no-create and --no-recursion so they do not pile up.
+# Also quote any args containing shell meta-characters.
+ac_configure_args=
+ac_sep=
+for ac_arg
+do
+  case $ac_arg in
+  -no-create | --no-create | --no-creat | --no-crea | --no-cre \
+  | --no-cr | --no-c) ;;
+  -no-recursion | --no-recursion | --no-recursio | --no-recursi \
+  | --no-recurs | --no-recur | --no-recu | --no-rec | --no-re | --no-r) ;;
+  *" "*|*"	"*|*[\[\]\~\#\$\^\&\*\(\)\{\}\\\|\;\<\>\?\"\']*)
+    ac_arg=`echo "$ac_arg" | sed "s/'/'\\\\\\\\''/g"`
+    ac_configure_args="$ac_configure_args$ac_sep'$ac_arg'"
+    ac_sep=" " ;;
+  *) ac_configure_args="$ac_configure_args$ac_sep$ac_arg"
+     ac_sep=" " ;;
+  esac
+  # Get rid of the leading space.
+done
 
+# When interrupted or exit'd, cleanup temporary files, and complete
+# config.log.  We remove comments because anyway the quotes in there
+# would cause problems or look ugly.
+trap 'exit_status=$?
+  # Save into config.log some information that might help in debugging.
+  echo >&5
+  echo "## ----------------- ##" >&5
+  echo "## Cache variables.  ##" >&5
+  echo "## ----------------- ##" >&5
+  echo >&5
+  # The following way of writing the cache mishandles newlines in values,
+{
+  (set) 2>&1 |
+    case `(ac_space='"'"' '"'"'; set | grep ac_space) 2>&1` in
+    *ac_space=\ *)
+      sed -n \
+        "s/'"'"'/'"'"'\\\\'"'"''"'"'/g;
+    	  s/^\\([_$as_cr_alnum]*_cv_[_$as_cr_alnum]*\\)=\\(.*\\)/\\1='"'"'\\2'"'"'/p"
+      ;;
+    *)
+      sed -n \
+        "s/^\\([_$as_cr_alnum]*_cv_[_$as_cr_alnum]*\\)=\\(.*\\)/\\1=\\2/p"
+      ;;
+    esac;
+} >&5
+  sed "/^$/d" confdefs.h >conftest.log
+  if test -s conftest.log; then
+    echo >&5
+    echo "## ------------ ##" >&5
+    echo "## confdefs.h.  ##" >&5
+    echo "## ------------ ##" >&5
+    echo >&5
+    cat conftest.log >&5
+  fi
+  (echo; echo) >&5
+  test "$ac_signal" != 0 &&
+    echo "$as_me: caught signal $ac_signal" >&5
+  echo "$as_me: exit $exit_status" >&5
+  rm -rf conftest* confdefs* core core.* *.core conf$$* $ac_clean_files &&
+    exit $exit_status
+     ' 0
+for ac_signal in 1 2 13 15; do
+  trap 'ac_signal='$ac_signal'; { (exit 1); exit 1; }' $ac_signal
+done
+ac_signal=0
+
+# confdefs.h avoids OS command line length limits that DEFS can exceed.
+rm -rf conftest* confdefs.h
+# AIX cpp loses on an empty file, so make sure it contains at least a newline.
+echo >confdefs.h
+
+# Let the site file select an alternate cache file if it wants to.
 # Prefer explicitly selected file to automatically selected ones.
 if test -z "$CONFIG_SITE"; then
   if test "x$prefix" != xNONE; then
@@ -578,42 +876,107 @@ if test -z "$CONFIG_SITE"; then
 fi
 for ac_site_file in $CONFIG_SITE; do
   if test -r "$ac_site_file"; then
-    echo "loading site script $ac_site_file"
+    { echo "$as_me:879: loading site script $ac_site_file" >&5
+echo "$as_me: loading site script $ac_site_file" >&6;}
+    cat "$ac_site_file" >&5
     . "$ac_site_file"
   fi
 done
 
 if test -r "$cache_file"; then
-  echo "loading cache $cache_file"
-  . $cache_file
+  # Some versions of bash will fail to source /dev/null (special
+  # files actually), so we avoid doing that.
+  if test -f "$cache_file"; then
+    { echo "$as_me:890: loading cache $cache_file" >&5
+echo "$as_me: loading cache $cache_file" >&6;}
+    case $cache_file in
+      [\\/]* | ?:[\\/]* ) . $cache_file;;
+      *)                      . ./$cache_file;;
+    esac
+  fi
 else
-  echo "creating cache $cache_file"
-  > $cache_file
+  { echo "$as_me:898: creating cache $cache_file" >&5
+echo "$as_me: creating cache $cache_file" >&6;}
+  >$cache_file
+fi
+
+# Check that the precious variables saved in the cache have kept the same
+# value.
+ac_cache_corrupted=false
+for ac_var in `(set) 2>&1 |
+               sed -n 's/^ac_env_\([a-zA-Z_0-9]*\)_set=.*/\1/p'`; do
+  eval ac_old_set=\$ac_cv_env_${ac_var}_set
+  eval ac_new_set=\$ac_env_${ac_var}_set
+  eval ac_old_val="\$ac_cv_env_${ac_var}_value"
+  eval ac_new_val="\$ac_env_${ac_var}_value"
+  case $ac_old_set,$ac_new_set in
+    set,)
+      { echo "$as_me:914: error: \`$ac_var' was set to \`$ac_old_val' in the previous run" >&5
+echo "$as_me: error: \`$ac_var' was set to \`$ac_old_val' in the previous run" >&2;}
+      ac_cache_corrupted=: ;;
+    ,set)
+      { echo "$as_me:918: error: \`$ac_var' was not set in the previous run" >&5
+echo "$as_me: error: \`$ac_var' was not set in the previous run" >&2;}
+      ac_cache_corrupted=: ;;
+    ,);;
+    *)
+      if test "x$ac_old_val" != "x$ac_new_val"; then
+        { echo "$as_me:924: error: \`$ac_var' has changed since the previous run:" >&5
+echo "$as_me: error: \`$ac_var' has changed since the previous run:" >&2;}
+        { echo "$as_me:926:   former value:  $ac_old_val" >&5
+echo "$as_me:   former value:  $ac_old_val" >&2;}
+        { echo "$as_me:928:   current value: $ac_new_val" >&5
+echo "$as_me:   current value: $ac_new_val" >&2;}
+        ac_cache_corrupted=:
+      fi;;
+  esac
+  # Pass precious variables to config.status.  It doesn't matter if
+  # we pass some twice (in addition to the command line arguments).
+  if test "$ac_new_set" = set; then
+    case $ac_new_val in
+    *" "*|*"	"*|*[\[\]\~\#\$\^\&\*\(\)\{\}\\\|\;\<\>\?\"\']*)
+      ac_arg=$ac_var=`echo "$ac_new_val" | sed "s/'/'\\\\\\\\''/g"`
+      ac_configure_args="$ac_configure_args '$ac_arg'"
+      ;;
+    *) ac_configure_args="$ac_configure_args $ac_var=$ac_new_val"
+       ;;
+    esac
+  fi
+done
+if $ac_cache_corrupted; then
+  { echo "$as_me:947: error: changes in the environment can compromise the build" >&5
+echo "$as_me: error: changes in the environment can compromise the build" >&2;}
+  { { echo "$as_me:949: error: run \`make distclean' and/or \`rm $cache_file' and start over" >&5
+echo "$as_me: error: run \`make distclean' and/or \`rm $cache_file' and start over" >&2;}
+   { (exit 1); exit 1; }; }
 fi
 
 ac_ext=c
-# CFLAGS is not in ac_cpp because -g, -O, etc. are not valid cpp options.
 ac_cpp='$CPP $CPPFLAGS'
-ac_compile='${CC-cc} -c $CFLAGS $CPPFLAGS conftest.$ac_ext 1>&5'
-ac_link='${CC-cc} -o conftest $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS 1>&5'
-cross_compiling=$ac_cv_prog_cc_cross
-
-if (echo "testing\c"; echo 1,2,3) | grep c >/dev/null; then
-  # Stardent Vistra SVR4 grep lacks -e, says ghazi@caip.rutgers.edu.
-  if (echo -n testing; echo 1,2,3) | sed s/-n/xn/ | grep xn >/dev/null; then
-    ac_n= ac_c='
-' ac_t='	'
-  else
-    ac_n=-n ac_c= ac_t=
-  fi
+ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5'
+ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5'
+ac_compiler_gnu=$ac_cv_c_compiler_gnu
+
+case `echo "testing\c"; echo 1,2,3`,`echo -n testing; echo 1,2,3` in
+  *c*,-n*) ECHO_N= ECHO_C='
+' ECHO_T='	' ;;
+  *c*,*  ) ECHO_N=-n ECHO_C= ECHO_T= ;;
+  *)      ECHO_N= ECHO_C='\c' ECHO_T= ;;
+esac
+echo "#! $SHELL" >conftest.sh
+echo  "exit 0"   >>conftest.sh
+chmod +x conftest.sh
+if { (echo "$as_me:969: PATH=\".;.\"; conftest.sh") >&5
+  (PATH=".;."; conftest.sh) 2>&5
+  ac_status=$?
+  echo "$as_me:972: \$? = $ac_status" >&5
+  (exit $ac_status); }; then
+  ac_path_separator=';'
 else
-  ac_n= ac_c='\c' ac_t=
+  ac_path_separator=:
 fi
-
-
-
-
-
+PATH_SEPARATOR="$ac_path_separator"
+rm -f conftest.sh
 
 ac_aux_dir=
 for ac_dir in ./support $srcdir/./support; do
@@ -625,387 +988,1135 @@ for ac_dir in ./support $srcdir/./support; do
     ac_aux_dir=$ac_dir
     ac_install_sh="$ac_aux_dir/install.sh -c"
     break
+  elif test -f $ac_dir/shtool; then
+    ac_aux_dir=$ac_dir
+    ac_install_sh="$ac_aux_dir/shtool install -c"
+    break
   fi
 done
 if test -z "$ac_aux_dir"; then
-  { echo "configure: error: can not find install-sh or install.sh in ./support $srcdir/./support" 1>&2; exit 1; }
+  { { echo "$as_me:998: error: cannot find install-sh or install.sh in ./support $srcdir/./support" >&5
+echo "$as_me: error: cannot find install-sh or install.sh in ./support $srcdir/./support" >&2;}
+   { (exit 1); exit 1; }; }
 fi
-ac_config_guess=$ac_aux_dir/config.guess
-ac_config_sub=$ac_aux_dir/config.sub
-ac_configure=$ac_aux_dir/configure # This should be Cygnus configure.
+ac_config_guess="$SHELL $ac_aux_dir/config.guess"
+ac_config_sub="$SHELL $ac_aux_dir/config.sub"
+ac_configure="$SHELL $ac_aux_dir/configure" # This should be Cygnus configure.
 
+ac_config_headers="$ac_config_headers config.h"
 
+LIBVERSION=4.3
 
 # Make sure we can run config.sub.
-if $ac_config_sub sun4 >/dev/null 2>&1; then :
-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:646: checking host system type" >&5
-
-host_alias=$host
-case "$host_alias" in
-NONE)
-  case $nonopt in
-  NONE)
-    if host_alias=`$ac_config_guess`; then :
-    else { echo "configure: error: can not guess host type; you must specify one" 1>&2; exit 1; }
-    fi ;;
-  *) host_alias=$nonopt ;;
-  esac ;;
-esac
-
-host=`$ac_config_sub $host_alias`
-host_cpu=`echo $host | sed 's/^\([^-]*\)-\([^-]*\)-\(.*\)$/\1/'`
-host_vendor=`echo $host | sed 's/^\([^-]*\)-\([^-]*\)-\(.*\)$/\2/'`
-host_os=`echo $host | sed 's/^\([^-]*\)-\([^-]*\)-\(.*\)$/\3/'`
-echo "$ac_t""$host" 1>&6
-
+$ac_config_sub sun4 >/dev/null 2>&1 ||
+  { { echo "$as_me:1012: error: cannot run $ac_config_sub" >&5
+echo "$as_me: error: cannot run $ac_config_sub" >&2;}
+   { (exit 1); exit 1; }; }
+
+echo "$as_me:1016: checking build system type" >&5
+echo $ECHO_N "checking build system type... $ECHO_C" >&6
+if test "${ac_cv_build+set}" = set; then
+  echo $ECHO_N "(cached) $ECHO_C" >&6
+else
+  ac_cv_build_alias=$build_alias
+test -z "$ac_cv_build_alias" &&
+  ac_cv_build_alias=`$ac_config_guess`
+test -z "$ac_cv_build_alias" &&
+  { { echo "$as_me:1025: error: cannot guess build type; you must specify one" >&5
+echo "$as_me: error: cannot guess build type; you must specify one" >&2;}
+   { (exit 1); exit 1; }; }
+ac_cv_build=`$ac_config_sub $ac_cv_build_alias` ||
+  { { echo "$as_me:1029: error: $ac_config_sub $ac_cv_build_alias failed." >&5
+echo "$as_me: error: $ac_config_sub $ac_cv_build_alias failed." >&2;}
+   { (exit 1); exit 1; }; }
+
+fi
+echo "$as_me:1034: result: $ac_cv_build" >&5
+echo "${ECHO_T}$ac_cv_build" >&6
+build=$ac_cv_build
+build_cpu=`echo $ac_cv_build | sed 's/^\([^-]*\)-\([^-]*\)-\(.*\)$/\1/'`
+build_vendor=`echo $ac_cv_build | sed 's/^\([^-]*\)-\([^-]*\)-\(.*\)$/\2/'`
+build_os=`echo $ac_cv_build | sed 's/^\([^-]*\)-\([^-]*\)-\(.*\)$/\3/'`
+
+echo "$as_me:1041: checking host system type" >&5
+echo $ECHO_N "checking host system type... $ECHO_C" >&6
+if test "${ac_cv_host+set}" = set; then
+  echo $ECHO_N "(cached) $ECHO_C" >&6
+else
+  ac_cv_host_alias=$host_alias
+test -z "$ac_cv_host_alias" &&
+  ac_cv_host_alias=$ac_cv_build_alias
+ac_cv_host=`$ac_config_sub $ac_cv_host_alias` ||
+  { { echo "$as_me:1050: error: $ac_config_sub $ac_cv_host_alias failed" >&5
+echo "$as_me: error: $ac_config_sub $ac_cv_host_alias failed" >&2;}
+   { (exit 1); exit 1; }; }
+
+fi
+echo "$as_me:1055: result: $ac_cv_host" >&5
+echo "${ECHO_T}$ac_cv_host" >&6
+host=$ac_cv_host
+host_cpu=`echo $ac_cv_host | sed 's/^\([^-]*\)-\([^-]*\)-\(.*\)$/\1/'`
+host_vendor=`echo $ac_cv_host | sed 's/^\([^-]*\)-\([^-]*\)-\(.*\)$/\2/'`
+host_os=`echo $ac_cv_host | sed 's/^\([^-]*\)-\([^-]*\)-\(.*\)$/\3/'`
 
 opt_curses=no
-opt_shared=no
 
 # Check whether --with-curses or --without-curses was given.
 if test "${with_curses+set}" = set; then
   withval="$with_curses"
   opt_curses=$withval
-fi
-
+fi;
 
 if test "$opt_curses" = "yes"; then
 	prefer_curses=yes
 fi
 
+opt_static_libs=yes
+opt_shared_libs=yes
+
+# Check whether --enable-shared or --disable-shared was given.
+if test "${enable_shared+set}" = set; then
+  enableval="$enable_shared"
+  opt_shared_libs=$enableval
+fi;
+# Check whether --enable-static or --disable-static was given.
+if test "${enable_static+set}" = set; then
+  enableval="$enable_static"
+  opt_static_libs=$enableval
+fi;
+
+echo ""
+echo "Beginning configuration for readline-$LIBVERSION for ${host_cpu}-${host_vendor}-${host_os}"
+echo ""
+
 # We want these before the checks, so the checks can modify their values.
 test -z "$CFLAGS" && CFLAGS=-g auto_cflags=1
 
-# Extract the first word of "gcc", so it can be a program name with args.
+echo "$as_me:1095: checking whether ${MAKE-make} sets \${MAKE}" >&5
+echo $ECHO_N "checking whether ${MAKE-make} sets \${MAKE}... $ECHO_C" >&6
+set dummy ${MAKE-make}; ac_make=`echo "$2" | sed 'y,./+-,__p_,'`
+if eval "test \"\${ac_cv_prog_make_${ac_make}_set+set}\" = set"; then
+  echo $ECHO_N "(cached) $ECHO_C" >&6
+else
+  cat >conftest.make <<\EOF
+all:
+	@echo 'ac_maketemp="${MAKE}"'
+EOF
+# GNU make sometimes prints "make[1]: Entering...", which would confuse us.
+eval `${MAKE-make} -f conftest.make 2>/dev/null | grep temp=`
+if test -n "$ac_maketemp"; then
+  eval ac_cv_prog_make_${ac_make}_set=yes
+else
+  eval ac_cv_prog_make_${ac_make}_set=no
+fi
+rm -f conftest.make
+fi
+if eval "test \"`echo '$ac_cv_prog_make_'${ac_make}_set`\" = yes"; then
+  echo "$as_me:1115: result: yes" >&5
+echo "${ECHO_T}yes" >&6
+  SET_MAKE=
+else
+  echo "$as_me:1119: result: no" >&5
+echo "${ECHO_T}no" >&6
+  SET_MAKE="MAKE=${MAKE-make}"
+fi
+
+ac_ext=c
+ac_cpp='$CPP $CPPFLAGS'
+ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5'
+ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5'
+ac_compiler_gnu=$ac_cv_c_compiler_gnu
+if test -n "$ac_tool_prefix"; then
+  # Extract the first word of "${ac_tool_prefix}gcc", so it can be a program name with args.
+set dummy ${ac_tool_prefix}gcc; ac_word=$2
+echo "$as_me:1132: checking for $ac_word" >&5
+echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6
+if test "${ac_cv_prog_CC+set}" = set; then
+  echo $ECHO_N "(cached) $ECHO_C" >&6
+else
+  if test -n "$CC"; then
+  ac_cv_prog_CC="$CC" # Let the user override the test.
+else
+  ac_save_IFS=$IFS; IFS=$ac_path_separator
+ac_dummy="$PATH"
+for ac_dir in $ac_dummy; do
+  IFS=$ac_save_IFS
+  test -z "$ac_dir" && ac_dir=.
+  $as_executable_p "$ac_dir/$ac_word" || continue
+ac_cv_prog_CC="${ac_tool_prefix}gcc"
+echo "$as_me:1147: found $ac_dir/$ac_word" >&5
+break
+done
+
+fi
+fi
+CC=$ac_cv_prog_CC
+if test -n "$CC"; then
+  echo "$as_me:1155: result: $CC" >&5
+echo "${ECHO_T}$CC" >&6
+else
+  echo "$as_me:1158: result: no" >&5
+echo "${ECHO_T}no" >&6
+fi
+
+fi
+if test -z "$ac_cv_prog_CC"; then
+  ac_ct_CC=$CC
+  # 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:687: checking for $ac_word" >&5
-if eval "test \"`echo '$''{'ac_cv_prog_CC'+set}'`\" = set"; then
-  echo $ac_n "(cached) $ac_c" 1>&6
+echo "$as_me:1167: checking for $ac_word" >&5
+echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6
+if test "${ac_cv_prog_ac_ct_CC+set}" = set; then
+  echo $ECHO_N "(cached) $ECHO_C" >&6
+else
+  if test -n "$ac_ct_CC"; then
+  ac_cv_prog_ac_ct_CC="$ac_ct_CC" # Let the user override the test.
+else
+  ac_save_IFS=$IFS; IFS=$ac_path_separator
+ac_dummy="$PATH"
+for ac_dir in $ac_dummy; do
+  IFS=$ac_save_IFS
+  test -z "$ac_dir" && ac_dir=.
+  $as_executable_p "$ac_dir/$ac_word" || continue
+ac_cv_prog_ac_ct_CC="gcc"
+echo "$as_me:1182: found $ac_dir/$ac_word" >&5
+break
+done
+
+fi
+fi
+ac_ct_CC=$ac_cv_prog_ac_ct_CC
+if test -n "$ac_ct_CC"; then
+  echo "$as_me:1190: result: $ac_ct_CC" >&5
+echo "${ECHO_T}$ac_ct_CC" >&6
+else
+  echo "$as_me:1193: result: no" >&5
+echo "${ECHO_T}no" >&6
+fi
+
+  CC=$ac_ct_CC
+else
+  CC="$ac_cv_prog_CC"
+fi
+
+if test -z "$CC"; then
+  if test -n "$ac_tool_prefix"; then
+  # Extract the first word of "${ac_tool_prefix}cc", so it can be a program name with args.
+set dummy ${ac_tool_prefix}cc; ac_word=$2
+echo "$as_me:1206: checking for $ac_word" >&5
+echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6
+if test "${ac_cv_prog_CC+set}" = set; then
+  echo $ECHO_N "(cached) $ECHO_C" >&6
 else
   if test -n "$CC"; then
   ac_cv_prog_CC="$CC" # Let the user override the test.
 else
-  IFS="${IFS= 	}"; ac_save_ifs="$IFS"; IFS="${IFS}:"
-  for ac_dir in $PATH; do
-    test -z "$ac_dir" && ac_dir=.
-    if test -f $ac_dir/$ac_word; then
-      ac_cv_prog_CC="gcc"
-      break
-    fi
-  done
-  IFS="$ac_save_ifs"
+  ac_save_IFS=$IFS; IFS=$ac_path_separator
+ac_dummy="$PATH"
+for ac_dir in $ac_dummy; do
+  IFS=$ac_save_IFS
+  test -z "$ac_dir" && ac_dir=.
+  $as_executable_p "$ac_dir/$ac_word" || continue
+ac_cv_prog_CC="${ac_tool_prefix}cc"
+echo "$as_me:1221: found $ac_dir/$ac_word" >&5
+break
+done
+
 fi
 fi
-CC="$ac_cv_prog_CC"
+CC=$ac_cv_prog_CC
 if test -n "$CC"; then
-  echo "$ac_t""$CC" 1>&6
+  echo "$as_me:1229: result: $CC" >&5
+echo "${ECHO_T}$CC" >&6
 else
-  echo "$ac_t""no" 1>&6
+  echo "$as_me:1232: result: no" >&5
+echo "${ECHO_T}no" >&6
 fi
 
+fi
+if test -z "$ac_cv_prog_CC"; then
+  ac_ct_CC=$CC
+  # Extract the first word of "cc", so it can be a program name with args.
+set dummy cc; ac_word=$2
+echo "$as_me:1241: checking for $ac_word" >&5
+echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6
+if test "${ac_cv_prog_ac_ct_CC+set}" = set; then
+  echo $ECHO_N "(cached) $ECHO_C" >&6
+else
+  if test -n "$ac_ct_CC"; then
+  ac_cv_prog_ac_ct_CC="$ac_ct_CC" # Let the user override the test.
+else
+  ac_save_IFS=$IFS; IFS=$ac_path_separator
+ac_dummy="$PATH"
+for ac_dir in $ac_dummy; do
+  IFS=$ac_save_IFS
+  test -z "$ac_dir" && ac_dir=.
+  $as_executable_p "$ac_dir/$ac_word" || continue
+ac_cv_prog_ac_ct_CC="cc"
+echo "$as_me:1256: found $ac_dir/$ac_word" >&5
+break
+done
+
+fi
+fi
+ac_ct_CC=$ac_cv_prog_ac_ct_CC
+if test -n "$ac_ct_CC"; then
+  echo "$as_me:1264: result: $ac_ct_CC" >&5
+echo "${ECHO_T}$ac_ct_CC" >&6
+else
+  echo "$as_me:1267: result: no" >&5
+echo "${ECHO_T}no" >&6
+fi
+
+  CC=$ac_ct_CC
+else
+  CC="$ac_cv_prog_CC"
+fi
+
+fi
 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:716: checking for $ac_word" >&5
-if eval "test \"`echo '$''{'ac_cv_prog_CC'+set}'`\" = set"; then
-  echo $ac_n "(cached) $ac_c" 1>&6
+echo "$as_me:1280: checking for $ac_word" >&5
+echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6
+if test "${ac_cv_prog_CC+set}" = set; then
+  echo $ECHO_N "(cached) $ECHO_C" >&6
 else
   if test -n "$CC"; then
   ac_cv_prog_CC="$CC" # Let the user override the test.
 else
-  IFS="${IFS= 	}"; ac_save_ifs="$IFS"; IFS="${IFS}:"
   ac_prog_rejected=no
-  for ac_dir in $PATH; do
-    test -z "$ac_dir" && ac_dir=.
-    if test -f $ac_dir/$ac_word; then
-      if test "$ac_dir/$ac_word" = "/usr/ucb/cc"; then
-        ac_prog_rejected=yes
-	continue
-      fi
-      ac_cv_prog_CC="cc"
-      break
-    fi
-  done
-  IFS="$ac_save_ifs"
+  ac_save_IFS=$IFS; IFS=$ac_path_separator
+ac_dummy="$PATH"
+for ac_dir in $ac_dummy; do
+  IFS=$ac_save_IFS
+  test -z "$ac_dir" && ac_dir=.
+  $as_executable_p "$ac_dir/$ac_word" || continue
+if test "$ac_dir/$ac_word" = "/usr/ucb/cc"; then
+  ac_prog_rejected=yes
+  continue
+fi
+ac_cv_prog_CC="cc"
+echo "$as_me:1300: found $ac_dir/$ac_word" >&5
+break
+done
+
 if test $ac_prog_rejected = yes; then
   # We found a bogon in the path, so make sure we never use it.
   set dummy $ac_cv_prog_CC
   shift
-  if test $# -gt 0; then
+  if test $# != 0; then
     # We chose a different compiler from the bogus one.
     # However, it has the same basename, so the bogon will be chosen
     # first if we set CC to just the basename; use the full file name.
     shift
-    set dummy "$ac_dir/$ac_word" "$@"
+    set dummy "$ac_dir/$ac_word" ${1+"$@"}
     shift
     ac_cv_prog_CC="$@"
   fi
 fi
 fi
 fi
-CC="$ac_cv_prog_CC"
+CC=$ac_cv_prog_CC
+if test -n "$CC"; then
+  echo "$as_me:1322: result: $CC" >&5
+echo "${ECHO_T}$CC" >&6
+else
+  echo "$as_me:1325: result: no" >&5
+echo "${ECHO_T}no" >&6
+fi
+
+fi
+if test -z "$CC"; then
+  if test -n "$ac_tool_prefix"; then
+  for ac_prog in cl
+  do
+    # Extract the first word of "$ac_tool_prefix$ac_prog", so it can be a program name with args.
+set dummy $ac_tool_prefix$ac_prog; ac_word=$2
+echo "$as_me:1336: checking for $ac_word" >&5
+echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6
+if test "${ac_cv_prog_CC+set}" = set; then
+  echo $ECHO_N "(cached) $ECHO_C" >&6
+else
+  if test -n "$CC"; then
+  ac_cv_prog_CC="$CC" # Let the user override the test.
+else
+  ac_save_IFS=$IFS; IFS=$ac_path_separator
+ac_dummy="$PATH"
+for ac_dir in $ac_dummy; do
+  IFS=$ac_save_IFS
+  test -z "$ac_dir" && ac_dir=.
+  $as_executable_p "$ac_dir/$ac_word" || continue
+ac_cv_prog_CC="$ac_tool_prefix$ac_prog"
+echo "$as_me:1351: found $ac_dir/$ac_word" >&5
+break
+done
+
+fi
+fi
+CC=$ac_cv_prog_CC
 if test -n "$CC"; then
-  echo "$ac_t""$CC" 1>&6
+  echo "$as_me:1359: result: $CC" >&5
+echo "${ECHO_T}$CC" >&6
 else
-  echo "$ac_t""no" 1>&6
+  echo "$as_me:1362: result: no" >&5
+echo "${ECHO_T}no" >&6
 fi
 
-  test -z "$CC" && { echo "configure: error: no acceptable cc found in \$PATH" 1>&2; exit 1; }
+    test -n "$CC" && break
+  done
 fi
+if test -z "$CC"; then
+  ac_ct_CC=$CC
+  for ac_prog in cl
+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 "$as_me:1375: checking for $ac_word" >&5
+echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6
+if test "${ac_cv_prog_ac_ct_CC+set}" = set; then
+  echo $ECHO_N "(cached) $ECHO_C" >&6
+else
+  if test -n "$ac_ct_CC"; then
+  ac_cv_prog_ac_ct_CC="$ac_ct_CC" # Let the user override the test.
+else
+  ac_save_IFS=$IFS; IFS=$ac_path_separator
+ac_dummy="$PATH"
+for ac_dir in $ac_dummy; do
+  IFS=$ac_save_IFS
+  test -z "$ac_dir" && ac_dir=.
+  $as_executable_p "$ac_dir/$ac_word" || continue
+ac_cv_prog_ac_ct_CC="$ac_prog"
+echo "$as_me:1390: found $ac_dir/$ac_word" >&5
+break
+done
 
-echo $ac_n "checking whether the C compiler ($CC $CFLAGS $LDFLAGS) works""... $ac_c" 1>&6
-echo "configure:764: checking whether the C compiler ($CC $CFLAGS $LDFLAGS) works" >&5
+fi
+fi
+ac_ct_CC=$ac_cv_prog_ac_ct_CC
+if test -n "$ac_ct_CC"; then
+  echo "$as_me:1398: result: $ac_ct_CC" >&5
+echo "${ECHO_T}$ac_ct_CC" >&6
+else
+  echo "$as_me:1401: result: no" >&5
+echo "${ECHO_T}no" >&6
+fi
 
-ac_ext=c
-# CFLAGS is not in ac_cpp because -g, -O, etc. are not valid cpp options.
-ac_cpp='$CPP $CPPFLAGS'
-ac_compile='${CC-cc} -c $CFLAGS $CPPFLAGS conftest.$ac_ext 1>&5'
-ac_link='${CC-cc} -o conftest $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS 1>&5'
-cross_compiling=$ac_cv_prog_cc_cross
+  test -n "$ac_ct_CC" && break
+done
 
-cat > conftest.$ac_ext <<EOF
-#line 774 "configure"
+  CC=$ac_ct_CC
+fi
+
+fi
+
+test -z "$CC" && { { echo "$as_me:1413: error: no acceptable cc found in \$PATH" >&5
+echo "$as_me: error: no acceptable cc found in \$PATH" >&2;}
+   { (exit 1); exit 1; }; }
+
+# Provide some information about the compiler.
+echo "$as_me:1418:" \
+     "checking for C compiler version" >&5
+ac_compiler=`set X $ac_compile; echo $2`
+{ (eval echo "$as_me:1421: \"$ac_compiler --version </dev/null >&5\"") >&5
+  (eval $ac_compiler --version </dev/null >&5) 2>&5
+  ac_status=$?
+  echo "$as_me:1424: \$? = $ac_status" >&5
+  (exit $ac_status); }
+{ (eval echo "$as_me:1426: \"$ac_compiler -v </dev/null >&5\"") >&5
+  (eval $ac_compiler -v </dev/null >&5) 2>&5
+  ac_status=$?
+  echo "$as_me:1429: \$? = $ac_status" >&5
+  (exit $ac_status); }
+{ (eval echo "$as_me:1431: \"$ac_compiler -V </dev/null >&5\"") >&5
+  (eval $ac_compiler -V </dev/null >&5) 2>&5
+  ac_status=$?
+  echo "$as_me:1434: \$? = $ac_status" >&5
+  (exit $ac_status); }
+
+cat >conftest.$ac_ext <<_ACEOF
+#line 1438 "configure"
 #include "confdefs.h"
-main(){return(0);}
-EOF
-if { (eval echo configure:778: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest; 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
-    ac_cv_prog_cc_cross=no
+
+int
+main ()
+{
+
+  ;
+  return 0;
+}
+_ACEOF
+ac_clean_files_save=$ac_clean_files
+ac_clean_files="$ac_clean_files a.out a.exe"
+# Try to create an executable without -o first, disregard a.out.
+# It will help us diagnose broken compilers, and finding out an intuition
+# of exeext.
+echo "$as_me:1454: checking for C compiler default output" >&5
+echo $ECHO_N "checking for C compiler default output... $ECHO_C" >&6
+ac_link_default=`echo "$ac_link" | sed 's/ -o *conftest[^ ]*//'`
+if { (eval echo "$as_me:1457: \"$ac_link_default\"") >&5
+  (eval $ac_link_default) 2>&5
+  ac_status=$?
+  echo "$as_me:1460: \$? = $ac_status" >&5
+  (exit $ac_status); }; then
+  # Find the output, starting from the most likely.  This scheme is
+# not robust to junk in `.', hence go to wildcards (a.*) only as a last
+# resort.
+for ac_file in `ls a.exe conftest.exe 2>/dev/null;
+                ls a.out conftest 2>/dev/null;
+                ls a.* conftest.* 2>/dev/null`; do
+  case $ac_file in
+    *.$ac_ext | *.o | *.obj | *.xcoff | *.tds | *.d | *.pdb ) ;;
+    a.out ) # We found the default executable, but exeext='' is most
+            # certainly right.
+            break;;
+    *.* ) ac_cv_exeext=`expr "$ac_file" : '[^.]*\(\..*\)'`
+          # FIXME: I believe we export ac_cv_exeext for Libtool --akim.
+          export ac_cv_exeext
+          break;;
+    * ) break;;
+  esac
+done
+else
+  echo "$as_me: failed program was:" >&5
+cat conftest.$ac_ext >&5
+{ { echo "$as_me:1483: error: C compiler cannot create executables" >&5
+echo "$as_me: error: C compiler cannot create executables" >&2;}
+   { (exit 77); exit 77; }; }
+fi
+
+ac_exeext=$ac_cv_exeext
+echo "$as_me:1489: result: $ac_file" >&5
+echo "${ECHO_T}$ac_file" >&6
+
+# Check the compiler produces executables we can run.  If not, either
+# the compiler is broken, or we cross compile.
+echo "$as_me:1494: checking whether the C compiler works" >&5
+echo $ECHO_N "checking whether the C compiler works... $ECHO_C" >&6
+# FIXME: These cross compiler hacks should be removed for Autoconf 3.0
+# If not cross compiling, check that we can run a simple program.
+if test "$cross_compiling" != yes; then
+  if { ac_try='./$ac_file'
+  { (eval echo "$as_me:1500: \"$ac_try\"") >&5
+  (eval $ac_try) 2>&5
+  ac_status=$?
+  echo "$as_me:1503: \$? = $ac_status" >&5
+  (exit $ac_status); }; }; then
+    cross_compiling=no
   else
-    ac_cv_prog_cc_cross=yes
+    if test "$cross_compiling" = maybe; then
+	cross_compiling=yes
+    else
+	{ { echo "$as_me:1510: error: cannot run C compiled programs.
+If you meant to cross compile, use \`--host'." >&5
+echo "$as_me: error: cannot run C compiled programs.
+If you meant to cross compile, use \`--host'." >&2;}
+   { (exit 1); exit 1; }; }
+    fi
   fi
-else
-  echo "configure: failed program was:" >&5
-  cat conftest.$ac_ext >&5
-  ac_cv_prog_cc_works=no
 fi
-rm -fr conftest*
+echo "$as_me:1518: result: yes" >&5
+echo "${ECHO_T}yes" >&6
+
+rm -f a.out a.exe conftest$ac_cv_exeext
+ac_clean_files=$ac_clean_files_save
+# Check the compiler produces executables we can run.  If not, either
+# the compiler is broken, or we cross compile.
+echo "$as_me:1525: checking whether we are cross compiling" >&5
+echo $ECHO_N "checking whether we are cross compiling... $ECHO_C" >&6
+echo "$as_me:1527: result: $cross_compiling" >&5
+echo "${ECHO_T}$cross_compiling" >&6
+
+echo "$as_me:1530: checking for executable suffix" >&5
+echo $ECHO_N "checking for executable suffix... $ECHO_C" >&6
+if { (eval echo "$as_me:1532: \"$ac_link\"") >&5
+  (eval $ac_link) 2>&5
+  ac_status=$?
+  echo "$as_me:1535: \$? = $ac_status" >&5
+  (exit $ac_status); }; then
+  # If both `conftest.exe' and `conftest' are `present' (well, observable)
+# catch `conftest.exe'.  For instance with Cygwin, `ls conftest' will
+# work properly (i.e., refer to `conftest.exe'), while it won't with
+# `rm'.
+for ac_file in `(ls conftest.exe; ls conftest; ls conftest.*) 2>/dev/null`; do
+  case $ac_file in
+    *.$ac_ext | *.o | *.obj | *.xcoff | *.tds | *.d | *.pdb ) ;;
+    *.* ) ac_cv_exeext=`expr "$ac_file" : '[^.]*\(\..*\)'`
+          export ac_cv_exeext
+          break;;
+    * ) break;;
+  esac
+done
+else
+  { { echo "$as_me:1551: error: cannot compute EXEEXT: cannot compile and link" >&5
+echo "$as_me: error: cannot compute EXEEXT: cannot compile and link" >&2;}
+   { (exit 1); exit 1; }; }
+fi
+
+rm -f conftest$ac_cv_exeext
+echo "$as_me:1557: result: $ac_cv_exeext" >&5
+echo "${ECHO_T}$ac_cv_exeext" >&6
+
+rm -f conftest.$ac_ext
+EXEEXT=$ac_cv_exeext
+ac_exeext=$EXEEXT
+echo "$as_me:1563: checking for object suffix" >&5
+echo $ECHO_N "checking for object suffix... $ECHO_C" >&6
+if test "${ac_cv_objext+set}" = set; then
+  echo $ECHO_N "(cached) $ECHO_C" >&6
+else
+  cat >conftest.$ac_ext <<_ACEOF
+#line 1569 "configure"
+#include "confdefs.h"
 
-echo "$ac_t""$ac_cv_prog_cc_works" 1>&6
-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:798: 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
+int
+main ()
+{
 
-echo $ac_n "checking whether we are using GNU C""... $ac_c" 1>&6
-echo "configure:803: 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
+  ;
+  return 0;
+}
+_ACEOF
+rm -f conftest.o conftest.obj
+if { (eval echo "$as_me:1581: \"$ac_compile\"") >&5
+  (eval $ac_compile) 2>&5
+  ac_status=$?
+  echo "$as_me:1584: \$? = $ac_status" >&5
+  (exit $ac_status); }; then
+  for ac_file in `(ls conftest.o conftest.obj; ls conftest.*) 2>/dev/null`; do
+  case $ac_file in
+    *.$ac_ext | *.xcoff | *.tds | *.d | *.pdb ) ;;
+    *) ac_cv_objext=`expr "$ac_file" : '.*\.\(.*\)'`
+       break;;
+  esac
+done
 else
-  cat > conftest.c <<EOF
-#ifdef __GNUC__
-  yes;
-#endif
-EOF
-if { ac_try='${CC-cc} -E conftest.c'; { (eval echo configure:812: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }; } | egrep yes >/dev/null 2>&1; then
-  ac_cv_prog_gcc=yes
+  echo "$as_me: failed program was:" >&5
+cat conftest.$ac_ext >&5
+{ { echo "$as_me:1596: error: cannot compute OBJEXT: cannot compile" >&5
+echo "$as_me: error: cannot compute OBJEXT: cannot compile" >&2;}
+   { (exit 1); exit 1; }; }
+fi
+
+rm -f conftest.$ac_cv_objext conftest.$ac_ext
+fi
+echo "$as_me:1603: result: $ac_cv_objext" >&5
+echo "${ECHO_T}$ac_cv_objext" >&6
+OBJEXT=$ac_cv_objext
+ac_objext=$OBJEXT
+echo "$as_me:1607: checking whether we are using the GNU C compiler" >&5
+echo $ECHO_N "checking whether we are using the GNU C compiler... $ECHO_C" >&6
+if test "${ac_cv_c_compiler_gnu+set}" = set; then
+  echo $ECHO_N "(cached) $ECHO_C" >&6
 else
-  ac_cv_prog_gcc=no
-fi
-fi
+  cat >conftest.$ac_ext <<_ACEOF
+#line 1613 "configure"
+#include "confdefs.h"
 
-echo "$ac_t""$ac_cv_prog_gcc" 1>&6
+int
+main ()
+{
+#ifndef __GNUC__
+       choke me
+#endif
 
-if test $ac_cv_prog_gcc = yes; then
-  GCC=yes
-  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:827: 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
+  ;
+  return 0;
+}
+_ACEOF
+rm -f conftest.$ac_objext
+if { (eval echo "$as_me:1628: \"$ac_compile\"") >&5
+  (eval $ac_compile) 2>&5
+  ac_status=$?
+  echo "$as_me:1631: \$? = $ac_status" >&5
+  (exit $ac_status); } &&
+         { ac_try='test -s conftest.$ac_objext'
+  { (eval echo "$as_me:1634: \"$ac_try\"") >&5
+  (eval $ac_try) 2>&5
+  ac_status=$?
+  echo "$as_me:1637: \$? = $ac_status" >&5
+  (exit $ac_status); }; }; then
+  ac_compiler_gnu=yes
 else
-  echo 'void f(){}' > conftest.c
-if test -z "`${CC-cc} -g -c conftest.c 2>&1`"; then
-  ac_cv_prog_cc_g=yes
+  echo "$as_me: failed program was:" >&5
+cat conftest.$ac_ext >&5
+ac_compiler_gnu=no
+fi
+rm -f conftest.$ac_objext conftest.$ac_ext
+ac_cv_c_compiler_gnu=$ac_compiler_gnu
+
+fi
+echo "$as_me:1649: result: $ac_cv_c_compiler_gnu" >&5
+echo "${ECHO_T}$ac_cv_c_compiler_gnu" >&6
+GCC=`test $ac_compiler_gnu = yes && echo yes`
+ac_test_CFLAGS=${CFLAGS+set}
+ac_save_CFLAGS=$CFLAGS
+CFLAGS="-g"
+echo "$as_me:1655: checking whether $CC accepts -g" >&5
+echo $ECHO_N "checking whether $CC accepts -g... $ECHO_C" >&6
+if test "${ac_cv_prog_cc_g+set}" = set; then
+  echo $ECHO_N "(cached) $ECHO_C" >&6
 else
-  ac_cv_prog_cc_g=no
-fi
-rm -f conftest*
+  cat >conftest.$ac_ext <<_ACEOF
+#line 1661 "configure"
+#include "confdefs.h"
 
-fi
+int
+main ()
+{
 
-echo "$ac_t""$ac_cv_prog_cc_g" 1>&6
-  if test "$ac_test_CFLAGS" = set; then
-    CFLAGS="$ac_save_CFLAGS"
-  elif test $ac_cv_prog_cc_g = yes; then
+  ;
+  return 0;
+}
+_ACEOF
+rm -f conftest.$ac_objext
+if { (eval echo "$as_me:1673: \"$ac_compile\"") >&5
+  (eval $ac_compile) 2>&5
+  ac_status=$?
+  echo "$as_me:1676: \$? = $ac_status" >&5
+  (exit $ac_status); } &&
+         { ac_try='test -s conftest.$ac_objext'
+  { (eval echo "$as_me:1679: \"$ac_try\"") >&5
+  (eval $ac_try) 2>&5
+  ac_status=$?
+  echo "$as_me:1682: \$? = $ac_status" >&5
+  (exit $ac_status); }; }; then
+  ac_cv_prog_cc_g=yes
+else
+  echo "$as_me: failed program was:" >&5
+cat conftest.$ac_ext >&5
+ac_cv_prog_cc_g=no
+fi
+rm -f conftest.$ac_objext conftest.$ac_ext
+fi
+echo "$as_me:1692: result: $ac_cv_prog_cc_g" >&5
+echo "${ECHO_T}$ac_cv_prog_cc_g" >&6
+if test "$ac_test_CFLAGS" = set; then
+  CFLAGS=$ac_save_CFLAGS
+elif test $ac_cv_prog_cc_g = yes; then
+  if test "$GCC" = yes; then
     CFLAGS="-g -O2"
   else
+    CFLAGS="-g"
+  fi
+else
+  if test "$GCC" = yes; then
     CFLAGS="-O2"
+  else
+    CFLAGS=
   fi
+fi
+# Some people use a C++ compiler to compile C.  Since we use `exit',
+# in C++ we need to declare it.  In case someone uses the same compiler
+# for both compiling C and C++ we need to have the C++ compiler decide
+# the declaration of exit, since it's the most demanding environment.
+cat >conftest.$ac_ext <<_ACEOF
+#ifndef __cplusplus
+  choke me
+#endif
+_ACEOF
+rm -f conftest.$ac_objext
+if { (eval echo "$as_me:1719: \"$ac_compile\"") >&5
+  (eval $ac_compile) 2>&5
+  ac_status=$?
+  echo "$as_me:1722: \$? = $ac_status" >&5
+  (exit $ac_status); } &&
+         { ac_try='test -s conftest.$ac_objext'
+  { (eval echo "$as_me:1725: \"$ac_try\"") >&5
+  (eval $ac_try) 2>&5
+  ac_status=$?
+  echo "$as_me:1728: \$? = $ac_status" >&5
+  (exit $ac_status); }; }; then
+  for ac_declaration in \
+   ''\
+   '#include <stdlib.h>' \
+   'extern "C" void std::exit (int) throw (); using std::exit;' \
+   'extern "C" void std::exit (int); using std::exit;' \
+   'extern "C" void exit (int) throw ();' \
+   'extern "C" void exit (int);' \
+   'void exit (int);'
+do
+  cat >conftest.$ac_ext <<_ACEOF
+#line 1740 "configure"
+#include "confdefs.h"
+#include <stdlib.h>
+$ac_declaration
+int
+main ()
+{
+exit (42);
+  ;
+  return 0;
+}
+_ACEOF
+rm -f conftest.$ac_objext
+if { (eval echo "$as_me:1753: \"$ac_compile\"") >&5
+  (eval $ac_compile) 2>&5
+  ac_status=$?
+  echo "$as_me:1756: \$? = $ac_status" >&5
+  (exit $ac_status); } &&
+         { ac_try='test -s conftest.$ac_objext'
+  { (eval echo "$as_me:1759: \"$ac_try\"") >&5
+  (eval $ac_try) 2>&5
+  ac_status=$?
+  echo "$as_me:1762: \$? = $ac_status" >&5
+  (exit $ac_status); }; }; then
+  :
+else
+  echo "$as_me: failed program was:" >&5
+cat conftest.$ac_ext >&5
+continue
+fi
+rm -f conftest.$ac_objext conftest.$ac_ext
+  cat >conftest.$ac_ext <<_ACEOF
+#line 1772 "configure"
+#include "confdefs.h"
+$ac_declaration
+int
+main ()
+{
+exit (42);
+  ;
+  return 0;
+}
+_ACEOF
+rm -f conftest.$ac_objext
+if { (eval echo "$as_me:1784: \"$ac_compile\"") >&5
+  (eval $ac_compile) 2>&5
+  ac_status=$?
+  echo "$as_me:1787: \$? = $ac_status" >&5
+  (exit $ac_status); } &&
+         { ac_try='test -s conftest.$ac_objext'
+  { (eval echo "$as_me:1790: \"$ac_try\"") >&5
+  (eval $ac_try) 2>&5
+  ac_status=$?
+  echo "$as_me:1793: \$? = $ac_status" >&5
+  (exit $ac_status); }; }; then
+  break
+else
+  echo "$as_me: failed program was:" >&5
+cat conftest.$ac_ext >&5
+fi
+rm -f conftest.$ac_objext conftest.$ac_ext
+done
+rm -f conftest*
+if test -n "$ac_declaration"; then
+  echo '#ifdef __cplusplus' >>confdefs.h
+  echo $ac_declaration      >>confdefs.h
+  echo '#endif'             >>confdefs.h
+fi
+
 else
-  GCC=
-  test "${CFLAGS+set}" = set || CFLAGS="-g"
+  echo "$as_me: failed program was:" >&5
+cat conftest.$ac_ext >&5
 fi
+rm -f conftest.$ac_objext conftest.$ac_ext
+ac_ext=c
+ac_cpp='$CPP $CPPFLAGS'
+ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5'
+ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5'
+ac_compiler_gnu=$ac_cv_c_compiler_gnu
 
-echo $ac_n "checking how to run the C preprocessor""... $ac_c" 1>&6
-echo "configure:855: checking how to run the C preprocessor" >&5
+ac_ext=c
+ac_cpp='$CPP $CPPFLAGS'
+ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5'
+ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5'
+ac_compiler_gnu=$ac_cv_c_compiler_gnu
+echo "$as_me:1825: checking how to run the C preprocessor" >&5
+echo $ECHO_N "checking how to run the C preprocessor... $ECHO_C" >&6
 # On Suns, sometimes $CPP names a directory.
 if test -n "$CPP" && test -d "$CPP"; then
   CPP=
 fi
 if test -z "$CPP"; then
-if eval "test \"`echo '$''{'ac_cv_prog_CPP'+set}'`\" = set"; then
-  echo $ac_n "(cached) $ac_c" 1>&6
+  if test "${ac_cv_prog_CPP+set}" = set; then
+  echo $ECHO_N "(cached) $ECHO_C" >&6
 else
-    # This must be in double quotes, not single quotes, because CPP may get
-  # substituted into the Makefile and "${CC-cc}" will confuse make.
-  CPP="${CC-cc} -E"
+      # Double quotes because CPP needs to be expanded
+    for CPP in "$CC -E" "$CC -E -traditional-cpp" "/lib/cpp"
+    do
+      ac_preproc_ok=false
+for ac_c_preproc_warn_flag in '' yes
+do
+  # Use a header file that comes with gcc, so configuring glibc
+  # with a fresh cross-compiler works.
   # On the NeXT, cc -E runs the code through the compiler's parser,
-  # not just through cpp.
-  cat > conftest.$ac_ext <<EOF
-#line 870 "configure"
+  # not just through cpp. "Syntax error" is here to catch this case.
+  cat >conftest.$ac_ext <<_ACEOF
+#line 1846 "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:876: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
-ac_err=`grep -v '^ *+' conftest.out`
-if test -z "$ac_err"; then
+                     Syntax error
+_ACEOF
+if { (eval echo "$as_me:1851: \"$ac_cpp conftest.$ac_ext\"") >&5
+  (eval $ac_cpp conftest.$ac_ext) 2>conftest.er1
+  ac_status=$?
+  egrep -v '^ *\+' conftest.er1 >conftest.err
+  rm -f conftest.er1
+  cat conftest.err >&5
+  echo "$as_me:1857: \$? = $ac_status" >&5
+  (exit $ac_status); } >/dev/null; then
+  if test -s conftest.err; then
+    ac_cpp_err=$ac_c_preproc_warn_flag
+  else
+    ac_cpp_err=
+  fi
+else
+  ac_cpp_err=yes
+fi
+if test -z "$ac_cpp_err"; then
   :
 else
-  echo "$ac_err" >&5
-  echo "configure: failed program was:" >&5
+  echo "$as_me: failed program was:" >&5
+  cat conftest.$ac_ext >&5
+  # Broken: fails on valid input.
+continue
+fi
+rm -f conftest.err conftest.$ac_ext
+
+  # OK, works on sane cases.  Now check whether non-existent headers
+  # can be detected and how.
+  cat >conftest.$ac_ext <<_ACEOF
+#line 1880 "configure"
+#include "confdefs.h"
+#include <ac_nonexistent.h>
+_ACEOF
+if { (eval echo "$as_me:1884: \"$ac_cpp conftest.$ac_ext\"") >&5
+  (eval $ac_cpp conftest.$ac_ext) 2>conftest.er1
+  ac_status=$?
+  egrep -v '^ *\+' conftest.er1 >conftest.err
+  rm -f conftest.er1
+  cat conftest.err >&5
+  echo "$as_me:1890: \$? = $ac_status" >&5
+  (exit $ac_status); } >/dev/null; then
+  if test -s conftest.err; then
+    ac_cpp_err=$ac_c_preproc_warn_flag
+  else
+    ac_cpp_err=
+  fi
+else
+  ac_cpp_err=yes
+fi
+if test -z "$ac_cpp_err"; then
+  # Broken: success on invalid input.
+continue
+else
+  echo "$as_me: failed program was:" >&5
   cat conftest.$ac_ext >&5
-  rm -rf conftest*
-  CPP="${CC-cc} -E -traditional-cpp"
-  cat > conftest.$ac_ext <<EOF
-#line 887 "configure"
+  # Passes both tests.
+ac_preproc_ok=:
+break
+fi
+rm -f conftest.err conftest.$ac_ext
+
+done
+# Because of `break', _AC_PREPROC_IFELSE's cleaning code was skipped.
+rm -f conftest.err conftest.$ac_ext
+if $ac_preproc_ok; then
+  break
+fi
+
+    done
+    ac_cv_prog_CPP=$CPP
+
+fi
+  CPP=$ac_cv_prog_CPP
+else
+  ac_cv_prog_CPP=$CPP
+fi
+echo "$as_me:1927: result: $CPP" >&5
+echo "${ECHO_T}$CPP" >&6
+ac_preproc_ok=false
+for ac_c_preproc_warn_flag in '' yes
+do
+  # Use a header file that comes with gcc, so configuring glibc
+  # with a fresh cross-compiler works.
+  # On the NeXT, cc -E runs the code through the compiler's parser,
+  # not just through cpp. "Syntax error" is here to catch this case.
+  cat >conftest.$ac_ext <<_ACEOF
+#line 1937 "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:893: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
-ac_err=`grep -v '^ *+' conftest.out`
-if test -z "$ac_err"; then
+                     Syntax error
+_ACEOF
+if { (eval echo "$as_me:1942: \"$ac_cpp conftest.$ac_ext\"") >&5
+  (eval $ac_cpp conftest.$ac_ext) 2>conftest.er1
+  ac_status=$?
+  egrep -v '^ *\+' conftest.er1 >conftest.err
+  rm -f conftest.er1
+  cat conftest.err >&5
+  echo "$as_me:1948: \$? = $ac_status" >&5
+  (exit $ac_status); } >/dev/null; then
+  if test -s conftest.err; then
+    ac_cpp_err=$ac_c_preproc_warn_flag
+  else
+    ac_cpp_err=
+  fi
+else
+  ac_cpp_err=yes
+fi
+if test -z "$ac_cpp_err"; then
   :
 else
-  echo "$ac_err" >&5
-  echo "configure: failed program was:" >&5
+  echo "$as_me: failed program was:" >&5
   cat conftest.$ac_ext >&5
-  rm -rf conftest*
-  CPP=/lib/cpp
+  # Broken: fails on valid input.
+continue
 fi
-rm -f conftest*
+rm -f conftest.err conftest.$ac_ext
+
+  # OK, works on sane cases.  Now check whether non-existent headers
+  # can be detected and how.
+  cat >conftest.$ac_ext <<_ACEOF
+#line 1971 "configure"
+#include "confdefs.h"
+#include <ac_nonexistent.h>
+_ACEOF
+if { (eval echo "$as_me:1975: \"$ac_cpp conftest.$ac_ext\"") >&5
+  (eval $ac_cpp conftest.$ac_ext) 2>conftest.er1
+  ac_status=$?
+  egrep -v '^ *\+' conftest.er1 >conftest.err
+  rm -f conftest.er1
+  cat conftest.err >&5
+  echo "$as_me:1981: \$? = $ac_status" >&5
+  (exit $ac_status); } >/dev/null; then
+  if test -s conftest.err; then
+    ac_cpp_err=$ac_c_preproc_warn_flag
+  else
+    ac_cpp_err=
+  fi
+else
+  ac_cpp_err=yes
 fi
-rm -f conftest*
-  ac_cv_prog_CPP="$CPP"
+if test -z "$ac_cpp_err"; then
+  # Broken: success on invalid input.
+continue
+else
+  echo "$as_me: failed program was:" >&5
+  cat conftest.$ac_ext >&5
+  # Passes both tests.
+ac_preproc_ok=:
+break
 fi
-  CPP="$ac_cv_prog_CPP"
+rm -f conftest.err conftest.$ac_ext
+
+done
+# Because of `break', _AC_PREPROC_IFELSE's cleaning code was skipped.
+rm -f conftest.err conftest.$ac_ext
+if $ac_preproc_ok; then
+  :
 else
-  ac_cv_prog_CPP="$CPP"
+  { { echo "$as_me:2009: error: C preprocessor \"$CPP\" fails sanity check" >&5
+echo "$as_me: error: C preprocessor \"$CPP\" fails sanity check" >&2;}
+   { (exit 1); exit 1; }; }
 fi
-echo "$ac_t""$CPP" 1>&6
 
-ac_safe=`echo "minix/config.h" | sed 'y%./+-%__p_%'`
-echo $ac_n "checking for minix/config.h""... $ac_c" 1>&6
-echo "configure:917: checking for minix/config.h" >&5
-if eval "test \"`echo '$''{'ac_cv_header_$ac_safe'+set}'`\" = set"; then
-  echo $ac_n "(cached) $ac_c" 1>&6
+ac_ext=c
+ac_cpp='$CPP $CPPFLAGS'
+ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5'
+ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5'
+ac_compiler_gnu=$ac_cv_c_compiler_gnu
+
+echo "$as_me:2020: checking for minix/config.h" >&5
+echo $ECHO_N "checking for minix/config.h... $ECHO_C" >&6
+if test "${ac_cv_header_minix_config_h+set}" = set; then
+  echo $ECHO_N "(cached) $ECHO_C" >&6
 else
-  cat > conftest.$ac_ext <<EOF
-#line 922 "configure"
+  cat >conftest.$ac_ext <<_ACEOF
+#line 2026 "configure"
 #include "confdefs.h"
 #include <minix/config.h>
-EOF
-ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out"
-{ (eval echo configure:927: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
-ac_err=`grep -v '^ *+' conftest.out`
-if test -z "$ac_err"; then
-  rm -rf conftest*
-  eval "ac_cv_header_$ac_safe=yes"
+_ACEOF
+if { (eval echo "$as_me:2030: \"$ac_cpp conftest.$ac_ext\"") >&5
+  (eval $ac_cpp conftest.$ac_ext) 2>conftest.er1
+  ac_status=$?
+  egrep -v '^ *\+' conftest.er1 >conftest.err
+  rm -f conftest.er1
+  cat conftest.err >&5
+  echo "$as_me:2036: \$? = $ac_status" >&5
+  (exit $ac_status); } >/dev/null; then
+  if test -s conftest.err; then
+    ac_cpp_err=$ac_c_preproc_warn_flag
+  else
+    ac_cpp_err=
+  fi
+else
+  ac_cpp_err=yes
+fi
+if test -z "$ac_cpp_err"; then
+  ac_cv_header_minix_config_h=yes
 else
-  echo "$ac_err" >&5
-  echo "configure: failed program was:" >&5
+  echo "$as_me: failed program was:" >&5
   cat conftest.$ac_ext >&5
-  rm -rf conftest*
-  eval "ac_cv_header_$ac_safe=no"
+  ac_cv_header_minix_config_h=no
 fi
-rm -f conftest*
+rm -f conftest.err conftest.$ac_ext
 fi
-if eval "test \"`echo '$ac_cv_header_'$ac_safe`\" = yes"; then
-  echo "$ac_t""yes" 1>&6
+echo "$as_me:2055: result: $ac_cv_header_minix_config_h" >&5
+echo "${ECHO_T}$ac_cv_header_minix_config_h" >&6
+if test $ac_cv_header_minix_config_h = yes; then
   MINIX=yes
 else
-  echo "$ac_t""no" 1>&6
-MINIX=
+  MINIX=
 fi
 
 if test "$MINIX" = yes; then
-  cat >> confdefs.h <<\EOF
+
+cat >>confdefs.h <<\EOF
 #define _POSIX_SOURCE 1
 EOF
 
-  cat >> confdefs.h <<\EOF
+cat >>confdefs.h <<\EOF
 #define _POSIX_1_SOURCE 2
 EOF
 
-  cat >> confdefs.h <<\EOF
+cat >>confdefs.h <<\EOF
 #define _MINIX 1
 EOF
 
 fi
 
-
 # If we're using gcc and the user hasn't specified CFLAGS, add -O to CFLAGS.
 test -n "$GCC" && test -n "$auto_cflags" && CFLAGS="$CFLAGS -O"
 
-if test $ac_cv_prog_gcc = yes; then
-    echo $ac_n "checking whether ${CC-cc} needs -traditional""... $ac_c" 1>&6
-echo "configure:970: checking whether ${CC-cc} needs -traditional" >&5
-if eval "test \"`echo '$''{'ac_cv_prog_gcc_traditional'+set}'`\" = set"; then
-  echo $ac_n "(cached) $ac_c" 1>&6
+if test $ac_cv_c_compiler_gnu = yes; then
+    echo "$as_me:2083: checking whether $CC needs -traditional" >&5
+echo $ECHO_N "checking whether $CC needs -traditional... $ECHO_C" >&6
+if test "${ac_cv_prog_gcc_traditional+set}" = set; then
+  echo $ECHO_N "(cached) $ECHO_C" >&6
 else
     ac_pattern="Autoconf.*'x'"
-  cat > conftest.$ac_ext <<EOF
-#line 976 "configure"
+  cat >conftest.$ac_ext <<_ACEOF
+#line 2090 "configure"
 #include "confdefs.h"
 #include <sgtty.h>
 Autoconf TIOCGETP
-EOF
+_ACEOF
 if (eval "$ac_cpp conftest.$ac_ext") 2>&5 |
   egrep "$ac_pattern" >/dev/null 2>&1; then
-  rm -rf conftest*
   ac_cv_prog_gcc_traditional=yes
 else
-  rm -rf conftest*
   ac_cv_prog_gcc_traditional=no
 fi
 rm -f conftest*
 
-
   if test $ac_cv_prog_gcc_traditional = no; then
-    cat > conftest.$ac_ext <<EOF
-#line 994 "configure"
+    cat >conftest.$ac_ext <<_ACEOF
+#line 2105 "configure"
 #include "confdefs.h"
 #include <termio.h>
 Autoconf TCGETA
-EOF
+_ACEOF
 if (eval "$ac_cpp conftest.$ac_ext") 2>&5 |
   egrep "$ac_pattern" >/dev/null 2>&1; then
-  rm -rf conftest*
   ac_cv_prog_gcc_traditional=yes
 fi
 rm -f conftest*
 
   fi
 fi
-
-echo "$ac_t""$ac_cv_prog_gcc_traditional" 1>&6
+echo "$as_me:2118: result: $ac_cv_prog_gcc_traditional" >&5
+echo "${ECHO_T}$ac_cv_prog_gcc_traditional" >&6
   if test $ac_cv_prog_gcc_traditional = yes; then
     CC="$CC -traditional"
   fi
@@ -1018,28 +2129,38 @@ fi
 # SunOS /usr/etc/install
 # IRIX /sbin/install
 # AIX /bin/install
+# AmigaOS /C/install, which installs bootblocks on floppy discs
+# AIX 4 /usr/bin/installbsd, which doesn't work without a -g flag
 # AFS /usr/afsws/bin/install, which mishandles nonexistent args
 # SVR4 /usr/ucb/install, which tries to use the nonexistent group "staff"
 # ./install, which can be erroneously created by make from ./install.sh.
-echo $ac_n "checking for a BSD compatible install""... $ac_c" 1>&6
-echo "configure:1026: checking for a BSD compatible install" >&5
+echo "$as_me:2137: checking for a BSD compatible install" >&5
+echo $ECHO_N "checking for a BSD compatible install... $ECHO_C" >&6
 if test -z "$INSTALL"; then
-if eval "test \"`echo '$''{'ac_cv_path_install'+set}'`\" = set"; then
-  echo $ac_n "(cached) $ac_c" 1>&6
+if test "${ac_cv_path_install+set}" = set; then
+  echo $ECHO_N "(cached) $ECHO_C" >&6
 else
-    IFS="${IFS= 	}"; ac_save_IFS="$IFS"; IFS="${IFS}:"
+    ac_save_IFS=$IFS; IFS=$ac_path_separator
   for ac_dir in $PATH; do
+    IFS=$ac_save_IFS
     # Account for people who put trailing slashes in PATH elements.
-    case "$ac_dir/" in
-    /|./|.//|/etc/*|/usr/sbin/*|/usr/etc/*|/sbin/*|/usr/afsws/bin/*|/usr/ucb/*) ;;
+    case $ac_dir/ in
+    / | ./ | .// | /cC/* \
+    | /etc/* | /usr/sbin/* | /usr/etc/* | /sbin/* | /usr/afsws/bin/* \
+    | /usr/ucb/* ) ;;
     *)
       # OSF1 and SCO ODT 3.0 have their own names for install.
-      for ac_prog in ginstall installbsd scoinst install; do
-        if test -f $ac_dir/$ac_prog; then
+      # Don't use installbsd from OSF since it installs stuff as root
+      # by default.
+      for ac_prog in ginstall scoinst install; do
+        if $as_executable_p "$ac_dir/$ac_prog"; then
 	  if test $ac_prog = install &&
-            grep dspmsg $ac_dir/$ac_prog >/dev/null 2>&1; then
+            grep dspmsg "$ac_dir/$ac_prog" >/dev/null 2>&1; then
 	    # AIX install.  It has an incompatible calling convention.
-	    # OSF/1 installbsd also uses dspmsg, but is usable.
+	    :
+	  elif test $ac_prog = install &&
+	    grep pwplus "$ac_dir/$ac_prog" >/dev/null 2>&1; then
+	    # program-specific install script used by HP pwplus--don't use.
 	    :
 	  else
 	    ac_cv_path_install="$ac_dir/$ac_prog -c"
@@ -1050,138 +2171,734 @@ else
       ;;
     esac
   done
-  IFS="$ac_save_IFS"
 
 fi
   if test "${ac_cv_path_install+set}" = set; then
-    INSTALL="$ac_cv_path_install"
+    INSTALL=$ac_cv_path_install
   else
     # As a last resort, use the slow shell script.  We don't cache a
     # path for INSTALL within a source directory, because that will
     # break other packages using the cache if that directory is
     # removed, or if the path is relative.
-    INSTALL="$ac_install_sh"
+    INSTALL=$ac_install_sh
   fi
 fi
-echo "$ac_t""$INSTALL" 1>&6
+echo "$as_me:2186: result: $INSTALL" >&5
+echo "${ECHO_T}$INSTALL" >&6
 
 # Use test -z because SunOS4 sh mishandles braces in ${var-val}.
 # It thinks the first close brace ends the variable substitution.
 test -z "$INSTALL_PROGRAM" && INSTALL_PROGRAM='${INSTALL}'
 
+test -z "$INSTALL_SCRIPT" && INSTALL_SCRIPT='${INSTALL}'
+
 test -z "$INSTALL_DATA" && INSTALL_DATA='${INSTALL} -m 644'
 
 # 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:1078: checking for $ac_word" >&5
-if eval "test \"`echo '$''{'ac_cv_prog_AR'+set}'`\" = set"; then
-  echo $ac_n "(cached) $ac_c" 1>&6
+echo "$as_me:2199: checking for $ac_word" >&5
+echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6
+if test "${ac_cv_prog_AR+set}" = set; then
+  echo $ECHO_N "(cached) $ECHO_C" >&6
 else
   if test -n "$AR"; then
   ac_cv_prog_AR="$AR" # Let the user override the test.
 else
-  IFS="${IFS= 	}"; ac_save_ifs="$IFS"; IFS="${IFS}:"
-  for ac_dir in $PATH; do
-    test -z "$ac_dir" && ac_dir=.
-    if test -f $ac_dir/$ac_word; then
-      ac_cv_prog_AR="ar"
-      break
-    fi
-  done
-  IFS="$ac_save_ifs"
+  ac_save_IFS=$IFS; IFS=$ac_path_separator
+ac_dummy="$PATH"
+for ac_dir in $ac_dummy; do
+  IFS=$ac_save_IFS
+  test -z "$ac_dir" && ac_dir=.
+  $as_executable_p "$ac_dir/$ac_word" || continue
+ac_cv_prog_AR=""
+echo "$as_me:2214: found $ac_dir/$ac_word" >&5
+break
+done
+
+  test -z "$ac_cv_prog_AR" && ac_cv_prog_AR="ar"
 fi
 fi
-AR="$ac_cv_prog_AR"
+AR=$ac_cv_prog_AR
 if test -n "$AR"; then
-  echo "$ac_t""$AR" 1>&6
+  echo "$as_me:2223: result: $AR" >&5
+echo "${ECHO_T}$AR" >&6
 else
-  echo "$ac_t""no" 1>&6
+  echo "$as_me:2226: result: no" >&5
+echo "${ECHO_T}no" >&6
 fi
 
 test -n "$ARFLAGS" || ARFLAGS="cr"
-# 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:1107: checking for $ac_word" >&5
-if eval "test \"`echo '$''{'ac_cv_prog_RANLIB'+set}'`\" = set"; then
-  echo $ac_n "(cached) $ac_c" 1>&6
+if test -n "$ac_tool_prefix"; then
+  # 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 "$as_me:2234: checking for $ac_word" >&5
+echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6
+if test "${ac_cv_prog_RANLIB+set}" = set; then
+  echo $ECHO_N "(cached) $ECHO_C" >&6
 else
   if test -n "$RANLIB"; then
   ac_cv_prog_RANLIB="$RANLIB" # Let the user override the test.
 else
-  IFS="${IFS= 	}"; ac_save_ifs="$IFS"; IFS="${IFS}:"
-  for ac_dir in $PATH; do
-    test -z "$ac_dir" && ac_dir=.
-    if test -f $ac_dir/$ac_word; then
-      ac_cv_prog_RANLIB="ranlib"
-      break
-    fi
-  done
-  IFS="$ac_save_ifs"
-  test -z "$ac_cv_prog_RANLIB" && ac_cv_prog_RANLIB=":"
+  ac_save_IFS=$IFS; IFS=$ac_path_separator
+ac_dummy="$PATH"
+for ac_dir in $ac_dummy; do
+  IFS=$ac_save_IFS
+  test -z "$ac_dir" && ac_dir=.
+  $as_executable_p "$ac_dir/$ac_word" || continue
+ac_cv_prog_RANLIB="${ac_tool_prefix}ranlib"
+echo "$as_me:2249: found $ac_dir/$ac_word" >&5
+break
+done
+
 fi
 fi
-RANLIB="$ac_cv_prog_RANLIB"
+RANLIB=$ac_cv_prog_RANLIB
 if test -n "$RANLIB"; then
-  echo "$ac_t""$RANLIB" 1>&6
+  echo "$as_me:2257: result: $RANLIB" >&5
+echo "${ECHO_T}$RANLIB" >&6
+else
+  echo "$as_me:2260: result: no" >&5
+echo "${ECHO_T}no" >&6
+fi
+
+fi
+if test -z "$ac_cv_prog_RANLIB"; then
+  ac_ct_RANLIB=$RANLIB
+  # Extract the first word of "ranlib", so it can be a program name with args.
+set dummy ranlib; ac_word=$2
+echo "$as_me:2269: checking for $ac_word" >&5
+echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6
+if test "${ac_cv_prog_ac_ct_RANLIB+set}" = set; then
+  echo $ECHO_N "(cached) $ECHO_C" >&6
+else
+  if test -n "$ac_ct_RANLIB"; then
+  ac_cv_prog_ac_ct_RANLIB="$ac_ct_RANLIB" # Let the user override the test.
+else
+  ac_save_IFS=$IFS; IFS=$ac_path_separator
+ac_dummy="$PATH"
+for ac_dir in $ac_dummy; do
+  IFS=$ac_save_IFS
+  test -z "$ac_dir" && ac_dir=.
+  $as_executable_p "$ac_dir/$ac_word" || continue
+ac_cv_prog_ac_ct_RANLIB="ranlib"
+echo "$as_me:2284: found $ac_dir/$ac_word" >&5
+break
+done
+
+  test -z "$ac_cv_prog_ac_ct_RANLIB" && ac_cv_prog_ac_ct_RANLIB=":"
+fi
+fi
+ac_ct_RANLIB=$ac_cv_prog_ac_ct_RANLIB
+if test -n "$ac_ct_RANLIB"; then
+  echo "$as_me:2293: result: $ac_ct_RANLIB" >&5
+echo "${ECHO_T}$ac_ct_RANLIB" >&6
 else
-  echo "$ac_t""no" 1>&6
+  echo "$as_me:2296: result: no" >&5
+echo "${ECHO_T}no" >&6
 fi
 
+  RANLIB=$ac_ct_RANLIB
+else
+  RANLIB="$ac_cv_prog_RANLIB"
+fi
 
 MAKE_SHELL=/bin/sh
 
-
-echo $ac_n "checking return type of signal handlers""... $ac_c" 1>&6
-echo "configure:1138: 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
+echo "$as_me:2307: checking for $CC option to accept ANSI C" >&5
+echo $ECHO_N "checking for $CC option to accept ANSI C... $ECHO_C" >&6
+if test "${ac_cv_prog_cc_stdc+set}" = set; then
+  echo $ECHO_N "(cached) $ECHO_C" >&6
 else
-  cat > conftest.$ac_ext <<EOF
-#line 1143 "configure"
+  ac_cv_prog_cc_stdc=no
+ac_save_CC=$CC
+cat >conftest.$ac_ext <<_ACEOF
+#line 2315 "configure"
 #include "confdefs.h"
+#include <stdarg.h>
+#include <stdio.h>
 #include <sys/types.h>
-#include <signal.h>
-#ifdef signal
-#undef signal
-#endif
+#include <sys/stat.h>
+/* Most of the following tests are stolen from RCS 5.7's src/conf.sh.  */
+struct buf { int x; };
+FILE * (*rcsopen) (struct buf *, struct stat *, int);
+static char *e (p, i)
+     char **p;
+     int i;
+{
+  return p[i];
+}
+static char *f (char * (*g) (char **, int), char **p, ...)
+{
+  char *s;
+  va_list v;
+  va_start (v,p);
+  s = g (p, va_arg (v,int));
+  va_end (v);
+  return s;
+}
+int test (int i, double x);
+struct s1 {int (*f) (int a);};
+struct s2 {int (*f) (double a);};
+int pairnames (int, char **, FILE *(*)(struct buf *, struct stat *, int), int, int);
+int argc;
+char **argv;
+int
+main ()
+{
+return f (e, argv, 0) != argv[0]  ||  f (e, argv, 1) != argv[1];
+  ;
+  return 0;
+}
+_ACEOF
+# Don't try gcc -ansi; that turns off useful extensions and
+# breaks some systems' header files.
+# AIX			-qlanglvl=ansi
+# Ultrix and OSF/1	-std1
+# HP-UX 10.20 and later	-Ae
+# HP-UX older versions	-Aa -D_HPUX_SOURCE
+# SVR4			-Xc -D__EXTENSIONS__
+for ac_arg in "" -qlanglvl=ansi -std1 -Ae "-Aa -D_HPUX_SOURCE" "-Xc -D__EXTENSIONS__"
+do
+  CC="$ac_save_CC $ac_arg"
+  rm -f conftest.$ac_objext
+if { (eval echo "$as_me:2364: \"$ac_compile\"") >&5
+  (eval $ac_compile) 2>&5
+  ac_status=$?
+  echo "$as_me:2367: \$? = $ac_status" >&5
+  (exit $ac_status); } &&
+         { ac_try='test -s conftest.$ac_objext'
+  { (eval echo "$as_me:2370: \"$ac_try\"") >&5
+  (eval $ac_try) 2>&5
+  ac_status=$?
+  echo "$as_me:2373: \$? = $ac_status" >&5
+  (exit $ac_status); }; }; then
+  ac_cv_prog_cc_stdc=$ac_arg
+break
+else
+  echo "$as_me: failed program was:" >&5
+cat conftest.$ac_ext >&5
+fi
+rm -f conftest.$ac_objext
+done
+rm -f conftest.$ac_ext conftest.$ac_objext
+CC=$ac_save_CC
+
+fi
+
+case "x$ac_cv_prog_cc_stdc" in
+  x|xno)
+    echo "$as_me:2390: result: none needed" >&5
+echo "${ECHO_T}none needed" >&6 ;;
+  *)
+    echo "$as_me:2393: result: $ac_cv_prog_cc_stdc" >&5
+echo "${ECHO_T}$ac_cv_prog_cc_stdc" >&6
+    CC="$CC $ac_cv_prog_cc_stdc" ;;
+esac
+
+echo "$as_me:2398: checking for an ANSI C-conforming const" >&5
+echo $ECHO_N "checking for an ANSI C-conforming const... $ECHO_C" >&6
+if test "${ac_cv_c_const+set}" = set; then
+  echo $ECHO_N "(cached) $ECHO_C" >&6
+else
+  cat >conftest.$ac_ext <<_ACEOF
+#line 2404 "configure"
+#include "confdefs.h"
+
+int
+main ()
+{
+/* FIXME: Include the comments suggested by Paul. */
+#ifndef __cplusplus
+  /* Ultrix mips cc rejects this.  */
+  typedef int charset[2];
+  const charset x;
+  /* SunOS 4.1.1 cc rejects this.  */
+  char const *const *ccp;
+  char **p;
+  /* NEC SVR4.0.2 mips cc rejects this.  */
+  struct point {int x, y;};
+  static struct point const zero = {0,0};
+  /* AIX XL C 1.02.0.0 rejects this.
+     It does not let you subtract one const X* pointer from another in
+     an arm of an if-expression whose if-part is not a constant
+     expression */
+  const char *g = "string";
+  ccp = &g + (g ? g-g : 0);
+  /* HPUX 7.0 cc rejects these. */
+  ++ccp;
+  p = (char**) ccp;
+  ccp = (char const *const *) p;
+  { /* SCO 3.2v4 cc rejects this.  */
+    char *t;
+    char const *s = 0 ? (char *) 0 : (char const *) 0;
+
+    *t++ = 0;
+  }
+  { /* Someone thinks the Sun supposedly-ANSI compiler will reject this.  */
+    int x[] = {25, 17};
+    const int *foo = &x[0];
+    ++foo;
+  }
+  { /* Sun SC1.0 ANSI compiler rejects this -- but not the above. */
+    typedef const int *iptr;
+    iptr p = 0;
+    ++p;
+  }
+  { /* AIX XL C 1.02.0.0 rejects this saying
+       "k.c", line 2.27: 1506-025 (S) Operand must be a modifiable lvalue. */
+    struct s { int j; const int *ap[3]; };
+    struct s *b; b->j = 5;
+  }
+  { /* ULTRIX-32 V3.1 (Rev 9) vcc rejects this */
+    const int foo = 10;
+  }
+#endif
+
+  ;
+  return 0;
+}
+_ACEOF
+rm -f conftest.$ac_objext
+if { (eval echo "$as_me:2462: \"$ac_compile\"") >&5
+  (eval $ac_compile) 2>&5
+  ac_status=$?
+  echo "$as_me:2465: \$? = $ac_status" >&5
+  (exit $ac_status); } &&
+         { ac_try='test -s conftest.$ac_objext'
+  { (eval echo "$as_me:2468: \"$ac_try\"") >&5
+  (eval $ac_try) 2>&5
+  ac_status=$?
+  echo "$as_me:2471: \$? = $ac_status" >&5
+  (exit $ac_status); }; }; then
+  ac_cv_c_const=yes
+else
+  echo "$as_me: failed program was:" >&5
+cat conftest.$ac_ext >&5
+ac_cv_c_const=no
+fi
+rm -f conftest.$ac_objext conftest.$ac_ext
+fi
+echo "$as_me:2481: result: $ac_cv_c_const" >&5
+echo "${ECHO_T}$ac_cv_c_const" >&6
+if test $ac_cv_c_const = no; then
+
+cat >>confdefs.h <<\EOF
+#define const
+EOF
+
+fi
+
+echo "$as_me:2491: checking for function prototypes" >&5
+echo $ECHO_N "checking for function prototypes... $ECHO_C" >&6
+if test "$ac_cv_prog_cc_stdc" != no; then
+  echo "$as_me:2494: result: yes" >&5
+echo "${ECHO_T}yes" >&6
+
+cat >>confdefs.h <<\EOF
+#define PROTOTYPES 1
+EOF
+
+else
+  echo "$as_me:2502: result: no" >&5
+echo "${ECHO_T}no" >&6
+fi
+
+echo "$as_me:2506: checking for ANSI C header files" >&5
+echo $ECHO_N "checking for ANSI C header files... $ECHO_C" >&6
+if test "${ac_cv_header_stdc+set}" = set; then
+  echo $ECHO_N "(cached) $ECHO_C" >&6
+else
+  cat >conftest.$ac_ext <<_ACEOF
+#line 2512 "configure"
+#include "confdefs.h"
+#include <stdlib.h>
+#include <stdarg.h>
+#include <string.h>
+#include <float.h>
+
+_ACEOF
+if { (eval echo "$as_me:2520: \"$ac_cpp conftest.$ac_ext\"") >&5
+  (eval $ac_cpp conftest.$ac_ext) 2>conftest.er1
+  ac_status=$?
+  egrep -v '^ *\+' conftest.er1 >conftest.err
+  rm -f conftest.er1
+  cat conftest.err >&5
+  echo "$as_me:2526: \$? = $ac_status" >&5
+  (exit $ac_status); } >/dev/null; then
+  if test -s conftest.err; then
+    ac_cpp_err=$ac_c_preproc_warn_flag
+  else
+    ac_cpp_err=
+  fi
+else
+  ac_cpp_err=yes
+fi
+if test -z "$ac_cpp_err"; then
+  ac_cv_header_stdc=yes
+else
+  echo "$as_me: failed program was:" >&5
+  cat conftest.$ac_ext >&5
+  ac_cv_header_stdc=no
+fi
+rm -f conftest.err conftest.$ac_ext
+
+if test $ac_cv_header_stdc = yes; then
+  # SunOS 4.x string.h does not declare mem*, contrary to ANSI.
+  cat >conftest.$ac_ext <<_ACEOF
+#line 2548 "configure"
+#include "confdefs.h"
+#include <string.h>
+
+_ACEOF
+if (eval "$ac_cpp conftest.$ac_ext") 2>&5 |
+  egrep "memchr" >/dev/null 2>&1; then
+  :
+else
+  ac_cv_header_stdc=no
+fi
+rm -f conftest*
+
+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 <<_ACEOF
+#line 2566 "configure"
+#include "confdefs.h"
+#include <stdlib.h>
+
+_ACEOF
+if (eval "$ac_cpp conftest.$ac_ext") 2>&5 |
+  egrep "free" >/dev/null 2>&1; then
+  :
+else
+  ac_cv_header_stdc=no
+fi
+rm -f conftest*
+
+fi
+
+if test $ac_cv_header_stdc = yes; then
+  # /bin/cc in Irix-4.0.5 gets non-ANSI ctype macros unless using -ansi.
+  if test "$cross_compiling" = yes; then
+  :
+else
+  cat >conftest.$ac_ext <<_ACEOF
+#line 2587 "configure"
+#include "confdefs.h"
+#include <ctype.h>
+#if ((' ' & 0x0FF) == 0x020)
+# define ISLOWER(c) ('a' <= (c) && (c) <= 'z')
+# define TOUPPER(c) (ISLOWER(c) ? 'A' + ((c) - 'a') : (c))
+#else
+# define ISLOWER(c) (('a' <= (c) && (c) <= 'i') \
+                     || ('j' <= (c) && (c) <= 'r') \
+                     || ('s' <= (c) && (c) <= 'z'))
+# define TOUPPER(c) (ISLOWER(c) ? ((c) | 0x40) : (c))
+#endif
+
+#define XOR(e, f) (((e) && !(f)) || (!(e) && (f)))
+int
+main ()
+{
+  int i;
+  for (i = 0; i < 256; i++)
+    if (XOR (islower (i), ISLOWER (i))
+        || toupper (i) != TOUPPER (i))
+      exit(2);
+  exit (0);
+}
+_ACEOF
+rm -f conftest$ac_exeext
+if { (eval echo "$as_me:2613: \"$ac_link\"") >&5
+  (eval $ac_link) 2>&5
+  ac_status=$?
+  echo "$as_me:2616: \$? = $ac_status" >&5
+  (exit $ac_status); } && { ac_try='./conftest$ac_exeext'
+  { (eval echo "$as_me:2618: \"$ac_try\"") >&5
+  (eval $ac_try) 2>&5
+  ac_status=$?
+  echo "$as_me:2621: \$? = $ac_status" >&5
+  (exit $ac_status); }; }; then
+  :
+else
+  echo "$as_me: program exited with status $ac_status" >&5
+echo "$as_me: failed program was:" >&5
+cat conftest.$ac_ext >&5
+ac_cv_header_stdc=no
+fi
+rm -f core core.* *.core conftest$ac_exeext conftest.$ac_objext conftest.$ac_ext
+fi
+fi
+fi
+echo "$as_me:2634: result: $ac_cv_header_stdc" >&5
+echo "${ECHO_T}$ac_cv_header_stdc" >&6
+if test $ac_cv_header_stdc = yes; then
+
+cat >>confdefs.h <<\EOF
+#define STDC_HEADERS 1
+EOF
+
+fi
+
+# On IRIX 5.3, sys/types and inttypes.h are conflicting.
+
+for ac_header in sys/types.h sys/stat.h stdlib.h string.h memory.h strings.h \
+                  inttypes.h stdint.h unistd.h
+do
+as_ac_Header=`echo "ac_cv_header_$ac_header" | $as_tr_sh`
+echo "$as_me:2650: checking for $ac_header" >&5
+echo $ECHO_N "checking for $ac_header... $ECHO_C" >&6
+if eval "test \"\${$as_ac_Header+set}\" = set"; then
+  echo $ECHO_N "(cached) $ECHO_C" >&6
+else
+  cat >conftest.$ac_ext <<_ACEOF
+#line 2656 "configure"
+#include "confdefs.h"
+$ac_includes_default
+#include <$ac_header>
+_ACEOF
+rm -f conftest.$ac_objext
+if { (eval echo "$as_me:2662: \"$ac_compile\"") >&5
+  (eval $ac_compile) 2>&5
+  ac_status=$?
+  echo "$as_me:2665: \$? = $ac_status" >&5
+  (exit $ac_status); } &&
+         { ac_try='test -s conftest.$ac_objext'
+  { (eval echo "$as_me:2668: \"$ac_try\"") >&5
+  (eval $ac_try) 2>&5
+  ac_status=$?
+  echo "$as_me:2671: \$? = $ac_status" >&5
+  (exit $ac_status); }; }; then
+  eval "$as_ac_Header=yes"
+else
+  echo "$as_me: failed program was:" >&5
+cat conftest.$ac_ext >&5
+eval "$as_ac_Header=no"
+fi
+rm -f conftest.$ac_objext conftest.$ac_ext
+fi
+echo "$as_me:2681: result: `eval echo '${'$as_ac_Header'}'`" >&5
+echo "${ECHO_T}`eval echo '${'$as_ac_Header'}'`" >&6
+if test `eval echo '${'$as_ac_Header'}'` = yes; then
+  cat >>confdefs.h <<EOF
+#define `echo "HAVE_$ac_header" | $as_tr_cpp` 1
+EOF
+
+fi
+done
+
+echo "$as_me:2691: checking whether char is unsigned" >&5
+echo $ECHO_N "checking whether char is unsigned... $ECHO_C" >&6
+if test "${ac_cv_c_char_unsigned+set}" = set; then
+  echo $ECHO_N "(cached) $ECHO_C" >&6
+else
+  cat >conftest.$ac_ext <<_ACEOF
+#line 2697 "configure"
+#include "confdefs.h"
+$ac_includes_default
+int
+main ()
+{
+int _array_ [1 - 2 * !(((char) -1) < 0)]
+  ;
+  return 0;
+}
+_ACEOF
+rm -f conftest.$ac_objext
+if { (eval echo "$as_me:2709: \"$ac_compile\"") >&5
+  (eval $ac_compile) 2>&5
+  ac_status=$?
+  echo "$as_me:2712: \$? = $ac_status" >&5
+  (exit $ac_status); } &&
+         { ac_try='test -s conftest.$ac_objext'
+  { (eval echo "$as_me:2715: \"$ac_try\"") >&5
+  (eval $ac_try) 2>&5
+  ac_status=$?
+  echo "$as_me:2718: \$? = $ac_status" >&5
+  (exit $ac_status); }; }; then
+  ac_cv_c_char_unsigned=no
+else
+  echo "$as_me: failed program was:" >&5
+cat conftest.$ac_ext >&5
+ac_cv_c_char_unsigned=yes
+fi
+rm -f conftest.$ac_objext conftest.$ac_ext
+fi
+echo "$as_me:2728: result: $ac_cv_c_char_unsigned" >&5
+echo "${ECHO_T}$ac_cv_c_char_unsigned" >&6
+if test $ac_cv_c_char_unsigned = yes && test "$GCC" != yes; then
+  cat >>confdefs.h <<\EOF
+#define __CHAR_UNSIGNED__ 1
+EOF
+
+fi
+
+echo "$as_me:2737: checking return type of signal handlers" >&5
+echo $ECHO_N "checking return type of signal handlers... $ECHO_C" >&6
+if test "${ac_cv_type_signal+set}" = set; then
+  echo $ECHO_N "(cached) $ECHO_C" >&6
+else
+  cat >conftest.$ac_ext <<_ACEOF
+#line 2743 "configure"
+#include "confdefs.h"
+#include <sys/types.h>
+#include <signal.h>
+#ifdef signal
+# undef signal
+#endif
 #ifdef __cplusplus
 extern "C" void (*signal (int, void (*)(int)))(int);
 #else
 void (*signal ()) ();
 #endif
 
-int main() {
+int
+main ()
+{
 int i;
-; return 0; }
-EOF
-if { (eval echo configure:1160: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
-  rm -rf conftest*
+  ;
+  return 0;
+}
+_ACEOF
+rm -f conftest.$ac_objext
+if { (eval echo "$as_me:2765: \"$ac_compile\"") >&5
+  (eval $ac_compile) 2>&5
+  ac_status=$?
+  echo "$as_me:2768: \$? = $ac_status" >&5
+  (exit $ac_status); } &&
+         { ac_try='test -s conftest.$ac_objext'
+  { (eval echo "$as_me:2771: \"$ac_try\"") >&5
+  (eval $ac_try) 2>&5
+  ac_status=$?
+  echo "$as_me:2774: \$? = $ac_status" >&5
+  (exit $ac_status); }; }; then
   ac_cv_type_signal=void
 else
-  echo "configure: failed program was:" >&5
-  cat conftest.$ac_ext >&5
-  rm -rf conftest*
-  ac_cv_type_signal=int
+  echo "$as_me: failed program was:" >&5
+cat conftest.$ac_ext >&5
+ac_cv_type_signal=int
 fi
-rm -f conftest*
+rm -f conftest.$ac_objext conftest.$ac_ext
 fi
+echo "$as_me:2784: result: $ac_cv_type_signal" >&5
+echo "${ECHO_T}$ac_cv_type_signal" >&6
 
-echo "$ac_t""$ac_cv_type_signal" 1>&6
-cat >> confdefs.h <<EOF
+cat >>confdefs.h <<EOF
 #define RETSIGTYPE $ac_cv_type_signal
 EOF
 
+echo "$as_me:2791: checking for size_t" >&5
+echo $ECHO_N "checking for size_t... $ECHO_C" >&6
+if test "${ac_cv_type_size_t+set}" = set; then
+  echo $ECHO_N "(cached) $ECHO_C" >&6
+else
+  cat >conftest.$ac_ext <<_ACEOF
+#line 2797 "configure"
+#include "confdefs.h"
+$ac_includes_default
+int
+main ()
+{
+if ((size_t *) 0)
+  return 0;
+if (sizeof (size_t))
+  return 0;
+  ;
+  return 0;
+}
+_ACEOF
+rm -f conftest.$ac_objext
+if { (eval echo "$as_me:2812: \"$ac_compile\"") >&5
+  (eval $ac_compile) 2>&5
+  ac_status=$?
+  echo "$as_me:2815: \$? = $ac_status" >&5
+  (exit $ac_status); } &&
+         { ac_try='test -s conftest.$ac_objext'
+  { (eval echo "$as_me:2818: \"$ac_try\"") >&5
+  (eval $ac_try) 2>&5
+  ac_status=$?
+  echo "$as_me:2821: \$? = $ac_status" >&5
+  (exit $ac_status); }; }; then
+  ac_cv_type_size_t=yes
+else
+  echo "$as_me: failed program was:" >&5
+cat conftest.$ac_ext >&5
+ac_cv_type_size_t=no
+fi
+rm -f conftest.$ac_objext conftest.$ac_ext
+fi
+echo "$as_me:2831: result: $ac_cv_type_size_t" >&5
+echo "${ECHO_T}$ac_cv_type_size_t" >&6
+if test $ac_cv_type_size_t = yes; then
+  :
+else
+
+cat >>confdefs.h <<EOF
+#define size_t unsigned
+EOF
+
+fi
+
+echo "$as_me:2843: checking for ssize_t" >&5
+echo $ECHO_N "checking for ssize_t... $ECHO_C" >&6
+if test "${ac_cv_type_ssize_t+set}" = set; then
+  echo $ECHO_N "(cached) $ECHO_C" >&6
+else
+  cat >conftest.$ac_ext <<_ACEOF
+#line 2849 "configure"
+#include "confdefs.h"
+$ac_includes_default
+int
+main ()
+{
+if ((ssize_t *) 0)
+  return 0;
+if (sizeof (ssize_t))
+  return 0;
+  ;
+  return 0;
+}
+_ACEOF
+rm -f conftest.$ac_objext
+if { (eval echo "$as_me:2864: \"$ac_compile\"") >&5
+  (eval $ac_compile) 2>&5
+  ac_status=$?
+  echo "$as_me:2867: \$? = $ac_status" >&5
+  (exit $ac_status); } &&
+         { ac_try='test -s conftest.$ac_objext'
+  { (eval echo "$as_me:2870: \"$ac_try\"") >&5
+  (eval $ac_try) 2>&5
+  ac_status=$?
+  echo "$as_me:2873: \$? = $ac_status" >&5
+  (exit $ac_status); }; }; then
+  ac_cv_type_ssize_t=yes
+else
+  echo "$as_me: failed program was:" >&5
+cat conftest.$ac_ext >&5
+ac_cv_type_ssize_t=no
+fi
+rm -f conftest.$ac_objext conftest.$ac_ext
+fi
+echo "$as_me:2883: result: $ac_cv_type_ssize_t" >&5
+echo "${ECHO_T}$ac_cv_type_ssize_t" >&6
+if test $ac_cv_type_ssize_t = yes; then
+  :
+else
+
+cat >>confdefs.h <<EOF
+#define ssize_t int
+EOF
 
+fi
 
-echo $ac_n "checking whether stat file-mode macros are broken""... $ac_c" 1>&6
-echo "configure:1180: checking whether stat file-mode macros are broken" >&5
-if eval "test \"`echo '$''{'ac_cv_header_stat_broken'+set}'`\" = set"; then
-  echo $ac_n "(cached) $ac_c" 1>&6
+echo "$as_me:2895: checking whether stat file-mode macros are broken" >&5
+echo $ECHO_N "checking whether stat file-mode macros are broken... $ECHO_C" >&6
+if test "${ac_cv_header_stat_broken+set}" = set; then
+  echo $ECHO_N "(cached) $ECHO_C" >&6
 else
-  cat > conftest.$ac_ext <<EOF
-#line 1185 "configure"
+  cat >conftest.$ac_ext <<_ACEOF
+#line 2901 "configure"
 #include "confdefs.h"
 #include <sys/types.h>
 #include <sys/stat.h>
@@ -1210,408 +2927,516 @@ You lose.
 # endif
 #endif
 
-EOF
+_ACEOF
 if (eval "$ac_cpp conftest.$ac_ext") 2>&5 |
   egrep "You lose" >/dev/null 2>&1; then
-  rm -rf conftest*
   ac_cv_header_stat_broken=yes
 else
-  rm -rf conftest*
   ac_cv_header_stat_broken=no
 fi
 rm -f conftest*
 
 fi
-
-echo "$ac_t""$ac_cv_header_stat_broken" 1>&6
+echo "$as_me:2940: result: $ac_cv_header_stat_broken" >&5
+echo "${ECHO_T}$ac_cv_header_stat_broken" >&6
 if test $ac_cv_header_stat_broken = yes; then
-  cat >> confdefs.h <<\EOF
+
+cat >>confdefs.h <<\EOF
 #define STAT_MACROS_BROKEN 1
 EOF
 
 fi
 
 ac_header_dirent=no
-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:1240: 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 1245 "configure"
+for ac_hdr in dirent.h sys/ndir.h sys/dir.h ndir.h; do
+  as_ac_Header=`echo "ac_cv_header_dirent_$ac_hdr" | $as_tr_sh`
+echo "$as_me:2953: checking for $ac_hdr that defines DIR" >&5
+echo $ECHO_N "checking for $ac_hdr that defines DIR... $ECHO_C" >&6
+if eval "test \"\${$as_ac_Header+set}\" = set"; then
+  echo $ECHO_N "(cached) $ECHO_C" >&6
+else
+  cat >conftest.$ac_ext <<_ACEOF
+#line 2959 "configure"
 #include "confdefs.h"
 #include <sys/types.h>
 #include <$ac_hdr>
-int main() {
-DIR *dirp = 0;
-; return 0; }
-EOF
-if { (eval echo configure:1253: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
-  rm -rf conftest*
-  eval "ac_cv_header_dirent_$ac_safe=yes"
+
+int
+main ()
+{
+if ((DIR *) 0)
+return 0;
+  ;
+  return 0;
+}
+_ACEOF
+rm -f conftest.$ac_objext
+if { (eval echo "$as_me:2974: \"$ac_compile\"") >&5
+  (eval $ac_compile) 2>&5
+  ac_status=$?
+  echo "$as_me:2977: \$? = $ac_status" >&5
+  (exit $ac_status); } &&
+         { ac_try='test -s conftest.$ac_objext'
+  { (eval echo "$as_me:2980: \"$ac_try\"") >&5
+  (eval $ac_try) 2>&5
+  ac_status=$?
+  echo "$as_me:2983: \$? = $ac_status" >&5
+  (exit $ac_status); }; }; then
+  eval "$as_ac_Header=yes"
 else
-  echo "configure: failed program was:" >&5
-  cat conftest.$ac_ext >&5
-  rm -rf conftest*
-  eval "ac_cv_header_dirent_$ac_safe=no"
+  echo "$as_me: failed program was:" >&5
+cat conftest.$ac_ext >&5
+eval "$as_ac_Header=no"
 fi
-rm -f conftest*
+rm -f conftest.$ac_objext conftest.$ac_ext
 fi
-if eval "test \"`echo '$ac_cv_header_dirent_'$ac_safe`\" = yes"; then
-  echo "$ac_t""yes" 1>&6
-    ac_tr_hdr=HAVE_`echo $ac_hdr | sed 'y%abcdefghijklmnopqrstuvwxyz./-%ABCDEFGHIJKLMNOPQRSTUVWXYZ___%'`
-  cat >> confdefs.h <<EOF
-#define $ac_tr_hdr 1
+echo "$as_me:2993: result: `eval echo '${'$as_ac_Header'}'`" >&5
+echo "${ECHO_T}`eval echo '${'$as_ac_Header'}'`" >&6
+if test `eval echo '${'$as_ac_Header'}'` = yes; then
+  cat >>confdefs.h <<EOF
+#define `echo "HAVE_$ac_hdr" | $as_tr_cpp` 1
 EOF
- ac_header_dirent=$ac_hdr; break
-else
-  echo "$ac_t""no" 1>&6
+
+ac_header_dirent=$ac_hdr; break
 fi
+
 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:1278: 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
+  echo "$as_me:3006: checking for opendir in -ldir" >&5
+echo $ECHO_N "checking for opendir in -ldir... $ECHO_C" >&6
+if test "${ac_cv_lib_dir_opendir+set}" = set; then
+  echo $ECHO_N "(cached) $ECHO_C" >&6
 else
-  ac_save_LIBS="$LIBS"
+  ac_check_lib_save_LIBS=$LIBS
 LIBS="-ldir  $LIBS"
-cat > conftest.$ac_ext <<EOF
-#line 1286 "configure"
+cat >conftest.$ac_ext <<_ACEOF
+#line 3014 "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 opendir();
-
-int main() {
-opendir()
-; return 0; }
-EOF
-if { (eval echo configure:1297: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest; then
-  rm -rf conftest*
-  eval "ac_cv_lib_$ac_lib_var=yes"
+   builtin and then its argument prototype would still apply.  */
+char opendir ();
+int
+main ()
+{
+opendir ();
+  ;
+  return 0;
+}
+_ACEOF
+rm -f conftest.$ac_objext conftest$ac_exeext
+if { (eval echo "$as_me:3033: \"$ac_link\"") >&5
+  (eval $ac_link) 2>&5
+  ac_status=$?
+  echo "$as_me:3036: \$? = $ac_status" >&5
+  (exit $ac_status); } &&
+         { ac_try='test -s conftest$ac_exeext'
+  { (eval echo "$as_me:3039: \"$ac_try\"") >&5
+  (eval $ac_try) 2>&5
+  ac_status=$?
+  echo "$as_me:3042: \$? = $ac_status" >&5
+  (exit $ac_status); }; }; then
+  ac_cv_lib_dir_opendir=yes
 else
-  echo "configure: failed program was:" >&5
-  cat conftest.$ac_ext >&5
-  rm -rf conftest*
-  eval "ac_cv_lib_$ac_lib_var=no"
+  echo "$as_me: failed program was:" >&5
+cat conftest.$ac_ext >&5
+ac_cv_lib_dir_opendir=no
 fi
-rm -f conftest*
-LIBS="$ac_save_LIBS"
-
+rm -f conftest.$ac_objext conftest$ac_exeext conftest.$ac_ext
+LIBS=$ac_check_lib_save_LIBS
 fi
-if eval "test \"`echo '$ac_cv_lib_'$ac_lib_var`\" = yes"; then
-  echo "$ac_t""yes" 1>&6
+echo "$as_me:3053: result: $ac_cv_lib_dir_opendir" >&5
+echo "${ECHO_T}$ac_cv_lib_dir_opendir" >&6
+if test $ac_cv_lib_dir_opendir = yes; then
   LIBS="$LIBS -ldir"
-else
-  echo "$ac_t""no" 1>&6
 fi
 
 else
-echo $ac_n "checking for opendir in -lx""... $ac_c" 1>&6
-echo "configure:1319: 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
+  echo "$as_me:3060: checking for opendir in -lx" >&5
+echo $ECHO_N "checking for opendir in -lx... $ECHO_C" >&6
+if test "${ac_cv_lib_x_opendir+set}" = set; then
+  echo $ECHO_N "(cached) $ECHO_C" >&6
 else
-  ac_save_LIBS="$LIBS"
+  ac_check_lib_save_LIBS=$LIBS
 LIBS="-lx  $LIBS"
-cat > conftest.$ac_ext <<EOF
-#line 1327 "configure"
+cat >conftest.$ac_ext <<_ACEOF
+#line 3068 "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 opendir();
-
-int main() {
-opendir()
-; return 0; }
-EOF
-if { (eval echo configure:1338: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest; then
-  rm -rf conftest*
-  eval "ac_cv_lib_$ac_lib_var=yes"
+   builtin and then its argument prototype would still apply.  */
+char opendir ();
+int
+main ()
+{
+opendir ();
+  ;
+  return 0;
+}
+_ACEOF
+rm -f conftest.$ac_objext conftest$ac_exeext
+if { (eval echo "$as_me:3087: \"$ac_link\"") >&5
+  (eval $ac_link) 2>&5
+  ac_status=$?
+  echo "$as_me:3090: \$? = $ac_status" >&5
+  (exit $ac_status); } &&
+         { ac_try='test -s conftest$ac_exeext'
+  { (eval echo "$as_me:3093: \"$ac_try\"") >&5
+  (eval $ac_try) 2>&5
+  ac_status=$?
+  echo "$as_me:3096: \$? = $ac_status" >&5
+  (exit $ac_status); }; }; then
+  ac_cv_lib_x_opendir=yes
 else
-  echo "configure: failed program was:" >&5
-  cat conftest.$ac_ext >&5
-  rm -rf conftest*
-  eval "ac_cv_lib_$ac_lib_var=no"
+  echo "$as_me: failed program was:" >&5
+cat conftest.$ac_ext >&5
+ac_cv_lib_x_opendir=no
 fi
-rm -f conftest*
-LIBS="$ac_save_LIBS"
-
+rm -f conftest.$ac_objext conftest$ac_exeext conftest.$ac_ext
+LIBS=$ac_check_lib_save_LIBS
 fi
-if eval "test \"`echo '$ac_cv_lib_'$ac_lib_var`\" = yes"; then
-  echo "$ac_t""yes" 1>&6
+echo "$as_me:3107: result: $ac_cv_lib_x_opendir" >&5
+echo "${ECHO_T}$ac_cv_lib_x_opendir" >&6
+if test $ac_cv_lib_x_opendir = yes; then
   LIBS="$LIBS -lx"
-else
-  echo "$ac_t""no" 1>&6
 fi
 
 fi
 
-
-for ac_func in strcasecmp select setenv putenv tcgetattr setlocale lstat
+for ac_func in lstat memmove putenv select setenv setlocale \
+		strcasecmp strpbrk tcgetattr vsnprintf isascii isxdigit
 do
-echo $ac_n "checking for $ac_func""... $ac_c" 1>&6
-echo "configure:1364: 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
+as_ac_var=`echo "ac_cv_func_$ac_func" | $as_tr_sh`
+echo "$as_me:3119: checking for $ac_func" >&5
+echo $ECHO_N "checking for $ac_func... $ECHO_C" >&6
+if eval "test \"\${$as_ac_var+set}\" = set"; then
+  echo $ECHO_N "(cached) $ECHO_C" >&6
 else
-  cat > conftest.$ac_ext <<EOF
-#line 1369 "configure"
+  cat >conftest.$ac_ext <<_ACEOF
+#line 3125 "configure"
 #include "confdefs.h"
 /* System header to define __stub macros and hopefully few prototypes,
-    which can conflict with char $ac_func(); below.  */
+    which can conflict with char $ac_func (); 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 $ac_func();
-
-int main() {
+   builtin and then its argument prototype would still apply.  */
+char $ac_func ();
+char (*f) ();
 
+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_$ac_func) || defined (__stub___$ac_func)
 choke me
 #else
-$ac_func();
+f = $ac_func;
 #endif
 
-; return 0; }
-EOF
-if { (eval echo configure:1392: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest; then
-  rm -rf conftest*
-  eval "ac_cv_func_$ac_func=yes"
+  ;
+  return 0;
+}
+_ACEOF
+rm -f conftest.$ac_objext conftest$ac_exeext
+if { (eval echo "$as_me:3156: \"$ac_link\"") >&5
+  (eval $ac_link) 2>&5
+  ac_status=$?
+  echo "$as_me:3159: \$? = $ac_status" >&5
+  (exit $ac_status); } &&
+         { ac_try='test -s conftest$ac_exeext'
+  { (eval echo "$as_me:3162: \"$ac_try\"") >&5
+  (eval $ac_try) 2>&5
+  ac_status=$?
+  echo "$as_me:3165: \$? = $ac_status" >&5
+  (exit $ac_status); }; }; then
+  eval "$as_ac_var=yes"
 else
-  echo "configure: failed program was:" >&5
-  cat conftest.$ac_ext >&5
-  rm -rf conftest*
-  eval "ac_cv_func_$ac_func=no"
+  echo "$as_me: failed program was:" >&5
+cat conftest.$ac_ext >&5
+eval "$as_ac_var=no"
 fi
-rm -f conftest*
+rm -f conftest.$ac_objext conftest$ac_exeext conftest.$ac_ext
 fi
-
-if eval "test \"`echo '$ac_cv_func_'$ac_func`\" = yes"; then
-  echo "$ac_t""yes" 1>&6
-    ac_tr_func=HAVE_`echo $ac_func | tr 'abcdefghijklmnopqrstuvwxyz' 'ABCDEFGHIJKLMNOPQRSTUVWXYZ'`
-  cat >> confdefs.h <<EOF
-#define $ac_tr_func 1
+echo "$as_me:3175: result: `eval echo '${'$as_ac_var'}'`" >&5
+echo "${ECHO_T}`eval echo '${'$as_ac_var'}'`" >&6
+if test `eval echo '${'$as_ac_var'}'` = yes; then
+  cat >>confdefs.h <<EOF
+#define `echo "HAVE_$ac_func" | $as_tr_cpp` 1
 EOF
- 
-else
-  echo "$ac_t""no" 1>&6
+
 fi
 done
 
-
-echo $ac_n "checking for working strcoll""... $ac_c" 1>&6
-echo "configure:1418: checking for working strcoll" >&5
-if eval "test \"`echo '$''{'ac_cv_func_strcoll_works'+set}'`\" = set"; then
-  echo $ac_n "(cached) $ac_c" 1>&6
+echo "$as_me:3185: checking for working strcoll" >&5
+echo $ECHO_N "checking for working strcoll... $ECHO_C" >&6
+if test "${ac_cv_func_strcoll_works+set}" = set; then
+  echo $ECHO_N "(cached) $ECHO_C" >&6
 else
   if test "$cross_compiling" = yes; then
   ac_cv_func_strcoll_works=no
 else
-  cat > conftest.$ac_ext <<EOF
-#line 1426 "configure"
+  cat >conftest.$ac_ext <<_ACEOF
+#line 3194 "configure"
 #include "confdefs.h"
-#include <string.h>
+$ac_includes_default
+int
 main ()
 {
-  exit (strcoll ("abc", "def") >= 0 ||
-	strcoll ("ABC", "DEF") >= 0 ||
-	strcoll ("123", "456") >= 0);
+exit (strcoll ("abc", "def") >= 0 ||
+	 strcoll ("ABC", "DEF") >= 0 ||
+	 strcoll ("123", "456") >= 0)
+  ;
+  return 0;
 }
-EOF
-if { (eval echo configure:1436: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest && (./conftest; exit) 2>/dev/null
-then
+_ACEOF
+rm -f conftest$ac_exeext
+if { (eval echo "$as_me:3208: \"$ac_link\"") >&5
+  (eval $ac_link) 2>&5
+  ac_status=$?
+  echo "$as_me:3211: \$? = $ac_status" >&5
+  (exit $ac_status); } && { ac_try='./conftest$ac_exeext'
+  { (eval echo "$as_me:3213: \"$ac_try\"") >&5
+  (eval $ac_try) 2>&5
+  ac_status=$?
+  echo "$as_me:3216: \$? = $ac_status" >&5
+  (exit $ac_status); }; }; then
   ac_cv_func_strcoll_works=yes
 else
-  echo "configure: failed program was:" >&5
-  cat conftest.$ac_ext >&5
-  rm -fr conftest*
-  ac_cv_func_strcoll_works=no
+  echo "$as_me: program exited with status $ac_status" >&5
+echo "$as_me: failed program was:" >&5
+cat conftest.$ac_ext >&5
+ac_cv_func_strcoll_works=no
 fi
-rm -fr conftest*
+rm -f core core.* *.core conftest$ac_exeext conftest.$ac_objext conftest.$ac_ext
 fi
-
 fi
-
-echo "$ac_t""$ac_cv_func_strcoll_works" 1>&6
+echo "$as_me:3228: result: $ac_cv_func_strcoll_works" >&5
+echo "${ECHO_T}$ac_cv_func_strcoll_works" >&6
 if test $ac_cv_func_strcoll_works = yes; then
-  cat >> confdefs.h <<\EOF
+
+cat >>confdefs.h <<\EOF
 #define HAVE_STRCOLL 1
 EOF
 
 fi
 
-
-for ac_hdr in unistd.h stdlib.h varargs.h stdarg.h string.h \
-		sys/ptem.h sys/pte.h sys/stream.h sys/select.h \
-		termcap.h termios.h termio.h sys/file.h locale.h
+for ac_header in unistd.h stdlib.h varargs.h stdarg.h string.h strings.h \
+		limits.h sys/ptem.h sys/pte.h sys/stream.h sys/select.h \
+		termcap.h termios.h termio.h sys/file.h locale.h memory.h
 do
-ac_safe=`echo "$ac_hdr" | sed 'y%./+-%__p_%'`
-echo $ac_n "checking for $ac_hdr""... $ac_c" 1>&6
-echo "configure:1465: 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 1470 "configure"
+as_ac_Header=`echo "ac_cv_header_$ac_header" | $as_tr_sh`
+echo "$as_me:3243: checking for $ac_header" >&5
+echo $ECHO_N "checking for $ac_header... $ECHO_C" >&6
+if eval "test \"\${$as_ac_Header+set}\" = set"; then
+  echo $ECHO_N "(cached) $ECHO_C" >&6
+else
+  cat >conftest.$ac_ext <<_ACEOF
+#line 3249 "configure"
 #include "confdefs.h"
-#include <$ac_hdr>
-EOF
-ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out"
-{ (eval echo configure:1475: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
-ac_err=`grep -v '^ *+' conftest.out`
-if test -z "$ac_err"; then
-  rm -rf conftest*
-  eval "ac_cv_header_$ac_safe=yes"
+#include <$ac_header>
+_ACEOF
+if { (eval echo "$as_me:3253: \"$ac_cpp conftest.$ac_ext\"") >&5
+  (eval $ac_cpp conftest.$ac_ext) 2>conftest.er1
+  ac_status=$?
+  egrep -v '^ *\+' conftest.er1 >conftest.err
+  rm -f conftest.er1
+  cat conftest.err >&5
+  echo "$as_me:3259: \$? = $ac_status" >&5
+  (exit $ac_status); } >/dev/null; then
+  if test -s conftest.err; then
+    ac_cpp_err=$ac_c_preproc_warn_flag
+  else
+    ac_cpp_err=
+  fi
+else
+  ac_cpp_err=yes
+fi
+if test -z "$ac_cpp_err"; then
+  eval "$as_ac_Header=yes"
 else
-  echo "$ac_err" >&5
-  echo "configure: failed program was:" >&5
+  echo "$as_me: failed program was:" >&5
   cat conftest.$ac_ext >&5
-  rm -rf conftest*
-  eval "ac_cv_header_$ac_safe=no"
+  eval "$as_ac_Header=no"
 fi
-rm -f conftest*
+rm -f conftest.err conftest.$ac_ext
 fi
-if eval "test \"`echo '$ac_cv_header_'$ac_safe`\" = yes"; then
-  echo "$ac_t""yes" 1>&6
-    ac_tr_hdr=HAVE_`echo $ac_hdr | sed 'y%abcdefghijklmnopqrstuvwxyz./-%ABCDEFGHIJKLMNOPQRSTUVWXYZ___%'`
-  cat >> confdefs.h <<EOF
-#define $ac_tr_hdr 1
+echo "$as_me:3278: result: `eval echo '${'$as_ac_Header'}'`" >&5
+echo "${ECHO_T}`eval echo '${'$as_ac_Header'}'`" >&6
+if test `eval echo '${'$as_ac_Header'}'` = yes; then
+  cat >>confdefs.h <<EOF
+#define `echo "HAVE_$ac_header" | $as_tr_cpp` 1
 EOF
- 
-else
-  echo "$ac_t""no" 1>&6
+
 fi
 done
 
-
-
-echo $ac_n "checking for type of signal functions""... $ac_c" 1>&6
-echo "configure:1504: checking for type of signal functions" >&5
-if eval "test \"`echo '$''{'bash_cv_signal_vintage'+set}'`\" = set"; then
-  echo $ac_n "(cached) $ac_c" 1>&6
+echo "$as_me:3288: checking for type of signal functions" >&5
+echo $ECHO_N "checking for type of signal functions... $ECHO_C" >&6
+if test "${bash_cv_signal_vintage+set}" = set; then
+  echo $ECHO_N "(cached) $ECHO_C" >&6
 else
-  
-  cat > conftest.$ac_ext <<EOF
-#line 1510 "configure"
+
+  cat >conftest.$ac_ext <<_ACEOF
+#line 3295 "configure"
 #include "confdefs.h"
 #include <signal.h>
-int main() {
+int
+main ()
+{
 
     sigset_t ss;
     struct sigaction sa;
     sigemptyset(&ss); sigsuspend(&ss);
     sigaction(SIGINT, &sa, (struct sigaction *) 0);
     sigprocmask(SIG_BLOCK, &ss, (sigset_t *) 0);
-  
-; return 0; }
-EOF
-if { (eval echo configure:1523: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest; then
-  rm -rf conftest*
+
+  ;
+  return 0;
+}
+_ACEOF
+rm -f conftest.$ac_objext conftest$ac_exeext
+if { (eval echo "$as_me:3313: \"$ac_link\"") >&5
+  (eval $ac_link) 2>&5
+  ac_status=$?
+  echo "$as_me:3316: \$? = $ac_status" >&5
+  (exit $ac_status); } &&
+         { ac_try='test -s conftest$ac_exeext'
+  { (eval echo "$as_me:3319: \"$ac_try\"") >&5
+  (eval $ac_try) 2>&5
+  ac_status=$?
+  echo "$as_me:3322: \$? = $ac_status" >&5
+  (exit $ac_status); }; }; then
   bash_cv_signal_vintage=posix
 else
-  echo "configure: failed program was:" >&5
-  cat conftest.$ac_ext >&5
-  rm -rf conftest*
-  
-    cat > conftest.$ac_ext <<EOF
-#line 1532 "configure"
+  echo "$as_me: failed program was:" >&5
+cat conftest.$ac_ext >&5
+
+    cat >conftest.$ac_ext <<_ACEOF
+#line 3330 "configure"
 #include "confdefs.h"
 #include <signal.h>
-int main() {
+int
+main ()
+{
 
 	int mask = sigmask(SIGINT);
 	sigsetmask(mask); sigblock(mask); sigpause(mask);
-    
-; return 0; }
-EOF
-if { (eval echo configure:1542: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest; then
-  rm -rf conftest*
+
+  ;
+  return 0;
+}
+_ACEOF
+rm -f conftest.$ac_objext conftest$ac_exeext
+if { (eval echo "$as_me:3345: \"$ac_link\"") >&5
+  (eval $ac_link) 2>&5
+  ac_status=$?
+  echo "$as_me:3348: \$? = $ac_status" >&5
+  (exit $ac_status); } &&
+         { ac_try='test -s conftest$ac_exeext'
+  { (eval echo "$as_me:3351: \"$ac_try\"") >&5
+  (eval $ac_try) 2>&5
+  ac_status=$?
+  echo "$as_me:3354: \$? = $ac_status" >&5
+  (exit $ac_status); }; }; then
   bash_cv_signal_vintage=4.2bsd
 else
-  echo "configure: failed program was:" >&5
-  cat conftest.$ac_ext >&5
-  rm -rf conftest*
-  
-      cat > conftest.$ac_ext <<EOF
-#line 1551 "configure"
+  echo "$as_me: failed program was:" >&5
+cat conftest.$ac_ext >&5
+
+      cat >conftest.$ac_ext <<_ACEOF
+#line 3362 "configure"
 #include "confdefs.h"
 
 	#include <signal.h>
 	RETSIGTYPE foo() { }
-int main() {
+int
+main ()
+{
 
 		int mask = sigmask(SIGINT);
 		sigset(SIGINT, foo); sigrelse(SIGINT);
 		sighold(SIGINT); sigpause(SIGINT);
-        
-; return 0; }
-EOF
-if { (eval echo configure:1564: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest; then
-  rm -rf conftest*
+
+  ;
+  return 0;
+}
+_ACEOF
+rm -f conftest.$ac_objext conftest$ac_exeext
+if { (eval echo "$as_me:3380: \"$ac_link\"") >&5
+  (eval $ac_link) 2>&5
+  ac_status=$?
+  echo "$as_me:3383: \$? = $ac_status" >&5
+  (exit $ac_status); } &&
+         { ac_try='test -s conftest$ac_exeext'
+  { (eval echo "$as_me:3386: \"$ac_try\"") >&5
+  (eval $ac_try) 2>&5
+  ac_status=$?
+  echo "$as_me:3389: \$? = $ac_status" >&5
+  (exit $ac_status); }; }; then
   bash_cv_signal_vintage=svr3
 else
-  echo "configure: failed program was:" >&5
-  cat conftest.$ac_ext >&5
-  rm -rf conftest*
-  bash_cv_signal_vintage=v7
-    
+  echo "$as_me: failed program was:" >&5
+cat conftest.$ac_ext >&5
+bash_cv_signal_vintage=v7
+
 fi
-rm -f conftest*
-  
+rm -f conftest.$ac_objext conftest$ac_exeext conftest.$ac_ext
+
 fi
-rm -f conftest*
+rm -f conftest.$ac_objext conftest$ac_exeext conftest.$ac_ext
 
 fi
-rm -f conftest*
+rm -f conftest.$ac_objext conftest$ac_exeext conftest.$ac_ext
 
 fi
 
-echo "$ac_t""$bash_cv_signal_vintage" 1>&6
+echo "$as_me:3408: result: $bash_cv_signal_vintage" >&5
+echo "${ECHO_T}$bash_cv_signal_vintage" >&6
 if test "$bash_cv_signal_vintage" = posix; then
-cat >> confdefs.h <<\EOF
+cat >>confdefs.h <<\EOF
 #define HAVE_POSIX_SIGNALS 1
 EOF
 
 elif test "$bash_cv_signal_vintage" = "4.2bsd"; then
-cat >> confdefs.h <<\EOF
+cat >>confdefs.h <<\EOF
 #define HAVE_BSD_SIGNALS 1
 EOF
 
 elif test "$bash_cv_signal_vintage" = svr3; then
-cat >> confdefs.h <<\EOF
+cat >>confdefs.h <<\EOF
 #define HAVE_USG_SIGHOLD 1
 EOF
 
 fi
 
-
-
-echo $ac_n "checking if signal handlers must be reinstalled when invoked""... $ac_c" 1>&6
-echo "configure:1605: checking if signal handlers must be reinstalled when invoked" >&5
-if eval "test \"`echo '$''{'bash_cv_must_reinstall_sighandlers'+set}'`\" = set"; then
-  echo $ac_n "(cached) $ac_c" 1>&6
+echo "$as_me:3427: checking if signal handlers must be reinstalled when invoked" >&5
+echo $ECHO_N "checking if signal handlers must be reinstalled when invoked... $ECHO_C" >&6
+if test "${bash_cv_must_reinstall_sighandlers+set}" = set; then
+  echo $ECHO_N "(cached) $ECHO_C" >&6
 else
   if test "$cross_compiling" = yes; then
-  echo "configure: warning: cannot check signal handling if cross compiling -- defaulting to no" 1>&2
+  { echo "$as_me:3433: WARNING: cannot check signal handling if cross compiling -- defaulting to no" >&5
+echo "$as_me: WARNING: cannot check signal handling if cross compiling -- defaulting to no" >&2;}
     bash_cv_must_reinstall_sighandlers=no
 
 else
-  cat > conftest.$ac_ext <<EOF
-#line 1615 "configure"
+  cat >conftest.$ac_ext <<_ACEOF
+#line 3439 "configure"
 #include "confdefs.h"
 
 #include <signal.h>
@@ -1657,43 +3482,51 @@ main()
 	exit(nsigint != 2);
 }
 
-EOF
-if { (eval echo configure:1662: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest && (./conftest; exit) 2>/dev/null
-then
+_ACEOF
+rm -f conftest$ac_exeext
+if { (eval echo "$as_me:3487: \"$ac_link\"") >&5
+  (eval $ac_link) 2>&5
+  ac_status=$?
+  echo "$as_me:3490: \$? = $ac_status" >&5
+  (exit $ac_status); } && { ac_try='./conftest$ac_exeext'
+  { (eval echo "$as_me:3492: \"$ac_try\"") >&5
+  (eval $ac_try) 2>&5
+  ac_status=$?
+  echo "$as_me:3495: \$? = $ac_status" >&5
+  (exit $ac_status); }; }; then
   bash_cv_must_reinstall_sighandlers=no
 else
-  echo "configure: failed program was:" >&5
-  cat conftest.$ac_ext >&5
-  rm -fr conftest*
-  bash_cv_must_reinstall_sighandlers=yes
+  echo "$as_me: program exited with status $ac_status" >&5
+echo "$as_me: failed program was:" >&5
+cat conftest.$ac_ext >&5
+bash_cv_must_reinstall_sighandlers=yes
 fi
-rm -fr conftest*
+rm -f core core.* *.core conftest$ac_exeext conftest.$ac_objext conftest.$ac_ext
 fi
-
 fi
 
-echo "$ac_t""$bash_cv_must_reinstall_sighandlers" 1>&6
+echo "$as_me:3508: result: $bash_cv_must_reinstall_sighandlers" >&5
+echo "${ECHO_T}$bash_cv_must_reinstall_sighandlers" >&6
 if test $bash_cv_must_reinstall_sighandlers = yes; then
-cat >> confdefs.h <<\EOF
+cat >>confdefs.h <<\EOF
 #define MUST_REINSTALL_SIGHANDLERS 1
 EOF
 
 fi
 
-
-
-echo $ac_n "checking for presence of POSIX-style sigsetjmp/siglongjmp""... $ac_c" 1>&6
-echo "configure:1687: checking for presence of POSIX-style sigsetjmp/siglongjmp" >&5
-if eval "test \"`echo '$''{'bash_cv_func_sigsetjmp'+set}'`\" = set"; then
-  echo $ac_n "(cached) $ac_c" 1>&6
+echo "$as_me:3517: checking for presence of POSIX-style sigsetjmp/siglongjmp" >&5
+echo $ECHO_N "checking for presence of POSIX-style sigsetjmp/siglongjmp... $ECHO_C" >&6
+if test "${bash_cv_func_sigsetjmp+set}" = set; then
+  echo $ECHO_N "(cached) $ECHO_C" >&6
 else
   if test "$cross_compiling" = yes; then
-  echo "configure: warning: cannot check for sigsetjmp/siglongjmp if cross-compiling -- defaulting to missing" 1>&2
+  { echo "$as_me:3523: WARNING: cannot check for sigsetjmp/siglongjmp if cross-compiling -- defaulting to missing" >&5
+echo "$as_me: WARNING: cannot check for sigsetjmp/siglongjmp if cross-compiling -- defaulting to missing" >&2;}
      bash_cv_func_sigsetjmp=missing
 
 else
-  cat > conftest.$ac_ext <<EOF
-#line 1697 "configure"
+  cat >conftest.$ac_ext <<_ACEOF
+#line 3529 "configure"
 #include "confdefs.h"
 
 #ifdef HAVE_UNISTD_H
@@ -1733,115 +3566,100 @@ siglongjmp(xx, 10);
 exit(1);
 #endif
 }
-EOF
-if { (eval echo configure:1738: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest && (./conftest; exit) 2>/dev/null
-then
+_ACEOF
+rm -f conftest$ac_exeext
+if { (eval echo "$as_me:3571: \"$ac_link\"") >&5
+  (eval $ac_link) 2>&5
+  ac_status=$?
+  echo "$as_me:3574: \$? = $ac_status" >&5
+  (exit $ac_status); } && { ac_try='./conftest$ac_exeext'
+  { (eval echo "$as_me:3576: \"$ac_try\"") >&5
+  (eval $ac_try) 2>&5
+  ac_status=$?
+  echo "$as_me:3579: \$? = $ac_status" >&5
+  (exit $ac_status); }; }; then
   bash_cv_func_sigsetjmp=present
 else
-  echo "configure: failed program was:" >&5
-  cat conftest.$ac_ext >&5
-  rm -fr conftest*
-  bash_cv_func_sigsetjmp=missing
+  echo "$as_me: program exited with status $ac_status" >&5
+echo "$as_me: failed program was:" >&5
+cat conftest.$ac_ext >&5
+bash_cv_func_sigsetjmp=missing
 fi
-rm -fr conftest*
+rm -f core core.* *.core conftest$ac_exeext conftest.$ac_objext conftest.$ac_ext
 fi
-
 fi
 
-echo "$ac_t""$bash_cv_func_sigsetjmp" 1>&6
+echo "$as_me:3592: result: $bash_cv_func_sigsetjmp" >&5
+echo "${ECHO_T}$bash_cv_func_sigsetjmp" >&6
 if test $bash_cv_func_sigsetjmp = present; then
-cat >> confdefs.h <<\EOF
+cat >>confdefs.h <<\EOF
 #define HAVE_POSIX_SIGSETJMP 1
 EOF
 
 fi
 
-echo $ac_n "checking for lstat""... $ac_c" 1>&6
-echo "configure:1761: checking for lstat" >&5
-if eval "test \"`echo '$''{'bash_cv_func_lstat'+set}'`\" = set"; then
-  echo $ac_n "(cached) $ac_c" 1>&6
+echo "$as_me:3601: checking for lstat" >&5
+echo $ECHO_N "checking for lstat... $ECHO_C" >&6
+if test "${bash_cv_func_lstat+set}" = set; then
+  echo $ECHO_N "(cached) $ECHO_C" >&6
 else
-  cat > conftest.$ac_ext <<EOF
-#line 1766 "configure"
+  cat >conftest.$ac_ext <<_ACEOF
+#line 3607 "configure"
 #include "confdefs.h"
 
 #include <sys/types.h>
 #include <sys/stat.h>
 
-int main() {
- lstat(".",(struct stat *)0); 
-; return 0; }
-EOF
-if { (eval echo configure:1776: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest; then
-  rm -rf conftest*
+int
+main ()
+{
+ lstat(".",(struct stat *)0);
+  ;
+  return 0;
+}
+_ACEOF
+rm -f conftest.$ac_objext conftest$ac_exeext
+if { (eval echo "$as_me:3622: \"$ac_link\"") >&5
+  (eval $ac_link) 2>&5
+  ac_status=$?
+  echo "$as_me:3625: \$? = $ac_status" >&5
+  (exit $ac_status); } &&
+         { ac_try='test -s conftest$ac_exeext'
+  { (eval echo "$as_me:3628: \"$ac_try\"") >&5
+  (eval $ac_try) 2>&5
+  ac_status=$?
+  echo "$as_me:3631: \$? = $ac_status" >&5
+  (exit $ac_status); }; }; then
   bash_cv_func_lstat=yes
 else
-  echo "configure: failed program was:" >&5
-  cat conftest.$ac_ext >&5
-  rm -rf conftest*
-  bash_cv_func_lstat=no
+  echo "$as_me: failed program was:" >&5
+cat conftest.$ac_ext >&5
+bash_cv_func_lstat=no
 fi
-rm -f conftest*
+rm -f conftest.$ac_objext conftest$ac_exeext conftest.$ac_ext
 fi
-
-echo "$ac_t""$bash_cv_func_lstat" 1>&6
+echo "$as_me:3641: result: $bash_cv_func_lstat" >&5
+echo "${ECHO_T}$bash_cv_func_lstat" >&6
 if test $bash_cv_func_lstat = yes; then
-  cat >> confdefs.h <<\EOF
+  cat >>confdefs.h <<\EOF
 #define HAVE_LSTAT 1
 EOF
 
 fi
 
-echo $ac_n "checking whether programs are able to redeclare getpw functions""... $ac_c" 1>&6
-echo "configure:1797: checking whether programs are able to redeclare getpw functions" >&5
-if eval "test \"`echo '$''{'bash_cv_can_redecl_getpw'+set}'`\" = set"; then
-  echo $ac_n "(cached) $ac_c" 1>&6
-else
-  cat > conftest.$ac_ext <<EOF
-#line 1802 "configure"
-#include "confdefs.h"
-#include <sys/types.h>
-#include <pwd.h>
-extern struct passwd *getpwent();
-extern struct passwd *getpwuid();
-extern struct passwd *getpwnam();
-int main() {
-struct passwd *z; z = getpwent(); z = getpwuid(0); z = getpwnam("root");
-; return 0; }
-EOF
-if { (eval echo configure:1813: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
-  rm -rf conftest*
-  bash_cv_can_redecl_getpw=yes
-else
-  echo "configure: failed program was:" >&5
-  cat conftest.$ac_ext >&5
-  rm -rf conftest*
-  bash_cv_can_redecl_getpw=no
-fi
-rm -f conftest*
-fi
-
-echo "$ac_t""$bash_cv_can_redecl_getpw" 1>&6
-if test $bash_cv_can_redecl_getpw = no; then
-cat >> confdefs.h <<\EOF
-#define HAVE_GETPW_DECLS 1
-EOF
-
-fi
-
-
-echo $ac_n "checking whether or not strcoll and strcmp differ""... $ac_c" 1>&6
-echo "configure:1835: checking whether or not strcoll and strcmp differ" >&5
-if eval "test \"`echo '$''{'bash_cv_func_strcoll_broken'+set}'`\" = set"; then
-  echo $ac_n "(cached) $ac_c" 1>&6
+echo "$as_me:3650: checking whether or not strcoll and strcmp differ" >&5
+echo $ECHO_N "checking whether or not strcoll and strcmp differ... $ECHO_C" >&6
+if test "${bash_cv_func_strcoll_broken+set}" = set; then
+  echo $ECHO_N "(cached) $ECHO_C" >&6
 else
   if test "$cross_compiling" = yes; then
-  echo "configure: warning: cannot check strcoll if cross compiling -- defaulting to no" 1>&2
+  { echo "$as_me:3656: WARNING: cannot check strcoll if cross compiling -- defaulting to no" >&5
+echo "$as_me: WARNING: cannot check strcoll if cross compiling -- defaulting to no" >&2;}
     bash_cv_func_strcoll_broken=no
 
 else
-  cat > conftest.$ac_ext <<EOF
-#line 1845 "configure"
+  cat >conftest.$ac_ext <<_ACEOF
+#line 3662 "configure"
 #include "confdefs.h"
 
 #include <stdio.h>
@@ -1879,274 +3697,476 @@ char    *v[];
 	exit (r1 > 0 && r2 > 0);
 }
 
-EOF
-if { (eval echo configure:1884: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest && (./conftest; exit) 2>/dev/null
-then
+_ACEOF
+rm -f conftest$ac_exeext
+if { (eval echo "$as_me:3702: \"$ac_link\"") >&5
+  (eval $ac_link) 2>&5
+  ac_status=$?
+  echo "$as_me:3705: \$? = $ac_status" >&5
+  (exit $ac_status); } && { ac_try='./conftest$ac_exeext'
+  { (eval echo "$as_me:3707: \"$ac_try\"") >&5
+  (eval $ac_try) 2>&5
+  ac_status=$?
+  echo "$as_me:3710: \$? = $ac_status" >&5
+  (exit $ac_status); }; }; then
   bash_cv_func_strcoll_broken=yes
 else
-  echo "configure: failed program was:" >&5
-  cat conftest.$ac_ext >&5
-  rm -fr conftest*
-  bash_cv_func_strcoll_broken=no
+  echo "$as_me: program exited with status $ac_status" >&5
+echo "$as_me: failed program was:" >&5
+cat conftest.$ac_ext >&5
+bash_cv_func_strcoll_broken=no
 fi
-rm -fr conftest*
+rm -f core core.* *.core conftest$ac_exeext conftest.$ac_objext conftest.$ac_ext
 fi
-
 fi
 
-echo "$ac_t""$bash_cv_func_strcoll_broken" 1>&6
+echo "$as_me:3723: result: $bash_cv_func_strcoll_broken" >&5
+echo "${ECHO_T}$bash_cv_func_strcoll_broken" >&6
 if test $bash_cv_func_strcoll_broken = yes; then
-cat >> confdefs.h <<\EOF
+cat >>confdefs.h <<\EOF
 #define STRCOLL_BROKEN 1
 EOF
 
 fi
 
-
-echo $ac_n "checking whether signal handlers are of type void""... $ac_c" 1>&6
-echo "configure:1908: checking whether signal handlers are of type void" >&5
-if eval "test \"`echo '$''{'bash_cv_void_sighandler'+set}'`\" = set"; then
-  echo $ac_n "(cached) $ac_c" 1>&6
+echo "$as_me:3732: checking whether getpw functions are declared in pwd.h" >&5
+echo $ECHO_N "checking whether getpw functions are declared in pwd.h... $ECHO_C" >&6
+if test "${bash_cv_getpw_declared+set}" = set; then
+  echo $ECHO_N "(cached) $ECHO_C" >&6
 else
-  cat > conftest.$ac_ext <<EOF
-#line 1913 "configure"
+  cat >conftest.$ac_ext <<_ACEOF
+#line 3738 "configure"
 #include "confdefs.h"
+
 #include <sys/types.h>
-#include <signal.h>
-#ifdef signal
-#undef signal
-#endif
-#ifdef __cplusplus
-extern "C"
+#ifdef HAVE_UNISTD_H
+#  include <unistd.h>
 #endif
-void (*signal ()) ();
-int main() {
-int i;
-; return 0; }
-EOF
-if { (eval echo configure:1928: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
-  rm -rf conftest*
-  bash_cv_void_sighandler=yes
+#include <pwd.h>
+
+_ACEOF
+if (eval "$ac_cpp conftest.$ac_ext") 2>&5 |
+  egrep "getpwuid" >/dev/null 2>&1; then
+  bash_cv_getpw_declared=yes
 else
-  echo "configure: failed program was:" >&5
-  cat conftest.$ac_ext >&5
-  rm -rf conftest*
-  bash_cv_void_sighandler=no
+  bash_cv_getpw_declared=no
 fi
 rm -f conftest*
+
 fi
-echo "$ac_t""$bash_cv_void_sighandler" 1>&6
-if test $bash_cv_void_sighandler = yes; then
-cat >> confdefs.h <<\EOF
-#define VOID_SIGHANDLER 1
+
+echo "$as_me:3758: result: $bash_cv_getpw_declared" >&5
+echo "${ECHO_T}$bash_cv_getpw_declared" >&6
+if test $bash_cv_getpw_declared = yes; then
+cat >>confdefs.h <<\EOF
+#define HAVE_GETPW_DECLS 1
 EOF
 
 fi
 
-echo $ac_n "checking for TIOCGWINSZ in sys/ioctl.h""... $ac_c" 1>&6
-echo "configure:1948: checking for TIOCGWINSZ in sys/ioctl.h" >&5
-if eval "test \"`echo '$''{'bash_cv_tiocgwinsz_in_ioctl'+set}'`\" = set"; then
-  echo $ac_n "(cached) $ac_c" 1>&6
+echo "$as_me:3767: checking POSIX termios" >&5
+echo $ECHO_N "checking POSIX termios... $ECHO_C" >&6
+if test "${ac_cv_sys_posix_termios+set}" = set; then
+  echo $ECHO_N "(cached) $ECHO_C" >&6
+else
+  cat >conftest.$ac_ext <<_ACEOF
+#line 3773 "configure"
+#include "confdefs.h"
+#include <sys/types.h>
+#include <unistd.h>
+#include <termios.h>
+int
+main ()
+{
+/* SunOS 4.0.3 has termios.h but not the library calls.  */
+   tcgetattr(0, 0);
+  ;
+  return 0;
+}
+_ACEOF
+rm -f conftest.$ac_objext conftest$ac_exeext
+if { (eval echo "$as_me:3788: \"$ac_link\"") >&5
+  (eval $ac_link) 2>&5
+  ac_status=$?
+  echo "$as_me:3791: \$? = $ac_status" >&5
+  (exit $ac_status); } &&
+         { ac_try='test -s conftest$ac_exeext'
+  { (eval echo "$as_me:3794: \"$ac_try\"") >&5
+  (eval $ac_try) 2>&5
+  ac_status=$?
+  echo "$as_me:3797: \$? = $ac_status" >&5
+  (exit $ac_status); }; }; then
+  ac_cv_sys_posix_termios=yes
+else
+  echo "$as_me: failed program was:" >&5
+cat conftest.$ac_ext >&5
+ac_cv_sys_posix_termios=no
+fi
+rm -f conftest.$ac_objext conftest$ac_exeext conftest.$ac_ext
+fi
+echo "$as_me:3807: result: $ac_cv_sys_posix_termios" >&5
+echo "${ECHO_T}$ac_cv_sys_posix_termios" >&6
+
+if test $ac_cv_sys_posix_termios = yes; then
+  echo "$as_me:3811: checking whether termios.h defines TIOCGWINSZ" >&5
+echo $ECHO_N "checking whether termios.h defines TIOCGWINSZ... $ECHO_C" >&6
+if test "${ac_cv_sys_tiocgwinsz_in_termios_h+set}" = set; then
+  echo $ECHO_N "(cached) $ECHO_C" >&6
+else
+  cat >conftest.$ac_ext <<_ACEOF
+#line 3817 "configure"
+#include "confdefs.h"
+#include <sys/types.h>
+#include <termios.h>
+#ifdef TIOCGWINSZ
+  yes
+#endif
+
+_ACEOF
+if (eval "$ac_cpp conftest.$ac_ext") 2>&5 |
+  egrep "yes" >/dev/null 2>&1; then
+  ac_cv_sys_tiocgwinsz_in_termios_h=yes
+else
+  ac_cv_sys_tiocgwinsz_in_termios_h=no
+fi
+rm -f conftest*
+
+fi
+echo "$as_me:3835: result: $ac_cv_sys_tiocgwinsz_in_termios_h" >&5
+echo "${ECHO_T}$ac_cv_sys_tiocgwinsz_in_termios_h" >&6
+
+fi
+if test $ac_cv_sys_tiocgwinsz_in_termios_h != yes; then
+  echo "$as_me:3840: checking whether sys/ioctl.h defines TIOCGWINSZ" >&5
+echo $ECHO_N "checking whether sys/ioctl.h defines TIOCGWINSZ... $ECHO_C" >&6
+if test "${ac_cv_sys_tiocgwinsz_in_sys_ioctl_h+set}" = set; then
+  echo $ECHO_N "(cached) $ECHO_C" >&6
 else
-  cat > conftest.$ac_ext <<EOF
-#line 1953 "configure"
+  cat >conftest.$ac_ext <<_ACEOF
+#line 3846 "configure"
 #include "confdefs.h"
 #include <sys/types.h>
 #include <sys/ioctl.h>
-int main() {
-int x = TIOCGWINSZ;
-; return 0; }
-EOF
-if { (eval echo configure:1961: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
-  rm -rf conftest*
-  bash_cv_tiocgwinsz_in_ioctl=yes
+#ifdef TIOCGWINSZ
+  yes
+#endif
+
+_ACEOF
+if (eval "$ac_cpp conftest.$ac_ext") 2>&5 |
+  egrep "yes" >/dev/null 2>&1; then
+  ac_cv_sys_tiocgwinsz_in_sys_ioctl_h=yes
 else
-  echo "configure: failed program was:" >&5
-  cat conftest.$ac_ext >&5
-  rm -rf conftest*
-  bash_cv_tiocgwinsz_in_ioctl=no
+  ac_cv_sys_tiocgwinsz_in_sys_ioctl_h=no
 fi
 rm -f conftest*
+
 fi
+echo "$as_me:3864: result: $ac_cv_sys_tiocgwinsz_in_sys_ioctl_h" >&5
+echo "${ECHO_T}$ac_cv_sys_tiocgwinsz_in_sys_ioctl_h" >&6
 
-echo "$ac_t""$bash_cv_tiocgwinsz_in_ioctl" 1>&6
-if test $bash_cv_tiocgwinsz_in_ioctl = yes; then   
-cat >> confdefs.h <<\EOF
+  if test $ac_cv_sys_tiocgwinsz_in_sys_ioctl_h = yes; then
+
+cat >>confdefs.h <<\EOF
 #define GWINSZ_IN_SYS_IOCTL 1
+EOF
+
+  fi
+fi
+
+echo "$as_me:3876: checking whether signal handlers are of type void" >&5
+echo $ECHO_N "checking whether signal handlers are of type void... $ECHO_C" >&6
+if test "${bash_cv_void_sighandler+set}" = set; then
+  echo $ECHO_N "(cached) $ECHO_C" >&6
+else
+  cat >conftest.$ac_ext <<_ACEOF
+#line 3882 "configure"
+#include "confdefs.h"
+#include <sys/types.h>
+#include <signal.h>
+#ifdef signal
+#undef signal
+#endif
+#ifdef __cplusplus
+extern "C"
+#endif
+void (*signal ()) ();
+int
+main ()
+{
+int i;
+  ;
+  return 0;
+}
+_ACEOF
+rm -f conftest.$ac_objext
+if { (eval echo "$as_me:3902: \"$ac_compile\"") >&5
+  (eval $ac_compile) 2>&5
+  ac_status=$?
+  echo "$as_me:3905: \$? = $ac_status" >&5
+  (exit $ac_status); } &&
+         { ac_try='test -s conftest.$ac_objext'
+  { (eval echo "$as_me:3908: \"$ac_try\"") >&5
+  (eval $ac_try) 2>&5
+  ac_status=$?
+  echo "$as_me:3911: \$? = $ac_status" >&5
+  (exit $ac_status); }; }; then
+  bash_cv_void_sighandler=yes
+else
+  echo "$as_me: failed program was:" >&5
+cat conftest.$ac_ext >&5
+bash_cv_void_sighandler=no
+fi
+rm -f conftest.$ac_objext conftest.$ac_ext
+fi
+echo "$as_me:3921: result: $bash_cv_void_sighandler" >&5
+echo "${ECHO_T}$bash_cv_void_sighandler" >&6
+if test $bash_cv_void_sighandler = yes; then
+cat >>confdefs.h <<\EOF
+#define VOID_SIGHANDLER 1
 EOF
 
 fi
 
-echo $ac_n "checking for TIOCSTAT in sys/ioctl.h""... $ac_c" 1>&6
-echo "configure:1982: checking for TIOCSTAT in sys/ioctl.h" >&5
-if eval "test \"`echo '$''{'bash_cv_tiocstat_in_ioctl'+set}'`\" = set"; then
-  echo $ac_n "(cached) $ac_c" 1>&6
+echo "$as_me:3930: checking for TIOCSTAT in sys/ioctl.h" >&5
+echo $ECHO_N "checking for TIOCSTAT in sys/ioctl.h... $ECHO_C" >&6
+if test "${bash_cv_tiocstat_in_ioctl+set}" = set; then
+  echo $ECHO_N "(cached) $ECHO_C" >&6
 else
-  cat > conftest.$ac_ext <<EOF
-#line 1987 "configure"
+  cat >conftest.$ac_ext <<_ACEOF
+#line 3936 "configure"
 #include "confdefs.h"
 #include <sys/types.h>
 #include <sys/ioctl.h>
-int main() {
+int
+main ()
+{
 int x = TIOCSTAT;
-; return 0; }
-EOF
-if { (eval echo configure:1995: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
-  rm -rf conftest*
+  ;
+  return 0;
+}
+_ACEOF
+rm -f conftest.$ac_objext
+if { (eval echo "$as_me:3949: \"$ac_compile\"") >&5
+  (eval $ac_compile) 2>&5
+  ac_status=$?
+  echo "$as_me:3952: \$? = $ac_status" >&5
+  (exit $ac_status); } &&
+         { ac_try='test -s conftest.$ac_objext'
+  { (eval echo "$as_me:3955: \"$ac_try\"") >&5
+  (eval $ac_try) 2>&5
+  ac_status=$?
+  echo "$as_me:3958: \$? = $ac_status" >&5
+  (exit $ac_status); }; }; then
   bash_cv_tiocstat_in_ioctl=yes
 else
-  echo "configure: failed program was:" >&5
-  cat conftest.$ac_ext >&5
-  rm -rf conftest*
-  bash_cv_tiocstat_in_ioctl=no
+  echo "$as_me: failed program was:" >&5
+cat conftest.$ac_ext >&5
+bash_cv_tiocstat_in_ioctl=no
 fi
-rm -f conftest*
+rm -f conftest.$ac_objext conftest.$ac_ext
 fi
 
-echo "$ac_t""$bash_cv_tiocstat_in_ioctl" 1>&6
-if test $bash_cv_tiocstat_in_ioctl = yes; then   
-cat >> confdefs.h <<\EOF
+echo "$as_me:3969: result: $bash_cv_tiocstat_in_ioctl" >&5
+echo "${ECHO_T}$bash_cv_tiocstat_in_ioctl" >&6
+if test $bash_cv_tiocstat_in_ioctl = yes; then
+cat >>confdefs.h <<\EOF
 #define TIOCSTAT_IN_SYS_IOCTL 1
 EOF
 
 fi
 
-echo $ac_n "checking for FIONREAD in sys/ioctl.h""... $ac_c" 1>&6
-echo "configure:2016: checking for FIONREAD in sys/ioctl.h" >&5
-if eval "test \"`echo '$''{'bash_cv_fionread_in_ioctl'+set}'`\" = set"; then
-  echo $ac_n "(cached) $ac_c" 1>&6
+echo "$as_me:3978: checking for FIONREAD in sys/ioctl.h" >&5
+echo $ECHO_N "checking for FIONREAD in sys/ioctl.h... $ECHO_C" >&6
+if test "${bash_cv_fionread_in_ioctl+set}" = set; then
+  echo $ECHO_N "(cached) $ECHO_C" >&6
 else
-  cat > conftest.$ac_ext <<EOF
-#line 2021 "configure"
+  cat >conftest.$ac_ext <<_ACEOF
+#line 3984 "configure"
 #include "confdefs.h"
 #include <sys/types.h>
 #include <sys/ioctl.h>
-int main() {
+int
+main ()
+{
 int x = FIONREAD;
-; return 0; }
-EOF
-if { (eval echo configure:2029: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
-  rm -rf conftest*
+  ;
+  return 0;
+}
+_ACEOF
+rm -f conftest.$ac_objext
+if { (eval echo "$as_me:3997: \"$ac_compile\"") >&5
+  (eval $ac_compile) 2>&5
+  ac_status=$?
+  echo "$as_me:4000: \$? = $ac_status" >&5
+  (exit $ac_status); } &&
+         { ac_try='test -s conftest.$ac_objext'
+  { (eval echo "$as_me:4003: \"$ac_try\"") >&5
+  (eval $ac_try) 2>&5
+  ac_status=$?
+  echo "$as_me:4006: \$? = $ac_status" >&5
+  (exit $ac_status); }; }; then
   bash_cv_fionread_in_ioctl=yes
 else
-  echo "configure: failed program was:" >&5
-  cat conftest.$ac_ext >&5
-  rm -rf conftest*
-  bash_cv_fionread_in_ioctl=no
+  echo "$as_me: failed program was:" >&5
+cat conftest.$ac_ext >&5
+bash_cv_fionread_in_ioctl=no
 fi
-rm -f conftest*
+rm -f conftest.$ac_objext conftest.$ac_ext
 fi
 
-echo "$ac_t""$bash_cv_fionread_in_ioctl" 1>&6
-if test $bash_cv_fionread_in_ioctl = yes; then   
-cat >> confdefs.h <<\EOF
+echo "$as_me:4017: result: $bash_cv_fionread_in_ioctl" >&5
+echo "${ECHO_T}$bash_cv_fionread_in_ioctl" >&6
+if test $bash_cv_fionread_in_ioctl = yes; then
+cat >>confdefs.h <<\EOF
 #define FIONREAD_IN_SYS_IOCTL 1
 EOF
 
 fi
 
-echo $ac_n "checking for speed_t in sys/types.h""... $ac_c" 1>&6
-echo "configure:2050: checking for speed_t in sys/types.h" >&5
-if eval "test \"`echo '$''{'bash_cv_speed_t_in_sys_types'+set}'`\" = set"; then
-  echo $ac_n "(cached) $ac_c" 1>&6
+echo "$as_me:4026: checking for speed_t in sys/types.h" >&5
+echo $ECHO_N "checking for speed_t in sys/types.h... $ECHO_C" >&6
+if test "${bash_cv_speed_t_in_sys_types+set}" = set; then
+  echo $ECHO_N "(cached) $ECHO_C" >&6
 else
-  cat > conftest.$ac_ext <<EOF
-#line 2055 "configure"
+  cat >conftest.$ac_ext <<_ACEOF
+#line 4032 "configure"
 #include "confdefs.h"
 #include <sys/types.h>
-int main() {
+int
+main ()
+{
 speed_t x;
-; return 0; }
-EOF
-if { (eval echo configure:2062: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
-  rm -rf conftest*
+  ;
+  return 0;
+}
+_ACEOF
+rm -f conftest.$ac_objext
+if { (eval echo "$as_me:4044: \"$ac_compile\"") >&5
+  (eval $ac_compile) 2>&5
+  ac_status=$?
+  echo "$as_me:4047: \$? = $ac_status" >&5
+  (exit $ac_status); } &&
+         { ac_try='test -s conftest.$ac_objext'
+  { (eval echo "$as_me:4050: \"$ac_try\"") >&5
+  (eval $ac_try) 2>&5
+  ac_status=$?
+  echo "$as_me:4053: \$? = $ac_status" >&5
+  (exit $ac_status); }; }; then
   bash_cv_speed_t_in_sys_types=yes
 else
-  echo "configure: failed program was:" >&5
-  cat conftest.$ac_ext >&5
-  rm -rf conftest*
-  bash_cv_speed_t_in_sys_types=no
+  echo "$as_me: failed program was:" >&5
+cat conftest.$ac_ext >&5
+bash_cv_speed_t_in_sys_types=no
 fi
-rm -f conftest*
+rm -f conftest.$ac_objext conftest.$ac_ext
 fi
 
-echo "$ac_t""$bash_cv_speed_t_in_sys_types" 1>&6
-if test $bash_cv_speed_t_in_sys_types = yes; then   
-cat >> confdefs.h <<\EOF
+echo "$as_me:4064: result: $bash_cv_speed_t_in_sys_types" >&5
+echo "${ECHO_T}$bash_cv_speed_t_in_sys_types" >&6
+if test $bash_cv_speed_t_in_sys_types = yes; then
+cat >>confdefs.h <<\EOF
 #define SPEED_T_IN_SYS_TYPES 1
 EOF
 
 fi
 
-echo $ac_n "checking for struct winsize in sys/ioctl.h and termios.h""... $ac_c" 1>&6
-echo "configure:2083: checking for struct winsize in sys/ioctl.h and termios.h" >&5
-if eval "test \"`echo '$''{'bash_cv_struct_winsize_header'+set}'`\" = set"; then
-  echo $ac_n "(cached) $ac_c" 1>&6
+echo "$as_me:4073: checking for struct winsize in sys/ioctl.h and termios.h" >&5
+echo $ECHO_N "checking for struct winsize in sys/ioctl.h and termios.h... $ECHO_C" >&6
+if test "${bash_cv_struct_winsize_header+set}" = set; then
+  echo $ECHO_N "(cached) $ECHO_C" >&6
 else
-  cat > conftest.$ac_ext <<EOF
-#line 2088 "configure"
+  cat >conftest.$ac_ext <<_ACEOF
+#line 4079 "configure"
 #include "confdefs.h"
 #include <sys/types.h>
 #include <sys/ioctl.h>
-int main() {
+int
+main ()
+{
 struct winsize x;
-; return 0; }
-EOF
-if { (eval echo configure:2096: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
-  rm -rf conftest*
+  ;
+  return 0;
+}
+_ACEOF
+rm -f conftest.$ac_objext
+if { (eval echo "$as_me:4092: \"$ac_compile\"") >&5
+  (eval $ac_compile) 2>&5
+  ac_status=$?
+  echo "$as_me:4095: \$? = $ac_status" >&5
+  (exit $ac_status); } &&
+         { ac_try='test -s conftest.$ac_objext'
+  { (eval echo "$as_me:4098: \"$ac_try\"") >&5
+  (eval $ac_try) 2>&5
+  ac_status=$?
+  echo "$as_me:4101: \$? = $ac_status" >&5
+  (exit $ac_status); }; }; then
   bash_cv_struct_winsize_header=ioctl_h
 else
-  echo "configure: failed program was:" >&5
-  cat conftest.$ac_ext >&5
-  rm -rf conftest*
-  cat > conftest.$ac_ext <<EOF
-#line 2104 "configure"
+  echo "$as_me: failed program was:" >&5
+cat conftest.$ac_ext >&5
+cat >conftest.$ac_ext <<_ACEOF
+#line 4108 "configure"
 #include "confdefs.h"
 #include <sys/types.h>
 #include <termios.h>
-int main() {
+int
+main ()
+{
 struct winsize x;
-; return 0; }
-EOF
-if { (eval echo configure:2112: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
-  rm -rf conftest*
+  ;
+  return 0;
+}
+_ACEOF
+rm -f conftest.$ac_objext
+if { (eval echo "$as_me:4121: \"$ac_compile\"") >&5
+  (eval $ac_compile) 2>&5
+  ac_status=$?
+  echo "$as_me:4124: \$? = $ac_status" >&5
+  (exit $ac_status); } &&
+         { ac_try='test -s conftest.$ac_objext'
+  { (eval echo "$as_me:4127: \"$ac_try\"") >&5
+  (eval $ac_try) 2>&5
+  ac_status=$?
+  echo "$as_me:4130: \$? = $ac_status" >&5
+  (exit $ac_status); }; }; then
   bash_cv_struct_winsize_header=termios_h
 else
-  echo "configure: failed program was:" >&5
-  cat conftest.$ac_ext >&5
-  rm -rf conftest*
-  bash_cv_struct_winsize_header=other
+  echo "$as_me: failed program was:" >&5
+cat conftest.$ac_ext >&5
+bash_cv_struct_winsize_header=other
 fi
-rm -f conftest*
+rm -f conftest.$ac_objext conftest.$ac_ext
 
 fi
-rm -f conftest*
+rm -f conftest.$ac_objext conftest.$ac_ext
 fi
 
 if test $bash_cv_struct_winsize_header = ioctl_h; then
-  echo "$ac_t""sys/ioctl.h" 1>&6
-  cat >> confdefs.h <<\EOF
+  echo "$as_me:4145: result: sys/ioctl.h" >&5
+echo "${ECHO_T}sys/ioctl.h" >&6
+  cat >>confdefs.h <<\EOF
 #define STRUCT_WINSIZE_IN_SYS_IOCTL 1
 EOF
 
 elif test $bash_cv_struct_winsize_header = termios_h; then
-  echo "$ac_t""termios.h" 1>&6
-  cat >> confdefs.h <<\EOF
+  echo "$as_me:4152: result: termios.h" >&5
+echo "${ECHO_T}termios.h" >&6
+  cat >>confdefs.h <<\EOF
 #define STRUCT_WINSIZE_IN_TERMIOS 1
 EOF
 
 else
-  echo "$ac_t""not found" 1>&6
+  echo "$as_me:4159: result: not found" >&5
+echo "${ECHO_T}not found" >&6
 fi
 
-
-echo $ac_n "checking if struct dirent has a d_ino member""... $ac_c" 1>&6
-echo "configure:2145: checking if struct dirent has a d_ino member" >&5
-if eval "test \"`echo '$''{'bash_cv_dirent_has_dino'+set}'`\" = set"; then
-  echo $ac_n "(cached) $ac_c" 1>&6
+echo "$as_me:4163: checking if struct dirent has a d_ino member" >&5
+echo $ECHO_N "checking if struct dirent has a d_ino member... $ECHO_C" >&6
+if test "${bash_cv_dirent_has_dino+set}" = set; then
+  echo $ECHO_N "(cached) $ECHO_C" >&6
 else
-  cat > conftest.$ac_ext <<EOF
-#line 2150 "configure"
+  cat >conftest.$ac_ext <<_ACEOF
+#line 4169 "configure"
 #include "confdefs.h"
 
 #include <stdio.h>
@@ -2169,40 +4189,53 @@ else
 # endif
 #endif /* HAVE_DIRENT_H */
 
-int main() {
+int
+main ()
+{
 
 struct dirent d; int z; z = d.d_ino;
 
-; return 0; }
-EOF
-if { (eval echo configure:2179: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
-  rm -rf conftest*
+  ;
+  return 0;
+}
+_ACEOF
+rm -f conftest.$ac_objext
+if { (eval echo "$as_me:4203: \"$ac_compile\"") >&5
+  (eval $ac_compile) 2>&5
+  ac_status=$?
+  echo "$as_me:4206: \$? = $ac_status" >&5
+  (exit $ac_status); } &&
+         { ac_try='test -s conftest.$ac_objext'
+  { (eval echo "$as_me:4209: \"$ac_try\"") >&5
+  (eval $ac_try) 2>&5
+  ac_status=$?
+  echo "$as_me:4212: \$? = $ac_status" >&5
+  (exit $ac_status); }; }; then
   bash_cv_dirent_has_dino=yes
 else
-  echo "configure: failed program was:" >&5
-  cat conftest.$ac_ext >&5
-  rm -rf conftest*
-  bash_cv_dirent_has_dino=no
+  echo "$as_me: failed program was:" >&5
+cat conftest.$ac_ext >&5
+bash_cv_dirent_has_dino=no
 fi
-rm -f conftest*
+rm -f conftest.$ac_objext conftest.$ac_ext
 fi
 
-echo "$ac_t""$bash_cv_dirent_has_dino" 1>&6
+echo "$as_me:4223: result: $bash_cv_dirent_has_dino" >&5
+echo "${ECHO_T}$bash_cv_dirent_has_dino" >&6
 if test $bash_cv_dirent_has_dino = yes; then
-cat >> confdefs.h <<\EOF
+cat >>confdefs.h <<\EOF
 #define STRUCT_DIRENT_HAS_D_INO 1
 EOF
 
 fi
 
-
-echo $ac_n "checking if struct dirent has a d_fileno member""... $ac_c" 1>&6
-echo "configure:2201: checking if struct dirent has a d_fileno member" >&5
-if eval "test \"`echo '$''{'bash_cv_dirent_has_d_fileno'+set}'`\" = set"; then
-  echo $ac_n "(cached) $ac_c" 1>&6
+echo "$as_me:4232: checking if struct dirent has a d_fileno member" >&5
+echo $ECHO_N "checking if struct dirent has a d_fileno member... $ECHO_C" >&6
+if test "${bash_cv_dirent_has_d_fileno+set}" = set; then
+  echo $ECHO_N "(cached) $ECHO_C" >&6
 else
-  cat > conftest.$ac_ext <<EOF
-#line 2206 "configure"
+  cat >conftest.$ac_ext <<_ACEOF
+#line 4238 "configure"
 #include "confdefs.h"
 
 #include <stdio.h>
@@ -2225,33 +4258,46 @@ else
 # endif
 #endif /* HAVE_DIRENT_H */
 
-int main() {
+int
+main ()
+{
 
 struct dirent d; int z; z = d.d_fileno;
 
-; return 0; }
-EOF
-if { (eval echo configure:2235: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
-  rm -rf conftest*
+  ;
+  return 0;
+}
+_ACEOF
+rm -f conftest.$ac_objext
+if { (eval echo "$as_me:4272: \"$ac_compile\"") >&5
+  (eval $ac_compile) 2>&5
+  ac_status=$?
+  echo "$as_me:4275: \$? = $ac_status" >&5
+  (exit $ac_status); } &&
+         { ac_try='test -s conftest.$ac_objext'
+  { (eval echo "$as_me:4278: \"$ac_try\"") >&5
+  (eval $ac_try) 2>&5
+  ac_status=$?
+  echo "$as_me:4281: \$? = $ac_status" >&5
+  (exit $ac_status); }; }; then
   bash_cv_dirent_has_d_fileno=yes
 else
-  echo "configure: failed program was:" >&5
-  cat conftest.$ac_ext >&5
-  rm -rf conftest*
-  bash_cv_dirent_has_d_fileno=no
+  echo "$as_me: failed program was:" >&5
+cat conftest.$ac_ext >&5
+bash_cv_dirent_has_d_fileno=no
 fi
-rm -f conftest*
+rm -f conftest.$ac_objext conftest.$ac_ext
 fi
 
-echo "$ac_t""$bash_cv_dirent_has_d_fileno" 1>&6
+echo "$as_me:4292: result: $bash_cv_dirent_has_d_fileno" >&5
+echo "${ECHO_T}$bash_cv_dirent_has_d_fileno" >&6
 if test $bash_cv_dirent_has_d_fileno = yes; then
-cat >> confdefs.h <<\EOF
+cat >>confdefs.h <<\EOF
 #define STRUCT_DIRENT_HAS_D_FILENO 1
 EOF
 
 fi
 
-
 case "$host_os" in
 aix*)   prefer_curses=yes ;;
 esac
@@ -2259,128 +4305,224 @@ esac
 if test "X$bash_cv_termcap_lib" = "X"; then
 _bash_needmsg=yes
 else
-echo $ac_n "checking which library has the termcap functions""... $ac_c" 1>&6
-echo "configure:2264: checking which library has the termcap functions" >&5
+echo "$as_me:4308: checking which library has the termcap functions" >&5
+echo $ECHO_N "checking which library has the termcap functions... $ECHO_C" >&6
 _bash_needmsg=
 fi
-if eval "test \"`echo '$''{'bash_cv_termcap_lib'+set}'`\" = set"; then
-  echo $ac_n "(cached) $ac_c" 1>&6
+if test "${bash_cv_termcap_lib+set}" = set; then
+  echo $ECHO_N "(cached) $ECHO_C" >&6
 else
-  echo $ac_n "checking for tgetent in -ltermcap""... $ac_c" 1>&6
-echo "configure:2271: 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
+  echo "$as_me:4315: checking for tgetent in -ltermcap" >&5
+echo $ECHO_N "checking for tgetent in -ltermcap... $ECHO_C" >&6
+if test "${ac_cv_lib_termcap_tgetent+set}" = set; then
+  echo $ECHO_N "(cached) $ECHO_C" >&6
 else
-  ac_save_LIBS="$LIBS"
+  ac_check_lib_save_LIBS=$LIBS
 LIBS="-ltermcap  $LIBS"
-cat > conftest.$ac_ext <<EOF
-#line 2279 "configure"
+cat >conftest.$ac_ext <<_ACEOF
+#line 4323 "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 tgetent();
-
-int main() {
-tgetent()
-; return 0; }
-EOF
-if { (eval echo configure:2290: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest; then
-  rm -rf conftest*
-  eval "ac_cv_lib_$ac_lib_var=yes"
+   builtin and then its argument prototype would still apply.  */
+char tgetent ();
+int
+main ()
+{
+tgetent ();
+  ;
+  return 0;
+}
+_ACEOF
+rm -f conftest.$ac_objext conftest$ac_exeext
+if { (eval echo "$as_me:4342: \"$ac_link\"") >&5
+  (eval $ac_link) 2>&5
+  ac_status=$?
+  echo "$as_me:4345: \$? = $ac_status" >&5
+  (exit $ac_status); } &&
+         { ac_try='test -s conftest$ac_exeext'
+  { (eval echo "$as_me:4348: \"$ac_try\"") >&5
+  (eval $ac_try) 2>&5
+  ac_status=$?
+  echo "$as_me:4351: \$? = $ac_status" >&5
+  (exit $ac_status); }; }; then
+  ac_cv_lib_termcap_tgetent=yes
 else
-  echo "configure: failed program was:" >&5
-  cat conftest.$ac_ext >&5
-  rm -rf conftest*
-  eval "ac_cv_lib_$ac_lib_var=no"
+  echo "$as_me: failed program was:" >&5
+cat conftest.$ac_ext >&5
+ac_cv_lib_termcap_tgetent=no
 fi
-rm -f conftest*
-LIBS="$ac_save_LIBS"
-
+rm -f conftest.$ac_objext conftest$ac_exeext conftest.$ac_ext
+LIBS=$ac_check_lib_save_LIBS
 fi
-if eval "test \"`echo '$ac_cv_lib_'$ac_lib_var`\" = yes"; then
-  echo "$ac_t""yes" 1>&6
+echo "$as_me:4362: result: $ac_cv_lib_termcap_tgetent" >&5
+echo "${ECHO_T}$ac_cv_lib_termcap_tgetent" >&6
+if test $ac_cv_lib_termcap_tgetent = yes; then
   bash_cv_termcap_lib=libtermcap
 else
-  echo "$ac_t""no" 1>&6
-echo $ac_n "checking for tgetent in -lcurses""... $ac_c" 1>&6
-echo "configure:2309: checking for tgetent in -lcurses" >&5
-ac_lib_var=`echo curses'_'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
+  echo "$as_me:4367: checking for tgetent in -ltinfo" >&5
+echo $ECHO_N "checking for tgetent in -ltinfo... $ECHO_C" >&6
+if test "${ac_cv_lib_tinfo_tgetent+set}" = set; then
+  echo $ECHO_N "(cached) $ECHO_C" >&6
 else
-  ac_save_LIBS="$LIBS"
-LIBS="-lcurses  $LIBS"
-cat > conftest.$ac_ext <<EOF
-#line 2317 "configure"
+  ac_check_lib_save_LIBS=$LIBS
+LIBS="-ltinfo  $LIBS"
+cat >conftest.$ac_ext <<_ACEOF
+#line 4375 "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 tgetent();
-
-int main() {
-tgetent()
-; return 0; }
-EOF
-if { (eval echo configure:2328: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest; then
-  rm -rf conftest*
-  eval "ac_cv_lib_$ac_lib_var=yes"
+   builtin and then its argument prototype would still apply.  */
+char tgetent ();
+int
+main ()
+{
+tgetent ();
+  ;
+  return 0;
+}
+_ACEOF
+rm -f conftest.$ac_objext conftest$ac_exeext
+if { (eval echo "$as_me:4394: \"$ac_link\"") >&5
+  (eval $ac_link) 2>&5
+  ac_status=$?
+  echo "$as_me:4397: \$? = $ac_status" >&5
+  (exit $ac_status); } &&
+         { ac_try='test -s conftest$ac_exeext'
+  { (eval echo "$as_me:4400: \"$ac_try\"") >&5
+  (eval $ac_try) 2>&5
+  ac_status=$?
+  echo "$as_me:4403: \$? = $ac_status" >&5
+  (exit $ac_status); }; }; then
+  ac_cv_lib_tinfo_tgetent=yes
 else
-  echo "configure: failed program was:" >&5
-  cat conftest.$ac_ext >&5
-  rm -rf conftest*
-  eval "ac_cv_lib_$ac_lib_var=no"
+  echo "$as_me: failed program was:" >&5
+cat conftest.$ac_ext >&5
+ac_cv_lib_tinfo_tgetent=no
 fi
-rm -f conftest*
-LIBS="$ac_save_LIBS"
+rm -f conftest.$ac_objext conftest$ac_exeext conftest.$ac_ext
+LIBS=$ac_check_lib_save_LIBS
+fi
+echo "$as_me:4414: result: $ac_cv_lib_tinfo_tgetent" >&5
+echo "${ECHO_T}$ac_cv_lib_tinfo_tgetent" >&6
+if test $ac_cv_lib_tinfo_tgetent = yes; then
+  bash_cv_termcap_lib=libtinfo
+else
+  echo "$as_me:4419: checking for tgetent in -lcurses" >&5
+echo $ECHO_N "checking for tgetent in -lcurses... $ECHO_C" >&6
+if test "${ac_cv_lib_curses_tgetent+set}" = set; then
+  echo $ECHO_N "(cached) $ECHO_C" >&6
+else
+  ac_check_lib_save_LIBS=$LIBS
+LIBS="-lcurses  $LIBS"
+cat >conftest.$ac_ext <<_ACEOF
+#line 4427 "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 tgetent ();
+int
+main ()
+{
+tgetent ();
+  ;
+  return 0;
+}
+_ACEOF
+rm -f conftest.$ac_objext conftest$ac_exeext
+if { (eval echo "$as_me:4446: \"$ac_link\"") >&5
+  (eval $ac_link) 2>&5
+  ac_status=$?
+  echo "$as_me:4449: \$? = $ac_status" >&5
+  (exit $ac_status); } &&
+         { ac_try='test -s conftest$ac_exeext'
+  { (eval echo "$as_me:4452: \"$ac_try\"") >&5
+  (eval $ac_try) 2>&5
+  ac_status=$?
+  echo "$as_me:4455: \$? = $ac_status" >&5
+  (exit $ac_status); }; }; then
+  ac_cv_lib_curses_tgetent=yes
+else
+  echo "$as_me: failed program was:" >&5
+cat conftest.$ac_ext >&5
+ac_cv_lib_curses_tgetent=no
 fi
-if eval "test \"`echo '$ac_cv_lib_'$ac_lib_var`\" = yes"; then
-  echo "$ac_t""yes" 1>&6
+rm -f conftest.$ac_objext conftest$ac_exeext conftest.$ac_ext
+LIBS=$ac_check_lib_save_LIBS
+fi
+echo "$as_me:4466: result: $ac_cv_lib_curses_tgetent" >&5
+echo "${ECHO_T}$ac_cv_lib_curses_tgetent" >&6
+if test $ac_cv_lib_curses_tgetent = yes; then
   bash_cv_termcap_lib=libcurses
 else
-  echo "$ac_t""no" 1>&6
-echo $ac_n "checking for tgetent in -lncurses""... $ac_c" 1>&6
-echo "configure:2347: 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
+  echo "$as_me:4471: checking for tgetent in -lncurses" >&5
+echo $ECHO_N "checking for tgetent in -lncurses... $ECHO_C" >&6
+if test "${ac_cv_lib_ncurses_tgetent+set}" = set; then
+  echo $ECHO_N "(cached) $ECHO_C" >&6
 else
-  ac_save_LIBS="$LIBS"
+  ac_check_lib_save_LIBS=$LIBS
 LIBS="-lncurses  $LIBS"
-cat > conftest.$ac_ext <<EOF
-#line 2355 "configure"
+cat >conftest.$ac_ext <<_ACEOF
+#line 4479 "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 tgetent();
-
-int main() {
-tgetent()
-; return 0; }
-EOF
-if { (eval echo configure:2366: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest; then
-  rm -rf conftest*
-  eval "ac_cv_lib_$ac_lib_var=yes"
+   builtin and then its argument prototype would still apply.  */
+char tgetent ();
+int
+main ()
+{
+tgetent ();
+  ;
+  return 0;
+}
+_ACEOF
+rm -f conftest.$ac_objext conftest$ac_exeext
+if { (eval echo "$as_me:4498: \"$ac_link\"") >&5
+  (eval $ac_link) 2>&5
+  ac_status=$?
+  echo "$as_me:4501: \$? = $ac_status" >&5
+  (exit $ac_status); } &&
+         { ac_try='test -s conftest$ac_exeext'
+  { (eval echo "$as_me:4504: \"$ac_try\"") >&5
+  (eval $ac_try) 2>&5
+  ac_status=$?
+  echo "$as_me:4507: \$? = $ac_status" >&5
+  (exit $ac_status); }; }; then
+  ac_cv_lib_ncurses_tgetent=yes
 else
-  echo "configure: failed program was:" >&5
-  cat conftest.$ac_ext >&5
-  rm -rf conftest*
-  eval "ac_cv_lib_$ac_lib_var=no"
+  echo "$as_me: failed program was:" >&5
+cat conftest.$ac_ext >&5
+ac_cv_lib_ncurses_tgetent=no
 fi
-rm -f conftest*
-LIBS="$ac_save_LIBS"
-
+rm -f conftest.$ac_objext conftest$ac_exeext conftest.$ac_ext
+LIBS=$ac_check_lib_save_LIBS
 fi
-if eval "test \"`echo '$ac_cv_lib_'$ac_lib_var`\" = yes"; then
-  echo "$ac_t""yes" 1>&6
+echo "$as_me:4518: result: $ac_cv_lib_ncurses_tgetent" >&5
+echo "${ECHO_T}$ac_cv_lib_ncurses_tgetent" >&6
+if test $ac_cv_lib_ncurses_tgetent = yes; then
   bash_cv_termcap_lib=libncurses
 else
-  echo "$ac_t""no" 1>&6
-bash_cv_termcap_lib=gnutermcap
+  bash_cv_termcap_lib=gnutermcap
+fi
+
 fi
 
 fi
@@ -2390,10 +4532,11 @@ fi
 fi
 
 if test "X$_bash_needmsg" = "Xyes"; then
-echo $ac_n "checking which library has the termcap functions""... $ac_c" 1>&6
-echo "configure:2395: checking which library has the termcap functions" >&5
+echo "$as_me:4535: checking which library has the termcap functions" >&5
+echo $ECHO_N "checking which library has the termcap functions... $ECHO_C" >&6
 fi
-echo "$ac_t""using $bash_cv_termcap_lib" 1>&6
+echo "$as_me:4538: result: using $bash_cv_termcap_lib" >&5
+echo "${ECHO_T}using $bash_cv_termcap_lib" >&6
 if test $bash_cv_termcap_lib = gnutermcap && test -z "$prefer_curses"; then
 LDFLAGS="$LDFLAGS -L./lib/termcap"
 TERMCAP_LIB="./lib/termcap/libtermcap.a"
@@ -2401,6 +4544,9 @@ TERMCAP_DEP="./lib/termcap/libtermcap.a"
 elif test $bash_cv_termcap_lib = libtermcap && test -z "$prefer_curses"; then
 TERMCAP_LIB=-ltermcap
 TERMCAP_DEP=
+elif test $bash_cv_termcap_lib = libtinfo; then
+TERMCAP_LIB=-ltinfo
+TERMCAP_DEP=
 elif test $bash_cv_termcap_lib = libncurses; then
 TERMCAP_LIB=-lncurses
 TERMCAP_DEP=
@@ -2410,440 +4556,1310 @@ TERMCAP_DEP=
 fi
 
 if test "$TERMCAP_LIB" = "./lib/termcap/libtermcap.a"; then
-	TERMCAP_LIB=-ltermcap	#default
+	if test "$prefer_curses" = yes; then
+		TERMCAP_LIB=-lcurses
+	else
+		TERMCAP_LIB=-ltermcap	#default
+	fi
 fi
 
-case "$host_cpu" in
-*cray*)	LOCAL_CFLAGS=-DCRAY ;;
-esac
+for ac_header in wctype.h
+do
+as_ac_Header=`echo "ac_cv_header_$ac_header" | $as_tr_sh`
+echo "$as_me:4569: checking for $ac_header" >&5
+echo $ECHO_N "checking for $ac_header... $ECHO_C" >&6
+if eval "test \"\${$as_ac_Header+set}\" = set"; then
+  echo $ECHO_N "(cached) $ECHO_C" >&6
+else
+  cat >conftest.$ac_ext <<_ACEOF
+#line 4575 "configure"
+#include "confdefs.h"
+#include <$ac_header>
+_ACEOF
+if { (eval echo "$as_me:4579: \"$ac_cpp conftest.$ac_ext\"") >&5
+  (eval $ac_cpp conftest.$ac_ext) 2>conftest.er1
+  ac_status=$?
+  egrep -v '^ *\+' conftest.er1 >conftest.err
+  rm -f conftest.er1
+  cat conftest.err >&5
+  echo "$as_me:4585: \$? = $ac_status" >&5
+  (exit $ac_status); } >/dev/null; then
+  if test -s conftest.err; then
+    ac_cpp_err=$ac_c_preproc_warn_flag
+  else
+    ac_cpp_err=
+  fi
+else
+  ac_cpp_err=yes
+fi
+if test -z "$ac_cpp_err"; then
+  eval "$as_ac_Header=yes"
+else
+  echo "$as_me: failed program was:" >&5
+  cat conftest.$ac_ext >&5
+  eval "$as_ac_Header=no"
+fi
+rm -f conftest.err conftest.$ac_ext
+fi
+echo "$as_me:4604: result: `eval echo '${'$as_ac_Header'}'`" >&5
+echo "${ECHO_T}`eval echo '${'$as_ac_Header'}'`" >&6
+if test `eval echo '${'$as_ac_Header'}'` = yes; then
+  cat >>confdefs.h <<EOF
+#define `echo "HAVE_$ac_header" | $as_tr_cpp` 1
+EOF
 
-case "$host_os" in
-isc*)	LOCAL_CFLAGS=-Disc386 ;;
-esac
+fi
+done
 
-# shared library configuration section
-#
-# Shared object configuration section.  These values are generated by
-# ${srcdir}/support/shobj-conf
-#
-if test -f ${srcdir}/support/shobj-conf; then
-        echo $ac_n "checking configuration for building shared libraries""... $ac_c" 1>&6
-echo "configure:2432: checking configuration for building shared libraries" >&5
-        eval `${CONFIG_SHELL-/bin/sh} ${srcdir}/support/shobj-conf -C ${CC} -c ${host_cpu} -o ${host_os} -v ${host_vendor}`
-        
-        
-        
-        
-	
-        
-        
-	
-	
-	
-	
-	
-        echo "$ac_t""$SHLIB_STATUS" 1>&6
+for ac_header in wchar.h
+do
+as_ac_Header=`echo "ac_cv_header_$ac_header" | $as_tr_sh`
+echo "$as_me:4617: checking for $ac_header" >&5
+echo $ECHO_N "checking for $ac_header... $ECHO_C" >&6
+if eval "test \"\${$as_ac_Header+set}\" = set"; then
+  echo $ECHO_N "(cached) $ECHO_C" >&6
+else
+  cat >conftest.$ac_ext <<_ACEOF
+#line 4623 "configure"
+#include "confdefs.h"
+#include <$ac_header>
+_ACEOF
+if { (eval echo "$as_me:4627: \"$ac_cpp conftest.$ac_ext\"") >&5
+  (eval $ac_cpp conftest.$ac_ext) 2>conftest.er1
+  ac_status=$?
+  egrep -v '^ *\+' conftest.er1 >conftest.err
+  rm -f conftest.er1
+  cat conftest.err >&5
+  echo "$as_me:4633: \$? = $ac_status" >&5
+  (exit $ac_status); } >/dev/null; then
+  if test -s conftest.err; then
+    ac_cpp_err=$ac_c_preproc_warn_flag
+  else
+    ac_cpp_err=
+  fi
+else
+  ac_cpp_err=yes
+fi
+if test -z "$ac_cpp_err"; then
+  eval "$as_ac_Header=yes"
+else
+  echo "$as_me: failed program was:" >&5
+  cat conftest.$ac_ext >&5
+  eval "$as_ac_Header=no"
 fi
+rm -f conftest.err conftest.$ac_ext
+fi
+echo "$as_me:4652: result: `eval echo '${'$as_ac_Header'}'`" >&5
+echo "${ECHO_T}`eval echo '${'$as_ac_Header'}'`" >&6
+if test `eval echo '${'$as_ac_Header'}'` = yes; then
+  cat >>confdefs.h <<EOF
+#define `echo "HAVE_$ac_header" | $as_tr_cpp` 1
+EOF
 
-BUILD_DIR=`pwd`
+fi
+done
 
+for ac_header in langinfo.h
+do
+as_ac_Header=`echo "ac_cv_header_$ac_header" | $as_tr_sh`
+echo "$as_me:4665: checking for $ac_header" >&5
+echo $ECHO_N "checking for $ac_header... $ECHO_C" >&6
+if eval "test \"\${$as_ac_Header+set}\" = set"; then
+  echo $ECHO_N "(cached) $ECHO_C" >&6
+else
+  cat >conftest.$ac_ext <<_ACEOF
+#line 4671 "configure"
+#include "confdefs.h"
+#include <$ac_header>
+_ACEOF
+if { (eval echo "$as_me:4675: \"$ac_cpp conftest.$ac_ext\"") >&5
+  (eval $ac_cpp conftest.$ac_ext) 2>conftest.er1
+  ac_status=$?
+  egrep -v '^ *\+' conftest.er1 >conftest.err
+  rm -f conftest.er1
+  cat conftest.err >&5
+  echo "$as_me:4681: \$? = $ac_status" >&5
+  (exit $ac_status); } >/dev/null; then
+  if test -s conftest.err; then
+    ac_cpp_err=$ac_c_preproc_warn_flag
+  else
+    ac_cpp_err=
+  fi
+else
+  ac_cpp_err=yes
+fi
+if test -z "$ac_cpp_err"; then
+  eval "$as_ac_Header=yes"
+else
+  echo "$as_me: failed program was:" >&5
+  cat conftest.$ac_ext >&5
+  eval "$as_ac_Header=no"
+fi
+rm -f conftest.err conftest.$ac_ext
+fi
+echo "$as_me:4700: result: `eval echo '${'$as_ac_Header'}'`" >&5
+echo "${ECHO_T}`eval echo '${'$as_ac_Header'}'`" >&6
+if test `eval echo '${'$as_ac_Header'}'` = yes; then
+  cat >>confdefs.h <<EOF
+#define `echo "HAVE_$ac_header" | $as_tr_cpp` 1
+EOF
 
+fi
+done
 
+echo "$as_me:4710: checking for mbsrtowcs" >&5
+echo $ECHO_N "checking for mbsrtowcs... $ECHO_C" >&6
+if test "${ac_cv_func_mbsrtowcs+set}" = set; then
+  echo $ECHO_N "(cached) $ECHO_C" >&6
+else
+  cat >conftest.$ac_ext <<_ACEOF
+#line 4716 "configure"
+#include "confdefs.h"
+/* System header to define __stub macros and hopefully few prototypes,
+    which can conflict with char mbsrtowcs (); 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 mbsrtowcs ();
+char (*f) ();
 
+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_mbsrtowcs) || defined (__stub___mbsrtowcs)
+choke me
+#else
+f = mbsrtowcs;
+#endif
 
+  ;
+  return 0;
+}
+_ACEOF
+rm -f conftest.$ac_objext conftest$ac_exeext
+if { (eval echo "$as_me:4747: \"$ac_link\"") >&5
+  (eval $ac_link) 2>&5
+  ac_status=$?
+  echo "$as_me:4750: \$? = $ac_status" >&5
+  (exit $ac_status); } &&
+         { ac_try='test -s conftest$ac_exeext'
+  { (eval echo "$as_me:4753: \"$ac_try\"") >&5
+  (eval $ac_try) 2>&5
+  ac_status=$?
+  echo "$as_me:4756: \$? = $ac_status" >&5
+  (exit $ac_status); }; }; then
+  ac_cv_func_mbsrtowcs=yes
+else
+  echo "$as_me: failed program was:" >&5
+cat conftest.$ac_ext >&5
+ac_cv_func_mbsrtowcs=no
+fi
+rm -f conftest.$ac_objext conftest$ac_exeext conftest.$ac_ext
+fi
+echo "$as_me:4766: result: $ac_cv_func_mbsrtowcs" >&5
+echo "${ECHO_T}$ac_cv_func_mbsrtowcs" >&6
+if test $ac_cv_func_mbsrtowcs = yes; then
+  cat >>confdefs.h <<\EOF
+#define HAVE_MBSRTOWCS 1
+EOF
 
+fi
 
+echo "$as_me:4775: checking for wcwidth" >&5
+echo $ECHO_N "checking for wcwidth... $ECHO_C" >&6
+if test "${ac_cv_func_wcwidth+set}" = set; then
+  echo $ECHO_N "(cached) $ECHO_C" >&6
+else
+  cat >conftest.$ac_ext <<_ACEOF
+#line 4781 "configure"
+#include "confdefs.h"
+/* System header to define __stub macros and hopefully few prototypes,
+    which can conflict with char wcwidth (); 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 wcwidth ();
+char (*f) ();
 
+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_wcwidth) || defined (__stub___wcwidth)
+choke me
+#else
+f = wcwidth;
+#endif
 
+  ;
+  return 0;
+}
+_ACEOF
+rm -f conftest.$ac_objext conftest$ac_exeext
+if { (eval echo "$as_me:4812: \"$ac_link\"") >&5
+  (eval $ac_link) 2>&5
+  ac_status=$?
+  echo "$as_me:4815: \$? = $ac_status" >&5
+  (exit $ac_status); } &&
+         { ac_try='test -s conftest$ac_exeext'
+  { (eval echo "$as_me:4818: \"$ac_try\"") >&5
+  (eval $ac_try) 2>&5
+  ac_status=$?
+  echo "$as_me:4821: \$? = $ac_status" >&5
+  (exit $ac_status); }; }; then
+  ac_cv_func_wcwidth=yes
+else
+  echo "$as_me: failed program was:" >&5
+cat conftest.$ac_ext >&5
+ac_cv_func_wcwidth=no
+fi
+rm -f conftest.$ac_objext conftest$ac_exeext conftest.$ac_ext
+fi
+echo "$as_me:4831: result: $ac_cv_func_wcwidth" >&5
+echo "${ECHO_T}$ac_cv_func_wcwidth" >&6
+if test $ac_cv_func_wcwidth = yes; then
+  cat >>confdefs.h <<\EOF
+#define HAVE_WCWIDTH 1
+EOF
 
+fi
 
+echo "$as_me:4840: checking for mbstate_t" >&5
+echo $ECHO_N "checking for mbstate_t... $ECHO_C" >&6
+if test "${bash_cv_have_mbstate_t+set}" = set; then
+  echo $ECHO_N "(cached) $ECHO_C" >&6
+else
+  if test "$cross_compiling" = yes; then
+  { { echo "$as_me:4846: error: cannot run test program while cross compiling" >&5
+echo "$as_me: error: cannot run test program while cross compiling" >&2;}
+   { (exit 1); exit 1; }; }
+else
+  cat >conftest.$ac_ext <<_ACEOF
+#line 4851 "configure"
+#include "confdefs.h"
 
+#include <wchar.h>
+int
+main ()
+{
+  mbstate_t ps;
+  return 0;
+}
+_ACEOF
+rm -f conftest$ac_exeext
+if { (eval echo "$as_me:4863: \"$ac_link\"") >&5
+  (eval $ac_link) 2>&5
+  ac_status=$?
+  echo "$as_me:4866: \$? = $ac_status" >&5
+  (exit $ac_status); } && { ac_try='./conftest$ac_exeext'
+  { (eval echo "$as_me:4868: \"$ac_try\"") >&5
+  (eval $ac_try) 2>&5
+  ac_status=$?
+  echo "$as_me:4871: \$? = $ac_status" >&5
+  (exit $ac_status); }; }; then
+  bash_cv_have_mbstate_t=yes
+else
+  echo "$as_me: program exited with status $ac_status" >&5
+echo "$as_me: failed program was:" >&5
+cat conftest.$ac_ext >&5
+bash_cv_have_mbstate_t=no
+fi
+rm -f core core.* *.core conftest$ac_exeext conftest.$ac_objext conftest.$ac_ext
+fi
+fi
+echo "$as_me:4883: result: $bash_cv_have_mbstate_t" >&5
+echo "${ECHO_T}$bash_cv_have_mbstate_t" >&6
+if test $bash_cv_have_mbstate_t = yes; then
+	cat >>confdefs.h <<\EOF
+#define HAVE_MBSTATE_T 1
+EOF
+
+fi
+
+echo "$as_me:4892: checking for nl_langinfo and CODESET" >&5
+echo $ECHO_N "checking for nl_langinfo and CODESET... $ECHO_C" >&6
+if test "${bash_cv_langinfo_codeset+set}" = set; then
+  echo $ECHO_N "(cached) $ECHO_C" >&6
+else
+  cat >conftest.$ac_ext <<_ACEOF
+#line 4898 "configure"
+#include "confdefs.h"
+#include <langinfo.h>
+int
+main ()
+{
+char* cs = nl_langinfo(CODESET);
+  ;
+  return 0;
+}
+_ACEOF
+rm -f conftest.$ac_objext conftest$ac_exeext
+if { (eval echo "$as_me:4910: \"$ac_link\"") >&5
+  (eval $ac_link) 2>&5
+  ac_status=$?
+  echo "$as_me:4913: \$? = $ac_status" >&5
+  (exit $ac_status); } &&
+         { ac_try='test -s conftest$ac_exeext'
+  { (eval echo "$as_me:4916: \"$ac_try\"") >&5
+  (eval $ac_try) 2>&5
+  ac_status=$?
+  echo "$as_me:4919: \$? = $ac_status" >&5
+  (exit $ac_status); }; }; then
+  bash_cv_langinfo_codeset=yes
+else
+  echo "$as_me: failed program was:" >&5
+cat conftest.$ac_ext >&5
+bash_cv_langinfo_codeset=no
+fi
+rm -f conftest.$ac_objext conftest$ac_exeext conftest.$ac_ext
+fi
+echo "$as_me:4929: result: $bash_cv_langinfo_codeset" >&5
+echo "${ECHO_T}$bash_cv_langinfo_codeset" >&6
+if test $bash_cv_langinfo_codeset = yes; then
+  cat >>confdefs.h <<\EOF
+#define HAVE_LANGINFO_CODESET 1
+EOF
+
+fi
+
+case "$host_cpu" in
+*cray*)	LOCAL_CFLAGS=-DCRAY ;;
+*s390*) LOCAL_CFLAGS=-fsigned-char ;;
+esac
+
+case "$host_os" in
+isc*)	LOCAL_CFLAGS=-Disc386 ;;
+esac
+
+# shared library configuration section
+#
+# Shared object configuration section.  These values are generated by
+# ${srcdir}/support/shobj-conf
+#
+if test -f ${srcdir}/support/shobj-conf; then
+        echo "$as_me:4953: checking configuration for building shared libraries" >&5
+echo $ECHO_N "checking configuration for building shared libraries... $ECHO_C" >&6
+        eval `${CONFIG_SHELL-/bin/sh} ${srcdir}/support/shobj-conf -C "${CC}" -c ${host_cpu} -o ${host_os} -v ${host_vendor}`
 
+        echo "$as_me:4957: result: $SHLIB_STATUS" >&5
+echo "${ECHO_T}$SHLIB_STATUS" >&6
 
+	# SHLIB_STATUS is either `supported' or `unsupported'.  If it's
+	# `unsupported', turn off any default shared library building
+	if test "$SHLIB_STATUS" = 'unsupported'; then
+		opt_shared_libs=no
+	fi
 
+	# shared library versioning
+	# quoted for m4 so I can use character classes
+	SHLIB_MAJOR=`expr "$LIBVERSION" : '\([0-9]\)\..*'`
+	SHLIB_MINOR=`expr "$LIBVERSION" : '[0-9]\.\([0-9]\).*'`
 
+fi
 
-trap '' 1 2 15
-cat > confcache <<\EOF
+if test "$opt_static_libs" = "yes"; then
+	STATIC_TARGET=static
+	STATIC_INSTALL_TARGET=install-static
+fi
+if test "$opt_shared_libs" = "yes"; then
+	SHARED_TARGET=shared
+	SHARED_INSTALL_TARGET=install-shared
+fi
+
+case "$host_os" in
+msdosdjgpp*)	BUILD_DIR=`pwd.exe` ;;	# to prevent //d/path/file
+*)		BUILD_DIR=`pwd` ;;
+esac
+
+ac_config_files="$ac_config_files Makefile doc/Makefile examples/Makefile shlib/Makefile"
+ac_config_commands="$ac_config_commands default"
+cat >confcache <<\_ACEOF
 # This file is a shell script that caches the results of configure
 # tests run on this system so they can be shared between configure
-# scripts and configure runs.  It is not useful on other systems.
-# If it contains results you don't want to keep, you may remove or edit it.
+# scripts and configure runs, see configure's option --config-cache.
+# It is not useful on other systems.  If it contains results you don't
+# want to keep, you may remove or edit it.
 #
-# By default, configure uses ./config.cache as the cache file,
-# creating it if it does not exist already.  You can give configure
-# the --cache-file=FILE option to use a different cache file; that is
-# what configure does when it calls configure scripts in
-# subdirectories, so they share the cache.
-# Giving --cache-file=/dev/null disables caching, for debugging configure.
-# config.status only pays attention to the cache file if you give it the
-# --recheck option to rerun configure.
+# config.status only pays attention to the cache file if you give it
+# the --recheck option to rerun configure.
 #
-EOF
+# `ac_cv_env_foo' variables (set or unset) will be overriden when
+# loading this file, other *unset* `ac_cv_foo' will be assigned the
+# following values.
+
+_ACEOF
+
 # The following way of writing the cache mishandles newlines in values,
 # but we know of no workaround that is simple, portable, and efficient.
 # So, don't put newlines in cache variables' values.
 # Ultrix sh set writes to stderr and can't be redirected directly,
 # and sets the high bit in the cache file unless we assign to the vars.
-(set) 2>&1 |
-  case `(ac_space=' '; set) 2>&1` in
-  *ac_space=\ *)
-    # `set' does not quote correctly, so add quotes (double-quote substitution
-    # turns \\\\ into \\, and sed turns \\ into \).
-    sed -n \
-      -e "s/'/'\\\\''/g" \
-      -e "s/^\\([a-zA-Z0-9_]*_cv_[a-zA-Z0-9_]*\\)=\\(.*\\)/\\1=\${\\1='\\2'}/p"
-    ;;
-  *)
-    # `set' quotes correctly as required by POSIX, so do not add quotes.
-    sed -n -e 's/^\([a-zA-Z0-9_]*_cv_[a-zA-Z0-9_]*\)=\(.*\)/\1=${\1=\2}/p'
-    ;;
-  esac >> confcache
-if cmp -s $cache_file confcache; then
-  :
-else
+{
+  (set) 2>&1 |
+    case `(ac_space=' '; set | grep ac_space) 2>&1` in
+    *ac_space=\ *)
+      # `set' does not quote correctly, so add quotes (double-quote
+      # substitution turns \\\\ into \\, and sed turns \\ into \).
+      sed -n \
+        "s/'/'\\\\''/g;
+    	  s/^\\([_$as_cr_alnum]*_cv_[_$as_cr_alnum]*\\)=\\(.*\\)/\\1='\\2'/p"
+      ;;
+    *)
+      # `set' quotes correctly as required by POSIX, so do not add quotes.
+      sed -n \
+        "s/^\\([_$as_cr_alnum]*_cv_[_$as_cr_alnum]*\\)=\\(.*\\)/\\1=\\2/p"
+      ;;
+    esac;
+} |
+  sed '
+     t clear
+     : clear
+     s/^\([^=]*\)=\(.*[{}].*\)$/test "${\1+set}" = set || &/
+     t end
+     /^ac_cv_env/!s/^\([^=]*\)=\(.*\)$/\1=${\1=\2}/
+     : end' >>confcache
+if cmp -s $cache_file confcache; then :; else
   if test -w $cache_file; then
-    echo "updating cache $cache_file"
-    cat confcache > $cache_file
+    test "x$cache_file" != "x/dev/null" && echo "updating cache $cache_file"
+    cat confcache >$cache_file
   else
     echo "not updating unwritable cache $cache_file"
   fi
 fi
 rm -f confcache
 
-trap 'rm -fr conftest* confdefs* core core.* *.core $ac_clean_files; exit 1' 1 2 15
-
 test "x$prefix" = xNONE && prefix=$ac_default_prefix
 # Let make expand exec_prefix.
 test "x$exec_prefix" = xNONE && exec_prefix='${prefix}'
 
-# Any assignment to VPATH causes Sun make to only execute
-# the first set of double-colon rules, so remove it if not needed.
-# If there is a colon in the path, we need to keep it.
+# VPATH may cause trouble with some makes, so we remove $(srcdir),
+# ${srcdir} and @srcdir@ from VPATH if srcdir is ".", strip leading and
+# trailing colons and then remove the whole line if VPATH becomes empty
+# (actually we leave an empty line to preserve line numbers).
 if test "x$srcdir" = x.; then
-  ac_vpsub='/^[ 	]*VPATH[ 	]*=[^:]*$/d'
+  ac_vpsub='/^[ 	]*VPATH[ 	]*=/{
+s/:*\$(srcdir):*/:/;
+s/:*\${srcdir}:*/:/;
+s/:*@srcdir@:*/:/;
+s/^\([^=]*=[ 	]*\):*/\1/;
+s/:*$//;
+s/^[^=]*=[ 	]*$//;
+}'
 fi
 
-trap 'rm -f $CONFIG_STATUS conftest*; exit 1' 1 2 15
-
 DEFS=-DHAVE_CONFIG_H
 
-# Without the "./", some shells look in PATH for config.status.
 : ${CONFIG_STATUS=./config.status}
-
-echo creating $CONFIG_STATUS
-rm -f $CONFIG_STATUS
-cat > $CONFIG_STATUS <<EOF
-#! /bin/sh
+ac_clean_files_save=$ac_clean_files
+ac_clean_files="$ac_clean_files $CONFIG_STATUS"
+{ echo "$as_me:5068: creating $CONFIG_STATUS" >&5
+echo "$as_me: creating $CONFIG_STATUS" >&6;}
+cat >$CONFIG_STATUS <<_ACEOF
+#! $SHELL
 # Generated automatically by configure.
 # Run this file to recreate the current configuration.
-# This directory was configured as follows,
-# on host `(hostname || uname -n) 2>/dev/null | sed 1q`:
-#
-# $0 $ac_configure_args
-#
 # Compiler output produced by configure, useful for debugging
-# configure, is in ./config.log if it exists.
+# configure, is in config.log if it exists.
 
-ac_cs_usage="Usage: $CONFIG_STATUS [--recheck] [--version] [--help]"
-for ac_option
+debug=false
+SHELL=\${CONFIG_SHELL-$SHELL}
+ac_cs_invocation="\$0 \$@"
+
+_ACEOF
+
+cat >>$CONFIG_STATUS <<\_ACEOF
+# Be Bourne compatible
+if test -n "${ZSH_VERSION+set}" && (emulate sh) >/dev/null 2>&1; then
+  emulate sh
+  NULLCMD=:
+elif test -n "${BASH_VERSION+set}" && (set -o posix) >/dev/null 2>&1; then
+  set -o posix
+fi
+
+# Name of the executable.
+as_me=`echo "$0" |sed 's,.*[\\/],,'`
+
+if expr a : '\(a\)' >/dev/null 2>&1; then
+  as_expr=expr
+else
+  as_expr=false
+fi
+
+rm -f conf$$ conf$$.exe conf$$.file
+echo >conf$$.file
+if ln -s conf$$.file conf$$ 2>/dev/null; then
+  # We could just check for DJGPP; but this test a) works b) is more generic
+  # and c) will remain valid once DJGPP supports symlinks (DJGPP 2.04).
+  if test -f conf$$.exe; then
+    # Don't use ln at all; we don't have any links
+    as_ln_s='cp -p'
+  else
+    as_ln_s='ln -s'
+  fi
+elif ln conf$$.file conf$$ 2>/dev/null; then
+  as_ln_s=ln
+else
+  as_ln_s='cp -p'
+fi
+rm -f conf$$ conf$$.exe conf$$.file
+
+as_executable_p="test -f"
+
+# Support unset when possible.
+if (FOO=FOO; unset FOO) >/dev/null 2>&1; then
+  as_unset=unset
+else
+  as_unset=false
+fi
+
+# NLS nuisances.
+$as_unset LANG || test "${LANG+set}" != set || { LANG=C; export LANG; }
+$as_unset LC_ALL || test "${LC_ALL+set}" != set || { LC_ALL=C; export LC_ALL; }
+$as_unset LC_TIME || test "${LC_TIME+set}" != set || { LC_TIME=C; export LC_TIME; }
+$as_unset LC_CTYPE || test "${LC_CTYPE+set}" != set || { LC_CTYPE=C; export LC_CTYPE; }
+$as_unset LANGUAGE || test "${LANGUAGE+set}" != set || { LANGUAGE=C; export LANGUAGE; }
+$as_unset LC_COLLATE || test "${LC_COLLATE+set}" != set || { LC_COLLATE=C; export LC_COLLATE; }
+$as_unset LC_NUMERIC || test "${LC_NUMERIC+set}" != set || { LC_NUMERIC=C; export LC_NUMERIC; }
+$as_unset LC_MESSAGES || test "${LC_MESSAGES+set}" != set || { LC_MESSAGES=C; export LC_MESSAGES; }
+
+# IFS
+# We need space, tab and new line, in precisely that order.
+as_nl='
+'
+IFS=" 	$as_nl"
+
+# CDPATH.
+$as_unset CDPATH || test "${CDPATH+set}" != set || { CDPATH=:; export CDPATH; }
+
+exec 6>&1
+
+_ACEOF
+
+# Files that config.status was made for.
+if test -n "$ac_config_files"; then
+  echo "config_files=\"$ac_config_files\"" >>$CONFIG_STATUS
+fi
+
+if test -n "$ac_config_headers"; then
+  echo "config_headers=\"$ac_config_headers\"" >>$CONFIG_STATUS
+fi
+
+if test -n "$ac_config_links"; then
+  echo "config_links=\"$ac_config_links\"" >>$CONFIG_STATUS
+fi
+
+if test -n "$ac_config_commands"; then
+  echo "config_commands=\"$ac_config_commands\"" >>$CONFIG_STATUS
+fi
+
+cat >>$CONFIG_STATUS <<\EOF
+
+ac_cs_usage="\
+\`$as_me' instantiates files from templates according to the
+current configuration.
+
+Usage: $0 [OPTIONS] [FILE]...
+
+  -h, --help       print this help, then exit
+  -V, --version    print version number, then exit
+  -d, --debug      don't remove temporary files
+      --recheck    update $as_me by reconfiguring in the same conditions
+  --file=FILE[:TEMPLATE]
+                   instantiate the configuration file FILE
+  --header=FILE[:TEMPLATE]
+                   instantiate the configuration header FILE
+
+Configuration files:
+$config_files
+
+Configuration headers:
+$config_headers
+
+Configuration commands:
+$config_commands
+
+Report bugs to <bug-autoconf@gnu.org>."
+EOF
+
+cat >>$CONFIG_STATUS <<EOF
+ac_cs_version="\\
+readline config.status 4.3
+configured by $0, generated by GNU Autoconf 2.52,
+  with options \\"`echo "$ac_configure_args" | sed 's/[\\""\`\$]/\\\\&/g'`\\"
+
+Copyright 1992, 1993, 1994, 1995, 1996, 1998, 1999, 2000, 2001
+Free Software Foundation, Inc.
+This config.status script is free software; the Free Software Foundation
+gives unlimited permission to copy, distribute and modify it."
+srcdir=$srcdir
+INSTALL="$INSTALL"
+EOF
+
+cat >>$CONFIG_STATUS <<\EOF
+# If no file are specified by the user, then we need to provide default
+# value.  By we need to know if files were specified by the user.
+ac_need_defaults=:
+while test $# != 0
 do
-  case "\$ac_option" in
+  case $1 in
+  --*=*)
+    ac_option=`expr "x$1" : 'x\([^=]*\)='`
+    ac_optarg=`expr "x$1" : 'x[^=]*=\(.*\)'`
+    shift
+    set dummy "$ac_option" "$ac_optarg" ${1+"$@"}
+    shift
+    ;;
+  -*);;
+  *) # This is not an option, so the user has probably given explicit
+     # arguments.
+     ac_need_defaults=false;;
+  esac
+
+  case $1 in
+  # Handling of the options.
+EOF
+cat >>$CONFIG_STATUS <<EOF
   -recheck | --recheck | --rechec | --reche | --rech | --rec | --re | --r)
-    echo "running \${CONFIG_SHELL-/bin/sh} $0 $ac_configure_args --no-create --no-recursion"
-    exec \${CONFIG_SHELL-/bin/sh} $0 $ac_configure_args --no-create --no-recursion ;;
-  -version | --version | --versio | --versi | --vers | --ver | --ve | --v)
-    echo "$CONFIG_STATUS generated by autoconf version 2.12"
-    exit 0 ;;
-  -help | --help | --hel | --he | --h)
-    echo "\$ac_cs_usage"; exit 0 ;;
-  *) echo "\$ac_cs_usage"; exit 1 ;;
+    echo "running $SHELL $0 " $ac_configure_args " --no-create --no-recursion"
+    exec $SHELL $0 $ac_configure_args --no-create --no-recursion ;;
+EOF
+cat >>$CONFIG_STATUS <<\EOF
+  --version | --vers* | -V )
+    echo "$ac_cs_version"; exit 0 ;;
+  --he | --h)
+    # Conflict between --help and --header
+    { { echo "$as_me:5244: error: ambiguous option: $1
+Try \`$0 --help' for more information." >&5
+echo "$as_me: error: ambiguous option: $1
+Try \`$0 --help' for more information." >&2;}
+   { (exit 1); exit 1; }; };;
+  --help | --hel | -h )
+    echo "$ac_cs_usage"; exit 0 ;;
+  --debug | --d* | -d )
+    debug=: ;;
+  --file | --fil | --fi | --f )
+    shift
+    CONFIG_FILES="$CONFIG_FILES $1"
+    ac_need_defaults=false;;
+  --header | --heade | --head | --hea )
+    shift
+    CONFIG_HEADERS="$CONFIG_HEADERS $1"
+    ac_need_defaults=false;;
+
+  # This is an error.
+  -*) { { echo "$as_me:5263: error: unrecognized option: $1
+Try \`$0 --help' for more information." >&5
+echo "$as_me: error: unrecognized option: $1
+Try \`$0 --help' for more information." >&2;}
+   { (exit 1); exit 1; }; } ;;
+
+  *) ac_config_targets="$ac_config_targets $1" ;;
+
   esac
+  shift
 done
 
-ac_given_srcdir=$srcdir
-ac_given_INSTALL="$INSTALL"
+exec 5>>config.log
+cat >&5 << _ACEOF
+
+## ----------------------- ##
+## Running config.status.  ##
+## ----------------------- ##
 
-trap 'rm -fr `echo "Makefile doc/Makefile examples/Makefile shlib/Makefile config.h" | sed "s/:[^ ]*//g"` conftest*; exit 1' 1 2 15
+This file was extended by $as_me (readline 4.3) 2.52, executed with
+  CONFIG_FILES    = $CONFIG_FILES
+  CONFIG_HEADERS  = $CONFIG_HEADERS
+  CONFIG_LINKS    = $CONFIG_LINKS
+  CONFIG_COMMANDS = $CONFIG_COMMANDS
+  > $ac_cs_invocation
+on `(hostname || uname -n) 2>/dev/null | sed 1q`
+
+_ACEOF
 EOF
-cat >> $CONFIG_STATUS <<EOF
 
-# Protect against being on the right side of a sed subst in config.status.
-sed 's/%@/@@/; s/@%/@@/; s/%g\$/@g/; /@g\$/s/[\\\\&%]/\\\\&/g;
- s/@@/%@/; s/@@/@%/; s/@g\$/%g/' > conftest.subs <<\\CEOF
-$ac_vpsub
-$extrasub
-s%@CFLAGS@%$CFLAGS%g
-s%@CPPFLAGS@%$CPPFLAGS%g
-s%@CXXFLAGS@%$CXXFLAGS%g
-s%@DEFS@%$DEFS%g
-s%@LDFLAGS@%$LDFLAGS%g
-s%@LIBS@%$LIBS%g
-s%@exec_prefix@%$exec_prefix%g
-s%@prefix@%$prefix%g
-s%@program_transform_name@%$program_transform_name%g
-s%@bindir@%$bindir%g
-s%@sbindir@%$sbindir%g
-s%@libexecdir@%$libexecdir%g
-s%@datadir@%$datadir%g
-s%@sysconfdir@%$sysconfdir%g
-s%@sharedstatedir@%$sharedstatedir%g
-s%@localstatedir@%$localstatedir%g
-s%@libdir@%$libdir%g
-s%@includedir@%$includedir%g
-s%@oldincludedir@%$oldincludedir%g
-s%@infodir@%$infodir%g
-s%@mandir@%$mandir%g
-s%@host@%$host%g
-s%@host_alias@%$host_alias%g
-s%@host_cpu@%$host_cpu%g
-s%@host_vendor@%$host_vendor%g
-s%@host_os@%$host_os%g
-s%@CC@%$CC%g
-s%@CPP@%$CPP%g
-s%@INSTALL_PROGRAM@%$INSTALL_PROGRAM%g
-s%@INSTALL_DATA@%$INSTALL_DATA%g
-s%@AR@%$AR%g
-s%@RANLIB@%$RANLIB%g
-s%@MAKE_SHELL@%$MAKE_SHELL%g
-s%@SHOBJ_CC@%$SHOBJ_CC%g
-s%@SHOBJ_CFLAGS@%$SHOBJ_CFLAGS%g
-s%@SHOBJ_LD@%$SHOBJ_LD%g
-s%@SHOBJ_LDFLAGS@%$SHOBJ_LDFLAGS%g
-s%@SHOBJ_XLDFLAGS@%$SHOBJ_XLDFLAGS%g
-s%@SHOBJ_LIBS@%$SHOBJ_LIBS%g
-s%@SHOBJ_STATUS@%$SHOBJ_STATUS%g
-s%@SHLIB_STATUS@%$SHLIB_STATUS%g
-s%@SHLIB_XLDFLAGS@%$SHLIB_XLDFLAGS%g
-s%@SHLIB_LIBSUFF@%$SHLIB_LIBSUFF%g
-s%@SHLIB_LIBVERSION@%$SHLIB_LIBVERSION%g
-s%@SHLIB_LIBS@%$SHLIB_LIBS%g
-s%@BUILD_DIR@%$BUILD_DIR%g
-s%@LOCAL_CFLAGS@%$LOCAL_CFLAGS%g
-s%@LOCAL_LDFLAGS@%$LOCAL_LDFLAGS%g
-s%@LOCAL_DEFS@%$LOCAL_DEFS%g
-s%@ARFLAGS@%$ARFLAGS%g
-s%@LIBVERSION@%$LIBVERSION%g
-s%@TERMCAP_LIB@%$TERMCAP_LIB%g
+cat >>$CONFIG_STATUS <<\EOF
+for ac_config_target in $ac_config_targets
+do
+  case "$ac_config_target" in
+  # Handling of arguments.
+  "Makefile" ) CONFIG_FILES="$CONFIG_FILES Makefile" ;;
+  "doc/Makefile" ) CONFIG_FILES="$CONFIG_FILES doc/Makefile" ;;
+  "examples/Makefile" ) CONFIG_FILES="$CONFIG_FILES examples/Makefile" ;;
+  "shlib/Makefile" ) CONFIG_FILES="$CONFIG_FILES shlib/Makefile" ;;
+  "default" ) CONFIG_COMMANDS="$CONFIG_COMMANDS default" ;;
+  "config.h" ) CONFIG_HEADERS="$CONFIG_HEADERS config.h" ;;
+  *) { { echo "$as_me:5304: error: invalid argument: $ac_config_target" >&5
+echo "$as_me: error: invalid argument: $ac_config_target" >&2;}
+   { (exit 1); exit 1; }; };;
+  esac
+done
+
+# If the user did not use the arguments to specify the items to instantiate,
+# then the envvar interface is used.  Set only those that are not.
+# We use the long form for the default assignment because of an extremely
+# bizarre bug on SunOS 4.1.3.
+if $ac_need_defaults; then
+  test "${CONFIG_FILES+set}" = set || CONFIG_FILES=$config_files
+  test "${CONFIG_HEADERS+set}" = set || CONFIG_HEADERS=$config_headers
+  test "${CONFIG_COMMANDS+set}" = set || CONFIG_COMMANDS=$config_commands
+fi
+
+# Create a temporary directory, and hook for its removal unless debugging.
+$debug ||
+{
+  trap 'exit_status=$?; rm -rf $tmp && exit $exit_status' 0
+  trap '{ (exit 1); exit 1; }' 1 2 13 15
+}
+
+# Create a (secure) tmp directory for tmp files.
+: ${TMPDIR=/tmp}
+{
+  tmp=`(umask 077 && mktemp -d -q "$TMPDIR/csXXXXXX") 2>/dev/null` &&
+  test -n "$tmp" && test -d "$tmp"
+}  ||
+{
+  tmp=$TMPDIR/cs$$-$RANDOM
+  (umask 077 && mkdir $tmp)
+} ||
+{
+   echo "$me: cannot create a temporary directory in $TMPDIR" >&2
+   { (exit 1); exit 1; }
+}
 
-CEOF
 EOF
 
-cat >> $CONFIG_STATUS <<\EOF
+cat >>$CONFIG_STATUS <<EOF
 
-# Split the substitutions into bite-sized pieces for seds with
-# small command number limits, like on Digital OSF/1 and HP-UX.
-ac_max_sed_cmds=90 # Maximum number of lines to put in a sed script.
-ac_file=1 # Number of current file.
-ac_beg=1 # First line for current file.
-ac_end=$ac_max_sed_cmds # Line after last line for current file.
-ac_more_lines=:
-ac_sed_cmds=""
-while $ac_more_lines; do
-  if test $ac_beg -gt 1; then
-    sed "1,${ac_beg}d; ${ac_end}q" conftest.subs > conftest.s$ac_file
-  else
-    sed "${ac_end}q" conftest.subs > conftest.s$ac_file
-  fi
-  if test ! -s conftest.s$ac_file; then
-    ac_more_lines=false
-    rm -f conftest.s$ac_file
-  else
-    if test -z "$ac_sed_cmds"; then
-      ac_sed_cmds="sed -f conftest.s$ac_file"
+#
+# CONFIG_FILES section.
+#
+
+# No need to generate the scripts if there are no CONFIG_FILES.
+# This happens for instance when ./config.status config.h
+if test -n "\$CONFIG_FILES"; then
+  # Protect against being on the right side of a sed subst in config.status.
+  sed 's/,@/@@/; s/@,/@@/; s/,;t t\$/@;t t/; /@;t t\$/s/[\\\\&,]/\\\\&/g;
+   s/@@/,@/; s/@@/@,/; s/@;t t\$/,;t t/' >\$tmp/subs.sed <<\\CEOF
+s,@SHELL@,$SHELL,;t t
+s,@exec_prefix@,$exec_prefix,;t t
+s,@prefix@,$prefix,;t t
+s,@program_transform_name@,$program_transform_name,;t t
+s,@bindir@,$bindir,;t t
+s,@sbindir@,$sbindir,;t t
+s,@libexecdir@,$libexecdir,;t t
+s,@datadir@,$datadir,;t t
+s,@sysconfdir@,$sysconfdir,;t t
+s,@sharedstatedir@,$sharedstatedir,;t t
+s,@localstatedir@,$localstatedir,;t t
+s,@libdir@,$libdir,;t t
+s,@includedir@,$includedir,;t t
+s,@oldincludedir@,$oldincludedir,;t t
+s,@infodir@,$infodir,;t t
+s,@mandir@,$mandir,;t t
+s,@PACKAGE_NAME@,$PACKAGE_NAME,;t t
+s,@PACKAGE_TARNAME@,$PACKAGE_TARNAME,;t t
+s,@PACKAGE_VERSION@,$PACKAGE_VERSION,;t t
+s,@PACKAGE_STRING@,$PACKAGE_STRING,;t t
+s,@PACKAGE_BUGREPORT@,$PACKAGE_BUGREPORT,;t t
+s,@build_alias@,$build_alias,;t t
+s,@host_alias@,$host_alias,;t t
+s,@target_alias@,$target_alias,;t t
+s,@ECHO_C@,$ECHO_C,;t t
+s,@ECHO_N@,$ECHO_N,;t t
+s,@ECHO_T@,$ECHO_T,;t t
+s,@PATH_SEPARATOR@,$PATH_SEPARATOR,;t t
+s,@DEFS@,$DEFS,;t t
+s,@LIBS@,$LIBS,;t t
+s,@build@,$build,;t t
+s,@build_cpu@,$build_cpu,;t t
+s,@build_vendor@,$build_vendor,;t t
+s,@build_os@,$build_os,;t t
+s,@host@,$host,;t t
+s,@host_cpu@,$host_cpu,;t t
+s,@host_vendor@,$host_vendor,;t t
+s,@host_os@,$host_os,;t t
+s,@SET_MAKE@,$SET_MAKE,;t t
+s,@CC@,$CC,;t t
+s,@CFLAGS@,$CFLAGS,;t t
+s,@LDFLAGS@,$LDFLAGS,;t t
+s,@CPPFLAGS@,$CPPFLAGS,;t t
+s,@ac_ct_CC@,$ac_ct_CC,;t t
+s,@EXEEXT@,$EXEEXT,;t t
+s,@OBJEXT@,$OBJEXT,;t t
+s,@CPP@,$CPP,;t t
+s,@INSTALL_PROGRAM@,$INSTALL_PROGRAM,;t t
+s,@INSTALL_SCRIPT@,$INSTALL_SCRIPT,;t t
+s,@INSTALL_DATA@,$INSTALL_DATA,;t t
+s,@AR@,$AR,;t t
+s,@RANLIB@,$RANLIB,;t t
+s,@ac_ct_RANLIB@,$ac_ct_RANLIB,;t t
+s,@MAKE_SHELL@,$MAKE_SHELL,;t t
+s,@SHOBJ_CC@,$SHOBJ_CC,;t t
+s,@SHOBJ_CFLAGS@,$SHOBJ_CFLAGS,;t t
+s,@SHOBJ_LD@,$SHOBJ_LD,;t t
+s,@SHOBJ_LDFLAGS@,$SHOBJ_LDFLAGS,;t t
+s,@SHOBJ_XLDFLAGS@,$SHOBJ_XLDFLAGS,;t t
+s,@SHOBJ_LIBS@,$SHOBJ_LIBS,;t t
+s,@SHOBJ_STATUS@,$SHOBJ_STATUS,;t t
+s,@SHLIB_STATUS@,$SHLIB_STATUS,;t t
+s,@SHLIB_XLDFLAGS@,$SHLIB_XLDFLAGS,;t t
+s,@SHLIB_LIBSUFF@,$SHLIB_LIBSUFF,;t t
+s,@SHLIB_LIBVERSION@,$SHLIB_LIBVERSION,;t t
+s,@SHLIB_LIBS@,$SHLIB_LIBS,;t t
+s,@SHLIB_MAJOR@,$SHLIB_MAJOR,;t t
+s,@SHLIB_MINOR@,$SHLIB_MINOR,;t t
+s,@STATIC_TARGET@,$STATIC_TARGET,;t t
+s,@SHARED_TARGET@,$SHARED_TARGET,;t t
+s,@STATIC_INSTALL_TARGET@,$STATIC_INSTALL_TARGET,;t t
+s,@SHARED_INSTALL_TARGET@,$SHARED_INSTALL_TARGET,;t t
+s,@BUILD_DIR@,$BUILD_DIR,;t t
+s,@LOCAL_CFLAGS@,$LOCAL_CFLAGS,;t t
+s,@LOCAL_LDFLAGS@,$LOCAL_LDFLAGS,;t t
+s,@LOCAL_DEFS@,$LOCAL_DEFS,;t t
+s,@ARFLAGS@,$ARFLAGS,;t t
+s,@LIBVERSION@,$LIBVERSION,;t t
+s,@TERMCAP_LIB@,$TERMCAP_LIB,;t t
+CEOF
+
+EOF
+
+  cat >>$CONFIG_STATUS <<\EOF
+  # Split the substitutions into bite-sized pieces for seds with
+  # small command number limits, like on Digital OSF/1 and HP-UX.
+  ac_max_sed_lines=48
+  ac_sed_frag=1 # Number of current file.
+  ac_beg=1 # First line for current file.
+  ac_end=$ac_max_sed_lines # Line after last line for current file.
+  ac_more_lines=:
+  ac_sed_cmds=
+  while $ac_more_lines; do
+    if test $ac_beg -gt 1; then
+      sed "1,${ac_beg}d; ${ac_end}q" $tmp/subs.sed >$tmp/subs.frag
+    else
+      sed "${ac_end}q" $tmp/subs.sed >$tmp/subs.frag
+    fi
+    if test ! -s $tmp/subs.frag; then
+      ac_more_lines=false
     else
-      ac_sed_cmds="$ac_sed_cmds | sed -f conftest.s$ac_file"
+      # The purpose of the label and of the branching condition is to
+      # speed up the sed processing (if there are no `@' at all, there
+      # is no need to browse any of the substitutions).
+      # These are the two extra sed commands mentioned above.
+      (echo ':t
+  /@[a-zA-Z_][a-zA-Z_0-9]*@/!b' && cat $tmp/subs.frag) >$tmp/subs-$ac_sed_frag.sed
+      if test -z "$ac_sed_cmds"; then
+  	ac_sed_cmds="sed -f $tmp/subs-$ac_sed_frag.sed"
+      else
+  	ac_sed_cmds="$ac_sed_cmds | sed -f $tmp/subs-$ac_sed_frag.sed"
+      fi
+      ac_sed_frag=`expr $ac_sed_frag + 1`
+      ac_beg=$ac_end
+      ac_end=`expr $ac_end + $ac_max_sed_lines`
     fi
-    ac_file=`expr $ac_file + 1`
-    ac_beg=$ac_end
-    ac_end=`expr $ac_end + $ac_max_sed_cmds`
+  done
+  if test -z "$ac_sed_cmds"; then
+    ac_sed_cmds=cat
   fi
-done
-if test -z "$ac_sed_cmds"; then
-  ac_sed_cmds=cat
-fi
-EOF
+fi # test -n "$CONFIG_FILES"
 
-cat >> $CONFIG_STATUS <<EOF
-
-CONFIG_FILES=\${CONFIG_FILES-"Makefile doc/Makefile examples/Makefile shlib/Makefile"}
 EOF
-cat >> $CONFIG_STATUS <<\EOF
-for ac_file in .. $CONFIG_FILES; do if test "x$ac_file" != x..; then
+cat >>$CONFIG_STATUS <<\EOF
+for ac_file in : $CONFIG_FILES; do test "x$ac_file" = x: && continue
   # Support "outfile[:infile[:infile...]]", defaulting infile="outfile.in".
-  case "$ac_file" in
-  *:*) ac_file_in=`echo "$ac_file"|sed 's%[^:]*:%%'`
-       ac_file=`echo "$ac_file"|sed 's%:.*%%'` ;;
-  *) ac_file_in="${ac_file}.in" ;;
+  case $ac_file in
+  - | *:- | *:-:* ) # input from stdin
+        cat >$tmp/stdin
+        ac_file_in=`echo "$ac_file" | sed 's,[^:]*:,,'`
+        ac_file=`echo "$ac_file" | sed 's,:.*,,'` ;;
+  *:* ) ac_file_in=`echo "$ac_file" | sed 's,[^:]*:,,'`
+        ac_file=`echo "$ac_file" | sed 's,:.*,,'` ;;
+  * )   ac_file_in=$ac_file.in ;;
   esac
 
-  # Adjust a relative srcdir, top_srcdir, and INSTALL for subdirectories.
-
-  # Remove last slash and all that follows it.  Not all systems have dirname.
-  ac_dir=`echo $ac_file|sed 's%/[^/][^/]*$%%'`
+  # Compute @srcdir@, @top_srcdir@, and @INSTALL@ for subdirectories.
+  ac_dir=`$as_expr X"$ac_file" : 'X\(.*[^/]\)//*[^/][^/]*/*$' \| \
+         X"$ac_file" : 'X\(//\)[^/]' \| \
+         X"$ac_file" : 'X\(//\)$' \| \
+         X"$ac_file" : 'X\(/\)' \| \
+         .     : '\(.\)' 2>/dev/null ||
+echo X"$ac_file" |
+    sed '/^X\(.*[^/]\)\/\/*[^/][^/]*\/*$/{ s//\1/; q; }
+  	  /^X\(\/\/\)[^/].*/{ s//\1/; q; }
+  	  /^X\(\/\/\)$/{ s//\1/; q; }
+  	  /^X\(\/\).*/{ s//\1/; q; }
+  	  s/.*/./; q'`
   if test "$ac_dir" != "$ac_file" && test "$ac_dir" != .; then
-    # The file is in a subdirectory.
-    test ! -d "$ac_dir" && mkdir "$ac_dir"
-    ac_dir_suffix="/`echo $ac_dir|sed 's%^\./%%'`"
+    { case "$ac_dir" in
+  [\\/]* | ?:[\\/]* ) as_incr_dir=;;
+  *)                      as_incr_dir=.;;
+esac
+as_dummy="$ac_dir"
+for as_mkdir_dir in `IFS='/\\'; set X $as_dummy; shift; echo "$@"`; do
+  case $as_mkdir_dir in
+    # Skip DOS drivespec
+    ?:) as_incr_dir=$as_mkdir_dir ;;
+    *)
+      as_incr_dir=$as_incr_dir/$as_mkdir_dir
+      test -d "$as_incr_dir" || mkdir "$as_incr_dir"
+    ;;
+  esac
+done; }
+
+    ac_dir_suffix="/`echo $ac_dir|sed 's,^\./,,'`"
     # A "../" for each directory in $ac_dir_suffix.
-    ac_dots=`echo $ac_dir_suffix|sed 's%/[^/]*%../%g'`
+    ac_dots=`echo "$ac_dir_suffix" | sed 's,/[^/]*,../,g'`
   else
     ac_dir_suffix= ac_dots=
   fi
 
-  case "$ac_given_srcdir" in
-  .)  srcdir=.
-      if test -z "$ac_dots"; then top_srcdir=.
-      else top_srcdir=`echo $ac_dots|sed 's%/$%%'`; fi ;;
-  /*) srcdir="$ac_given_srcdir$ac_dir_suffix"; top_srcdir="$ac_given_srcdir" ;;
+  case $srcdir in
+  .)  ac_srcdir=.
+      if test -z "$ac_dots"; then
+         ac_top_srcdir=.
+      else
+         ac_top_srcdir=`echo $ac_dots | sed 's,/$,,'`
+      fi ;;
+  [\\/]* | ?:[\\/]* )
+      ac_srcdir=$srcdir$ac_dir_suffix;
+      ac_top_srcdir=$srcdir ;;
   *) # Relative path.
-    srcdir="$ac_dots$ac_given_srcdir$ac_dir_suffix"
-    top_srcdir="$ac_dots$ac_given_srcdir" ;;
+    ac_srcdir=$ac_dots$srcdir$ac_dir_suffix
+    ac_top_srcdir=$ac_dots$srcdir ;;
   esac
 
-  case "$ac_given_INSTALL" in
-  [/$]*) INSTALL="$ac_given_INSTALL" ;;
-  *) INSTALL="$ac_dots$ac_given_INSTALL" ;;
+  case $INSTALL in
+  [\\/$]* | ?:[\\/]* ) ac_INSTALL=$INSTALL ;;
+  *) ac_INSTALL=$ac_dots$INSTALL ;;
   esac
 
-  echo creating "$ac_file"
-  rm -f "$ac_file"
-  configure_input="Generated automatically from `echo $ac_file_in|sed 's%.*/%%'` by configure."
-  case "$ac_file" in
-  *Makefile*) ac_comsub="1i\\
-# $configure_input" ;;
-  *) ac_comsub= ;;
-  esac
+  if test x"$ac_file" != x-; then
+    { echo "$as_me:5549: creating $ac_file" >&5
+echo "$as_me: creating $ac_file" >&6;}
+    rm -f "$ac_file"
+  fi
+  # Let's still pretend it is `configure' which instantiates (i.e., don't
+  # use $as_me), people would be surprised to read:
+  #    /* config.h.  Generated automatically by config.status.  */
+  configure_input="Generated automatically from `echo $ac_file_in |
+                                                 sed 's,.*/,,'` by configure."
+
+  # First look for the input files in the build tree, otherwise in the
+  # src tree.
+  ac_file_inputs=`IFS=:
+    for f in $ac_file_in; do
+      case $f in
+      -) echo $tmp/stdin ;;
+      [\\/$]*)
+         # Absolute (can't be DOS-style, as IFS=:)
+         test -f "$f" || { { echo "$as_me:5567: error: cannot find input file: $f" >&5
+echo "$as_me: error: cannot find input file: $f" >&2;}
+   { (exit 1); exit 1; }; }
+         echo $f;;
+      *) # Relative
+         if test -f "$f"; then
+           # Build tree
+           echo $f
+         elif test -f "$srcdir/$f"; then
+           # Source tree
+           echo $srcdir/$f
+         else
+           # /dev/null tree
+           { { echo "$as_me:5580: error: cannot find input file: $f" >&5
+echo "$as_me: error: cannot find input file: $f" >&2;}
+   { (exit 1); exit 1; }; }
+         fi;;
+      esac
+    done` || { (exit 1); exit 1; }
+EOF
+cat >>$CONFIG_STATUS <<EOF
+  sed "$ac_vpsub
+$extrasub
+EOF
+cat >>$CONFIG_STATUS <<\EOF
+:t
+/@[a-zA-Z_][a-zA-Z_0-9]*@/!b
+s,@configure_input@,$configure_input,;t t
+s,@srcdir@,$ac_srcdir,;t t
+s,@top_srcdir@,$ac_top_srcdir,;t t
+s,@INSTALL@,$ac_INSTALL,;t t
+" $ac_file_inputs | (eval "$ac_sed_cmds") >$tmp/out
+  rm -f $tmp/stdin
+  if test x"$ac_file" != x-; then
+    mv $tmp/out $ac_file
+  else
+    cat $tmp/out
+    rm -f $tmp/out
+  fi
 
-  ac_file_inputs=`echo $ac_file_in|sed -e "s%^%$ac_given_srcdir/%" -e "s%:% $ac_given_srcdir/%g"`
-  sed -e "$ac_comsub
-s%@configure_input@%$configure_input%g
-s%@srcdir@%$srcdir%g
-s%@top_srcdir@%$top_srcdir%g
-s%@INSTALL@%$INSTALL%g
-" $ac_file_inputs | (eval "$ac_sed_cmds") > $ac_file
-fi; done
-rm -f conftest.s*
+done
+EOF
+cat >>$CONFIG_STATUS <<\EOF
+
+#
+# CONFIG_HEADER section.
+#
 
 # These sed commands are passed to sed as "A NAME B NAME C VALUE D", where
 # NAME is the cpp macro being defined and VALUE is the value it is being given.
 #
 # ac_d sets the value in "#define NAME VALUE" lines.
-ac_dA='s%^\([ 	]*\)#\([ 	]*define[ 	][ 	]*\)'
-ac_dB='\([ 	][ 	]*\)[^ 	]*%\1#\2'
-ac_dC='\3'
-ac_dD='%g'
-# ac_u turns "#undef NAME" with trailing blanks into "#define NAME VALUE".
-ac_uA='s%^\([ 	]*\)#\([ 	]*\)undef\([ 	][ 	]*\)'
-ac_uB='\([ 	]\)%\1#\2define\3'
+ac_dA='s,^\([ 	]*\)#\([ 	]*define[ 	][ 	]*\)'
+ac_dB='[ 	].*$,\1#\2'
+ac_dC=' '
+ac_dD=',;t'
+# ac_u turns "#undef NAME" without trailing blanks into "#define NAME VALUE".
+ac_uA='s,^\([ 	]*\)#\([ 	]*\)undef\([ 	][ 	]*\)'
+ac_uB='$,\1#\2define\3'
 ac_uC=' '
-ac_uD='\4%g'
-# ac_e turns "#undef NAME" without trailing blanks into "#define NAME VALUE".
-ac_eA='s%^\([ 	]*\)#\([ 	]*\)undef\([ 	][ 	]*\)'
-ac_eB='$%\1#\2define\3'
-ac_eC=' '
-ac_eD='%g'
+ac_uD=',;t'
 
-if test "${CONFIG_HEADERS+set}" != set; then
-EOF
-cat >> $CONFIG_STATUS <<EOF
-  CONFIG_HEADERS="config.h"
-EOF
-cat >> $CONFIG_STATUS <<\EOF
-fi
-for ac_file in .. $CONFIG_HEADERS; do if test "x$ac_file" != x..; then
+for ac_file in : $CONFIG_HEADERS; do test "x$ac_file" = x: && continue
   # Support "outfile[:infile[:infile...]]", defaulting infile="outfile.in".
-  case "$ac_file" in
-  *:*) ac_file_in=`echo "$ac_file"|sed 's%[^:]*:%%'`
-       ac_file=`echo "$ac_file"|sed 's%:.*%%'` ;;
-  *) ac_file_in="${ac_file}.in" ;;
+  case $ac_file in
+  - | *:- | *:-:* ) # input from stdin
+        cat >$tmp/stdin
+        ac_file_in=`echo "$ac_file" | sed 's,[^:]*:,,'`
+        ac_file=`echo "$ac_file" | sed 's,:.*,,'` ;;
+  *:* ) ac_file_in=`echo "$ac_file" | sed 's,[^:]*:,,'`
+        ac_file=`echo "$ac_file" | sed 's,:.*,,'` ;;
+  * )   ac_file_in=$ac_file.in ;;
   esac
 
-  echo creating $ac_file
-
-  rm -f conftest.frag conftest.in conftest.out
-  ac_file_inputs=`echo $ac_file_in|sed -e "s%^%$ac_given_srcdir/%" -e "s%:% $ac_given_srcdir/%g"`
-  cat $ac_file_inputs > conftest.in
+  test x"$ac_file" != x- && { echo "$as_me:5641: creating $ac_file" >&5
+echo "$as_me: creating $ac_file" >&6;}
+
+  # First look for the input files in the build tree, otherwise in the
+  # src tree.
+  ac_file_inputs=`IFS=:
+    for f in $ac_file_in; do
+      case $f in
+      -) echo $tmp/stdin ;;
+      [\\/$]*)
+         # Absolute (can't be DOS-style, as IFS=:)
+         test -f "$f" || { { echo "$as_me:5652: error: cannot find input file: $f" >&5
+echo "$as_me: error: cannot find input file: $f" >&2;}
+   { (exit 1); exit 1; }; }
+         echo $f;;
+      *) # Relative
+         if test -f "$f"; then
+           # Build tree
+           echo $f
+         elif test -f "$srcdir/$f"; then
+           # Source tree
+           echo $srcdir/$f
+         else
+           # /dev/null tree
+           { { echo "$as_me:5665: error: cannot find input file: $f" >&5
+echo "$as_me: error: cannot find input file: $f" >&2;}
+   { (exit 1); exit 1; }; }
+         fi;;
+      esac
+    done` || { (exit 1); exit 1; }
+  # Remove the trailing spaces.
+  sed 's/[ 	]*$//' $ac_file_inputs >$tmp/in
 
 EOF
 
-# Transform confdefs.h into a sed script conftest.vals that substitutes
-# the proper values into config.h.in to produce config.h.  And first:
-# Protect against being on the right side of a sed subst in config.status.
-# Protect against being in an unquoted here document in config.status.
-rm -f conftest.vals
-cat > conftest.hdr <<\EOF
-s/[\\&%]/\\&/g
-s%[\\$`]%\\&%g
-s%#define \([A-Za-z_][A-Za-z0-9_]*\) *\(.*\)%${ac_dA}\1${ac_dB}\1${ac_dC}\2${ac_dD}%gp
-s%ac_d%ac_u%gp
-s%ac_u%ac_e%gp
+# Transform confdefs.h into two sed scripts, `conftest.defines' and
+# `conftest.undefs', that substitutes the proper values into
+# config.h.in to produce config.h.  The first handles `#define'
+# templates, and the second `#undef' templates.
+# And first: Protect against being on the right side of a sed subst in
+# config.status.  Protect against being in an unquoted here document
+# in config.status.
+rm -f conftest.defines conftest.undefs
+# Using a here document instead of a string reduces the quoting nightmare.
+# Putting comments in sed scripts is not portable.
+#
+# `end' is used to avoid that the second main sed command (meant for
+# 0-ary CPP macros) applies to n-ary macro definitions.
+# See the Autoconf documentation for `clear'.
+cat >confdef2sed.sed <<\EOF
+s/[\\&,]/\\&/g
+s,[\\$`],\\&,g
+t clear
+: clear
+s,^[ 	]*#[ 	]*define[ 	][ 	]*\(\([^ 	(][^ 	(]*\)([^)]*)\)[ 	]*\(.*\)$,${ac_dA}\2${ac_dB}\1${ac_dC}\3${ac_dD},gp
+t end
+s,^[ 	]*#[ 	]*define[ 	][ 	]*\([^ 	][^ 	]*\)[ 	]*\(.*\)$,${ac_dA}\1${ac_dB}\1${ac_dC}\2${ac_dD},gp
+: end
 EOF
-sed -n -f conftest.hdr confdefs.h > conftest.vals
-rm -f conftest.hdr
+# If some macros were called several times there might be several times
+# the same #defines, which is useless.  Nevertheless, we may not want to
+# sort them, since we want the *last* AC-DEFINE to be honored.
+uniq confdefs.h | sed -n -f confdef2sed.sed >conftest.defines
+sed 's/ac_d/ac_u/g' conftest.defines >conftest.undefs
+rm -f confdef2sed.sed
 
 # This sed command replaces #undef with comments.  This is necessary, for
 # example, in the case of _POSIX_SOURCE, which is predefined and required
 # on some systems where configure will not decide to define it.
-cat >> conftest.vals <<\EOF
-s%^[ 	]*#[ 	]*undef[ 	][ 	]*[a-zA-Z_][a-zA-Z_0-9]*%/* & */%
+cat >>conftest.undefs <<\EOF
+s,^[ 	]*#[ 	]*undef[ 	][ 	]*[a-zA-Z_][a-zA-Z_0-9]*,/* & */,
 EOF
 
-# Break up conftest.vals because some shells have a limit on
-# the size of here documents, and old seds have small limits too.
+# Break up conftest.defines because some shells have a limit on the size
+# of here documents, and old seds have small limits too (100 cmds).
+echo '  # Handle all the #define templates only if necessary.' >>$CONFIG_STATUS
+echo '  if egrep "^[ 	]*#[ 	]*define" $tmp/in >/dev/null; then' >>$CONFIG_STATUS
+echo '  # If there are no defines, we may have an empty if/fi' >>$CONFIG_STATUS
+echo '  :' >>$CONFIG_STATUS
+rm -f conftest.tail
+while grep . conftest.defines >/dev/null
+do
+  # Write a limited-size here document to $tmp/defines.sed.
+  echo '  cat >$tmp/defines.sed <<CEOF' >>$CONFIG_STATUS
+  # Speed up: don't consider the non `#define' lines.
+  echo '/^[ 	]*#[ 	]*define/!b' >>$CONFIG_STATUS
+  # Work around the forget-to-reset-the-flag bug.
+  echo 't clr' >>$CONFIG_STATUS
+  echo ': clr' >>$CONFIG_STATUS
+  sed ${ac_max_here_lines}q conftest.defines >>$CONFIG_STATUS
+  echo 'CEOF
+  sed -f $tmp/defines.sed $tmp/in >$tmp/out
+  rm -f $tmp/in
+  mv $tmp/out $tmp/in
+' >>$CONFIG_STATUS
+  sed 1,${ac_max_here_lines}d conftest.defines >conftest.tail
+  rm -f conftest.defines
+  mv conftest.tail conftest.defines
+done
+rm -f conftest.defines
+echo '  fi # egrep' >>$CONFIG_STATUS
+echo >>$CONFIG_STATUS
 
+# Break up conftest.undefs because some shells have a limit on the size
+# of here documents, and old seds have small limits too (100 cmds).
+echo '  # Handle all the #undef templates' >>$CONFIG_STATUS
 rm -f conftest.tail
-while :
+while grep . conftest.undefs >/dev/null
 do
-  ac_lines=`grep -c . conftest.vals`
-  # grep -c gives empty output for an empty file on some AIX systems.
-  if test -z "$ac_lines" || test "$ac_lines" -eq 0; then break; fi
-  # Write a limited-size here document to conftest.frag.
-  echo '  cat > conftest.frag <<CEOF' >> $CONFIG_STATUS
-  sed ${ac_max_here_lines}q conftest.vals >> $CONFIG_STATUS
+  # Write a limited-size here document to $tmp/undefs.sed.
+  echo '  cat >$tmp/undefs.sed <<CEOF' >>$CONFIG_STATUS
+  # Speed up: don't consider the non `#undef'
+  echo '/^[ 	]*#[ 	]*undef/!b' >>$CONFIG_STATUS
+  # Work around the forget-to-reset-the-flag bug.
+  echo 't clr' >>$CONFIG_STATUS
+  echo ': clr' >>$CONFIG_STATUS
+  sed ${ac_max_here_lines}q conftest.undefs >>$CONFIG_STATUS
   echo 'CEOF
-  sed -f conftest.frag conftest.in > conftest.out
-  rm -f conftest.in
-  mv conftest.out conftest.in
-' >> $CONFIG_STATUS
-  sed 1,${ac_max_here_lines}d conftest.vals > conftest.tail
-  rm -f conftest.vals
-  mv conftest.tail conftest.vals
+  sed -f $tmp/undefs.sed $tmp/in >$tmp/out
+  rm -f $tmp/in
+  mv $tmp/out $tmp/in
+' >>$CONFIG_STATUS
+  sed 1,${ac_max_here_lines}d conftest.undefs >conftest.tail
+  rm -f conftest.undefs
+  mv conftest.tail conftest.undefs
 done
-rm -f conftest.vals
-
-cat >> $CONFIG_STATUS <<\EOF
-  rm -f conftest.frag conftest.h
-  echo "/* $ac_file.  Generated automatically by configure.  */" > conftest.h
-  cat conftest.in >> conftest.h
-  rm -f conftest.in
-  if cmp -s $ac_file conftest.h 2>/dev/null; then
-    echo "$ac_file is unchanged"
-    rm -f conftest.h
+rm -f conftest.undefs
+
+cat >>$CONFIG_STATUS <<\EOF
+  # Let's still pretend it is `configure' which instantiates (i.e., don't
+  # use $as_me), people would be surprised to read:
+  #    /* config.h.  Generated automatically by config.status.  */
+  if test x"$ac_file" = x-; then
+    echo "/* Generated automatically by configure.  */" >$tmp/config.h
   else
-    # Remove last slash and all that follows it.  Not all systems have dirname.
-      ac_dir=`echo $ac_file|sed 's%/[^/][^/]*$%%'`
+    echo "/* $ac_file.  Generated automatically by configure.  */" >$tmp/config.h
+  fi
+  cat $tmp/in >>$tmp/config.h
+  rm -f $tmp/in
+  if test x"$ac_file" != x-; then
+    if cmp -s $ac_file $tmp/config.h 2>/dev/null; then
+      { echo "$as_me:5782: $ac_file is unchanged" >&5
+echo "$as_me: $ac_file is unchanged" >&6;}
+    else
+      ac_dir=`$as_expr X"$ac_file" : 'X\(.*[^/]\)//*[^/][^/]*/*$' \| \
+         X"$ac_file" : 'X\(//\)[^/]' \| \
+         X"$ac_file" : 'X\(//\)$' \| \
+         X"$ac_file" : 'X\(/\)' \| \
+         .     : '\(.\)' 2>/dev/null ||
+echo X"$ac_file" |
+    sed '/^X\(.*[^/]\)\/\/*[^/][^/]*\/*$/{ s//\1/; q; }
+  	  /^X\(\/\/\)[^/].*/{ s//\1/; q; }
+  	  /^X\(\/\/\)$/{ s//\1/; q; }
+  	  /^X\(\/\).*/{ s//\1/; q; }
+  	  s/.*/./; q'`
       if test "$ac_dir" != "$ac_file" && test "$ac_dir" != .; then
-      # The file is in a subdirectory.
-      test ! -d "$ac_dir" && mkdir "$ac_dir"
+        { case "$ac_dir" in
+  [\\/]* | ?:[\\/]* ) as_incr_dir=;;
+  *)                      as_incr_dir=.;;
+esac
+as_dummy="$ac_dir"
+for as_mkdir_dir in `IFS='/\\'; set X $as_dummy; shift; echo "$@"`; do
+  case $as_mkdir_dir in
+    # Skip DOS drivespec
+    ?:) as_incr_dir=$as_mkdir_dir ;;
+    *)
+      as_incr_dir=$as_incr_dir/$as_mkdir_dir
+      test -d "$as_incr_dir" || mkdir "$as_incr_dir"
+    ;;
+  esac
+done; }
+
+      fi
+      rm -f $ac_file
+      mv $tmp/config.h $ac_file
     fi
-    rm -f $ac_file
-    mv conftest.h $ac_file
+  else
+    cat $tmp/config.h
+    rm -f $tmp/config.h
   fi
-fi; done
-
+done
 EOF
-cat >> $CONFIG_STATUS <<EOF
+cat >>$CONFIG_STATUS <<\EOF
 
-EOF
-cat >> $CONFIG_STATUS <<\EOF
+#
+# CONFIG_COMMANDS section.
+#
+for ac_file in : $CONFIG_COMMANDS; do test "x$ac_file" = x: && continue
+  ac_dest=`echo "$ac_file" | sed 's,:.*,,'`
+  ac_source=`echo "$ac_file" | sed 's,[^:]*:,,'`
 
+  case $ac_dest in
+    default )
 # Makefile uses this timestamp file to record whether config.h is up to date.
 echo > stamp-h
+ ;;
+  esac
+done
+EOF
 
-exit 0
+cat >>$CONFIG_STATUS <<\EOF
+
+{ (exit 0); exit 0; }
 EOF
 chmod +x $CONFIG_STATUS
-rm -fr confdefs* $ac_clean_files
-test "$no_create" = yes || ${CONFIG_SHELL-/bin/sh} $CONFIG_STATUS || exit 1
+ac_clean_files=$ac_clean_files_save
+
+# configure is writing to config.log, and then calls config.status.
+# config.status does its own redirection, appending to config.log.
+# Unfortunately, on DOS this fails, as config.log is still kept open
+# by configure, so config.status won't be able to write to it; its
+# output is simply discarded.  So we exec the FD to /dev/null,
+# effectively closing config.log, so it can be properly (re)opened and
+# appended to by config.status.  When coming back to configure, we
+# need to make the FD available again.
+if test "$no_create" != yes; then
+  ac_cs_success=:
+  exec 5>/dev/null
+  $SHELL $CONFIG_STATUS || ac_cs_success=false
+  exec 5>>config.log
+  # Use ||, not &&, to avoid exiting from the if with $? = 1, which
+  # would make configure fail if this is the last instruction.
+  $ac_cs_success || { (exit 1); exit 1; }
+fi
 
diff --git a/readline/configure.in b/readline/configure.in
index 240a3addc45052a773e11b8333a24f5138d19ed8..bc78f8a0f6090adfca312249fee4497e36581240 100644
--- a/readline/configure.in
+++ b/readline/configure.in
@@ -4,34 +4,49 @@ dnl
 dnl report bugs to chet@po.cwru.edu
 dnl
 dnl Process this file with autoconf to produce a configure script.
-AC_REVISION([for Readline 4.0, version 2.14, from autoconf version] AC_ACVERSION)
-LIBVERSION=4.0
+AC_REVISION([for Readline 4.3, version 2.45, from autoconf version] AC_ACVERSION)
 
-AC_INIT(readline.h)
-AC_CONFIG_HEADER(config.h)
+AC_INIT(readline, 4.3, bug-readline@gnu.org)
 
 dnl make sure we are using a recent autoconf version
-AC_PREREQ(2.10)
+AC_PREREQ(2.50)
 
+AC_CONFIG_SRCDIR(readline.h)
 AC_CONFIG_AUX_DIR(./support)
+AC_CONFIG_HEADERS(config.h)
+
+dnl update the value of RL_READLINE_VERSION in readline.h when this changes
+LIBVERSION=4.3
 
 AC_CANONICAL_HOST
 
 dnl configure defaults
 opt_curses=no
-opt_shared=no
 
 dnl arguments to configure
-AC_ARG_WITH(curses, --with-curses               use the curses library instead of the termcap library,opt_curses=$withval)
+AC_ARG_WITH(curses, AC_HELP_STRING([--with-curses], [use the curses library instead of the termcap library]), opt_curses=$withval)
 
 if test "$opt_curses" = "yes"; then
 	prefer_curses=yes
 fi
 
+dnl option parsing for optional features
+opt_static_libs=yes
+opt_shared_libs=yes
+
+AC_ARG_ENABLE(shared, AC_HELP_STRING([--enable-shared], [build shared libraries [[default=YES]]]), opt_shared_libs=$enableval)
+AC_ARG_ENABLE(static, AC_HELP_STRING([--enable-static], [build static libraries [[default=YES]]]), opt_static_libs=$enableval)
+
+echo ""
+echo "Beginning configuration for readline-$LIBVERSION for ${host_cpu}-${host_vendor}-${host_os}"
+echo ""
+
 # We want these before the checks, so the checks can modify their values.
 test -z "$CFLAGS" && CFLAGS=-g auto_cflags=1
 
+AC_PROG_MAKE_SET
 AC_PROG_CC
+dnl AC_AIX
 AC_MINIX
 
 # If we're using gcc and the user hasn't specified CFLAGS, add -O to CFLAGS.
@@ -39,7 +54,7 @@ test -n "$GCC" && test -n "$auto_cflags" && CFLAGS="$CFLAGS -O"
 
 AC_PROG_GCC_TRADITIONAL
 AC_PROG_INSTALL
-AC_CHECK_PROG(AR, ar, ar)
+AC_CHECK_PROG(AR, ar, , ar)
 dnl Set default for ARFLAGS, since autoconf does not have a macro for it.
 dnl This allows people to set it when running configure or make
 test -n "$ARFLAGS" || ARFLAGS="cr"
@@ -48,32 +63,42 @@ AC_PROG_RANLIB
 MAKE_SHELL=/bin/sh
 AC_SUBST(MAKE_SHELL)
 
-AC_RETSIGTYPE
+AC_C_CONST
+AC_C_PROTOTYPES
+AC_C_CHAR_UNSIGNED
+
+AC_TYPE_SIGNAL
+
+AC_TYPE_SIZE_T
+AC_CHECK_TYPE(ssize_t, int)
 
 AC_HEADER_STAT
 AC_HEADER_DIRENT
 
-AC_CHECK_FUNCS(strcasecmp select setenv putenv tcgetattr setlocale lstat)
+AC_CHECK_FUNCS(lstat memmove putenv select setenv setlocale \
+		strcasecmp strpbrk tcgetattr vsnprintf isascii isxdigit)
 
 AC_FUNC_STRCOLL
 
-AC_CHECK_HEADERS(unistd.h stdlib.h varargs.h stdarg.h string.h \
-		sys/ptem.h sys/pte.h sys/stream.h sys/select.h \
-		termcap.h termios.h termio.h sys/file.h locale.h)
+AC_CHECK_HEADERS(unistd.h stdlib.h varargs.h stdarg.h string.h strings.h \
+		limits.h sys/ptem.h sys/pte.h sys/stream.h sys/select.h \
+		termcap.h termios.h termio.h sys/file.h locale.h memory.h )
 
-BASH_SIGNAL_CHECK
-BASH_REINSTALL_SIGHANDLERS
+BASH_SYS_SIGNAL_VINTAGE
+BASH_SYS_REINSTALL_SIGHANDLERS
 
 BASH_FUNC_POSIX_SETJMP
 BASH_FUNC_LSTAT
-BASH_CHECK_GETPW_FUNCS
 BASH_FUNC_STRCOLL
 
+BASH_CHECK_GETPW_FUNCS
+
+AC_HEADER_TIOCGWINSZ
+
 BASH_TYPE_SIGHANDLER
-BASH_HAVE_TIOCGWINSZ
 BASH_HAVE_TIOCSTAT
 BASH_HAVE_FIONREAD
-BASH_MISC_SPEED_T
+BASH_CHECK_SPEED_T
 BASH_STRUCT_WINSIZE
 BASH_STRUCT_DIRENT_D_INO
 BASH_STRUCT_DIRENT_D_FILENO
@@ -84,11 +109,18 @@ aix*)   prefer_curses=yes ;;
 esac
 BASH_CHECK_LIB_TERMCAP
 if test "$TERMCAP_LIB" = "./lib/termcap/libtermcap.a"; then
-	TERMCAP_LIB=-ltermcap	#default
+	if test "$prefer_curses" = yes; then
+		TERMCAP_LIB=-lcurses
+	else
+		TERMCAP_LIB=-ltermcap	#default
+	fi
 fi
 
+BASH_CHECK_MULTIBYTE
+
 case "$host_cpu" in
 *cray*)	LOCAL_CFLAGS=-DCRAY ;;
+*s390*) LOCAL_CFLAGS=-fsigned-char ;;
 esac
 
 case "$host_os" in
@@ -102,7 +134,7 @@ esac
 #
 if test -f ${srcdir}/support/shobj-conf; then
         AC_MSG_CHECKING(configuration for building shared libraries)
-        eval `${CONFIG_SHELL-/bin/sh} ${srcdir}/support/shobj-conf -C ${CC} -c ${host_cpu} -o ${host_os} -v ${host_vendor}`
+        eval `${CONFIG_SHELL-/bin/sh} ${srcdir}/support/shobj-conf -C "${CC}" -c ${host_cpu} -o ${host_os} -v ${host_vendor}`
         AC_SUBST(SHOBJ_CC)
         AC_SUBST(SHOBJ_CFLAGS)
         AC_SUBST(SHOBJ_LD)
@@ -116,9 +148,40 @@ if test -f ${srcdir}/support/shobj-conf; then
 	AC_SUBST(SHLIB_LIBVERSION)
 	AC_SUBST(SHLIB_LIBS)
         AC_MSG_RESULT($SHLIB_STATUS)
+
+	# SHLIB_STATUS is either `supported' or `unsupported'.  If it's
+	# `unsupported', turn off any default shared library building
+	if test "$SHLIB_STATUS" = 'unsupported'; then
+		opt_shared_libs=no
+	fi
+
+	# shared library versioning
+	# quoted for m4 so I can use character classes
+	SHLIB_MAJOR=[`expr "$LIBVERSION" : '\([0-9]\)\..*'`]
+	SHLIB_MINOR=[`expr "$LIBVERSION" : '[0-9]\.\([0-9]\).*'`]
+	AC_SUBST(SHLIB_MAJOR)
+	AC_SUBST(SHLIB_MINOR)
+fi
+
+if test "$opt_static_libs" = "yes"; then
+	STATIC_TARGET=static
+	STATIC_INSTALL_TARGET=install-static
+fi
+if test "$opt_shared_libs" = "yes"; then
+	SHARED_TARGET=shared
+	SHARED_INSTALL_TARGET=install-shared
 fi
 
-BUILD_DIR=`pwd`
+AC_SUBST(STATIC_TARGET)
+AC_SUBST(SHARED_TARGET)
+AC_SUBST(STATIC_INSTALL_TARGET)
+AC_SUBST(SHARED_INSTALL_TARGET)
+
+case "$host_os" in
+msdosdjgpp*)	BUILD_DIR=`pwd.exe` ;;	# to prevent //d/path/file
+*)		BUILD_DIR=`pwd` ;;
+esac
+
 AC_SUBST(BUILD_DIR)
 
 AC_SUBST(CFLAGS)
diff --git a/readline/display.c b/readline/display.c
index df9e212ac0cab57f3a4f69abad4126bcdb180f0e..f393e7e851617c6ea6732eb99f3455810d1d1199 100644
--- a/readline/display.c
+++ b/readline/display.c
@@ -7,7 +7,7 @@
 
    The GNU Readline Library is free software; you can redistribute it
    and/or modify it under the terms of the GNU General Public License
-   as published by the Free Software Foundation; either version 1, or
+   as published by the Free Software Foundation; either version 2, or
    (at your option) any later version.
 
    The GNU Readline Library is distributed in the hope that it will be
@@ -18,7 +18,7 @@
    The GNU General Public License is often shipped with GNU software, and
    is generally kept in a file called COPYING or LICENSE.  If you do not
    have a copy of the license, write to the Free Software Foundation,
-   675 Mass Ave, Cambridge, MA 02139, USA. */
+   59 Temple Place, Suite 330, Boston, MA 02111 USA. */
 #define READLINE_LIBRARY
 
 #if defined (HAVE_CONFIG_H)
@@ -41,13 +41,9 @@
 
 #include <stdio.h>
 
-#if defined (__GO32__)
-#  include <go32.h>
-#  include <pc.h>
-#endif /* __GO32__ */
-
 /* System-specific feature definitions and include files. */
 #include "rldefs.h"
+#include "rlmbutil.h"
 
 /* Termcap library stuff. */
 #include "tcap.h"
@@ -56,48 +52,32 @@
 #include "readline.h"
 #include "history.h"
 
+#include "rlprivate.h"
+#include "xmalloc.h"
+
 #if !defined (strchr) && !defined (__STDC__)
 extern char *strchr (), *strrchr ();
 #endif /* !strchr && !__STDC__ */
 
-/* Global and pseudo-global variables and functions
-   imported from readline.c. */
-extern char *rl_prompt;
-extern int readline_echoing_p;
+#if defined (HACK_TERMCAP_MOTION)
+extern char *_rl_term_forward_char;
+#endif
 
-extern int _rl_output_meta_chars;
-extern int _rl_horizontal_scroll_mode;
-extern int _rl_mark_modified_lines;
-extern int _rl_prefer_visible_bell;
+static void update_line PARAMS((char *, char *, int, int, int, int));
+static void space_to_eol PARAMS((int));
+static void delete_chars PARAMS((int));
+static void insert_some_chars PARAMS((char *, int, int));
+static void cr PARAMS((void));
 
-/* Variables and functions imported from terminal.c */
-extern void _rl_output_some_chars ();
-#ifdef _MINIX
-extern void _rl_output_character_function ();
+#if defined (HANDLE_MULTIBYTE)
+static int _rl_col_width PARAMS((const char *, int, int));
+static int *_rl_wrapped_line;
 #else
-extern int _rl_output_character_function ();
+#  define _rl_col_width(l, s, e)	(((e) <= (s)) ? 0 : (e) - (s))
 #endif
-extern int _rl_backspace ();
-
-extern const char *term_clreol, *term_clrpag;
-extern const char *term_im, *term_ic, *term_ei, *term_DC;
-extern const char *term_up, *term_dc, *term_cr, *term_IC;
-extern int screenheight, screenwidth, screenchars;
-extern int terminal_can_insert, _rl_term_autowrap;
-
-/* Pseudo-global functions (local to the readline library) exported
-   by this file. */
-void _rl_move_cursor_relative (), _rl_output_some_chars ();
-void _rl_move_vert ();
-void _rl_clear_to_eol (), _rl_clear_screen ();
-
-static void update_line (), space_to_eol ();
-static void delete_chars (), insert_some_chars ();
-static void cr ();
 
 static int *inv_lbreaks, *vis_lbreaks;
-
-extern char *xmalloc (), *xrealloc ();
+static int inv_lbsize, vis_lbsize;
 
 /* Heuristic used to decide whether it is faster to move from CUR to NEW
    by backing up or outputting a carriage return and moving forward. */
@@ -131,7 +111,7 @@ extern char *xmalloc (), *xrealloc ();
    RL_DISPLAY_FIXED variable.  This is good for efficiency. */
 
 /* Application-specific redisplay function. */
-VFunction *rl_redisplay_function = rl_redisplay;
+rl_voidfunc_t *rl_redisplay_function = rl_redisplay;
 
 /* Global variables declared here. */
 /* What YOU turn on when you have handled all redisplay yourself. */
@@ -170,27 +150,40 @@ static int forced_display;
 /* Default and initial buffer size.  Can grow. */
 static int line_size = 1024;
 
+/* Variables to keep track of the expanded prompt string, which may
+   include invisible characters. */
+
 static char *local_prompt, *local_prompt_prefix;
-static int visible_length, prefix_length;
+static int prompt_visible_length, prompt_prefix_length;
 
 /* The number of invisible characters in the line currently being
    displayed on the screen. */
 static int visible_wrap_offset;
 
-/* static so it can be shared between rl_redisplay and update_line */
+/* The number of invisible characters in the prompt string.  Static so it
+   can be shared between rl_redisplay and update_line */
 static int wrap_offset;
 
-/* The index of the last invisible_character in the prompt string. */
-static int last_invisible;
+/* The index of the last invisible character in the prompt string. */
+static int prompt_last_invisible;
 
 /* The length (buffer offset) of the first line of the last (possibly
    multi-line) buffer displayed on the screen. */
 static int visible_first_line_len;
 
+/* Number of invisible characters on the first physical line of the prompt.
+   Only valid when the number of physical characters in the prompt exceeds
+   (or is equal to) _rl_screenwidth. */
+static int prompt_invis_chars_first_line;
+
+static int prompt_last_screen_line;
+
 /* Expand the prompt string S and return the number of visible
    characters in *LP, if LP is not null.  This is currently more-or-less
    a placeholder for expansion.  LIP, if non-null is a place to store the
-   index of the last invisible character in ther eturned string. */
+   index of the last invisible character in the returned string. NIFLP,
+   if non-zero, is a place to store the number of invisible characters in
+   the first prompt line. */
 
 /* Current implementation:
 	\001 (^A) start non-visible characters
@@ -200,12 +193,12 @@ static int visible_first_line_len;
    \002 are assumed to be `visible'. */	
 
 static char *
-expand_prompt (pmt, lp, lip)
+expand_prompt (pmt, lp, lip, niflp)
      char *pmt;
-     int *lp, *lip;
+     int *lp, *lip, *niflp;
 {
   char *r, *ret, *p;
-  int l, rl, last, ignoring;
+  int l, rl, last, ignoring, ninvis, invfl;
 
   /* Short-circuit if we can. */
   if (strchr (pmt, RL_PROMPT_START_IGNORE) == 0)
@@ -217,9 +210,11 @@ expand_prompt (pmt, lp, lip)
     }
 
   l = strlen (pmt);
-  r = ret = xmalloc (l + 1);
+  r = ret = (char *)xmalloc (l + 1);
+
+  invfl = 0;	/* invisible chars in first line of prompt */
 
-  for (rl = ignoring = last = 0, p = pmt; p && *p; p++)
+  for (rl = ignoring = last = ninvis = 0, p = pmt; p && *p; p++)
     {
       /* This code strips the invisible character string markers
 	 RL_PROMPT_START_IGNORE and RL_PROMPT_END_IGNORE */
@@ -239,14 +234,35 @@ expand_prompt (pmt, lp, lip)
 	  *r++ = *p;
 	  if (!ignoring)
 	    rl++;
+	  else
+	    ninvis++;
+	  if (rl == _rl_screenwidth)
+	    invfl = ninvis;
 	}
     }
 
+  if (rl < _rl_screenwidth)
+    invfl = ninvis;
+
   *r = '\0';
   if (lp)
     *lp = rl;
   if (lip)
     *lip = last;
+  if (niflp)
+    *niflp = invfl;
+  return ret;
+}
+
+/* Just strip out RL_PROMPT_START_IGNORE and RL_PROMPT_END_IGNORE from
+   PMT and return the rest of PMT. */
+char *
+_rl_strip_prompt (pmt)
+     char *pmt;
+{
+  char *ret;
+
+  ret = expand_prompt (pmt, (int *)NULL, (int *)NULL, (int *)NULL);
   return ret;
 }
 
@@ -258,8 +274,8 @@ expand_prompt (pmt, lp, lip)
  *		  (portion after the final newline)
  * local_prompt_prefix = portion before last newline of rl_display_prompt,
  *			 expanded via expand_prompt
- * visible_length = number of visible characters in local_prompt
- * prefix_length = number of visible characters in local_prompt_prefix
+ * prompt_visible_length = number of visible characters in local_prompt
+ * prompt_prefix_length = number of visible characters in local_prompt_prefix
  *
  * This function is called once per call to readline().  It may also be
  * called arbitrarily to expand the primary prompt.
@@ -275,12 +291,11 @@ rl_expand_prompt (prompt)
   int c;
 
   /* Clear out any saved values. */
-  if (local_prompt)
-    free (local_prompt);
-  if (local_prompt_prefix)
-    free (local_prompt_prefix);
+  FREE (local_prompt);
+  FREE (local_prompt_prefix);
+
   local_prompt = local_prompt_prefix = (char *)0;
-  last_invisible = visible_length = 0;
+  prompt_last_invisible = prompt_visible_length = 0;
 
   if (prompt == 0 || *prompt == 0)
     return (0);
@@ -288,25 +303,77 @@ rl_expand_prompt (prompt)
   p = strrchr (prompt, '\n');
   if (!p)
     {
-      /* The prompt is only one line. */
-      local_prompt = expand_prompt (prompt, &visible_length, &last_invisible);
+      /* The prompt is only one logical line, though it might wrap. */
+      local_prompt = expand_prompt (prompt, &prompt_visible_length,
+					    &prompt_last_invisible,
+					    &prompt_invis_chars_first_line);
       local_prompt_prefix = (char *)0;
-      return (visible_length);
+      return (prompt_visible_length);
     }
   else
     {
       /* The prompt spans multiple lines. */
       t = ++p;
-      local_prompt = expand_prompt (p, &visible_length, &last_invisible);
+      local_prompt = expand_prompt (p, &prompt_visible_length,
+				       &prompt_last_invisible,
+				       &prompt_invis_chars_first_line);
       c = *t; *t = '\0';
       /* The portion of the prompt string up to and including the
 	 final newline is now null-terminated. */
-      local_prompt_prefix = expand_prompt (prompt, &prefix_length, (int *)NULL);
+      local_prompt_prefix = expand_prompt (prompt, &prompt_prefix_length,
+						   (int *)NULL,
+						   &prompt_invis_chars_first_line);
       *t = c;
-      return (prefix_length);
+      return (prompt_prefix_length);
     }
 }
 
+/* Initialize the VISIBLE_LINE and INVISIBLE_LINE arrays, and their associated
+   arrays of line break markers.  MINSIZE is the minimum size of VISIBLE_LINE
+   and INVISIBLE_LINE; if it is greater than LINE_SIZE, LINE_SIZE is
+   increased.  If the lines have already been allocated, this ensures that
+   they can hold at least MINSIZE characters. */
+static void
+init_line_structures (minsize)
+      int minsize;
+{
+  register int n;
+
+  if (invisible_line == 0)	/* initialize it */
+    {
+      if (line_size < minsize)
+	line_size = minsize;
+      visible_line = (char *)xmalloc (line_size);
+      invisible_line = (char *)xmalloc (line_size);
+    }
+  else if (line_size < minsize)	/* ensure it can hold MINSIZE chars */
+    {
+      line_size *= 2;
+      if (line_size < minsize)
+	line_size = minsize;
+      visible_line = (char *)xrealloc (visible_line, line_size);
+      invisible_line = (char *)xrealloc (invisible_line, line_size);
+    }
+
+  for (n = minsize; n < line_size; n++)
+    {
+      visible_line[n] = 0;
+      invisible_line[n] = 1;
+    }
+
+  if (vis_lbreaks == 0)
+    {
+      /* should be enough. */
+      inv_lbsize = vis_lbsize = 256;
+      inv_lbreaks = (int *)xmalloc (inv_lbsize * sizeof (int));
+      vis_lbreaks = (int *)xmalloc (vis_lbsize * sizeof (int));
+#if defined (HANDLE_MULTIBYTE)
+      _rl_wrapped_line = (int *)xmalloc (vis_lbsize * sizeof (int));
+#endif
+      inv_lbreaks[0] = vis_lbreaks[0] = 0;
+    }
+}
+  
 /* Basic redisplay algorithm. */
 void
 rl_redisplay ()
@@ -316,6 +383,13 @@ rl_redisplay ()
   int c_pos, inv_botlin, lb_botlin, lb_linenum;
   int newlines, lpos, temp;
   const char *prompt_this_line;
+#if defined (HANDLE_MULTIBYTE)
+  wchar_t wc;
+  size_t wc_bytes;
+  int wc_width;
+  mbstate_t ps;
+  int _rl_wrapped_multicolumn = 0;
+#endif
 
   if (!readline_echoing_p)
     return;
@@ -325,19 +399,7 @@ rl_redisplay ()
 
   if (invisible_line == 0)
     {
-      visible_line = xmalloc (line_size);
-      invisible_line = xmalloc (line_size);
-      for (in = 0; in < line_size; in++)
-	{
-	  visible_line[in] = 0;
-	  invisible_line[in] = 1;
-	}
-
-      /* should be enough, but then again, this is just for testing. */
-      inv_lbreaks = (int *)malloc (256 * sizeof (int));
-      vis_lbreaks = (int *)malloc (256 * sizeof (int));
-      inv_lbreaks[0] = vis_lbreaks[0] = 0;
-
+      init_line_structures (0);
       rl_on_new_line ();
     }
 
@@ -377,14 +439,14 @@ rl_redisplay ()
 	  if (temp >= line_size)
 	    {
 	      line_size = (temp + 1024) - (temp % 1024);
-	      visible_line = xrealloc (visible_line, line_size);
-	      line = invisible_line = xrealloc (invisible_line, line_size);
+	      visible_line = (char *)xrealloc (visible_line, line_size);
+	      line = invisible_line = (char *)xrealloc (invisible_line, line_size);
 	    }
 	  strncpy (line + out, local_prompt, local_len);
 	  out += local_len;
 	}
       line[out] = '\0';
-      wrap_offset = local_len - visible_length;
+      wrap_offset = local_len - prompt_visible_length;
     }
   else
     {
@@ -395,12 +457,13 @@ rl_redisplay ()
       else
 	{
 	  prompt_this_line++;
+	  pmtlen = prompt_this_line - rl_display_prompt;	/* temp var */
 	  if (forced_display)
 	    {
-	      _rl_output_some_chars (rl_display_prompt, prompt_this_line - rl_display_prompt);
+	      _rl_output_some_chars (rl_display_prompt, pmtlen);
 	      /* Make sure we are at column zero even after a newline,
 		 regardless of the state of terminal output processing. */
-	      if (prompt_this_line[-2] != '\r')
+	      if (pmtlen < 2 || prompt_this_line[-2] != '\r')
 		cr ();
 	    }
 	}
@@ -410,55 +473,143 @@ rl_redisplay ()
       if (temp >= line_size)
 	{
 	  line_size = (temp + 1024) - (temp % 1024);
-	  visible_line = xrealloc (visible_line, line_size);
-	  line = invisible_line = xrealloc (invisible_line, line_size);
+	  visible_line = (char *)xrealloc (visible_line, line_size);
+	  line = invisible_line = (char *)xrealloc (invisible_line, line_size);
 	}
       strncpy (line + out,  prompt_this_line, pmtlen);
       out += pmtlen;
       line[out] = '\0';
-      wrap_offset = 0;
+      wrap_offset = prompt_invis_chars_first_line = 0;
     }
 
+#define CHECK_INV_LBREAKS() \
+      do { \
+	if (newlines >= (inv_lbsize - 2)) \
+	  { \
+	    inv_lbsize *= 2; \
+	    inv_lbreaks = (int *)xrealloc (inv_lbreaks, inv_lbsize * sizeof (int)); \
+	  } \
+      } while (0)
+
+#if defined (HANDLE_MULTIBYTE)	  
+#define CHECK_LPOS() \
+      do { \
+	lpos++; \
+	if (lpos >= _rl_screenwidth) \
+	  { \
+	    if (newlines >= (inv_lbsize - 2)) \
+	      { \
+		inv_lbsize *= 2; \
+		inv_lbreaks = (int *)xrealloc (inv_lbreaks, inv_lbsize * sizeof (int)); \
+		_rl_wrapped_line = (int *)xrealloc (_rl_wrapped_line, inv_lbsize * sizeof (int)); \
+	      } \
+	    inv_lbreaks[++newlines] = out; \
+	    _rl_wrapped_line[newlines] = _rl_wrapped_multicolumn; \
+	    lpos = 0; \
+	  } \
+      } while (0)
+#else
 #define CHECK_LPOS() \
       do { \
 	lpos++; \
-	if (lpos >= screenwidth) \
+	if (lpos >= _rl_screenwidth) \
 	  { \
+	    if (newlines >= (inv_lbsize - 2)) \
+	      { \
+		inv_lbsize *= 2; \
+		inv_lbreaks = (int *)xrealloc (inv_lbreaks, inv_lbsize * sizeof (int)); \
+	      } \
 	    inv_lbreaks[++newlines] = out; \
 	    lpos = 0; \
 	  } \
       } while (0)
+#endif
 
   /* inv_lbreaks[i] is where line i starts in the buffer. */
   inv_lbreaks[newlines = 0] = 0;
   lpos = out - wrap_offset;
+#if defined (HANDLE_MULTIBYTE)
+  memset (_rl_wrapped_line, 0, vis_lbsize);
+#endif
+
+  /* prompt_invis_chars_first_line is the number of invisible characters in
+     the first physical line of the prompt.
+     wrap_offset - prompt_invis_chars_first_line is the number of invis
+     chars on the second line. */
 
-  /* XXX - what if lpos is already >= screenwidth before we start drawing the
+  /* what if lpos is already >= _rl_screenwidth before we start drawing the
      contents of the command line? */
-  while (lpos >= screenwidth)
+  while (lpos >= _rl_screenwidth)
     {
+      /* fix from Darin Johnson <darin@acuson.com> for prompt string with
+         invisible characters that is longer than the screen width.  The
+         prompt_invis_chars_first_line variable could be made into an array
+         saying how many invisible characters there are per line, but that's
+         probably too much work for the benefit gained.  How many people have
+         prompts that exceed two physical lines? */
+      temp = ((newlines + 1) * _rl_screenwidth) +
 #if 0
-      temp = ((newlines + 1) * screenwidth) - ((newlines == 0) ? wrap_offset : 0);
+             ((newlines == 0) ? prompt_invis_chars_first_line : 0) +
 #else
-      /* XXX - possible fix from Darin Johnson <darin@acuson.com> for prompt
-	 string with invisible characters that is longer than the screen
-	 width. */
-      temp = ((newlines + 1) * screenwidth) + ((newlines == 0) ? wrap_offset : 0);
+             ((newlines == 0 && local_prompt_prefix == 0) ? prompt_invis_chars_first_line : 0) +
 #endif
+             ((newlines == 1) ? wrap_offset : 0);
+
       inv_lbreaks[++newlines] = temp;
-      lpos -= screenwidth;
+      lpos -= _rl_screenwidth;
     }
 
+  prompt_last_screen_line = newlines;
+
+  /* Draw the rest of the line (after the prompt) into invisible_line, keeping
+     track of where the cursor is (c_pos), the number of the line containing
+     the cursor (lb_linenum), the last line number (lb_botlin and inv_botlin).
+     It maintains an array of line breaks for display (inv_lbreaks).
+     This handles expanding tabs for display and displaying meta characters. */
   lb_linenum = 0;
+#if defined (HANDLE_MULTIBYTE)
+  in = 0;
+  if (MB_CUR_MAX > 1 && rl_byte_oriented == 0)
+    {
+      memset (&ps, 0, sizeof (mbstate_t));
+      wc_bytes = mbrtowc (&wc, rl_line_buffer, rl_end, &ps);
+    }
+  else
+    wc_bytes = 1;
+  while (in < rl_end)
+#else
   for (in = 0; in < rl_end; in++)
+#endif
     {
       c = (unsigned char)rl_line_buffer[in];
 
+#if defined (HANDLE_MULTIBYTE)
+      if (MB_CUR_MAX > 1 && rl_byte_oriented == 0)
+	{
+	  if (wc_bytes == (size_t)-1 || wc_bytes == (size_t)-2)
+	    {
+	      /* Byte sequence is invalid or shortened.  Assume that the
+	         first byte represents a character. */
+	      wc_bytes = 1;
+	      /* Assume that a character occupies a single column. */
+	      wc_width = 1;
+	      memset (&ps, 0, sizeof (mbstate_t));
+	    }
+	  else if (wc_bytes == (size_t)0)
+	    break;			/* Found '\0' */
+	  else
+	    {
+	      temp = wcwidth (wc);
+	      wc_width = (temp < 0) ? 1 : temp;
+	    }
+	}
+#endif
+
       if (out + 8 >= line_size)		/* XXX - 8 for \t */
 	{
 	  line_size *= 2;
-	  visible_line = xrealloc (visible_line, line_size);
-	  invisible_line = xrealloc (invisible_line, line_size);
+	  visible_line = (char *)xrealloc (visible_line, line_size);
+	  invisible_line = (char *)xrealloc (invisible_line, line_size);
 	  line = invisible_line;
 	}
 
@@ -468,15 +619,20 @@ rl_redisplay ()
 	  lb_linenum = newlines;
 	}
 
+#if defined (HANDLE_MULTIBYTE)
+      if (META_CHAR (c) && _rl_output_meta_chars == 0)	/* XXX - clean up */
+#else
       if (META_CHAR (c))
+#endif
 	{
 	  if (_rl_output_meta_chars == 0)
 	    {
 	      sprintf (line + out, "\\%o", c);
 
-	      if (lpos + 4 >= screenwidth)
+	      if (lpos + 4 >= _rl_screenwidth)
 		{
-		  temp = screenwidth - lpos;
+		  temp = _rl_screenwidth - lpos;
+		  CHECK_INV_LBREAKS ();
 		  inv_lbreaks[++newlines] = out + temp;
 		  lpos = 4 - temp;
 		}
@@ -494,7 +650,7 @@ rl_redisplay ()
 #if defined (DISPLAY_TABS)
       else if (c == '\t')
 	{
-	  register int temp, newout;
+	  register int newout;
 
 #if 0
 	  newout = (out | (int)7) + 1;
@@ -502,10 +658,11 @@ rl_redisplay ()
 	  newout = out + 8 - lpos % 8;
 #endif
 	  temp = newout - out;
-	  if (lpos + temp >= screenwidth)
+	  if (lpos + temp >= _rl_screenwidth)
 	    {
 	      register int temp2;
-	      temp2 = screenwidth - lpos;
+	      temp2 = _rl_screenwidth - lpos;
+	      CHECK_INV_LBREAKS ();
 	      inv_lbreaks[++newlines] = out + temp2;
 	      lpos = temp - temp2;
 	      while (out < newout)
@@ -519,9 +676,10 @@ rl_redisplay ()
 	    }
 	}
 #endif
-      else if (c == '\n' && _rl_horizontal_scroll_mode == 0 && term_up && *term_up)
+      else if (c == '\n' && _rl_horizontal_scroll_mode == 0 && _rl_term_up && *_rl_term_up)
 	{
 	  line[out++] = '\0';	/* XXX - sentinel */
+	  CHECK_INV_LBREAKS ();
 	  inv_lbreaks[++newlines] = out;
 	  lpos = 0;
 	}
@@ -534,9 +692,52 @@ rl_redisplay ()
 	}
       else
 	{
+#if defined (HANDLE_MULTIBYTE)
+	  if (MB_CUR_MAX > 1 && rl_byte_oriented == 0)
+	    {
+	      register int i;
+
+	      _rl_wrapped_multicolumn = 0;
+
+	      if (_rl_screenwidth < lpos + wc_width)
+		for (i = lpos; i < _rl_screenwidth; i++)
+		  {
+		    /* The space will be removed in update_line() */
+		    line[out++] = ' ';
+		    _rl_wrapped_multicolumn++;
+		    CHECK_LPOS();
+		  }
+	      if (in == rl_point)
+		{
+		  c_pos = out;
+		  lb_linenum = newlines;
+		}
+	      for (i = in; i < in+wc_bytes; i++)
+		line[out++] = rl_line_buffer[i];
+	      for (i = 0; i < wc_width; i++)
+		CHECK_LPOS();
+	    }
+	  else
+	    {
+	      line[out++] = c;
+	      CHECK_LPOS();
+	    }
+#else
 	  line[out++] = c;
 	  CHECK_LPOS();
+#endif
 	}
+
+#if defined (HANDLE_MULTIBYTE)
+      if (MB_CUR_MAX > 1 && rl_byte_oriented == 0)
+	{
+	  in += wc_bytes;
+	  wc_bytes = mbrtowc (&wc, rl_line_buffer + in, rl_end - in, &ps);
+	}
+      else
+        in++;
+#endif
+
     }
   line[out] = '\0';
   if (c_pos < 0)
@@ -546,10 +747,12 @@ rl_redisplay ()
     }
 
   inv_botlin = lb_botlin = newlines;
+  CHECK_INV_LBREAKS ();
   inv_lbreaks[newlines+1] = out;
   cursor_linenum = lb_linenum;
 
-  /* C_POS == position in buffer where cursor should be placed. */
+  /* C_POS == position in buffer where cursor should be placed.
+     CURSOR_LINENUM == line number where the cursor should be placed. */
 
   /* PWP: now is when things get a bit hairy.  The visible and invisible
      line buffers are really multiple lines, which would wrap every
@@ -560,7 +763,7 @@ rl_redisplay ()
      otherwise, let long lines display in a single terminal line, and
      horizontally scroll it. */
 
-  if (_rl_horizontal_scroll_mode == 0 && term_up && *term_up)
+  if (_rl_horizontal_scroll_mode == 0 && _rl_term_up && *_rl_term_up)
     {
       int nleft, pos, changed_screen_line;
 
@@ -571,8 +774,13 @@ rl_redisplay ()
 	  /* If we have more than a screenful of material to display, then
 	     only display a screenful.  We should display the last screen,
 	     not the first.  */
-	  if (out >= screenchars)
-	    out = screenchars - 1;
+	  if (out >= _rl_screenchars)
+	    {
+	      if (MB_CUR_MAX > 1 && rl_byte_oriented == 0)
+		out = _rl_find_prev_mbchar (line, _rl_screenchars, MB_FIND_ANY);
+	      else
+		out = _rl_screenchars - 1;
+	    }
 
 	  /* The first line is at character position 0 in the buffer.  The
 	     second and subsequent lines start at inv_lbreaks[N], offset by
@@ -582,7 +790,7 @@ rl_redisplay ()
 #define VIS_LLEN(l)	((l) > _rl_vis_botlin ? 0 : (vis_lbreaks[l+1] - vis_lbreaks[l]))
 #define INV_LLEN(l)	(inv_lbreaks[l+1] - inv_lbreaks[l])
 #define VIS_CHARS(line) (visible_line + vis_lbreaks[line])
-#define VIS_LINE(line) ((line) > _rl_vis_botlin) ? "" : VIS_CHARS(line)
+#define VIS_LINE(line) ((line) > _rl_vis_botlin) ? (char*)"" : VIS_CHARS(line)
 #define INV_LINE(line) (invisible_line + inv_lbreaks[line])
 
 	  /* For each line in the buffer, do the updating display. */
@@ -602,7 +810,7 @@ rl_redisplay ()
 		  (wrap_offset > visible_wrap_offset) &&
 		  (_rl_last_c_pos < visible_first_line_len))
 		{
-		  nleft = screenwidth + wrap_offset - _rl_last_c_pos;
+		  nleft = _rl_screenwidth + wrap_offset - _rl_last_c_pos;
 		  if (nleft)
 		    _rl_clear_to_eol (nleft);
 		}
@@ -623,7 +831,7 @@ rl_redisplay ()
 		  _rl_move_vert (linenum);
 		  _rl_move_cursor_relative (0, tt);
 		  _rl_clear_to_eol
-		    ((linenum == _rl_vis_botlin) ? (int) strlen (tt) : screenwidth);
+		    ((linenum == _rl_vis_botlin) ? (int)strlen (tt) : _rl_screenwidth);
 		}
 	    }
 	  _rl_vis_botlin = inv_botlin;
@@ -634,7 +842,7 @@ rl_redisplay ()
 	  if (changed_screen_line)
 	    {
 	      _rl_move_vert (cursor_linenum);
-	      /* If we moved up to the line with the prompt using term_up,
+	      /* If we moved up to the line with the prompt using _rl_term_up,
 		 the physical cursor position on the screen stays the same,
 		 but the buffer position needs to be adjusted to account
 		 for invisible characters. */
@@ -647,14 +855,21 @@ rl_redisplay ()
 	     the characters from the current cursor position.  But we
 	     only need to reprint it if the cursor is before the last
 	     invisible character in the prompt string. */
-	  nleft = visible_length + wrap_offset;
+	  nleft = prompt_visible_length + wrap_offset;
 	  if (cursor_linenum == 0 && wrap_offset > 0 && _rl_last_c_pos > 0 &&
-	      _rl_last_c_pos <= last_invisible && local_prompt)
+	      _rl_last_c_pos <= prompt_last_invisible && local_prompt)
 	    {
-	      if (term_cr)
-		tputs (term_cr, 1, _rl_output_character_function);
+#if defined (__MSDOS__)
+	      putc ('\r', rl_outstream);
+#else
+	      if (_rl_term_cr)
+		tputs (_rl_term_cr, 1, _rl_output_character_function);
+#endif
 	      _rl_output_some_chars (local_prompt, nleft);
-	      _rl_last_c_pos = nleft;
+	      if (MB_CUR_MAX > 1 && rl_byte_oriented == 0)
+		_rl_last_c_pos = _rl_col_width(local_prompt, 0, nleft);
+	      else
+		_rl_last_c_pos = nleft;
 	    }
 
 	  /* Where on that line?  And where does that line start
@@ -670,10 +885,15 @@ rl_redisplay ()
 	  if (wrap_offset && cursor_linenum == 0 && nleft < _rl_last_c_pos)
 	    {
 	      _rl_backspace (_rl_last_c_pos - nleft);
-	      _rl_last_c_pos = nleft;
+	      if (MB_CUR_MAX > 1 && rl_byte_oriented == 0)
+		_rl_last_c_pos = _rl_col_width (&visible_line[pos], 0, nleft);
+	      else
+		_rl_last_c_pos = nleft;
 	    }
 
-	  if (nleft != _rl_last_c_pos)
+	  if (MB_CUR_MAX > 1 && rl_byte_oriented == 0)
+	    _rl_move_cursor_relative (nleft, &invisible_line[pos]);
+	  else if (nleft != _rl_last_c_pos)
 	    _rl_move_cursor_relative (nleft, &invisible_line[pos]);
 	}
     }
@@ -690,11 +910,11 @@ rl_redisplay ()
 
       /* The number of characters that will be displayed before the cursor. */
       ndisp = c_pos - wrap_offset;
-      nleft  = visible_length + wrap_offset;
+      nleft  = prompt_visible_length + wrap_offset;
       /* Where the new cursor position will be on the screen.  This can be
 	 longer than SCREENWIDTH; if it is, lmargin will be adjusted. */
       phys_c_pos = c_pos - (last_lmargin ? last_lmargin : wrap_offset);
-      t = screenwidth / 3;
+      t = _rl_screenwidth / 3;
 
       /* If the number of characters had already exceeded the screenwidth,
 	 last_lmargin will be > 0. */
@@ -702,7 +922,7 @@ rl_redisplay ()
       /* If the number of characters to be displayed is more than the screen
 	 width, compute the starting offset so that the cursor is about
 	 two-thirds of the way across the screen. */
-      if (phys_c_pos > screenwidth - 2)
+      if (phys_c_pos > _rl_screenwidth - 2)
 	{
 	  lmargin = c_pos - (2 * t);
 	  if (lmargin < 0)
@@ -712,7 +932,7 @@ rl_redisplay ()
 	  if (wrap_offset && lmargin > 0 && lmargin < nleft)
 	    lmargin = nleft;
 	}
-      else if (ndisp < screenwidth - 2)		/* XXX - was -1 */
+      else if (ndisp < _rl_screenwidth - 2)		/* XXX - was -1 */
 	lmargin = 0;
       else if (phys_c_pos < 1)
 	{
@@ -734,7 +954,7 @@ rl_redisplay ()
 	 the whole line, indicate that with a special character at the
 	 right edge of the screen.  If LMARGIN is 0, we need to take the
 	 wrap offset into account. */
-      t = lmargin + M_OFFSET (lmargin, wrap_offset) + screenwidth;
+      t = lmargin + M_OFFSET (lmargin, wrap_offset) + _rl_screenwidth;
       if (t < out)
 	line[t - 1] = '>';
 
@@ -744,8 +964,8 @@ rl_redisplay ()
 	  update_line (&visible_line[last_lmargin],
 		       &invisible_line[lmargin],
 		       0,
-		       screenwidth + visible_wrap_offset,
-		       screenwidth + (lmargin ? 0 : wrap_offset),
+		       _rl_screenwidth + visible_wrap_offset,
+		       _rl_screenwidth + (lmargin ? 0 : wrap_offset),
 		       0);
 
 	  /* If the visible new line is shorter than the old, but the number
@@ -756,12 +976,12 @@ rl_redisplay ()
 	      (_rl_last_c_pos == out) &&
 	      t < visible_first_line_len)
 	    {
-	      nleft = screenwidth - t;
+	      nleft = _rl_screenwidth - t;
 	      _rl_clear_to_eol (nleft);
 	    }
 	  visible_first_line_len = out - lmargin - M_OFFSET (lmargin, wrap_offset);
-	  if (visible_first_line_len > screenwidth)
-	    visible_first_line_len = screenwidth;
+	  if (visible_first_line_len > _rl_screenwidth)
+	    visible_first_line_len = _rl_screenwidth;
 
 	  _rl_move_cursor_relative (c_pos - lmargin, &invisible_line[lmargin]);
 	  last_lmargin = lmargin;
@@ -771,12 +991,18 @@ rl_redisplay ()
 
   /* Swap visible and non-visible lines. */
   {
-    char *temp = visible_line;
-    int *itemp = vis_lbreaks;
+    char *vtemp = visible_line;
+    int *itemp = vis_lbreaks, ntemp = vis_lbsize;
+
     visible_line = invisible_line;
-    invisible_line = temp;
+    invisible_line = vtemp;
+
     vis_lbreaks = inv_lbreaks;
     inv_lbreaks = itemp;
+
+    vis_lbsize = inv_lbsize;
+    inv_lbsize = ntemp;
+
     rl_display_fixed = 0;
     /* If we are displaying on a single line, and last_lmargin is > 0, we
        are not displaying any invisible characters, so set visible_wrap_offset
@@ -812,6 +1038,11 @@ update_line (old, new, current_line, omax, nmax, inv_botlin)
   register char *ofd, *ols, *oe, *nfd, *nls, *ne;
   int temp, lendiff, wsatend, od, nd;
   int current_invis_chars;
+  int col_lendiff, col_temp;
+#if defined (HANDLE_MULTIBYTE)
+  mbstate_t ps_new, ps_old;
+  int new_offset, old_offset, tmp;
+#endif
 
   /* If we're at the right edge of a terminal that supports xn, we're
      ready to wrap around, so do so.  This fixes problems with knowing
@@ -819,20 +1050,98 @@ update_line (old, new, current_line, omax, nmax, inv_botlin)
      emulators.  In this calculation, TEMP is the physical screen
      position of the cursor. */
   temp = _rl_last_c_pos - W_OFFSET(_rl_last_v_pos, visible_wrap_offset);
-  if (temp == screenwidth && _rl_term_autowrap && !_rl_horizontal_scroll_mode
-      && _rl_last_v_pos == current_line - 1)
+  if (temp == _rl_screenwidth && _rl_term_autowrap && !_rl_horizontal_scroll_mode
+	&& _rl_last_v_pos == current_line - 1)
     {
-      if (new[0])
-	putc (new[0], rl_outstream);
+#if defined (HANDLE_MULTIBYTE)
+      if (MB_CUR_MAX > 1 && rl_byte_oriented == 0)
+	{
+	  wchar_t wc;
+	  mbstate_t ps;
+	  int tempwidth, bytes;
+	  size_t ret;
+
+	  /* This fixes only double-column characters, but if the wrapped
+	     character comsumes more than three columns, spaces will be
+	     inserted in the string buffer. */
+	  if (_rl_wrapped_line[current_line] > 0)
+	    _rl_clear_to_eol (_rl_wrapped_line[current_line]);
+
+	  memset (&ps, 0, sizeof (mbstate_t));
+	  ret = mbrtowc (&wc, new, MB_CUR_MAX, &ps);
+	  if (ret == (size_t)-1 || ret == (size_t)-2)
+	    {
+	      tempwidth = 1;
+	      ret = 1;
+	    }
+	  else if (ret == 0)
+	    tempwidth = 0;
+	  else
+	    tempwidth = wcwidth (wc);
+
+	  if (tempwidth > 0)
+	    {
+	      int count;
+	      bytes = ret;
+	      for (count = 0; count < bytes; count++)
+		putc (new[count], rl_outstream);
+	      _rl_last_c_pos = tempwidth;
+	      _rl_last_v_pos++;
+	      memset (&ps, 0, sizeof (mbstate_t));
+	      ret = mbrtowc (&wc, old, MB_CUR_MAX, &ps);
+	      if (ret != 0 && bytes != 0)
+		{
+		  if (ret == (size_t)-1 || ret == (size_t)-2)
+		    memmove (old+bytes, old+1, strlen (old+1));
+		  else
+		    memmove (old+bytes, old+ret, strlen (old+ret));
+		  memcpy (old, new, bytes);
+		}
+	    }
+	  else
+	    {
+	      putc (' ', rl_outstream);
+	      _rl_last_c_pos = 1;
+	      _rl_last_v_pos++;
+	      if (old[0] && new[0])
+		old[0] = new[0];
+	    }
+	}
       else
-	putc (' ', rl_outstream);
-      _rl_last_c_pos = 1;		/* XXX */
-      _rl_last_v_pos++;
-      if (old[0] && new[0])
-	old[0] = new[0];
+#endif
+	{
+	  if (new[0])
+	    putc (new[0], rl_outstream);
+	  else
+	    putc (' ', rl_outstream);
+	  _rl_last_c_pos = 1;		/* XXX */
+	  _rl_last_v_pos++;
+	  if (old[0] && new[0])
+	    old[0] = new[0];
+	}
     }
 
+      
   /* Find first difference. */
+#if defined (HANDLE_MULTIBYTE)
+  if (MB_CUR_MAX > 1 && rl_byte_oriented == 0)
+    {
+      memset (&ps_new, 0, sizeof(mbstate_t));
+      memset (&ps_old, 0, sizeof(mbstate_t));
+
+      new_offset = old_offset = 0;
+      for (ofd = old, nfd = new;
+	   (ofd - old < omax) && *ofd &&
+	     _rl_compare_chars(old, old_offset, &ps_old, new, new_offset, &ps_new); )
+	{
+	  old_offset = _rl_find_next_mbchar (old, old_offset, 1, MB_FIND_ANY);
+	  new_offset = _rl_find_next_mbchar (new, new_offset, 1, MB_FIND_ANY);
+	  ofd = old + old_offset;
+	  nfd = new + new_offset;
+	}
+    }
+  else
+#endif
   for (ofd = old, nfd = new;
        (ofd - old < omax) && *ofd && (*ofd == *nfd);
        ofd++, nfd++)
@@ -849,6 +1158,33 @@ update_line (old, new, current_line, omax, nmax, inv_botlin)
     return;
 
   wsatend = 1;			/* flag for trailing whitespace */
+
+#if defined (HANDLE_MULTIBYTE)
+  if (MB_CUR_MAX > 1 && rl_byte_oriented == 0)
+    {
+      ols = old + _rl_find_prev_mbchar (old, oe - old, MB_FIND_ANY);
+      nls = new + _rl_find_prev_mbchar (new, ne - new, MB_FIND_ANY);
+      while ((ols > ofd) && (nls > nfd))
+	{
+	  memset (&ps_old, 0, sizeof (mbstate_t));
+	  memset (&ps_new, 0, sizeof (mbstate_t));
+
+	  _rl_adjust_point (old, ols - old, &ps_old);
+	  _rl_adjust_point (new, nls - new, &ps_new);
+
+	  if (_rl_compare_chars (old, ols - old, &ps_old, new, nls - new, &ps_new) == 0)
+	    break;
+
+	  if (*ols == ' ')
+	    wsatend = 0;
+
+	  ols = old + _rl_find_prev_mbchar (old, ols - old, MB_FIND_ANY);
+	  nls = new + _rl_find_prev_mbchar (new, nls - new, MB_FIND_ANY);
+	}
+    }
+  else
+    {
+#endif /* HANDLE_MULTIBYTE */
   ols = oe - 1;			/* find last same */
   nls = ne - 1;
   while ((ols > ofd) && (nls > nfd) && (*ols == *nls))
@@ -858,18 +1194,38 @@ update_line (old, new, current_line, omax, nmax, inv_botlin)
       ols--;
       nls--;
     }
+#if defined (HANDLE_MULTIBYTE)
+    }
+#endif
 
   if (wsatend)
     {
       ols = oe;
       nls = ne;
     }
+#if defined (HANDLE_MULTIBYTE)
+  /* This may not work for stateful encoding, but who cares?  To handle
+     stateful encoding properly, we have to scan each string from the
+     beginning and compare. */
+  else if (_rl_compare_chars (ols, 0, NULL, nls, 0, NULL) == 0)
+#else
   else if (*ols != *nls)
+#endif
     {
       if (*ols)			/* don't step past the NUL */
-	ols++;
+	{
+	  if (MB_CUR_MAX > 1 && rl_byte_oriented == 0)
+	    ols = old + _rl_find_next_mbchar (old, ols - old, 1, MB_FIND_ANY);
+	  else
+	    ols++;
+	}
       if (*nls)
-	nls++;
+	{
+	  if (MB_CUR_MAX > 1 && rl_byte_oriented == 0)
+	    nls = new + _rl_find_next_mbchar (new, nls - new, 1, MB_FIND_ANY);
+	  else
+	    nls++;
+	}
     }
 
   /* count of invisible characters in the current invisible line. */
@@ -896,29 +1252,59 @@ update_line (old, new, current_line, omax, nmax, inv_botlin)
   lendiff = local_prompt ? strlen (local_prompt) : 0;
   od = ofd - old;	/* index of first difference in visible line */
   if (current_line == 0 && !_rl_horizontal_scroll_mode &&
-      term_cr && lendiff > visible_length && _rl_last_c_pos > 0 &&
-      od > lendiff && _rl_last_c_pos < last_invisible)
+      _rl_term_cr && lendiff > prompt_visible_length && _rl_last_c_pos > 0 &&
+      od >= lendiff && _rl_last_c_pos <= prompt_last_invisible)
     {
-      tputs (term_cr, 1, _rl_output_character_function);
+#if defined (__MSDOS__)
+      putc ('\r', rl_outstream);
+#else
+      tputs (_rl_term_cr, 1, _rl_output_character_function);
+#endif
       _rl_output_some_chars (local_prompt, lendiff);
-      _rl_last_c_pos = lendiff;
+      if (MB_CUR_MAX > 1 && rl_byte_oriented == 0)
+	_rl_last_c_pos = _rl_col_width (local_prompt, 0, lendiff);
+      else
+	_rl_last_c_pos = lendiff;
     }
 
   _rl_move_cursor_relative (od, old);
 
-  /* if (len (new) > len (old)) */
+  /* if (len (new) > len (old))
+     lendiff == difference in buffer
+     col_lendiff == difference on screen
+     When not using multibyte characters, these are equal */
   lendiff = (nls - nfd) - (ols - ofd);
+  if (MB_CUR_MAX > 1 && rl_byte_oriented == 0)
+    col_lendiff = _rl_col_width (new, nfd - new, nls - new) - _rl_col_width (old, ofd - old, ols - old);
+  else
+    col_lendiff = lendiff;
 
   /* If we are changing the number of invisible characters in a line, and
      the spot of first difference is before the end of the invisible chars,
      lendiff needs to be adjusted. */
   if (current_line == 0 && !_rl_horizontal_scroll_mode &&
       current_invis_chars != visible_wrap_offset)
-    lendiff += visible_wrap_offset - current_invis_chars;
+    {
+      if (MB_CUR_MAX > 1 && rl_byte_oriented == 0)
+	{
+	  lendiff += visible_wrap_offset - current_invis_chars;
+	  col_lendiff += visible_wrap_offset - current_invis_chars;
+	}
+      else
+	{
+	  lendiff += visible_wrap_offset - current_invis_chars;
+	  col_lendiff = lendiff;
+	}
+    }
 
   /* Insert (diff (len (old), len (new)) ch. */
   temp = ne - nfd;
-  if (lendiff > 0)
+  if (MB_CUR_MAX > 1 && rl_byte_oriented == 0)
+    col_temp = _rl_col_width (new, nfd - new, ne - new);
+  else
+    col_temp = temp;
+
+  if (col_lendiff > 0)	/* XXX - was lendiff */
     {
       /* Non-zero if we're increasing the number of lines. */
       int gl = current_line >= _rl_vis_botlin && inv_botlin > _rl_vis_botlin;
@@ -926,17 +1312,17 @@ update_line (old, new, current_line, omax, nmax, inv_botlin)
 	 use the terminal's capabilities.  If we're growing the number
 	 of lines, make sure we actually cause the new line to wrap
 	 around on auto-wrapping terminals. */
-      if (terminal_can_insert && ((2 * temp) >= lendiff || term_IC) && (!_rl_term_autowrap || !gl))
+      if (_rl_terminal_can_insert && ((2 * col_temp) >= col_lendiff || _rl_term_IC) && (!_rl_term_autowrap || !gl))
 	{
-	  /* If lendiff > visible_length and _rl_last_c_pos == 0 and
+	  /* If lendiff > prompt_visible_length and _rl_last_c_pos == 0 and
 	     _rl_horizontal_scroll_mode == 1, inserting the characters with
-	     term_IC or term_ic will screw up the screen because of the
+	     _rl_term_IC or _rl_term_ic will screw up the screen because of the
 	     invisible characters.  We need to just draw them. */
 	  if (*ols && (!_rl_horizontal_scroll_mode || _rl_last_c_pos > 0 ||
-			lendiff <= visible_length || !current_invis_chars))
+			lendiff <= prompt_visible_length || !current_invis_chars))
 	    {
-	      insert_some_chars (nfd, lendiff);
-	      _rl_last_c_pos += lendiff;
+	      insert_some_chars (nfd, lendiff, col_lendiff);
+	      _rl_last_c_pos += col_lendiff;
 	    }
 	  else if (*ols == 0)
 	    {
@@ -945,7 +1331,7 @@ update_line (old, new, current_line, omax, nmax, inv_botlin)
 	      /* However, this screws up the rest of this block, which
 		 assumes you've done the insert because you can. */
 	      _rl_output_some_chars (nfd, lendiff);
-	      _rl_last_c_pos += lendiff;
+	      _rl_last_c_pos += col_lendiff;
 	    }
 	  else
 	    {
@@ -953,7 +1339,7 @@ update_line (old, new, current_line, omax, nmax, inv_botlin)
 		 the end.  We have invisible characters in this line.  This
 		 is a dumb update. */
 	      _rl_output_some_chars (nfd, temp);
-	      _rl_last_c_pos += temp;
+	      _rl_last_c_pos += col_temp;
 	      return;
 	    }
 	  /* Copy (new) chars to screen from first diff to last match. */
@@ -961,37 +1347,41 @@ update_line (old, new, current_line, omax, nmax, inv_botlin)
 	  if ((temp - lendiff) > 0)
 	    {
 	      _rl_output_some_chars (nfd + lendiff, temp - lendiff);
-	      _rl_last_c_pos += temp - lendiff;
+#if 0
+	      _rl_last_c_pos += _rl_col_width (nfd+lendiff, 0, temp-lendiff) - col_lendiff;
+#else
+	      _rl_last_c_pos += _rl_col_width (nfd+lendiff, 0, temp-col_lendiff);
+#endif
 	    }
 	}
       else
 	{
 	  /* cannot insert chars, write to EOL */
 	  _rl_output_some_chars (nfd, temp);
-	  _rl_last_c_pos += temp;
+	  _rl_last_c_pos += col_temp;
 	}
     }
   else				/* Delete characters from line. */
     {
       /* If possible and inexpensive to use terminal deletion, then do so. */
-      if (term_dc && (2 * temp) >= -lendiff)
+      if (_rl_term_dc && (2 * col_temp) >= -col_lendiff)
 	{
 	  /* If all we're doing is erasing the invisible characters in the
 	     prompt string, don't bother.  It screws up the assumptions
 	     about what's on the screen. */
 	  if (_rl_horizontal_scroll_mode && _rl_last_c_pos == 0 &&
 	      -lendiff == visible_wrap_offset)
-	    lendiff = 0;
+	    col_lendiff = 0;
 
-	  if (lendiff)
-	    delete_chars (-lendiff); /* delete (diff) characters */
+	  if (col_lendiff)
+	    delete_chars (-col_lendiff); /* delete (diff) characters */
 
 	  /* Copy (new) chars to screen from first diff to last match */
 	  temp = nls - nfd;
 	  if (temp > 0)
 	    {
 	      _rl_output_some_chars (nfd, temp);
-	      _rl_last_c_pos += temp;
+	      _rl_last_c_pos += _rl_col_width (nfd, 0, temp);;
 	    }
 	}
       /* Otherwise, print over the existing material. */
@@ -1000,15 +1390,20 @@ update_line (old, new, current_line, omax, nmax, inv_botlin)
 	  if (temp > 0)
 	    {
 	      _rl_output_some_chars (nfd, temp);
-	      _rl_last_c_pos += temp;
+	      _rl_last_c_pos += col_temp;
 	    }
 	  lendiff = (oe - old) - (ne - new);
-	  if (lendiff)
+	  if (MB_CUR_MAX > 1 && rl_byte_oriented == 0)
+	    col_lendiff = _rl_col_width (old, 0, oe - old) - _rl_col_width (new, 0, ne - new);
+	  else
+	    col_lendiff = lendiff;
+
+	  if (col_lendiff)
 	    {	  
 	      if (_rl_term_autowrap && current_line < inv_botlin)
-		space_to_eol (lendiff);
+		space_to_eol (col_lendiff);
 	      else
-		_rl_clear_to_eol (lendiff);
+		_rl_clear_to_eol (col_lendiff);
 	    }
 	}
     }
@@ -1029,6 +1424,61 @@ rl_on_new_line ()
   return 0;
 }
 
+/* Tell the update routines that we have moved onto a new line with the
+   prompt already displayed.  Code originally from the version of readline
+   distributed with CLISP. */
+int
+rl_on_new_line_with_prompt ()
+{
+  int prompt_size, i, l, real_screenwidth, newlines;
+  char *prompt_last_line;
+
+  /* Initialize visible_line and invisible_line to ensure that they can hold
+     the already-displayed prompt. */
+  prompt_size = strlen (rl_prompt) + 1;
+  init_line_structures (prompt_size);
+
+  /* Make sure the line structures hold the already-displayed prompt for
+     redisplay. */
+  strcpy (visible_line, rl_prompt);
+  strcpy (invisible_line, rl_prompt);
+
+  /* If the prompt contains newlines, take the last tail. */
+  prompt_last_line = strrchr (rl_prompt, '\n');
+  if (!prompt_last_line)
+    prompt_last_line = rl_prompt;
+
+  l = strlen (prompt_last_line);
+  if (MB_CUR_MAX > 1 && rl_byte_oriented == 0)
+    _rl_last_c_pos = _rl_col_width (prompt_last_line, 0, l);
+  else
+    _rl_last_c_pos = l;
+
+  /* Dissect prompt_last_line into screen lines. Note that here we have
+     to use the real screenwidth. Readline's notion of screenwidth might be
+     one less, see terminal.c. */
+  real_screenwidth = _rl_screenwidth + (_rl_term_autowrap ? 0 : 1);
+  _rl_last_v_pos = l / real_screenwidth;
+  /* If the prompt length is a multiple of real_screenwidth, we don't know
+     whether the cursor is at the end of the last line, or already at the
+     beginning of the next line. Output a newline just to be safe. */
+  if (l > 0 && (l % real_screenwidth) == 0)
+    _rl_output_some_chars ("\n", 1);
+  last_lmargin = 0;
+
+  newlines = 0; i = 0;
+  while (i <= l)
+    {
+      _rl_vis_botlin = newlines;
+      vis_lbreaks[newlines++] = i;
+      i += real_screenwidth;
+    }
+  vis_lbreaks[newlines] = l;
+  visible_wrap_offset = 0;
+
+  return 0;
+}
+
 /* Actually update the display, period. */
 int
 rl_forced_update_display ()
@@ -1052,24 +1502,31 @@ rl_forced_update_display ()
 void
 _rl_move_cursor_relative (new, data)
      int new;
-     char *data;
+     const char *data;
 {
   register int i;
 
   /* If we don't have to do anything, then return. */
+#if defined (HANDLE_MULTIBYTE)
+  /* If we have multibyte characters, NEW is indexed by the buffer point in
+     a multibyte string, but _rl_last_c_pos is the display position.  In
+     this case, NEW's display position is not obvious. */
+  if ((MB_CUR_MAX == 1 || rl_byte_oriented ) && _rl_last_c_pos == new) return;
+#else
   if (_rl_last_c_pos == new) return;
+#endif
 
   /* It may be faster to output a CR, and then move forwards instead
      of moving backwards. */
   /* i == current physical cursor position. */
   i = _rl_last_c_pos - W_OFFSET(_rl_last_v_pos, visible_wrap_offset);
   if (new == 0 || CR_FASTER (new, _rl_last_c_pos) ||
-      (_rl_term_autowrap && i == screenwidth))
+      (_rl_term_autowrap && i == _rl_screenwidth))
     {
 #if defined (__MSDOS__)
       putc ('\r', rl_outstream);
 #else
-      tputs (term_cr, 1, _rl_output_character_function);
+      tputs (_rl_term_cr, 1, _rl_output_character_function);
 #endif /* !__MSDOS__ */
       _rl_last_c_pos = 0;
     }
@@ -1086,22 +1543,70 @@ _rl_move_cursor_relative (new, data)
 	 That kind of control is for people who don't know what the
 	 data is underneath the cursor. */
 #if defined (HACK_TERMCAP_MOTION)
-      extern char *term_forward_char;
-
-      if (term_forward_char)
+      if (_rl_term_forward_char)
+	{
+	  if (MB_CUR_MAX > 1 && rl_byte_oriented == 0)
+	    {
+	      int width;
+	      width = _rl_col_width (data, _rl_last_c_pos, new);
+	      for (i = 0; i < width; i++)
+		tputs (_rl_term_forward_char, 1, _rl_output_character_function);
+	    }
+	  else
+	    {
+	      for (i = _rl_last_c_pos; i < new; i++)
+		tputs (_rl_term_forward_char, 1, _rl_output_character_function);
+	    }
+	}
+      else if (MB_CUR_MAX > 1 && rl_byte_oriented == 0)
+	{
+	  tputs (_rl_term_cr, 1, _rl_output_character_function);
+	  for (i = 0; i < new; i++)
+	    putc (data[i], rl_outstream);
+	}
+      else
 	for (i = _rl_last_c_pos; i < new; i++)
-	  tputs (term_forward_char, 1, _rl_output_character_function);
+	  putc (data[i], rl_outstream);
+
+#else /* !HACK_TERMCAP_MOTION */
+
+      if (MB_CUR_MAX > 1 && rl_byte_oriented == 0)
+	{
+	  tputs (_rl_term_cr, 1, _rl_output_character_function);
+	  for (i = 0; i < new; i++)
+	    putc (data[i], rl_outstream);
+	}
       else
 	for (i = _rl_last_c_pos; i < new; i++)
 	  putc (data[i], rl_outstream);
-#else
-      for (i = _rl_last_c_pos; i < new; i++)
-	putc (data[i], rl_outstream);
-#endif /* HACK_TERMCAP_MOTION */
+
+#endif /* !HACK_TERMCAP_MOTION */
+
     }
+#if defined (HANDLE_MULTIBYTE)
+  /* NEW points to the buffer point, but _rl_last_c_pos is the display point.
+     The byte length of the string is probably bigger than the column width
+     of the string, which means that if NEW == _rl_last_c_pos, then NEW's
+     display point is less than _rl_last_c_pos. */
+  else if (_rl_last_c_pos >= new)
+#else
   else if (_rl_last_c_pos > new)
-    _rl_backspace (_rl_last_c_pos - new);
-  _rl_last_c_pos = new;
+#endif
+    {
+      if (MB_CUR_MAX > 1 && rl_byte_oriented == 0)
+	{
+	  tputs (_rl_term_cr, 1, _rl_output_character_function);
+	  for (i = 0; i < new; i++)
+	    putc (data[i], rl_outstream);
+	}
+      else
+	_rl_backspace (_rl_last_c_pos - new);
+    }
+
+  if (MB_CUR_MAX > 1 && rl_byte_oriented == 0)
+    _rl_last_c_pos =  _rl_col_width (data, 0, new);
+  else
+    _rl_last_c_pos = new;
 }
 
 /* PWP: move the cursor up or down. */
@@ -1111,32 +1616,27 @@ _rl_move_vert (to)
 {
   register int delta, i;
 
-  if (_rl_last_v_pos == to || to > screenheight)
+  if (_rl_last_v_pos == to || to > _rl_screenheight)
     return;
 
-#if defined (__GO32__)
-  {
-    int row, col;
-
-    ScreenGetCursor (&row, &col);
-    ScreenSetCursor ((row + to - _rl_last_v_pos), col);
-  }
-#else /* !__GO32__ */
-
   if ((delta = to - _rl_last_v_pos) > 0)
     {
       for (i = 0; i < delta; i++)
 	putc ('\n', rl_outstream);
-      tputs (term_cr, 1, _rl_output_character_function);
+#if defined (__MSDOS__)
+      putc ('\r', rl_outstream);
+#else
+      tputs (_rl_term_cr, 1, _rl_output_character_function);
+#endif
       _rl_last_c_pos = 0;
     }
   else
     {			/* delta < 0 */
-      if (term_up && *term_up)
+      if (_rl_term_up && *_rl_term_up)
 	for (i = 0; i < -delta; i++)
-	  tputs (term_up, 1, _rl_output_character_function);
+	  tputs (_rl_term_up, 1, _rl_output_character_function);
     }
-#endif /* !__GO32__ */
+
   _rl_last_v_pos = to;		/* Now TO is here */
 }
 
@@ -1193,7 +1693,7 @@ rl_character_len (c, pos)
   if (CTRL_CHAR (c) || c == RUBOUT)
     return (2);
 
-  return ((isprint (uc)) ? 1 : 2);
+  return ((ISPRINT (uc)) ? 1 : 2);
 }
 
 /* How to print things in the "echo-area".  The prompt is treated as a
@@ -1220,7 +1720,12 @@ rl_message (va_alist)
   format = va_arg (args, char *);
 #endif
 
+#if defined (HAVE_VSNPRINTF)
+  vsnprintf (msg_buf, sizeof (msg_buf) - 1, format, args);
+#else
   vsprintf (msg_buf, format, args);
+  msg_buf[sizeof(msg_buf) - 1] = '\0';	/* overflow? */
+#endif
   va_end (args);
 
   rl_display_prompt = msg_buf;
@@ -1229,9 +1734,12 @@ rl_message (va_alist)
 }
 #else /* !USE_VARARGS */
 int
-rl_message (char *format, void *arg1, void *arg2)
+rl_message (format, arg1, arg2)
+     char *format;
+     int arg1, arg2;
 {
   sprintf (msg_buf, format, arg1, arg2);
+  msg_buf[sizeof(msg_buf) - 1] = '\0';	/* overflow? */
   rl_display_prompt = msg_buf;
   (*rl_redisplay_function) ();
   return 0;
@@ -1267,25 +1775,23 @@ rl_save_prompt ()
 {
   saved_local_prompt = local_prompt;
   saved_local_prefix = local_prompt_prefix;
-  saved_last_invisible = last_invisible;
-  saved_visible_length = visible_length;
+  saved_last_invisible = prompt_last_invisible;
+  saved_visible_length = prompt_visible_length;
 
   local_prompt = local_prompt_prefix = (char *)0;
-  last_invisible = visible_length = 0;
+  prompt_last_invisible = prompt_visible_length = 0;
 }
 
 void
 rl_restore_prompt ()
 {
-  if (local_prompt)
-    free (local_prompt);
-  if (local_prompt_prefix)
-    free (local_prompt_prefix);
+  FREE (local_prompt);
+  FREE (local_prompt_prefix);
 
   local_prompt = saved_local_prompt;
   local_prompt_prefix = saved_local_prefix;
-  last_invisible = saved_last_invisible;
-  visible_length = saved_visible_length;
+  prompt_last_invisible = saved_last_invisible;
+  prompt_visible_length = saved_visible_length;
 }
 
 char *
@@ -1300,7 +1806,7 @@ _rl_make_prompt_for_search (pchar)
   if (saved_local_prompt == 0)
     {
       len = (rl_prompt && *rl_prompt) ? strlen (rl_prompt) : 0;
-      pmt = xmalloc (len + 2);
+      pmt = (char *)xmalloc (len + 2);
       if (len)
 	strcpy (pmt, rl_prompt);
       pmt[len] = pchar;
@@ -1309,14 +1815,14 @@ _rl_make_prompt_for_search (pchar)
   else
     {
       len = *saved_local_prompt ? strlen (saved_local_prompt) : 0;
-      pmt = xmalloc (len + 2);
+      pmt = (char *)xmalloc (len + 2);
       if (len)
 	strcpy (pmt, saved_local_prompt);
       pmt[len] = pchar;
       pmt[len+1] = '\0';
       local_prompt = savestring (pmt);
-      last_invisible = saved_last_invisible;
-      visible_length = saved_visible_length + 1;
+      prompt_last_invisible = saved_last_invisible;
+      prompt_visible_length = saved_visible_length + 1;
     }
   return pmt;
 }
@@ -1343,11 +1849,9 @@ void
 _rl_clear_to_eol (count)
      int count;
 {
-#if !defined (__GO32__)
-  if (term_clreol)
-    tputs (term_clreol, 1, _rl_output_character_function);
+  if (_rl_term_clreol)
+    tputs (_rl_term_clreol, 1, _rl_output_character_function);
   else if (count)
-#endif /* !__GO32__ */
     space_to_eol (count);
 }
 
@@ -1368,39 +1872,29 @@ space_to_eol (count)
 void
 _rl_clear_screen ()
 {
-#if !defined (__GO32__)
-  if (term_clrpag)
-    tputs (term_clrpag, 1, _rl_output_character_function);
+  if (_rl_term_clrpag)
+    tputs (_rl_term_clrpag, 1, _rl_output_character_function);
   else
-#endif /* !__GO32__ */
-    crlf ();
+    rl_crlf ();
 }
 
-/* Insert COUNT characters from STRING to the output stream. */
+/* Insert COUNT characters from STRING to the output stream at column COL. */
 static void
-insert_some_chars (string, count)
+insert_some_chars (string, count, col)
      char *string;
-     int count;
+     int count, col;
 {
-#if defined (__GO32__)
-  int row, col, width;
-  char *row_start;
-
-  ScreenGetCursor (&row, &col);
-  width = ScreenCols ();
-  row_start = ScreenPrimary + (row * width);
-
-  memcpy (row_start + col + count, row_start + col, width - col - count);
-
-  /* Place the text on the screen. */
-  _rl_output_some_chars (string, count);
-#else /* !_GO32 */
+  /* DEBUGGING */
+  if (MB_CUR_MAX == 1 || rl_byte_oriented)
+    if (count != col)
+      fprintf(stderr, "readline: debug: insert_some_chars: count (%d) != col (%d)\n", count, col);
 
   /* If IC is defined, then we do not have to "enter" insert mode. */
-  if (term_IC)
+  if (_rl_term_IC)
     {
       char *buffer;
-      buffer = tgoto (term_IC, 0, count);
+
+      buffer = tgoto (_rl_term_IC, 0, col);
       tputs (buffer, 1, _rl_output_character_function);
       _rl_output_some_chars (string, count);
     }
@@ -1409,15 +1903,15 @@ insert_some_chars (string, count)
       register int i;
 
       /* If we have to turn on insert-mode, then do so. */
-      if (term_im && *term_im)
-	tputs (term_im, 1, _rl_output_character_function);
+      if (_rl_term_im && *_rl_term_im)
+	tputs (_rl_term_im, 1, _rl_output_character_function);
 
       /* If there is a special command for inserting characters, then
 	 use that first to open up the space. */
-      if (term_ic && *term_ic)
+      if (_rl_term_ic && *_rl_term_ic)
 	{
-	  for (i = count; i--; )
-	    tputs (term_ic, 1, _rl_output_character_function);
+	  for (i = col; i--; )
+	    tputs (_rl_term_ic, 1, _rl_output_character_function);
 	}
 
       /* Print the text. */
@@ -1425,10 +1919,9 @@ insert_some_chars (string, count)
 
       /* If there is a string to turn off insert mode, we had best use
 	 it now. */
-      if (term_ei && *term_ei)
-	tputs (term_ei, 1, _rl_output_character_function);
+      if (_rl_term_ei && *_rl_term_ei)
+	tputs (_rl_term_ei, 1, _rl_output_character_function);
     }
-#endif /* !__GO32__ */
 }
 
 /* Delete COUNT characters from the display line. */
@@ -1436,34 +1929,21 @@ static void
 delete_chars (count)
      int count;
 {
-#if defined (__GO32__)
-  int row, col, width;
-  char *row_start;
-
-  ScreenGetCursor (&row, &col);
-  width = ScreenCols ();
-  row_start = ScreenPrimary + (row * width);
-
-  memcpy (row_start + col, row_start + col + count, width - col - count);
-  memset (row_start + width - count, 0, count * 2);
-#else /* !_GO32 */
-
-  if (count > screenwidth)	/* XXX */
+  if (count > _rl_screenwidth)	/* XXX */
     return;
 
-  if (term_DC && *term_DC)
+  if (_rl_term_DC && *_rl_term_DC)
     {
       char *buffer;
-      buffer = tgoto (term_DC, count, count);
+      buffer = tgoto (_rl_term_DC, count, count);
       tputs (buffer, count, _rl_output_character_function);
     }
   else
     {
-      if (term_dc && *term_dc)
+      if (_rl_term_dc && *_rl_term_dc)
 	while (count--)
-	  tputs (term_dc, 1, _rl_output_character_function);
+	  tputs (_rl_term_dc, 1, _rl_output_character_function);
     }
-#endif /* !__GO32__ */
 }
 
 void
@@ -1482,16 +1962,17 @@ _rl_update_final ()
     }
   _rl_move_vert (_rl_vis_botlin);
   /* If we've wrapped lines, remove the final xterm line-wrap flag. */
-  if (full_lines && _rl_term_autowrap && (VIS_LLEN(_rl_vis_botlin) == screenwidth))
+  if (full_lines && _rl_term_autowrap && (VIS_LLEN(_rl_vis_botlin) == _rl_screenwidth))
     {
       char *last_line;
-      last_line = &visible_line[inv_lbreaks[_rl_vis_botlin]];
-      _rl_move_cursor_relative (screenwidth - 1, last_line);
+
+      last_line = &visible_line[vis_lbreaks[_rl_vis_botlin]];
+      _rl_move_cursor_relative (_rl_screenwidth - 1, last_line);
       _rl_clear_to_eol (0);
-      putc (last_line[screenwidth - 1], rl_outstream);
+      putc (last_line[_rl_screenwidth - 1], rl_outstream);
     }
   _rl_vis_botlin = 0;
-  crlf ();
+  rl_crlf ();
   fflush (rl_outstream);
   rl_display_fixed++;
 }
@@ -1500,53 +1981,91 @@ _rl_update_final ()
 static void
 cr ()
 {
-  if (term_cr)
+  if (_rl_term_cr)
     {
-      tputs (term_cr, 1, _rl_output_character_function);
+#if defined (__MSDOS__)
+      putc ('\r', rl_outstream);
+#else
+      tputs (_rl_term_cr, 1, _rl_output_character_function);
+#endif
       _rl_last_c_pos = 0;
     }
 }
 
+/* Redraw the last line of a multi-line prompt that may possibly contain
+   terminal escape sequences.  Called with the cursor at column 0 of the
+   line to draw the prompt on. */
+static void
+redraw_prompt (t)
+     char *t;
+{
+  const char *oldp;
+  char *oldl, *oldlprefix;
+  int oldlen, oldlast, oldplen, oldninvis;
+
+  /* Geez, I should make this a struct. */
+  oldp = rl_display_prompt;
+  oldl = local_prompt;
+  oldlprefix = local_prompt_prefix;
+  oldlen = prompt_visible_length;
+  oldplen = prompt_prefix_length;
+  oldlast = prompt_last_invisible;
+  oldninvis = prompt_invis_chars_first_line;
+
+  rl_display_prompt = t;
+  local_prompt = expand_prompt (t, &prompt_visible_length,
+				   &prompt_last_invisible,
+				   &prompt_invis_chars_first_line);
+  local_prompt_prefix = (char *)NULL;
+  rl_forced_update_display ();
+
+  rl_display_prompt = oldp;
+  local_prompt = oldl;
+  local_prompt_prefix = oldlprefix;
+  prompt_visible_length = oldlen;
+  prompt_prefix_length = oldplen;
+  prompt_last_invisible = oldlast;
+  prompt_invis_chars_first_line = oldninvis;
+}
+      
 /* Redisplay the current line after a SIGWINCH is received. */
 void
 _rl_redisplay_after_sigwinch ()
 {
-  char *t, *oldl, *oldlprefix;
-  const char *oldp;
+  char *t;
 
   /* Clear the current line and put the cursor at column 0.  Make sure
      the right thing happens if we have wrapped to a new screen line. */
-  if (term_cr)
+  if (_rl_term_cr)
     {
-      tputs (term_cr, 1, _rl_output_character_function);
+#if defined (__MSDOS__)
+      putc ('\r', rl_outstream);
+#else
+      tputs (_rl_term_cr, 1, _rl_output_character_function);
+#endif
       _rl_last_c_pos = 0;
-      if (term_clreol)
-	tputs (term_clreol, 1, _rl_output_character_function);
+#if defined (__MSDOS__)
+      space_to_eol (_rl_screenwidth);
+      putc ('\r', rl_outstream);
+#else
+      if (_rl_term_clreol)
+	tputs (_rl_term_clreol, 1, _rl_output_character_function);
       else
 	{
-	  space_to_eol (screenwidth);
-	  tputs (term_cr, 1, _rl_output_character_function);
+	  space_to_eol (_rl_screenwidth);
+	  tputs (_rl_term_cr, 1, _rl_output_character_function);
 	}
+#endif
       if (_rl_last_v_pos > 0)
 	_rl_move_vert (0);
     }
   else
-    crlf ();
+    rl_crlf ();
 
   /* Redraw only the last line of a multi-line prompt. */
   t = strrchr (rl_display_prompt, '\n');
   if (t)
-    {
-      oldp = rl_display_prompt;
-      oldl = local_prompt;
-      oldlprefix = local_prompt_prefix;
-      rl_display_prompt = ++t;
-      local_prompt = local_prompt_prefix = (char *)NULL;
-      rl_forced_update_display ();
-      rl_display_prompt = oldp;
-      local_prompt = oldl;
-      local_prompt_prefix = oldlprefix;
-    }
+    redraw_prompt (++t);
   else
     rl_forced_update_display ();
 }
@@ -1571,3 +2090,109 @@ _rl_erase_entire_line ()
   cr ();
   fflush (rl_outstream);
 }
+
+/* return the `current display line' of the cursor -- the number of lines to
+   move up to get to the first screen line of the current readline line. */
+int
+_rl_current_display_line ()
+{
+  int ret, nleft;
+
+  /* Find out whether or not there might be invisible characters in the
+     editing buffer. */
+  if (rl_display_prompt == rl_prompt)
+    nleft = _rl_last_c_pos - _rl_screenwidth - rl_visible_prompt_length;
+  else
+    nleft = _rl_last_c_pos - _rl_screenwidth;
+
+  if (nleft > 0)
+    ret = 1 + nleft / _rl_screenwidth;
+  else
+    ret = 0;
+
+  return ret;
+}
+
+#if defined (HANDLE_MULTIBYTE)
+/* Calculate the number of screen columns occupied by STR from START to END.
+   In the case of multibyte characters with stateful encoding, we have to
+   scan from the beginning of the string to take the state into account. */
+static int
+_rl_col_width (str, start, end)
+     const char *str;
+     int start, end;
+{
+  wchar_t wc;
+  mbstate_t ps = {0};
+  int tmp, point, width, max;
+
+  if (end <= start)
+    return 0;
+
+  point = 0;
+  max = end;
+
+  while (point < start)
+    {
+      tmp = mbrlen (str + point, max, &ps);
+      if ((size_t)tmp == (size_t)-1 || (size_t)tmp == (size_t)-2)
+	{
+	  /* In this case, the bytes are invalid or too short to compose a
+	     multibyte character, so we assume that the first byte represents
+	     a single character. */
+	  point++;
+	  max--;
+
+	  /* Clear the state of the byte sequence, because in this case the
+	     effect of mbstate is undefined. */
+	  memset (&ps, 0, sizeof (mbstate_t));
+	}
+      else if (tmp == 0)
+        break;		/* Found '\0' */
+      else
+	{
+	  point += tmp;
+	  max -= tmp;
+	}
+    }
+
+  /* If START is not a byte that starts a character, then POINT will be
+     greater than START.  In this case, assume that (POINT - START) gives
+     a byte count that is the number of columns of difference. */
+  width = point - start;
+
+  while (point < end)
+    {
+      tmp = mbrtowc (&wc, str + point, max, &ps);
+      if ((size_t)tmp == (size_t)-1 || (size_t)tmp == (size_t)-2)
+	{
+	  /* In this case, the bytes are invalid or too short to compose a
+	     multibyte character, so we assume that the first byte represents
+	     a single character. */
+	  point++;
+	  max--;
+
+	  /* and assume that the byte occupies a single column. */
+	  width++;
+
+	  /* Clear the state of the byte sequence, because in this case the
+	     effect of mbstate is undefined. */
+	  memset (&ps, 0, sizeof (mbstate_t));
+	}
+      else if (tmp == 0)
+        break;			/* Found '\0' */
+      else
+	{
+	  point += tmp;
+	  max -= tmp;
+	  tmp = wcwidth(wc);
+	  width += (tmp >= 0) ? tmp : 1;
+	}
+    }
+
+  width += point - end;
+
+  return width;
+}
+#endif /* HANDLE_MULTIBYTE */
+	  
diff --git a/readline/emacs_keymap.c b/readline/emacs_keymap.c
index 4ba385843f613f25053ed2043434738741e65128..ca9d1343b655ca2eae3a04d6bc99c87e1be69854 100644
--- a/readline/emacs_keymap.c
+++ b/readline/emacs_keymap.c
@@ -7,7 +7,7 @@
 
    The GNU Readline Library is free software; you can redistribute it
    and/or modify it under the terms of the GNU General Public License
-   as published by the Free Software Foundation; either version 1, or
+   as published by the Free Software Foundation; either version 2, or
    (at your option) any later version.
 
    The GNU Readline Library is distributed in the hope that it will be
@@ -18,7 +18,7 @@
    The GNU General Public License is often shipped with GNU software, and
    is generally kept in a file called COPYING or LICENSE.  If you do not
    have a copy of the license, write to the Free Software Foundation,
-   675 Mass Ave, Cambridge, MA 02139, USA. */
+   59 Temple Place, Suite 330, Boston, MA 02111 USA. */
 
 #if !defined (BUFSIZ)
 #include <stdio.h>
@@ -33,197 +33,185 @@
 KEYMAP_ENTRY_ARRAY emacs_standard_keymap = {
 
   /* Control keys. */
-  { ISFUNC, rl_set_mark },		/* Control-@ */
-  { ISFUNC, rl_beg_of_line },		/* Control-a */
-  { ISFUNC, rl_backward },		/* Control-b */
-  { ISFUNC, (Function *)0x0 },		/* Control-c */
-  { ISFUNC, rl_delete },		/* Control-d */
-  { ISFUNC, rl_end_of_line },		/* Control-e */
-  { ISFUNC, rl_forward },		/* Control-f */
-  { ISFUNC, rl_abort },			/* Control-g */
-  { ISFUNC, rl_rubout },		/* Control-h */
-  { ISFUNC, rl_complete },		/* Control-i */
-  { ISFUNC, rl_newline },		/* Control-j */
-  { ISFUNC, rl_kill_line },		/* Control-k */
-  { ISFUNC, rl_clear_screen },		/* Control-l */
-  { ISFUNC, rl_newline },		/* Control-m */
-  { ISFUNC, rl_get_next_history },	/* Control-n */
-  { ISFUNC, (Function *)0x0 },		/* Control-o */
-  { ISFUNC, rl_get_previous_history },	/* Control-p */
-  { ISFUNC, rl_quoted_insert },		/* Control-q */
-  { ISFUNC, rl_reverse_search_history }, /* Control-r */
-  { ISFUNC, rl_forward_search_history }, /* Control-s */
-  { ISFUNC, rl_transpose_chars },	/* Control-t */
-  { ISFUNC, rl_unix_line_discard },	/* Control-u */
-  { ISFUNC, rl_quoted_insert },		/* Control-v */
-  { ISFUNC, rl_unix_word_rubout },	/* Control-w */
-  { ISKMAP, (Function *)emacs_ctlx_keymap },	/* Control-x */
-  { ISFUNC, rl_yank },			/* Control-y */
-  { ISFUNC, (Function *)0x0 },		/* Control-z */
-  { ISKMAP, (Function *)emacs_meta_keymap }, /* Control-[ */
-  { ISFUNC, (Function *)0x0 },		/* Control-\ */
-  { ISFUNC, rl_char_search },		/* Control-] */
-  { ISFUNC, (Function *)0x0 },		/* Control-^ */
-  { ISFUNC, rl_undo_command },		/* Control-_ */
+  { ISFUNC, rl_set_mark },			/* Control-@ */
+  { ISFUNC, rl_beg_of_line },			/* Control-a */
+  { ISFUNC, rl_backward_char },			/* Control-b */
+  { ISFUNC, (rl_command_func_t *)0x0 },		/* Control-c */
+  { ISFUNC, rl_delete },			/* Control-d */
+  { ISFUNC, rl_end_of_line },			/* Control-e */
+  { ISFUNC, rl_forward_char },			/* Control-f */
+  { ISFUNC, rl_abort },				/* Control-g */
+  { ISFUNC, rl_rubout },			/* Control-h */
+  { ISFUNC, rl_complete },			/* Control-i */
+  { ISFUNC, rl_newline },			/* Control-j */
+  { ISFUNC, rl_kill_line },			/* Control-k */
+  { ISFUNC, rl_clear_screen },			/* Control-l */
+  { ISFUNC, rl_newline },			/* Control-m */
+  { ISFUNC, rl_get_next_history },		/* Control-n */
+  { ISFUNC, (rl_command_func_t *)0x0 },		/* Control-o */
+  { ISFUNC, rl_get_previous_history },		/* Control-p */
+  { ISFUNC, rl_quoted_insert },			/* Control-q */
+  { ISFUNC, rl_reverse_search_history },	/* Control-r */
+  { ISFUNC, rl_forward_search_history },	/* Control-s */
+  { ISFUNC, rl_transpose_chars },		/* Control-t */
+  { ISFUNC, rl_unix_line_discard },		/* Control-u */
+  { ISFUNC, rl_quoted_insert },			/* Control-v */
+  { ISFUNC, rl_unix_word_rubout },		/* Control-w */
+  { ISKMAP, (rl_command_func_t *)emacs_ctlx_keymap },	/* Control-x */
+  { ISFUNC, rl_yank },				/* Control-y */
+  { ISFUNC, (rl_command_func_t *)0x0 },		/* Control-z */
+  { ISKMAP, (rl_command_func_t *)emacs_meta_keymap }, /* Control-[ */
+  { ISFUNC, (rl_command_func_t *)0x0 },		/* Control-\ */
+  { ISFUNC, rl_char_search },			/* Control-] */
+  { ISFUNC, (rl_command_func_t *)0x0 },		/* Control-^ */
+  { ISFUNC, rl_undo_command },			/* Control-_ */
 
   /* The start of printing characters. */
-  { ISFUNC, rl_insert },	/* SPACE */
-  { ISFUNC, rl_insert },	/* ! */
-  { ISFUNC, rl_insert },	/* " */
-  { ISFUNC, rl_insert },	/* # */
-  { ISFUNC, rl_insert },	/* $ */
-  { ISFUNC, rl_insert },	/* % */
-  { ISFUNC, rl_insert },	/* & */
-  { ISFUNC, rl_insert },	/* ' */
-  { ISFUNC, rl_insert },	/* ( */
-#if defined (PAREN_MATCHING)
-  { ISFUNC, rl_insert_close },	/* ) */
-#else
-  { ISFUNC, rl_insert },	/* ) */
-#endif /* !PAREN_MATCHING */
-  { ISFUNC, rl_insert },	/* * */
-  { ISFUNC, rl_insert },	/* + */
-  { ISFUNC, rl_insert },	/* , */
-  { ISFUNC, rl_insert },	/* - */
-  { ISFUNC, rl_insert },	/* . */
-  { ISFUNC, rl_insert },	/* / */
-
-  /* Regular digits. */
-  { ISFUNC, rl_insert },	/* 0 */
-  { ISFUNC, rl_insert },	/* 1 */
-  { ISFUNC, rl_insert },	/* 2 */
-  { ISFUNC, rl_insert },	/* 3 */
-  { ISFUNC, rl_insert },	/* 4 */
-  { ISFUNC, rl_insert },	/* 5 */
-  { ISFUNC, rl_insert },	/* 6 */
-  { ISFUNC, rl_insert },	/* 7 */
-  { ISFUNC, rl_insert },	/* 8 */
-  { ISFUNC, rl_insert },	/* 9 */
+  { ISFUNC, rl_insert },		/* SPACE */
+  { ISFUNC, rl_insert },		/* ! */
+  { ISFUNC, rl_insert },		/* " */
+  { ISFUNC, rl_insert },		/* # */
+  { ISFUNC, rl_insert },		/* $ */
+  { ISFUNC, rl_insert },		/* % */
+  { ISFUNC, rl_insert },		/* & */
+  { ISFUNC, rl_insert },		/* ' */
+  { ISFUNC, rl_insert },		/* ( */
+  { ISFUNC, rl_insert },		/* ) */
+  { ISFUNC, rl_insert },		/* * */
+  { ISFUNC, rl_insert },		/* + */
+  { ISFUNC, rl_insert },		/* , */
+  { ISFUNC, rl_insert },		/* - */
+  { ISFUNC, rl_insert },		/* . */
+  { ISFUNC, rl_insert },		/* / */
+	
+	  /* Regular digits. */
+  { ISFUNC, rl_insert },		/* 0 */
+  { ISFUNC, rl_insert },		/* 1 */
+  { ISFUNC, rl_insert },		/* 2 */
+  { ISFUNC, rl_insert },		/* 3 */
+  { ISFUNC, rl_insert },		/* 4 */
+  { ISFUNC, rl_insert },		/* 5 */
+  { ISFUNC, rl_insert },		/* 6 */
+  { ISFUNC, rl_insert },		/* 7 */
+  { ISFUNC, rl_insert },		/* 8 */
+  { ISFUNC, rl_insert },		/* 9 */
 
   /* A little more punctuation. */
-  { ISFUNC, rl_insert },	/* : */
-  { ISFUNC, rl_insert },	/* ; */
-  { ISFUNC, rl_insert },	/* < */
-  { ISFUNC, rl_insert },	/* = */
-  { ISFUNC, rl_insert },	/* > */
-  { ISFUNC, rl_insert },	/* ? */
-  { ISFUNC, rl_insert },	/* @ */
+  { ISFUNC, rl_insert },		/* : */
+  { ISFUNC, rl_insert },		/* ; */
+  { ISFUNC, rl_insert },		/* < */
+  { ISFUNC, rl_insert },		/* = */
+  { ISFUNC, rl_insert },		/* > */
+  { ISFUNC, rl_insert },		/* ? */
+  { ISFUNC, rl_insert },		/* @ */
 
   /* Uppercase alphabet. */
-  { ISFUNC, rl_insert },	/* A */
-  { ISFUNC, rl_insert },	/* B */
-  { ISFUNC, rl_insert },	/* C */
-  { ISFUNC, rl_insert },	/* D */
-  { ISFUNC, rl_insert },	/* E */
-  { ISFUNC, rl_insert },	/* F */
-  { ISFUNC, rl_insert },	/* G */
-  { ISFUNC, rl_insert },	/* H */
-  { ISFUNC, rl_insert },	/* I */
-  { ISFUNC, rl_insert },	/* J */
-  { ISFUNC, rl_insert },	/* K */
-  { ISFUNC, rl_insert },	/* L */
-  { ISFUNC, rl_insert },	/* M */
-  { ISFUNC, rl_insert },	/* N */
-  { ISFUNC, rl_insert },	/* O */
-  { ISFUNC, rl_insert },	/* P */
-  { ISFUNC, rl_insert },	/* Q */
-  { ISFUNC, rl_insert },	/* R */
-  { ISFUNC, rl_insert },	/* S */
-  { ISFUNC, rl_insert },	/* T */
-  { ISFUNC, rl_insert },	/* U */
-  { ISFUNC, rl_insert },	/* V */
-  { ISFUNC, rl_insert },	/* W */
-  { ISFUNC, rl_insert },	/* X */
-  { ISFUNC, rl_insert },	/* Y */
-  { ISFUNC, rl_insert },	/* Z */
+  { ISFUNC, rl_insert },		/* A */
+  { ISFUNC, rl_insert },		/* B */
+  { ISFUNC, rl_insert },		/* C */
+  { ISFUNC, rl_insert },		/* D */
+  { ISFUNC, rl_insert },		/* E */
+  { ISFUNC, rl_insert },		/* F */
+  { ISFUNC, rl_insert },		/* G */
+  { ISFUNC, rl_insert },		/* H */
+  { ISFUNC, rl_insert },		/* I */
+  { ISFUNC, rl_insert },		/* J */
+  { ISFUNC, rl_insert },		/* K */
+  { ISFUNC, rl_insert },		/* L */
+  { ISFUNC, rl_insert },		/* M */
+  { ISFUNC, rl_insert },		/* N */
+  { ISFUNC, rl_insert },		/* O */
+  { ISFUNC, rl_insert },		/* P */
+  { ISFUNC, rl_insert },		/* Q */
+  { ISFUNC, rl_insert },		/* R */
+  { ISFUNC, rl_insert },		/* S */
+  { ISFUNC, rl_insert },		/* T */
+  { ISFUNC, rl_insert },		/* U */
+  { ISFUNC, rl_insert },		/* V */
+  { ISFUNC, rl_insert },		/* W */
+  { ISFUNC, rl_insert },		/* X */
+  { ISFUNC, rl_insert },		/* Y */
+  { ISFUNC, rl_insert },		/* Z */
 
   /* Some more punctuation. */
-  { ISFUNC, rl_insert },	/* [ */
-  { ISFUNC, rl_insert },	/* \ */
-#if defined (PAREN_MATCHING)
-  { ISFUNC, rl_insert_close },	/* ] */
-#else
-  { ISFUNC, rl_insert },	/* ] */
-#endif /* !PAREN_MATCHING */
-  { ISFUNC, rl_insert },	/* ^ */
-  { ISFUNC, rl_insert },	/* _ */
-  { ISFUNC, rl_insert },	/* ` */
+  { ISFUNC, rl_insert },		/* [ */
+  { ISFUNC, rl_insert },		/* \ */
+  { ISFUNC, rl_insert },		/* ] */
+  { ISFUNC, rl_insert },		/* ^ */
+  { ISFUNC, rl_insert },		/* _ */
+  { ISFUNC, rl_insert },		/* ` */
 
   /* Lowercase alphabet. */
-  { ISFUNC, rl_insert },	/* a */
-  { ISFUNC, rl_insert },	/* b */
-  { ISFUNC, rl_insert },	/* c */
-  { ISFUNC, rl_insert },	/* d */
-  { ISFUNC, rl_insert },	/* e */
-  { ISFUNC, rl_insert },	/* f */
-  { ISFUNC, rl_insert },	/* g */
-  { ISFUNC, rl_insert },	/* h */
-  { ISFUNC, rl_insert },	/* i */
-  { ISFUNC, rl_insert },	/* j */
-  { ISFUNC, rl_insert },	/* k */
-  { ISFUNC, rl_insert },	/* l */
-  { ISFUNC, rl_insert },	/* m */
-  { ISFUNC, rl_insert },	/* n */
-  { ISFUNC, rl_insert },	/* o */
-  { ISFUNC, rl_insert },	/* p */
-  { ISFUNC, rl_insert },	/* q */
-  { ISFUNC, rl_insert },	/* r */
-  { ISFUNC, rl_insert },	/* s */
-  { ISFUNC, rl_insert },	/* t */
-  { ISFUNC, rl_insert },	/* u */
-  { ISFUNC, rl_insert },	/* v */
-  { ISFUNC, rl_insert },	/* w */
-  { ISFUNC, rl_insert },	/* x */
-  { ISFUNC, rl_insert },	/* y */
-  { ISFUNC, rl_insert },	/* z */
+  { ISFUNC, rl_insert },		/* a */
+  { ISFUNC, rl_insert },		/* b */
+  { ISFUNC, rl_insert },		/* c */
+  { ISFUNC, rl_insert },		/* d */
+  { ISFUNC, rl_insert },		/* e */
+  { ISFUNC, rl_insert },		/* f */
+  { ISFUNC, rl_insert },		/* g */
+  { ISFUNC, rl_insert },		/* h */
+  { ISFUNC, rl_insert },		/* i */
+  { ISFUNC, rl_insert },		/* j */
+  { ISFUNC, rl_insert },		/* k */
+  { ISFUNC, rl_insert },		/* l */
+  { ISFUNC, rl_insert },		/* m */
+  { ISFUNC, rl_insert },		/* n */
+  { ISFUNC, rl_insert },		/* o */
+  { ISFUNC, rl_insert },		/* p */
+  { ISFUNC, rl_insert },		/* q */
+  { ISFUNC, rl_insert },		/* r */
+  { ISFUNC, rl_insert },		/* s */
+  { ISFUNC, rl_insert },		/* t */
+  { ISFUNC, rl_insert },		/* u */
+  { ISFUNC, rl_insert },		/* v */
+  { ISFUNC, rl_insert },		/* w */
+  { ISFUNC, rl_insert },		/* x */
+  { ISFUNC, rl_insert },		/* y */
+  { ISFUNC, rl_insert },		/* z */
 
   /* Final punctuation. */
-  { ISFUNC, rl_insert },	/* { */
-  { ISFUNC, rl_insert },	/* | */
-#if defined (PAREN_MATCHING)
-  { ISFUNC, rl_insert_close },	/* } */
-#else
-  { ISFUNC, rl_insert },	/* } */
-#endif /* !PAREN_MATCHING */
-  { ISFUNC, rl_insert },	/* ~ */
-  { ISFUNC, rl_rubout },	/* RUBOUT */
+  { ISFUNC, rl_insert },		/* { */
+  { ISFUNC, rl_insert },		/* | */
+  { ISFUNC, rl_insert },		/* } */
+  { ISFUNC, rl_insert },		/* ~ */
+  { ISFUNC, rl_rubout },		/* RUBOUT */
 
 #if KEYMAP_SIZE > 128
   /* Pure 8-bit characters (128 - 159).
      These might be used in some
      character sets. */
-  { ISFUNC, rl_insert },	/* ? */
-  { ISFUNC, rl_insert },	/* ? */
-  { ISFUNC, rl_insert },	/* ? */
-  { ISFUNC, rl_insert },	/* ? */
-  { ISFUNC, rl_insert },	/* ? */
-  { ISFUNC, rl_insert },	/* ? */
-  { ISFUNC, rl_insert },	/* ? */
-  { ISFUNC, rl_insert },	/* ? */
-  { ISFUNC, rl_insert },	/* ? */
-  { ISFUNC, rl_insert },	/* ? */
-  { ISFUNC, rl_insert },	/* ? */
-  { ISFUNC, rl_insert },	/* ? */
-  { ISFUNC, rl_insert },	/* ? */
-  { ISFUNC, rl_insert },	/* ? */
-  { ISFUNC, rl_insert },	/* ? */
-  { ISFUNC, rl_insert },	/* ? */
-  { ISFUNC, rl_insert },	/* ? */
-  { ISFUNC, rl_insert },	/* ? */
-  { ISFUNC, rl_insert },	/* ? */
-  { ISFUNC, rl_insert },	/* ? */
-  { ISFUNC, rl_insert },	/* ? */
-  { ISFUNC, rl_insert },	/* ? */
-  { ISFUNC, rl_insert },	/* ? */
-  { ISFUNC, rl_insert },	/* ? */
-  { ISFUNC, rl_insert },	/* ? */
-  { ISFUNC, rl_insert },	/* ? */
-  { ISFUNC, rl_insert },	/* ? */
-  { ISFUNC, rl_insert },	/* ? */
-  { ISFUNC, rl_insert },	/* ? */
-  { ISFUNC, rl_insert },	/* ? */
-  { ISFUNC, rl_insert },	/* ? */
-  { ISFUNC, rl_insert },	/* ? */
+  { ISFUNC, rl_insert },		/* ? */
+  { ISFUNC, rl_insert },		/* ? */
+  { ISFUNC, rl_insert },		/* ? */
+  { ISFUNC, rl_insert },		/* ? */
+  { ISFUNC, rl_insert },		/* ? */
+  { ISFUNC, rl_insert },		/* ? */
+  { ISFUNC, rl_insert },		/* ? */
+  { ISFUNC, rl_insert },		/* ? */
+  { ISFUNC, rl_insert },		/* ? */
+  { ISFUNC, rl_insert },		/* ? */
+  { ISFUNC, rl_insert },		/* ? */
+  { ISFUNC, rl_insert },		/* ? */
+  { ISFUNC, rl_insert },		/* ? */
+  { ISFUNC, rl_insert },		/* ? */
+  { ISFUNC, rl_insert },		/* ? */
+  { ISFUNC, rl_insert },		/* ? */
+  { ISFUNC, rl_insert },		/* ? */
+  { ISFUNC, rl_insert },		/* ? */
+  { ISFUNC, rl_insert },		/* ? */
+  { ISFUNC, rl_insert },		/* ? */
+  { ISFUNC, rl_insert },		/* ? */
+  { ISFUNC, rl_insert },		/* ? */
+  { ISFUNC, rl_insert },		/* ? */
+  { ISFUNC, rl_insert },		/* ? */
+  { ISFUNC, rl_insert },		/* ? */
+  { ISFUNC, rl_insert },		/* ? */
+  { ISFUNC, rl_insert },		/* ? */
+  { ISFUNC, rl_insert },		/* ? */
+  { ISFUNC, rl_insert },		/* ? */
+  { ISFUNC, rl_insert },		/* ? */
+  { ISFUNC, rl_insert },		/* ? */
+  { ISFUNC, rl_insert },		/* ? */
 
   /* ISO Latin-1 characters (160 - 255) */
   { ISFUNC, rl_insert },	/* No-break space */
@@ -328,78 +316,78 @@ KEYMAP_ENTRY_ARRAY emacs_standard_keymap = {
 KEYMAP_ENTRY_ARRAY emacs_meta_keymap = {
 
   /* Meta keys.  Just like above, but the high bit is set. */
-  { ISFUNC, (Function *)0x0 },	/* Meta-Control-@ */
-  { ISFUNC, (Function *)0x0 },	/* Meta-Control-a */
-  { ISFUNC, (Function *)0x0 },	/* Meta-Control-b */
-  { ISFUNC, (Function *)0x0 },	/* Meta-Control-c */
-  { ISFUNC, (Function *)0x0 },	/* Meta-Control-d */
-  { ISFUNC, (Function *)0x0 },	/* Meta-Control-e */
-  { ISFUNC, (Function *)0x0 },	/* Meta-Control-f */
-  { ISFUNC, rl_abort },		/* Meta-Control-g */
+  { ISFUNC, (rl_command_func_t *)0x0 },	/* Meta-Control-@ */
+  { ISFUNC, (rl_command_func_t *)0x0 },	/* Meta-Control-a */
+  { ISFUNC, (rl_command_func_t *)0x0 },	/* Meta-Control-b */
+  { ISFUNC, (rl_command_func_t *)0x0 },	/* Meta-Control-c */
+  { ISFUNC, (rl_command_func_t *)0x0 },	/* Meta-Control-d */
+  { ISFUNC, (rl_command_func_t *)0x0 },	/* Meta-Control-e */
+  { ISFUNC, (rl_command_func_t *)0x0 },	/* Meta-Control-f */
+  { ISFUNC, rl_abort },			/* Meta-Control-g */
   { ISFUNC, rl_backward_kill_word },	/* Meta-Control-h */
-  { ISFUNC, rl_tab_insert },	/* Meta-Control-i */
-  { ISFUNC, rl_vi_editing_mode }, /* Meta-Control-j */
-  { ISFUNC, (Function *)0x0 },	/* Meta-Control-k */
-  { ISFUNC, (Function *)0x0 },	/* Meta-Control-l */
-  { ISFUNC, rl_vi_editing_mode }, /* Meta-Control-m */
-  { ISFUNC, (Function *)0x0 },	/* Meta-Control-n */
-  { ISFUNC, (Function *)0x0 },	/* Meta-Control-o */
-  { ISFUNC, (Function *)0x0 },	/* Meta-Control-p */
-  { ISFUNC, (Function *)0x0 },	/* Meta-Control-q */
-  { ISFUNC, rl_revert_line },	/* Meta-Control-r */
-  { ISFUNC, (Function *)0x0 },	/* Meta-Control-s */
-  { ISFUNC, (Function *)0x0 },	/* Meta-Control-t */
-  { ISFUNC, (Function *)0x0 },	/* Meta-Control-u */
-  { ISFUNC, (Function *)0x0 },	/* Meta-Control-v */
-  { ISFUNC, (Function *)0x0 },	/* Meta-Control-w */
-  { ISFUNC, (Function *)0x0 },	/* Meta-Control-x */
-  { ISFUNC, rl_yank_nth_arg },	/* Meta-Control-y */
-  { ISFUNC, (Function *)0x0 },	/* Meta-Control-z */
-
-  { ISFUNC, rl_complete },	/* Meta-Control-[ */
-  { ISFUNC, (Function *)0x0 },	/* Meta-Control-\ */
+  { ISFUNC, rl_tab_insert },		/* Meta-Control-i */
+  { ISFUNC, rl_vi_editing_mode },	/* Meta-Control-j */
+  { ISFUNC, (rl_command_func_t *)0x0 },	/* Meta-Control-k */
+  { ISFUNC, (rl_command_func_t *)0x0 },	/* Meta-Control-l */
+  { ISFUNC, rl_vi_editing_mode }, 	/* Meta-Control-m */
+  { ISFUNC, (rl_command_func_t *)0x0 },	/* Meta-Control-n */
+  { ISFUNC, (rl_command_func_t *)0x0 },	/* Meta-Control-o */
+  { ISFUNC, (rl_command_func_t *)0x0 },	/* Meta-Control-p */
+  { ISFUNC, (rl_command_func_t *)0x0 },	/* Meta-Control-q */
+  { ISFUNC, rl_revert_line },		/* Meta-Control-r */
+  { ISFUNC, (rl_command_func_t *)0x0 },	/* Meta-Control-s */
+  { ISFUNC, (rl_command_func_t *)0x0 },	/* Meta-Control-t */
+  { ISFUNC, (rl_command_func_t *)0x0 },	/* Meta-Control-u */
+  { ISFUNC, (rl_command_func_t *)0x0 },	/* Meta-Control-v */
+  { ISFUNC, (rl_command_func_t *)0x0 },	/* Meta-Control-w */
+  { ISFUNC, (rl_command_func_t *)0x0 },	/* Meta-Control-x */
+  { ISFUNC, rl_yank_nth_arg },		/* Meta-Control-y */
+  { ISFUNC, (rl_command_func_t *)0x0 },	/* Meta-Control-z */
+
+  { ISFUNC, rl_complete },		/* Meta-Control-[ */
+  { ISFUNC, (rl_command_func_t *)0x0 },	/* Meta-Control-\ */
   { ISFUNC, rl_backward_char_search },	/* Meta-Control-] */
-  { ISFUNC, (Function *)0x0 },	/* Meta-Control-^ */
-  { ISFUNC, (Function *)0x0 },	/* Meta-Control-_ */
+  { ISFUNC, (rl_command_func_t *)0x0 },	/* Meta-Control-^ */
+  { ISFUNC, (rl_command_func_t *)0x0 },	/* Meta-Control-_ */
 
   /* The start of printing characters. */
-  { ISFUNC, rl_set_mark },	/* Meta-SPACE */
-  { ISFUNC, (Function *)0x0 },	/* Meta-! */
-  { ISFUNC, (Function *)0x0 },	/* Meta-" */
-  { ISFUNC, rl_insert_comment },/* Meta-# */
-  { ISFUNC, (Function *)0x0 },	/* Meta-$ */
-  { ISFUNC, (Function *)0x0 },	/* Meta-% */
-  { ISFUNC, rl_tilde_expand },	/* Meta-& */
-  { ISFUNC, (Function *)0x0 },	/* Meta-' */
-  { ISFUNC, (Function *)0x0 },	/* Meta-( */
-  { ISFUNC, (Function *)0x0 },	/* Meta-) */
+  { ISFUNC, rl_set_mark },		/* Meta-SPACE */
+  { ISFUNC, (rl_command_func_t *)0x0 },	/* Meta-! */
+  { ISFUNC, (rl_command_func_t *)0x0 },	/* Meta-" */
+  { ISFUNC, rl_insert_comment },	/* Meta-# */
+  { ISFUNC, (rl_command_func_t *)0x0 },	/* Meta-$ */
+  { ISFUNC, (rl_command_func_t *)0x0 },	/* Meta-% */
+  { ISFUNC, rl_tilde_expand },		/* Meta-& */
+  { ISFUNC, (rl_command_func_t *)0x0 },	/* Meta-' */
+  { ISFUNC, (rl_command_func_t *)0x0 },	/* Meta-( */
+  { ISFUNC, (rl_command_func_t *)0x0 },	/* Meta-) */
   { ISFUNC, rl_insert_completions },	/* Meta-* */
-  { ISFUNC, (Function *)0x0 },	/* Meta-+ */
-  { ISFUNC, (Function *)0x0 },	/* Meta-, */
-  { ISFUNC, rl_digit_argument }, /* Meta-- */
-  { ISFUNC, rl_yank_last_arg},	/* Meta-. */
-  { ISFUNC, (Function *)0x0 },	/* Meta-/ */
+  { ISFUNC, (rl_command_func_t *)0x0 },	/* Meta-+ */
+  { ISFUNC, (rl_command_func_t *)0x0 },	/* Meta-, */
+  { ISFUNC, rl_digit_argument }, 	/* Meta-- */
+  { ISFUNC, rl_yank_last_arg},		/* Meta-. */
+  { ISFUNC, (rl_command_func_t *)0x0 },	/* Meta-/ */
 
   /* Regular digits. */
-  { ISFUNC, rl_digit_argument }, /* Meta-0 */
-  { ISFUNC, rl_digit_argument }, /* Meta-1 */
-  { ISFUNC, rl_digit_argument }, /* Meta-2 */
-  { ISFUNC, rl_digit_argument }, /* Meta-3 */
-  { ISFUNC, rl_digit_argument }, /* Meta-4 */
-  { ISFUNC, rl_digit_argument }, /* Meta-5 */
-  { ISFUNC, rl_digit_argument }, /* Meta-6 */
-  { ISFUNC, rl_digit_argument }, /* Meta-7 */
-  { ISFUNC, rl_digit_argument }, /* Meta-8 */
-  { ISFUNC, rl_digit_argument }, /* Meta-9 */
+  { ISFUNC, rl_digit_argument }, 	/* Meta-0 */
+  { ISFUNC, rl_digit_argument }, 	/* Meta-1 */
+  { ISFUNC, rl_digit_argument }, 	/* Meta-2 */
+  { ISFUNC, rl_digit_argument }, 	/* Meta-3 */
+  { ISFUNC, rl_digit_argument }, 	/* Meta-4 */
+  { ISFUNC, rl_digit_argument }, 	/* Meta-5 */
+  { ISFUNC, rl_digit_argument }, 	/* Meta-6 */
+  { ISFUNC, rl_digit_argument }, 	/* Meta-7 */
+  { ISFUNC, rl_digit_argument }, 	/* Meta-8 */
+  { ISFUNC, rl_digit_argument }, 	/* Meta-9 */
 
   /* A little more punctuation. */
-  { ISFUNC, (Function *)0x0 },		/* Meta-: */
-  { ISFUNC, (Function *)0x0 },		/* Meta-; */
+  { ISFUNC, (rl_command_func_t *)0x0 },	/* Meta-: */
+  { ISFUNC, (rl_command_func_t *)0x0 },	/* Meta-; */
   { ISFUNC, rl_beginning_of_history },	/* Meta-< */
   { ISFUNC, rl_possible_completions },	/* Meta-= */
   { ISFUNC, rl_end_of_history },	/* Meta-> */
   { ISFUNC, rl_possible_completions },	/* Meta-? */
-  { ISFUNC, (Function *)0x0 },		/* Meta-@ */
+  { ISFUNC, (rl_command_func_t *)0x0 },	/* Meta-@ */
 
   /* Uppercase alphabet. */
   { ISFUNC, rl_do_lowercase_version },	/* Meta-A */
@@ -430,456 +418,456 @@ KEYMAP_ENTRY_ARRAY emacs_meta_keymap = {
   { ISFUNC, rl_do_lowercase_version },	/* Meta-Z */
 
   /* Some more punctuation. */
-  { ISFUNC, (Function *)0x0 },		/* Meta-[ */	/* was rl_arrow_keys */
+  { ISFUNC, (rl_command_func_t *)0x0 },		/* Meta-[ */	/* was rl_arrow_keys */
   { ISFUNC, rl_delete_horizontal_space },	/* Meta-\ */
-  { ISFUNC, (Function *)0x0 },		/* Meta-] */
-  { ISFUNC, (Function *)0x0 },		/* Meta-^ */
-  { ISFUNC, rl_yank_last_arg },		/* Meta-_ */
-  { ISFUNC, (Function *)0x0 },		/* Meta-` */
+  { ISFUNC, (rl_command_func_t *)0x0 },		/* Meta-] */
+  { ISFUNC, (rl_command_func_t *)0x0 },		/* Meta-^ */
+  { ISFUNC, rl_yank_last_arg },			/* Meta-_ */
+  { ISFUNC, (rl_command_func_t *)0x0 },		/* Meta-` */
 
   /* Lowercase alphabet. */
-  { ISFUNC, (Function *)0x0 },	/* Meta-a */
-  { ISFUNC, rl_backward_word },	/* Meta-b */
-  { ISFUNC, rl_capitalize_word }, /* Meta-c */
-  { ISFUNC, rl_kill_word },	/* Meta-d */
-  { ISFUNC, (Function *)0x0 },	/* Meta-e */
-  { ISFUNC, rl_forward_word },	/* Meta-f */
-  { ISFUNC, (Function *)0x0 },	/* Meta-g */
-  { ISFUNC, (Function *)0x0 },	/* Meta-h */
-  { ISFUNC, (Function *)0x0 },	/* Meta-i */
-  { ISFUNC, (Function *)0x0 },	/* Meta-j */
-  { ISFUNC, (Function *)0x0 },	/* Meta-k */
-  { ISFUNC, rl_downcase_word },	/* Meta-l */
-  { ISFUNC, (Function *)0x0 },	/* Meta-m */
+  { ISFUNC, (rl_command_func_t *)0x0 },	/* Meta-a */
+  { ISFUNC, rl_backward_word },		/* Meta-b */
+  { ISFUNC, rl_capitalize_word }, 	/* Meta-c */
+  { ISFUNC, rl_kill_word },		/* Meta-d */
+  { ISFUNC, (rl_command_func_t *)0x0 },	/* Meta-e */
+  { ISFUNC, rl_forward_word },		/* Meta-f */
+  { ISFUNC, (rl_command_func_t *)0x0 },	/* Meta-g */
+  { ISFUNC, (rl_command_func_t *)0x0 },	/* Meta-h */
+  { ISFUNC, (rl_command_func_t *)0x0 },	/* Meta-i */
+  { ISFUNC, (rl_command_func_t *)0x0 },	/* Meta-j */
+  { ISFUNC, (rl_command_func_t *)0x0 },	/* Meta-k */
+  { ISFUNC, rl_downcase_word },		/* Meta-l */
+  { ISFUNC, (rl_command_func_t *)0x0 },	/* Meta-m */
   { ISFUNC, rl_noninc_forward_search },	/* Meta-n */
-  { ISFUNC, (Function *)0x0 },	/* Meta-o */	/* was rl_arrow_keys */
+  { ISFUNC, (rl_command_func_t *)0x0 },	/* Meta-o */	/* was rl_arrow_keys */
   { ISFUNC, rl_noninc_reverse_search },	/* Meta-p */
-  { ISFUNC, (Function *)0x0 },	/* Meta-q */
-  { ISFUNC, rl_revert_line },	/* Meta-r */
-  { ISFUNC, (Function *)0x0 },	/* Meta-s */
-  { ISFUNC, rl_transpose_words }, /* Meta-t */
-  { ISFUNC, rl_upcase_word },	/* Meta-u */
-  { ISFUNC, (Function *)0x0 },	/* Meta-v */
-  { ISFUNC, (Function *)0x0 },	/* Meta-w */
-  { ISFUNC, (Function *)0x0 },	/* Meta-x */
-  { ISFUNC, rl_yank_pop },	/* Meta-y */
-  { ISFUNC, (Function *)0x0 },	/* Meta-z */
+  { ISFUNC, (rl_command_func_t *)0x0 },	/* Meta-q */
+  { ISFUNC, rl_revert_line },		/* Meta-r */
+  { ISFUNC, (rl_command_func_t *)0x0 },	/* Meta-s */
+  { ISFUNC, rl_transpose_words }, 	/* Meta-t */
+  { ISFUNC, rl_upcase_word },		/* Meta-u */
+  { ISFUNC, (rl_command_func_t *)0x0 },	/* Meta-v */
+  { ISFUNC, (rl_command_func_t *)0x0 },	/* Meta-w */
+  { ISFUNC, (rl_command_func_t *)0x0 },	/* Meta-x */
+  { ISFUNC, rl_yank_pop },		/* Meta-y */
+  { ISFUNC, (rl_command_func_t *)0x0 },	/* Meta-z */
 
   /* Final punctuation. */
-  { ISFUNC, (Function *)0x0 },	/* Meta-{ */
-  { ISFUNC, (Function *)0x0 },	/* Meta-| */
-  { ISFUNC, (Function *)0x0 },	/* Meta-} */
-  { ISFUNC, rl_tilde_expand },	/* Meta-~ */
-  { ISFUNC, rl_backward_kill_word }, /* Meta-rubout */
+  { ISFUNC, (rl_command_func_t *)0x0 },	/* Meta-{ */
+  { ISFUNC, (rl_command_func_t *)0x0 },	/* Meta-| */
+  { ISFUNC, (rl_command_func_t *)0x0 },	/* Meta-} */
+  { ISFUNC, rl_tilde_expand },		/* Meta-~ */
+  { ISFUNC, rl_backward_kill_word },	/* Meta-rubout */
 
 #if KEYMAP_SIZE > 128
   /* Undefined keys. */
-  { ISFUNC, (Function *)0x0 },
-  { ISFUNC, (Function *)0x0 },
-  { ISFUNC, (Function *)0x0 },
-  { ISFUNC, (Function *)0x0 },
-  { ISFUNC, (Function *)0x0 },
-  { ISFUNC, (Function *)0x0 },
-  { ISFUNC, (Function *)0x0 },
-  { ISFUNC, (Function *)0x0 },
-  { ISFUNC, (Function *)0x0 },
-  { ISFUNC, (Function *)0x0 },
-  { ISFUNC, (Function *)0x0 },
-  { ISFUNC, (Function *)0x0 },
-  { ISFUNC, (Function *)0x0 },
-  { ISFUNC, (Function *)0x0 },
-  { ISFUNC, (Function *)0x0 },
-  { ISFUNC, (Function *)0x0 },
-  { ISFUNC, (Function *)0x0 },
-  { ISFUNC, (Function *)0x0 },
-  { ISFUNC, (Function *)0x0 },
-  { ISFUNC, (Function *)0x0 },
-  { ISFUNC, (Function *)0x0 },
-  { ISFUNC, (Function *)0x0 },
-  { ISFUNC, (Function *)0x0 },
-  { ISFUNC, (Function *)0x0 },
-  { ISFUNC, (Function *)0x0 },
-  { ISFUNC, (Function *)0x0 },
-  { ISFUNC, (Function *)0x0 },
-  { ISFUNC, (Function *)0x0 },
-  { ISFUNC, (Function *)0x0 },
-  { ISFUNC, (Function *)0x0 },
-  { ISFUNC, (Function *)0x0 },
-  { ISFUNC, (Function *)0x0 },
-  { ISFUNC, (Function *)0x0 },
-  { ISFUNC, (Function *)0x0 },
-  { ISFUNC, (Function *)0x0 },
-  { ISFUNC, (Function *)0x0 },
-  { ISFUNC, (Function *)0x0 },
-  { ISFUNC, (Function *)0x0 },
-  { ISFUNC, (Function *)0x0 },
-  { ISFUNC, (Function *)0x0 },
-  { ISFUNC, (Function *)0x0 },
-  { ISFUNC, (Function *)0x0 },
-  { ISFUNC, (Function *)0x0 },
-  { ISFUNC, (Function *)0x0 },
-  { ISFUNC, (Function *)0x0 },
-  { ISFUNC, (Function *)0x0 },
-  { ISFUNC, (Function *)0x0 },
-  { ISFUNC, (Function *)0x0 },
-  { ISFUNC, (Function *)0x0 },
-  { ISFUNC, (Function *)0x0 },
-  { ISFUNC, (Function *)0x0 },
-  { ISFUNC, (Function *)0x0 },
-  { ISFUNC, (Function *)0x0 },
-  { ISFUNC, (Function *)0x0 },
-  { ISFUNC, (Function *)0x0 },
-  { ISFUNC, (Function *)0x0 },
-  { ISFUNC, (Function *)0x0 },
-  { ISFUNC, (Function *)0x0 },
-  { ISFUNC, (Function *)0x0 },
-  { ISFUNC, (Function *)0x0 },
-  { ISFUNC, (Function *)0x0 },
-  { ISFUNC, (Function *)0x0 },
-  { ISFUNC, (Function *)0x0 },
-  { ISFUNC, (Function *)0x0 },
-  { ISFUNC, (Function *)0x0 },
-  { ISFUNC, (Function *)0x0 },
-  { ISFUNC, (Function *)0x0 },
-  { ISFUNC, (Function *)0x0 },
-  { ISFUNC, (Function *)0x0 },
-  { ISFUNC, (Function *)0x0 },
-  { ISFUNC, (Function *)0x0 },
-  { ISFUNC, (Function *)0x0 },
-  { ISFUNC, (Function *)0x0 },
-  { ISFUNC, (Function *)0x0 },
-  { ISFUNC, (Function *)0x0 },
-  { ISFUNC, (Function *)0x0 },
-  { ISFUNC, (Function *)0x0 },
-  { ISFUNC, (Function *)0x0 },
-  { ISFUNC, (Function *)0x0 },
-  { ISFUNC, (Function *)0x0 },
-  { ISFUNC, (Function *)0x0 },
-  { ISFUNC, (Function *)0x0 },
-  { ISFUNC, (Function *)0x0 },
-  { ISFUNC, (Function *)0x0 },
-  { ISFUNC, (Function *)0x0 },
-  { ISFUNC, (Function *)0x0 },
-  { ISFUNC, (Function *)0x0 },
-  { ISFUNC, (Function *)0x0 },
-  { ISFUNC, (Function *)0x0 },
-  { ISFUNC, (Function *)0x0 },
-  { ISFUNC, (Function *)0x0 },
-  { ISFUNC, (Function *)0x0 },
-  { ISFUNC, (Function *)0x0 },
-  { ISFUNC, (Function *)0x0 },
-  { ISFUNC, (Function *)0x0 },
-  { ISFUNC, (Function *)0x0 },
-  { ISFUNC, (Function *)0x0 },
-  { ISFUNC, (Function *)0x0 },
-  { ISFUNC, (Function *)0x0 },
-  { ISFUNC, (Function *)0x0 },
-  { ISFUNC, (Function *)0x0 },
-  { ISFUNC, (Function *)0x0 },
-  { ISFUNC, (Function *)0x0 },
-  { ISFUNC, (Function *)0x0 },
-  { ISFUNC, (Function *)0x0 },
-  { ISFUNC, (Function *)0x0 },
-  { ISFUNC, (Function *)0x0 },
-  { ISFUNC, (Function *)0x0 },
-  { ISFUNC, (Function *)0x0 },
-  { ISFUNC, (Function *)0x0 },
-  { ISFUNC, (Function *)0x0 },
-  { ISFUNC, (Function *)0x0 },
-  { ISFUNC, (Function *)0x0 },
-  { ISFUNC, (Function *)0x0 },
-  { ISFUNC, (Function *)0x0 },
-  { ISFUNC, (Function *)0x0 },
-  { ISFUNC, (Function *)0x0 },
-  { ISFUNC, (Function *)0x0 },
-  { ISFUNC, (Function *)0x0 },
-  { ISFUNC, (Function *)0x0 },
-  { ISFUNC, (Function *)0x0 },
-  { ISFUNC, (Function *)0x0 },
-  { ISFUNC, (Function *)0x0 },
-  { ISFUNC, (Function *)0x0 },
-  { ISFUNC, (Function *)0x0 },
-  { ISFUNC, (Function *)0x0 },
-  { ISFUNC, (Function *)0x0 },
-  { ISFUNC, (Function *)0x0 }
+  { ISFUNC, (rl_command_func_t *)0x0 },
+  { ISFUNC, (rl_command_func_t *)0x0 },
+  { ISFUNC, (rl_command_func_t *)0x0 },
+  { ISFUNC, (rl_command_func_t *)0x0 },
+  { ISFUNC, (rl_command_func_t *)0x0 },
+  { ISFUNC, (rl_command_func_t *)0x0 },
+  { ISFUNC, (rl_command_func_t *)0x0 },
+  { ISFUNC, (rl_command_func_t *)0x0 },
+  { ISFUNC, (rl_command_func_t *)0x0 },
+  { ISFUNC, (rl_command_func_t *)0x0 },
+  { ISFUNC, (rl_command_func_t *)0x0 },
+  { ISFUNC, (rl_command_func_t *)0x0 },
+  { ISFUNC, (rl_command_func_t *)0x0 },
+  { ISFUNC, (rl_command_func_t *)0x0 },
+  { ISFUNC, (rl_command_func_t *)0x0 },
+  { ISFUNC, (rl_command_func_t *)0x0 },
+  { ISFUNC, (rl_command_func_t *)0x0 },
+  { ISFUNC, (rl_command_func_t *)0x0 },
+  { ISFUNC, (rl_command_func_t *)0x0 },
+  { ISFUNC, (rl_command_func_t *)0x0 },
+  { ISFUNC, (rl_command_func_t *)0x0 },
+  { ISFUNC, (rl_command_func_t *)0x0 },
+  { ISFUNC, (rl_command_func_t *)0x0 },
+  { ISFUNC, (rl_command_func_t *)0x0 },
+  { ISFUNC, (rl_command_func_t *)0x0 },
+  { ISFUNC, (rl_command_func_t *)0x0 },
+  { ISFUNC, (rl_command_func_t *)0x0 },
+  { ISFUNC, (rl_command_func_t *)0x0 },
+  { ISFUNC, (rl_command_func_t *)0x0 },
+  { ISFUNC, (rl_command_func_t *)0x0 },
+  { ISFUNC, (rl_command_func_t *)0x0 },
+  { ISFUNC, (rl_command_func_t *)0x0 },
+  { ISFUNC, (rl_command_func_t *)0x0 },
+  { ISFUNC, (rl_command_func_t *)0x0 },
+  { ISFUNC, (rl_command_func_t *)0x0 },
+  { ISFUNC, (rl_command_func_t *)0x0 },
+  { ISFUNC, (rl_command_func_t *)0x0 },
+  { ISFUNC, (rl_command_func_t *)0x0 },
+  { ISFUNC, (rl_command_func_t *)0x0 },
+  { ISFUNC, (rl_command_func_t *)0x0 },
+  { ISFUNC, (rl_command_func_t *)0x0 },
+  { ISFUNC, (rl_command_func_t *)0x0 },
+  { ISFUNC, (rl_command_func_t *)0x0 },
+  { ISFUNC, (rl_command_func_t *)0x0 },
+  { ISFUNC, (rl_command_func_t *)0x0 },
+  { ISFUNC, (rl_command_func_t *)0x0 },
+  { ISFUNC, (rl_command_func_t *)0x0 },
+  { ISFUNC, (rl_command_func_t *)0x0 },
+  { ISFUNC, (rl_command_func_t *)0x0 },
+  { ISFUNC, (rl_command_func_t *)0x0 },
+  { ISFUNC, (rl_command_func_t *)0x0 },
+  { ISFUNC, (rl_command_func_t *)0x0 },
+  { ISFUNC, (rl_command_func_t *)0x0 },
+  { ISFUNC, (rl_command_func_t *)0x0 },
+  { ISFUNC, (rl_command_func_t *)0x0 },
+  { ISFUNC, (rl_command_func_t *)0x0 },
+  { ISFUNC, (rl_command_func_t *)0x0 },
+  { ISFUNC, (rl_command_func_t *)0x0 },
+  { ISFUNC, (rl_command_func_t *)0x0 },
+  { ISFUNC, (rl_command_func_t *)0x0 },
+  { ISFUNC, (rl_command_func_t *)0x0 },
+  { ISFUNC, (rl_command_func_t *)0x0 },
+  { ISFUNC, (rl_command_func_t *)0x0 },
+  { ISFUNC, (rl_command_func_t *)0x0 },
+  { ISFUNC, (rl_command_func_t *)0x0 },
+  { ISFUNC, (rl_command_func_t *)0x0 },
+  { ISFUNC, (rl_command_func_t *)0x0 },
+  { ISFUNC, (rl_command_func_t *)0x0 },
+  { ISFUNC, (rl_command_func_t *)0x0 },
+  { ISFUNC, (rl_command_func_t *)0x0 },
+  { ISFUNC, (rl_command_func_t *)0x0 },
+  { ISFUNC, (rl_command_func_t *)0x0 },
+  { ISFUNC, (rl_command_func_t *)0x0 },
+  { ISFUNC, (rl_command_func_t *)0x0 },
+  { ISFUNC, (rl_command_func_t *)0x0 },
+  { ISFUNC, (rl_command_func_t *)0x0 },
+  { ISFUNC, (rl_command_func_t *)0x0 },
+  { ISFUNC, (rl_command_func_t *)0x0 },
+  { ISFUNC, (rl_command_func_t *)0x0 },
+  { ISFUNC, (rl_command_func_t *)0x0 },
+  { ISFUNC, (rl_command_func_t *)0x0 },
+  { ISFUNC, (rl_command_func_t *)0x0 },
+  { ISFUNC, (rl_command_func_t *)0x0 },
+  { ISFUNC, (rl_command_func_t *)0x0 },
+  { ISFUNC, (rl_command_func_t *)0x0 },
+  { ISFUNC, (rl_command_func_t *)0x0 },
+  { ISFUNC, (rl_command_func_t *)0x0 },
+  { ISFUNC, (rl_command_func_t *)0x0 },
+  { ISFUNC, (rl_command_func_t *)0x0 },
+  { ISFUNC, (rl_command_func_t *)0x0 },
+  { ISFUNC, (rl_command_func_t *)0x0 },
+  { ISFUNC, (rl_command_func_t *)0x0 },
+  { ISFUNC, (rl_command_func_t *)0x0 },
+  { ISFUNC, (rl_command_func_t *)0x0 },
+  { ISFUNC, (rl_command_func_t *)0x0 },
+  { ISFUNC, (rl_command_func_t *)0x0 },
+  { ISFUNC, (rl_command_func_t *)0x0 },
+  { ISFUNC, (rl_command_func_t *)0x0 },
+  { ISFUNC, (rl_command_func_t *)0x0 },
+  { ISFUNC, (rl_command_func_t *)0x0 },
+  { ISFUNC, (rl_command_func_t *)0x0 },
+  { ISFUNC, (rl_command_func_t *)0x0 },
+  { ISFUNC, (rl_command_func_t *)0x0 },
+  { ISFUNC, (rl_command_func_t *)0x0 },
+  { ISFUNC, (rl_command_func_t *)0x0 },
+  { ISFUNC, (rl_command_func_t *)0x0 },
+  { ISFUNC, (rl_command_func_t *)0x0 },
+  { ISFUNC, (rl_command_func_t *)0x0 },
+  { ISFUNC, (rl_command_func_t *)0x0 },
+  { ISFUNC, (rl_command_func_t *)0x0 },
+  { ISFUNC, (rl_command_func_t *)0x0 },
+  { ISFUNC, (rl_command_func_t *)0x0 },
+  { ISFUNC, (rl_command_func_t *)0x0 },
+  { ISFUNC, (rl_command_func_t *)0x0 },
+  { ISFUNC, (rl_command_func_t *)0x0 },
+  { ISFUNC, (rl_command_func_t *)0x0 },
+  { ISFUNC, (rl_command_func_t *)0x0 },
+  { ISFUNC, (rl_command_func_t *)0x0 },
+  { ISFUNC, (rl_command_func_t *)0x0 },
+  { ISFUNC, (rl_command_func_t *)0x0 },
+  { ISFUNC, (rl_command_func_t *)0x0 },
+  { ISFUNC, (rl_command_func_t *)0x0 },
+  { ISFUNC, (rl_command_func_t *)0x0 },
+  { ISFUNC, (rl_command_func_t *)0x0 },
+  { ISFUNC, (rl_command_func_t *)0x0 },
+  { ISFUNC, (rl_command_func_t *)0x0 },
+  { ISFUNC, (rl_command_func_t *)0x0 },
+  { ISFUNC, (rl_command_func_t *)0x0 }
 #endif /* KEYMAP_SIZE > 128 */
 };
 
 KEYMAP_ENTRY_ARRAY emacs_ctlx_keymap = {
 
   /* Control keys. */
-  { ISFUNC, (Function *)0x0 },		/* Control-@ */
-  { ISFUNC, (Function *)0x0 },		/* Control-a */
-  { ISFUNC, (Function *)0x0 },		/* Control-b */
-  { ISFUNC, (Function *)0x0 },		/* Control-c */
-  { ISFUNC, (Function *)0x0 },		/* Control-d */
-  { ISFUNC, (Function *)0x0 },		/* Control-e */
-  { ISFUNC, (Function *)0x0 },		/* Control-f */
-  { ISFUNC, rl_abort },			/* Control-g */
-  { ISFUNC, (Function *)0x0 },		/* Control-h */
-  { ISFUNC, (Function *)0x0 },		/* Control-i */
-  { ISFUNC, (Function *)0x0 },		/* Control-j */
-  { ISFUNC, (Function *)0x0 },		/* Control-k */
-  { ISFUNC, (Function *)0x0 },		/* Control-l */
-  { ISFUNC, (Function *)0x0 },		/* Control-m */
-  { ISFUNC, (Function *)0x0 },		/* Control-n */
-  { ISFUNC, (Function *)0x0 },		/* Control-o */
-  { ISFUNC, (Function *)0x0 },		/* Control-p */
-  { ISFUNC, (Function *)0x0 },		/* Control-q */
-  { ISFUNC, rl_re_read_init_file },	/* Control-r */
-  { ISFUNC, (Function *)0x0 },		/* Control-s */
-  { ISFUNC, (Function *)0x0 },		/* Control-t */
-  { ISFUNC, rl_undo_command },		/* Control-u */
-  { ISFUNC, (Function *)0x0 },		/* Control-v */
-  { ISFUNC, (Function *)0x0 },		/* Control-w */
-  { ISFUNC, rl_exchange_point_and_mark },/* Control-x */
-  { ISFUNC, (Function *)0x0 },		/* Control-y */
-  { ISFUNC, (Function *)0x0 },		/* Control-z */
-  { ISFUNC, (Function *)0x0 },		/* Control-[ */
-  { ISFUNC, (Function *)0x0 },		/* Control-\ */
-  { ISFUNC, (Function *)0x0 },		/* Control-] */
-  { ISFUNC, (Function *)0x0 },		/* Control-^ */
-  { ISFUNC, (Function *)0x0 },		/* Control-_ */
+  { ISFUNC, (rl_command_func_t *)0x0 },		/* Control-@ */
+  { ISFUNC, (rl_command_func_t *)0x0 },		/* Control-a */
+  { ISFUNC, (rl_command_func_t *)0x0 },		/* Control-b */
+  { ISFUNC, (rl_command_func_t *)0x0 },		/* Control-c */
+  { ISFUNC, (rl_command_func_t *)0x0 },		/* Control-d */
+  { ISFUNC, (rl_command_func_t *)0x0 },		/* Control-e */
+  { ISFUNC, (rl_command_func_t *)0x0 },		/* Control-f */
+  { ISFUNC, rl_abort },				/* Control-g */
+  { ISFUNC, (rl_command_func_t *)0x0 },		/* Control-h */
+  { ISFUNC, (rl_command_func_t *)0x0 },		/* Control-i */
+  { ISFUNC, (rl_command_func_t *)0x0 },		/* Control-j */
+  { ISFUNC, (rl_command_func_t *)0x0 },		/* Control-k */
+  { ISFUNC, (rl_command_func_t *)0x0 },		/* Control-l */
+  { ISFUNC, (rl_command_func_t *)0x0 },		/* Control-m */
+  { ISFUNC, (rl_command_func_t *)0x0 },		/* Control-n */
+  { ISFUNC, (rl_command_func_t *)0x0 },		/* Control-o */
+  { ISFUNC, (rl_command_func_t *)0x0 },		/* Control-p */
+  { ISFUNC, (rl_command_func_t *)0x0 },		/* Control-q */
+  { ISFUNC, rl_re_read_init_file },		/* Control-r */
+  { ISFUNC, (rl_command_func_t *)0x0 },		/* Control-s */
+  { ISFUNC, (rl_command_func_t *)0x0 },		/* Control-t */
+  { ISFUNC, rl_undo_command },			/* Control-u */
+  { ISFUNC, (rl_command_func_t *)0x0 },		/* Control-v */
+  { ISFUNC, (rl_command_func_t *)0x0 },		/* Control-w */
+  { ISFUNC, rl_exchange_point_and_mark },	/* Control-x */
+  { ISFUNC, (rl_command_func_t *)0x0 },		/* Control-y */
+  { ISFUNC, (rl_command_func_t *)0x0 },		/* Control-z */
+  { ISFUNC, (rl_command_func_t *)0x0 },		/* Control-[ */
+  { ISFUNC, (rl_command_func_t *)0x0 },		/* Control-\ */
+  { ISFUNC, (rl_command_func_t *)0x0 },		/* Control-] */
+  { ISFUNC, (rl_command_func_t *)0x0 },		/* Control-^ */
+  { ISFUNC, (rl_command_func_t *)0x0 },		/* Control-_ */
 
   /* The start of printing characters. */
-  { ISFUNC, (Function *)0x0 },		/* SPACE */
-  { ISFUNC, (Function *)0x0 },		/* ! */
-  { ISFUNC, (Function *)0x0 },		/* " */
-  { ISFUNC, (Function *)0x0 },		/* # */
-  { ISFUNC, (Function *)0x0 },		/* $ */
-  { ISFUNC, (Function *)0x0 },		/* % */
-  { ISFUNC, (Function *)0x0 },		/* & */
-  { ISFUNC, (Function *)0x0 },		/* ' */
-  { ISFUNC, rl_start_kbd_macro },	/* ( */
-  { ISFUNC, rl_end_kbd_macro  },	/* ) */
-  { ISFUNC, (Function *)0x0 },		/* * */
-  { ISFUNC, (Function *)0x0 },		/* + */
-  { ISFUNC, (Function *)0x0 },		/* , */
-  { ISFUNC, (Function *)0x0 },		/* - */
-  { ISFUNC, (Function *)0x0 },		/* . */
-  { ISFUNC, (Function *)0x0 },		/* / */
+  { ISFUNC, (rl_command_func_t *)0x0 },		/* SPACE */
+  { ISFUNC, (rl_command_func_t *)0x0 },		/* ! */
+  { ISFUNC, (rl_command_func_t *)0x0 },		/* " */
+  { ISFUNC, (rl_command_func_t *)0x0 },		/* # */
+  { ISFUNC, (rl_command_func_t *)0x0 },		/* $ */
+  { ISFUNC, (rl_command_func_t *)0x0 },		/* % */
+  { ISFUNC, (rl_command_func_t *)0x0 },		/* & */
+  { ISFUNC, (rl_command_func_t *)0x0 },		/* ' */
+  { ISFUNC, rl_start_kbd_macro },		/* ( */
+  { ISFUNC, rl_end_kbd_macro  },		/* ) */
+  { ISFUNC, (rl_command_func_t *)0x0 },		/* * */
+  { ISFUNC, (rl_command_func_t *)0x0 },		/* + */
+  { ISFUNC, (rl_command_func_t *)0x0 },		/* , */
+  { ISFUNC, (rl_command_func_t *)0x0 },		/* - */
+  { ISFUNC, (rl_command_func_t *)0x0 },		/* . */
+  { ISFUNC, (rl_command_func_t *)0x0 },		/* / */
 
   /* Regular digits. */
-  { ISFUNC, (Function *)0x0 },		/* 0 */
-  { ISFUNC, (Function *)0x0 },		/* 1 */
-  { ISFUNC, (Function *)0x0 },		/* 2 */
-  { ISFUNC, (Function *)0x0 },		/* 3 */
-  { ISFUNC, (Function *)0x0 },		/* 4 */
-  { ISFUNC, (Function *)0x0 },		/* 5 */
-  { ISFUNC, (Function *)0x0 },		/* 6 */
-  { ISFUNC, (Function *)0x0 },		/* 7 */
-  { ISFUNC, (Function *)0x0 },		/* 8 */
-  { ISFUNC, (Function *)0x0 },		/* 9 */
+  { ISFUNC, (rl_command_func_t *)0x0 },		/* 0 */
+  { ISFUNC, (rl_command_func_t *)0x0 },		/* 1 */
+  { ISFUNC, (rl_command_func_t *)0x0 },		/* 2 */
+  { ISFUNC, (rl_command_func_t *)0x0 },		/* 3 */
+  { ISFUNC, (rl_command_func_t *)0x0 },		/* 4 */
+  { ISFUNC, (rl_command_func_t *)0x0 },		/* 5 */
+  { ISFUNC, (rl_command_func_t *)0x0 },		/* 6 */
+  { ISFUNC, (rl_command_func_t *)0x0 },		/* 7 */
+  { ISFUNC, (rl_command_func_t *)0x0 },		/* 8 */
+  { ISFUNC, (rl_command_func_t *)0x0 },		/* 9 */
 
   /* A little more punctuation. */
-  { ISFUNC, (Function *)0x0 },	/* : */
-  { ISFUNC, (Function *)0x0 },	/* ; */
-  { ISFUNC, (Function *)0x0 },	/* < */
-  { ISFUNC, (Function *)0x0 },	/* = */
-  { ISFUNC, (Function *)0x0 },	/* > */
-  { ISFUNC, (Function *)0x0 },	/* ? */
-  { ISFUNC, (Function *)0x0 },	/* @ */
+  { ISFUNC, (rl_command_func_t *)0x0 },		/* : */
+  { ISFUNC, (rl_command_func_t *)0x0 },		/* ; */
+  { ISFUNC, (rl_command_func_t *)0x0 },		/* < */
+  { ISFUNC, (rl_command_func_t *)0x0 },		/* = */
+  { ISFUNC, (rl_command_func_t *)0x0 },		/* > */
+  { ISFUNC, (rl_command_func_t *)0x0 },		/* ? */
+  { ISFUNC, (rl_command_func_t *)0x0 },		/* @ */
 
   /* Uppercase alphabet. */
-  { ISFUNC, rl_do_lowercase_version },	/* A */
-  { ISFUNC, rl_do_lowercase_version },	/* B */
-  { ISFUNC, rl_do_lowercase_version },	/* C */
-  { ISFUNC, rl_do_lowercase_version },	/* D */
-  { ISFUNC, rl_do_lowercase_version },	/* E */
-  { ISFUNC, rl_do_lowercase_version },	/* F */
-  { ISFUNC, rl_do_lowercase_version },	/* G */
-  { ISFUNC, rl_do_lowercase_version },	/* H */
-  { ISFUNC, rl_do_lowercase_version },	/* I */
-  { ISFUNC, rl_do_lowercase_version },	/* J */
-  { ISFUNC, rl_do_lowercase_version },	/* K */
-  { ISFUNC, rl_do_lowercase_version },	/* L */
-  { ISFUNC, rl_do_lowercase_version },	/* M */
-  { ISFUNC, rl_do_lowercase_version },	/* N */
-  { ISFUNC, rl_do_lowercase_version },	/* O */
-  { ISFUNC, rl_do_lowercase_version },	/* P */
-  { ISFUNC, rl_do_lowercase_version },	/* Q */
-  { ISFUNC, rl_do_lowercase_version },	/* R */
-  { ISFUNC, rl_do_lowercase_version },	/* S */
-  { ISFUNC, rl_do_lowercase_version },	/* T */
-  { ISFUNC, rl_do_lowercase_version },	/* U */
-  { ISFUNC, rl_do_lowercase_version },	/* V */
-  { ISFUNC, rl_do_lowercase_version },	/* W */
-  { ISFUNC, rl_do_lowercase_version },	/* X */
-  { ISFUNC, rl_do_lowercase_version },	/* Y */
-  { ISFUNC, rl_do_lowercase_version },	/* Z */
+  { ISFUNC, rl_do_lowercase_version },		/* A */
+  { ISFUNC, rl_do_lowercase_version },		/* B */
+  { ISFUNC, rl_do_lowercase_version },		/* C */
+  { ISFUNC, rl_do_lowercase_version },		/* D */
+  { ISFUNC, rl_do_lowercase_version },		/* E */
+  { ISFUNC, rl_do_lowercase_version },		/* F */
+  { ISFUNC, rl_do_lowercase_version },		/* G */
+  { ISFUNC, rl_do_lowercase_version },		/* H */
+  { ISFUNC, rl_do_lowercase_version },		/* I */
+  { ISFUNC, rl_do_lowercase_version },		/* J */
+  { ISFUNC, rl_do_lowercase_version },		/* K */
+  { ISFUNC, rl_do_lowercase_version },		/* L */
+  { ISFUNC, rl_do_lowercase_version },		/* M */
+  { ISFUNC, rl_do_lowercase_version },		/* N */
+  { ISFUNC, rl_do_lowercase_version },		/* O */
+  { ISFUNC, rl_do_lowercase_version },		/* P */
+  { ISFUNC, rl_do_lowercase_version },		/* Q */
+  { ISFUNC, rl_do_lowercase_version },		/* R */
+  { ISFUNC, rl_do_lowercase_version },		/* S */
+  { ISFUNC, rl_do_lowercase_version },		/* T */
+  { ISFUNC, rl_do_lowercase_version },		/* U */
+  { ISFUNC, rl_do_lowercase_version },		/* V */
+  { ISFUNC, rl_do_lowercase_version },		/* W */
+  { ISFUNC, rl_do_lowercase_version },		/* X */
+  { ISFUNC, rl_do_lowercase_version },		/* Y */
+  { ISFUNC, rl_do_lowercase_version },		/* Z */
 
   /* Some more punctuation. */
-  { ISFUNC, (Function *)0x0 },		/* [ */
-  { ISFUNC, (Function *)0x0 },		/* \ */
-  { ISFUNC, (Function *)0x0 },		/* ] */
-  { ISFUNC, (Function *)0x0 },		/* ^ */
-  { ISFUNC, (Function *)0x0 },		/* _ */
-  { ISFUNC, (Function *)0x0 },		/* ` */
+  { ISFUNC, (rl_command_func_t *)0x0 },		/* [ */
+  { ISFUNC, (rl_command_func_t *)0x0 },		/* \ */
+  { ISFUNC, (rl_command_func_t *)0x0 },		/* ] */
+  { ISFUNC, (rl_command_func_t *)0x0 },		/* ^ */
+  { ISFUNC, (rl_command_func_t *)0x0 },		/* _ */
+  { ISFUNC, (rl_command_func_t *)0x0 },		/* ` */
 
   /* Lowercase alphabet. */
-  { ISFUNC, (Function *)0x0 },		/* a */
-  { ISFUNC, (Function *)0x0 },		/* b */
-  { ISFUNC, (Function *)0x0 },		/* c */
-  { ISFUNC, (Function *)0x0 },		/* d */
-  { ISFUNC, rl_call_last_kbd_macro },	/* e */
-  { ISFUNC, (Function *)0x0 },		/* f */
-  { ISFUNC, (Function *)0x0 },		/* g */
-  { ISFUNC, (Function *)0x0 },		/* h */
-  { ISFUNC, (Function *)0x0 },		/* i */
-  { ISFUNC, (Function *)0x0 },		/* j */
-  { ISFUNC, (Function *)0x0 },		/* k */
-  { ISFUNC, (Function *)0x0 },		/* l */
-  { ISFUNC, (Function *)0x0 },		/* m */
-  { ISFUNC, (Function *)0x0 },		/* n */
-  { ISFUNC, (Function *)0x0 },		/* o */
-  { ISFUNC, (Function *)0x0 },		/* p */
-  { ISFUNC, (Function *)0x0 },		/* q */
-  { ISFUNC, (Function *)0x0 },		/* r */
-  { ISFUNC, (Function *)0x0 },		/* s */
-  { ISFUNC, (Function *)0x0 },		/* t */
-  { ISFUNC, (Function *)0x0 },		/* u */
-  { ISFUNC, (Function *)0x0 },		/* v */
-  { ISFUNC, (Function *)0x0 },		/* w */
-  { ISFUNC, (Function *)0x0 },		/* x */
-  { ISFUNC, (Function *)0x0 },		/* y */
-  { ISFUNC, (Function *)0x0 },		/* z */
+  { ISFUNC, (rl_command_func_t *)0x0 },		/* a */
+  { ISFUNC, (rl_command_func_t *)0x0 },		/* b */
+  { ISFUNC, (rl_command_func_t *)0x0 },		/* c */
+  { ISFUNC, (rl_command_func_t *)0x0 },		/* d */
+  { ISFUNC, rl_call_last_kbd_macro },		/* e */
+  { ISFUNC, (rl_command_func_t *)0x0 },		/* f */
+  { ISFUNC, (rl_command_func_t *)0x0 },		/* g */
+  { ISFUNC, (rl_command_func_t *)0x0 },		/* h */
+  { ISFUNC, (rl_command_func_t *)0x0 },		/* i */
+  { ISFUNC, (rl_command_func_t *)0x0 },		/* j */
+  { ISFUNC, (rl_command_func_t *)0x0 },		/* k */
+  { ISFUNC, (rl_command_func_t *)0x0 },		/* l */
+  { ISFUNC, (rl_command_func_t *)0x0 },		/* m */
+  { ISFUNC, (rl_command_func_t *)0x0 },		/* n */
+  { ISFUNC, (rl_command_func_t *)0x0 },		/* o */
+  { ISFUNC, (rl_command_func_t *)0x0 },		/* p */
+  { ISFUNC, (rl_command_func_t *)0x0 },		/* q */
+  { ISFUNC, (rl_command_func_t *)0x0 },		/* r */
+  { ISFUNC, (rl_command_func_t *)0x0 },		/* s */
+  { ISFUNC, (rl_command_func_t *)0x0 },		/* t */
+  { ISFUNC, (rl_command_func_t *)0x0 },		/* u */
+  { ISFUNC, (rl_command_func_t *)0x0 },		/* v */
+  { ISFUNC, (rl_command_func_t *)0x0 },		/* w */
+  { ISFUNC, (rl_command_func_t *)0x0 },		/* x */
+  { ISFUNC, (rl_command_func_t *)0x0 },		/* y */
+  { ISFUNC, (rl_command_func_t *)0x0 },		/* z */
 
   /* Final punctuation. */
-  { ISFUNC, (Function *)0x0 },		/* { */
-  { ISFUNC, (Function *)0x0 },		/* | */
-  { ISFUNC, (Function *)0x0 },		/* } */
-  { ISFUNC, (Function *)0x0 },		/* ~ */
-  { ISFUNC, rl_backward_kill_line },	/* RUBOUT */
+  { ISFUNC, (rl_command_func_t *)0x0 },		/* { */
+  { ISFUNC, (rl_command_func_t *)0x0 },		/* | */
+  { ISFUNC, (rl_command_func_t *)0x0 },		/* } */
+  { ISFUNC, (rl_command_func_t *)0x0 },		/* ~ */
+  { ISFUNC, rl_backward_kill_line },		/* RUBOUT */
 
 #if KEYMAP_SIZE > 128
   /* Undefined keys. */
-  { ISFUNC, (Function *)0x0 },
-  { ISFUNC, (Function *)0x0 },
-  { ISFUNC, (Function *)0x0 },
-  { ISFUNC, (Function *)0x0 },
-  { ISFUNC, (Function *)0x0 },
-  { ISFUNC, (Function *)0x0 },
-  { ISFUNC, (Function *)0x0 },
-  { ISFUNC, (Function *)0x0 },
-  { ISFUNC, (Function *)0x0 },
-  { ISFUNC, (Function *)0x0 },
-  { ISFUNC, (Function *)0x0 },
-  { ISFUNC, (Function *)0x0 },
-  { ISFUNC, (Function *)0x0 },
-  { ISFUNC, (Function *)0x0 },
-  { ISFUNC, (Function *)0x0 },
-  { ISFUNC, (Function *)0x0 },
-  { ISFUNC, (Function *)0x0 },
-  { ISFUNC, (Function *)0x0 },
-  { ISFUNC, (Function *)0x0 },
-  { ISFUNC, (Function *)0x0 },
-  { ISFUNC, (Function *)0x0 },
-  { ISFUNC, (Function *)0x0 },
-  { ISFUNC, (Function *)0x0 },
-  { ISFUNC, (Function *)0x0 },
-  { ISFUNC, (Function *)0x0 },
-  { ISFUNC, (Function *)0x0 },
-  { ISFUNC, (Function *)0x0 },
-  { ISFUNC, (Function *)0x0 },
-  { ISFUNC, (Function *)0x0 },
-  { ISFUNC, (Function *)0x0 },
-  { ISFUNC, (Function *)0x0 },
-  { ISFUNC, (Function *)0x0 },
-  { ISFUNC, (Function *)0x0 },
-  { ISFUNC, (Function *)0x0 },
-  { ISFUNC, (Function *)0x0 },
-  { ISFUNC, (Function *)0x0 },
-  { ISFUNC, (Function *)0x0 },
-  { ISFUNC, (Function *)0x0 },
-  { ISFUNC, (Function *)0x0 },
-  { ISFUNC, (Function *)0x0 },
-  { ISFUNC, (Function *)0x0 },
-  { ISFUNC, (Function *)0x0 },
-  { ISFUNC, (Function *)0x0 },
-  { ISFUNC, (Function *)0x0 },
-  { ISFUNC, (Function *)0x0 },
-  { ISFUNC, (Function *)0x0 },
-  { ISFUNC, (Function *)0x0 },
-  { ISFUNC, (Function *)0x0 },
-  { ISFUNC, (Function *)0x0 },
-  { ISFUNC, (Function *)0x0 },
-  { ISFUNC, (Function *)0x0 },
-  { ISFUNC, (Function *)0x0 },
-  { ISFUNC, (Function *)0x0 },
-  { ISFUNC, (Function *)0x0 },
-  { ISFUNC, (Function *)0x0 },
-  { ISFUNC, (Function *)0x0 },
-  { ISFUNC, (Function *)0x0 },
-  { ISFUNC, (Function *)0x0 },
-  { ISFUNC, (Function *)0x0 },
-  { ISFUNC, (Function *)0x0 },
-  { ISFUNC, (Function *)0x0 },
-  { ISFUNC, (Function *)0x0 },
-  { ISFUNC, (Function *)0x0 },
-  { ISFUNC, (Function *)0x0 },
-  { ISFUNC, (Function *)0x0 },
-  { ISFUNC, (Function *)0x0 },
-  { ISFUNC, (Function *)0x0 },
-  { ISFUNC, (Function *)0x0 },
-  { ISFUNC, (Function *)0x0 },
-  { ISFUNC, (Function *)0x0 },
-  { ISFUNC, (Function *)0x0 },
-  { ISFUNC, (Function *)0x0 },
-  { ISFUNC, (Function *)0x0 },
-  { ISFUNC, (Function *)0x0 },
-  { ISFUNC, (Function *)0x0 },
-  { ISFUNC, (Function *)0x0 },
-  { ISFUNC, (Function *)0x0 },
-  { ISFUNC, (Function *)0x0 },
-  { ISFUNC, (Function *)0x0 },
-  { ISFUNC, (Function *)0x0 },
-  { ISFUNC, (Function *)0x0 },
-  { ISFUNC, (Function *)0x0 },
-  { ISFUNC, (Function *)0x0 },
-  { ISFUNC, (Function *)0x0 },
-  { ISFUNC, (Function *)0x0 },
-  { ISFUNC, (Function *)0x0 },
-  { ISFUNC, (Function *)0x0 },
-  { ISFUNC, (Function *)0x0 },
-  { ISFUNC, (Function *)0x0 },
-  { ISFUNC, (Function *)0x0 },
-  { ISFUNC, (Function *)0x0 },
-  { ISFUNC, (Function *)0x0 },
-  { ISFUNC, (Function *)0x0 },
-  { ISFUNC, (Function *)0x0 },
-  { ISFUNC, (Function *)0x0 },
-  { ISFUNC, (Function *)0x0 },
-  { ISFUNC, (Function *)0x0 },
-  { ISFUNC, (Function *)0x0 },
-  { ISFUNC, (Function *)0x0 },
-  { ISFUNC, (Function *)0x0 },
-  { ISFUNC, (Function *)0x0 },
-  { ISFUNC, (Function *)0x0 },
-  { ISFUNC, (Function *)0x0 },
-  { ISFUNC, (Function *)0x0 },
-  { ISFUNC, (Function *)0x0 },
-  { ISFUNC, (Function *)0x0 },
-  { ISFUNC, (Function *)0x0 },
-  { ISFUNC, (Function *)0x0 },
-  { ISFUNC, (Function *)0x0 },
-  { ISFUNC, (Function *)0x0 },
-  { ISFUNC, (Function *)0x0 },
-  { ISFUNC, (Function *)0x0 },
-  { ISFUNC, (Function *)0x0 },
-  { ISFUNC, (Function *)0x0 },
-  { ISFUNC, (Function *)0x0 },
-  { ISFUNC, (Function *)0x0 },
-  { ISFUNC, (Function *)0x0 },
-  { ISFUNC, (Function *)0x0 },
-  { ISFUNC, (Function *)0x0 },
-  { ISFUNC, (Function *)0x0 },
-  { ISFUNC, (Function *)0x0 },
-  { ISFUNC, (Function *)0x0 },
-  { ISFUNC, (Function *)0x0 },
-  { ISFUNC, (Function *)0x0 },
-  { ISFUNC, (Function *)0x0 },
-  { ISFUNC, (Function *)0x0 },
-  { ISFUNC, (Function *)0x0 },
-  { ISFUNC, (Function *)0x0 }
+  { ISFUNC, (rl_command_func_t *)0x0 },
+  { ISFUNC, (rl_command_func_t *)0x0 },
+  { ISFUNC, (rl_command_func_t *)0x0 },
+  { ISFUNC, (rl_command_func_t *)0x0 },
+  { ISFUNC, (rl_command_func_t *)0x0 },
+  { ISFUNC, (rl_command_func_t *)0x0 },
+  { ISFUNC, (rl_command_func_t *)0x0 },
+  { ISFUNC, (rl_command_func_t *)0x0 },
+  { ISFUNC, (rl_command_func_t *)0x0 },
+  { ISFUNC, (rl_command_func_t *)0x0 },
+  { ISFUNC, (rl_command_func_t *)0x0 },
+  { ISFUNC, (rl_command_func_t *)0x0 },
+  { ISFUNC, (rl_command_func_t *)0x0 },
+  { ISFUNC, (rl_command_func_t *)0x0 },
+  { ISFUNC, (rl_command_func_t *)0x0 },
+  { ISFUNC, (rl_command_func_t *)0x0 },
+  { ISFUNC, (rl_command_func_t *)0x0 },
+  { ISFUNC, (rl_command_func_t *)0x0 },
+  { ISFUNC, (rl_command_func_t *)0x0 },
+  { ISFUNC, (rl_command_func_t *)0x0 },
+  { ISFUNC, (rl_command_func_t *)0x0 },
+  { ISFUNC, (rl_command_func_t *)0x0 },
+  { ISFUNC, (rl_command_func_t *)0x0 },
+  { ISFUNC, (rl_command_func_t *)0x0 },
+  { ISFUNC, (rl_command_func_t *)0x0 },
+  { ISFUNC, (rl_command_func_t *)0x0 },
+  { ISFUNC, (rl_command_func_t *)0x0 },
+  { ISFUNC, (rl_command_func_t *)0x0 },
+  { ISFUNC, (rl_command_func_t *)0x0 },
+  { ISFUNC, (rl_command_func_t *)0x0 },
+  { ISFUNC, (rl_command_func_t *)0x0 },
+  { ISFUNC, (rl_command_func_t *)0x0 },
+  { ISFUNC, (rl_command_func_t *)0x0 },
+  { ISFUNC, (rl_command_func_t *)0x0 },
+  { ISFUNC, (rl_command_func_t *)0x0 },
+  { ISFUNC, (rl_command_func_t *)0x0 },
+  { ISFUNC, (rl_command_func_t *)0x0 },
+  { ISFUNC, (rl_command_func_t *)0x0 },
+  { ISFUNC, (rl_command_func_t *)0x0 },
+  { ISFUNC, (rl_command_func_t *)0x0 },
+  { ISFUNC, (rl_command_func_t *)0x0 },
+  { ISFUNC, (rl_command_func_t *)0x0 },
+  { ISFUNC, (rl_command_func_t *)0x0 },
+  { ISFUNC, (rl_command_func_t *)0x0 },
+  { ISFUNC, (rl_command_func_t *)0x0 },
+  { ISFUNC, (rl_command_func_t *)0x0 },
+  { ISFUNC, (rl_command_func_t *)0x0 },
+  { ISFUNC, (rl_command_func_t *)0x0 },
+  { ISFUNC, (rl_command_func_t *)0x0 },
+  { ISFUNC, (rl_command_func_t *)0x0 },
+  { ISFUNC, (rl_command_func_t *)0x0 },
+  { ISFUNC, (rl_command_func_t *)0x0 },
+  { ISFUNC, (rl_command_func_t *)0x0 },
+  { ISFUNC, (rl_command_func_t *)0x0 },
+  { ISFUNC, (rl_command_func_t *)0x0 },
+  { ISFUNC, (rl_command_func_t *)0x0 },
+  { ISFUNC, (rl_command_func_t *)0x0 },
+  { ISFUNC, (rl_command_func_t *)0x0 },
+  { ISFUNC, (rl_command_func_t *)0x0 },
+  { ISFUNC, (rl_command_func_t *)0x0 },
+  { ISFUNC, (rl_command_func_t *)0x0 },
+  { ISFUNC, (rl_command_func_t *)0x0 },
+  { ISFUNC, (rl_command_func_t *)0x0 },
+  { ISFUNC, (rl_command_func_t *)0x0 },
+  { ISFUNC, (rl_command_func_t *)0x0 },
+  { ISFUNC, (rl_command_func_t *)0x0 },
+  { ISFUNC, (rl_command_func_t *)0x0 },
+  { ISFUNC, (rl_command_func_t *)0x0 },
+  { ISFUNC, (rl_command_func_t *)0x0 },
+  { ISFUNC, (rl_command_func_t *)0x0 },
+  { ISFUNC, (rl_command_func_t *)0x0 },
+  { ISFUNC, (rl_command_func_t *)0x0 },
+  { ISFUNC, (rl_command_func_t *)0x0 },
+  { ISFUNC, (rl_command_func_t *)0x0 },
+  { ISFUNC, (rl_command_func_t *)0x0 },
+  { ISFUNC, (rl_command_func_t *)0x0 },
+  { ISFUNC, (rl_command_func_t *)0x0 },
+  { ISFUNC, (rl_command_func_t *)0x0 },
+  { ISFUNC, (rl_command_func_t *)0x0 },
+  { ISFUNC, (rl_command_func_t *)0x0 },
+  { ISFUNC, (rl_command_func_t *)0x0 },
+  { ISFUNC, (rl_command_func_t *)0x0 },
+  { ISFUNC, (rl_command_func_t *)0x0 },
+  { ISFUNC, (rl_command_func_t *)0x0 },
+  { ISFUNC, (rl_command_func_t *)0x0 },
+  { ISFUNC, (rl_command_func_t *)0x0 },
+  { ISFUNC, (rl_command_func_t *)0x0 },
+  { ISFUNC, (rl_command_func_t *)0x0 },
+  { ISFUNC, (rl_command_func_t *)0x0 },
+  { ISFUNC, (rl_command_func_t *)0x0 },
+  { ISFUNC, (rl_command_func_t *)0x0 },
+  { ISFUNC, (rl_command_func_t *)0x0 },
+  { ISFUNC, (rl_command_func_t *)0x0 },
+  { ISFUNC, (rl_command_func_t *)0x0 },
+  { ISFUNC, (rl_command_func_t *)0x0 },
+  { ISFUNC, (rl_command_func_t *)0x0 },
+  { ISFUNC, (rl_command_func_t *)0x0 },
+  { ISFUNC, (rl_command_func_t *)0x0 },
+  { ISFUNC, (rl_command_func_t *)0x0 },
+  { ISFUNC, (rl_command_func_t *)0x0 },
+  { ISFUNC, (rl_command_func_t *)0x0 },
+  { ISFUNC, (rl_command_func_t *)0x0 },
+  { ISFUNC, (rl_command_func_t *)0x0 },
+  { ISFUNC, (rl_command_func_t *)0x0 },
+  { ISFUNC, (rl_command_func_t *)0x0 },
+  { ISFUNC, (rl_command_func_t *)0x0 },
+  { ISFUNC, (rl_command_func_t *)0x0 },
+  { ISFUNC, (rl_command_func_t *)0x0 },
+  { ISFUNC, (rl_command_func_t *)0x0 },
+  { ISFUNC, (rl_command_func_t *)0x0 },
+  { ISFUNC, (rl_command_func_t *)0x0 },
+  { ISFUNC, (rl_command_func_t *)0x0 },
+  { ISFUNC, (rl_command_func_t *)0x0 },
+  { ISFUNC, (rl_command_func_t *)0x0 },
+  { ISFUNC, (rl_command_func_t *)0x0 },
+  { ISFUNC, (rl_command_func_t *)0x0 },
+  { ISFUNC, (rl_command_func_t *)0x0 },
+  { ISFUNC, (rl_command_func_t *)0x0 },
+  { ISFUNC, (rl_command_func_t *)0x0 },
+  { ISFUNC, (rl_command_func_t *)0x0 },
+  { ISFUNC, (rl_command_func_t *)0x0 },
+  { ISFUNC, (rl_command_func_t *)0x0 },
+  { ISFUNC, (rl_command_func_t *)0x0 },
+  { ISFUNC, (rl_command_func_t *)0x0 },
+  { ISFUNC, (rl_command_func_t *)0x0 },
+  { ISFUNC, (rl_command_func_t *)0x0 },
+  { ISFUNC, (rl_command_func_t *)0x0 },
+  { ISFUNC, (rl_command_func_t *)0x0 }
 #endif /* KEYMAP_SIZE > 128 */
 };
diff --git a/readline/funmap.c b/readline/funmap.c
index 472119bd80ade422a290b533facf2cc2f34e7bd3..fe9a1da43d7ee73fc05fe0b9be89c52164fbd257 100644
--- a/readline/funmap.c
+++ b/readline/funmap.c
@@ -7,7 +7,7 @@
 
    The GNU Readline Library is free software; you can redistribute it
    and/or modify it under the terms of the GNU General Public License
-   as published by the Free Software Foundation; either version 1, or
+   as published by the Free Software Foundation; either version 2, or
    (at your option) any later version.
 
    The GNU Readline Library is distributed in the hope that it will be
@@ -18,15 +18,13 @@
    The GNU General Public License is often shipped with GNU software, and
    is generally kept in a file called COPYING or LICENSE.  If you do not
    have a copy of the license, write to the Free Software Foundation,
-   675 Mass Ave, Cambridge, MA 02139, USA. */
+   59 Temple Place, Suite 330, Boston, MA 02111 USA. */
 #define READLINE_LIBRARY
 
 #if defined (HAVE_CONFIG_H)
 #  include <config.h>
 #endif
 
-extern char *xmalloc (), *xrealloc ();
-
 #if !defined (BUFSIZ)
 #include <stdio.h>
 #endif /* BUFSIZ */
@@ -40,7 +38,15 @@ extern char *xmalloc (), *xrealloc ();
 #include "rlconf.h"
 #include "readline.h"
 
-extern int _rl_qsort_string_compare ();
+#include "xmalloc.h"
+
+#ifdef __STDC__
+typedef int QSFUNC (const void *, const void *);
+#else
+typedef int QSFUNC ();
+#endif
+
+extern int _rl_qsort_string_compare PARAMS((char **, char **));
 
 FUNMAP **funmap;
 static int funmap_size;
@@ -54,7 +60,8 @@ static FUNMAP default_funmap[] = {
   { "abort", rl_abort },
   { "accept-line", rl_newline },
   { "arrow-key-prefix", rl_arrow_keys },
-  { "backward-char", rl_backward },
+  { "backward-byte", rl_backward_byte },
+  { "backward-char", rl_backward_char },
   { "backward-delete-char", rl_rubout },
   { "backward-kill-line", rl_backward_kill_line },
   { "backward-kill-word", rl_backward_kill_word },
@@ -85,7 +92,8 @@ static FUNMAP default_funmap[] = {
   { "end-of-line", rl_end_of_line },
   { "exchange-point-and-mark", rl_exchange_point_and_mark },
   { "forward-backward-delete-char", rl_rubout_or_delete },
-  { "forward-char", rl_forward },
+  { "forward-byte", rl_forward_byte },
+  { "forward-char", rl_forward_char },
   { "forward-search-history", rl_forward_search_history },
   { "forward-word", rl_forward_word },
   { "history-search-backward", rl_history_search_backward },
@@ -102,7 +110,8 @@ static FUNMAP default_funmap[] = {
   { "non-incremental-reverse-search-history", rl_noninc_reverse_search },
   { "non-incremental-forward-search-history-again", rl_noninc_forward_search_again },
   { "non-incremental-reverse-search-history-again", rl_noninc_reverse_search_again },
-#ifdef __CYGWIN32__
+  { "overwrite-mode", rl_overwrite_mode },
+#ifdef __CYGWIN__
   { "paste-from-clipboard", rl_paste_from_clipboard },
 #endif
   { "possible-completions", rl_possible_completions },
@@ -136,7 +145,6 @@ static FUNMAP default_funmap[] = {
   { "vi-arg-digit", rl_vi_arg_digit },
   { "vi-back-to-indent", rl_vi_back_to_indent },
   { "vi-bWord", rl_vi_bWord },
-  { "vi-bracktype", rl_vi_bracktype },
   { "vi-bword", rl_vi_bword },
   { "vi-change-case", rl_vi_change_case },
   { "vi-change-char", rl_vi_change_char },
@@ -176,18 +184,20 @@ static FUNMAP default_funmap[] = {
   { "vi-yank-to", rl_vi_yank_to },
 #endif /* VI_MODE */
 
- {(char *)NULL, (Function *)NULL }
+ {(char *)NULL, (rl_command_func_t *)NULL }
 };
 
 int
-rl_add_funmap_entry (const char *name, Function *function)
+rl_add_funmap_entry (name, function)
+     const char *name;
+     rl_command_func_t *function;
 {
   if (funmap_entry + 2 >= funmap_size)
     {
       funmap_size += 64;
       funmap = (FUNMAP **)xrealloc (funmap, funmap_size * sizeof (FUNMAP *));
     }
-
+  
   funmap[funmap_entry] = (FUNMAP *)xmalloc (sizeof (FUNMAP));
   funmap[funmap_entry]->name = name;
   funmap[funmap_entry]->function = function;
@@ -217,36 +227,27 @@ rl_initialize_funmap ()
 /* Produce a NULL terminated array of known function names.  The array
    is sorted.  The array itself is allocated, but not the strings inside.
    You should free () the array when you done, but not the pointrs. */
-char **
+const char **
 rl_funmap_names ()
 {
-  char **result;
+  const char **result;
   int result_size, result_index;
 
   /* Make sure that the function map has been initialized. */
   rl_initialize_funmap ();
 
-  for (result_index = result_size = 0, result = (char **)NULL; funmap[result_index]; result_index++)
+  for (result_index = result_size = 0, result = (const char **)NULL; funmap[result_index]; result_index++)
     {
       if (result_index + 2 > result_size)
 	{
 	  result_size += 20;
-	  result = (char **)xrealloc (result, result_size * sizeof (char *));
+	  result = (const char **)xrealloc (result, result_size * sizeof (char *));
 	}
 
-      result[result_index] = (char*) funmap[result_index]->name;
+      result[result_index] = funmap[result_index]->name;
       result[result_index + 1] = (char *)NULL;
     }
 
-  qsort (result, result_index, sizeof (char *), _rl_qsort_string_compare);
+  qsort (result, result_index, sizeof (char *), (QSFUNC *)_rl_qsort_string_compare);
   return (result);
 }
-
-/* Things that mean `Control'. */
-const char *possible_control_prefixes[] = {
-  "Control-", "C-", "CTRL-", (char *)NULL
-};
-
-const char *possible_meta_prefixes[] = {
-  "Meta", "M-", (char *)NULL
-};
diff --git a/readline/histexpand.c b/readline/histexpand.c
index f78838ef2ba518fd1b083c4cf300524c09ace823..f01d54c5b1dc65d7326c5913682dc8d1d1063e25 100644
--- a/readline/histexpand.c
+++ b/readline/histexpand.c
@@ -7,7 +7,7 @@
 
    The Library is free software; you can redistribute it and/or modify
    it under the terms of the GNU General Public License as published by
-   the Free Software Foundation; either version 1, or (at your option)
+   the Free Software Foundation; either version 2, or (at your option)
    any later version.
 
    The Library is distributed in the hope that it will be useful, but
@@ -18,7 +18,7 @@
    The GNU General Public License is often shipped with GNU software, and
    is generally kept in a file called COPYING or LICENSE.  If you do not
    have a copy of the license, write to the Free Software Foundation,
-   675 Mass Ave, Cambridge, MA 02139, USA. */
+   59 Temple Place, Suite 330, Boston, MA 02111 USA. */
 
 #define READLINE_LIBRARY
 
@@ -41,18 +41,21 @@
 #  include <unistd.h>
 #endif
 
-#if defined (HAVE_STRING_H)
-#  include <string.h>
-#else
-#  include <strings.h>
-#endif /* !HAVE_STRING_H */
+#include "rlmbutil.h"
 
 #include "history.h"
 #include "histlib.h"
 
+#include "rlshell.h"
+#include "xmalloc.h"
+
 #define HISTORY_WORD_DELIMITERS		" \t\n;&()|<>"
 #define HISTORY_QUOTE_CHARACTERS	"\"'`"
 
+typedef int _hist_search_func_t PARAMS((const char *, int));
+
+extern int rl_byte_oriented;	/* declared in mbutil.c */
+
 static char error_pointer;
 
 static char *subst_lhs;
@@ -60,15 +63,10 @@ static char *subst_rhs;
 static int subst_lhs_len;
 static int subst_rhs_len;
 
-static char *get_history_word_specifier ();
-static char *history_find_word ();
+static char *get_history_word_specifier PARAMS((char *, char *, int *));
+static char *history_find_word PARAMS((char *, int));
 
-extern int history_offset;
-
-extern char *single_quote ();
-static char *quote_breaks ();
-
-extern char *xmalloc (), *xrealloc ();
+static char *quote_breaks PARAMS((char *));
 
 /* Variables exported by this file. */
 /* The character that represents the start of a history expansion
@@ -93,9 +91,12 @@ const char *history_no_expand_chars = " \t\n\r=";
    The default is 0. */
 int history_quotes_inhibit_expansion = 0;
 
+/* Used to split words by history_tokenize_internal. */
+const char *history_word_delimiters = HISTORY_WORD_DELIMITERS;
+
 /* If set, this points to a function that is called to verify that a
    particular history expansion should be performed. */
-Function *history_inhibit_expansion_function;
+rl_linebuf_func_t *history_inhibit_expansion_function;
 
 /* **************************************************************** */
 /*								    */
@@ -124,7 +125,7 @@ static char *search_match;
    line = get_history_event ("!echo:p", &index, 0);  */
 char *
 get_history_event (string, caller_index, delimiting_quote)
-     char *string;
+     const char *string;
      int *caller_index;
      int delimiting_quote;
 {
@@ -132,7 +133,7 @@ get_history_event (string, caller_index, delimiting_quote)
   register char c;
   HIST_ENTRY *entry;
   int which, sign, local_index, substring_okay;
-  Function *search_func;
+  _hist_search_func_t *search_func;
   char *temp;
 
   /* The event can be specified in a number of ways.
@@ -201,15 +202,33 @@ get_history_event (string, caller_index, delimiting_quote)
 
   /* Only a closing `?' or a newline delimit a substring search string. */
   for (local_index = i; (c = string[i]); i++)
-    if ((!substring_okay && (whitespace (c) || c == ':' ||
-	(history_search_delimiter_chars && member (c, history_search_delimiter_chars)) ||
-	string[i] == delimiting_quote)) ||
-	string[i] == '\n' ||
-	(substring_okay && string[i] == '?'))
-      break;
+#if defined (HANDLE_MULTIBYTE)
+    if (MB_CUR_MAX > 1 && rl_byte_oriented == 0)
+      {
+	int v;
+	mbstate_t ps;
+
+	memset (&ps, 0, sizeof (mbstate_t));
+	/* These produce warnings because we're passing a const string to a
+	   function that takes a non-const string. */
+	_rl_adjust_point (string, i, &ps);
+	if ((v = _rl_get_char_len (string + i, &ps)) > 1)
+	  {
+	    i += v - 1;
+	    continue;
+	  }
+      }
+    else
+#endif /* HANDLE_MULTIBYTE */
+      if ((!substring_okay && (whitespace (c) || c == ':' ||
+	  (history_search_delimiter_chars && member (c, history_search_delimiter_chars)) ||
+	  string[i] == delimiting_quote)) ||
+	  string[i] == '\n' ||
+	  (substring_okay && string[i] == '?'))
+	break;
 
   which = i - local_index;
-  temp = xmalloc (1 + which);
+  temp = (char *)xmalloc (1 + which);
   if (which)
     strncpy (temp, string + local_index, which);
   temp[which] = '\0';
@@ -249,7 +268,7 @@ get_history_event (string, caller_index, delimiting_quote)
 	{
 	  entry = current_history ();
 	  history_offset = history_length;
-
+	
 	  /* If this was a substring search, then remember the
 	     string that we matched for word substitution. */
 	  if (substring_okay)
@@ -311,7 +330,7 @@ quote_breaks (s)
 	len += 2;
     }
 
-  r = ret = xmalloc (len);
+  r = ret = (char *)xmalloc (len);
   *r++ = '\'';
   for (p = s; p && *p; )
     {
@@ -376,7 +395,7 @@ hist_error(s, start, current, errtype)
       break;
     }
 
-  temp = xmalloc (ll + elen + 3);
+  temp = (char *)xmalloc (ll + elen + 3);
   strncpy (temp, s + start, ll);
   temp[ll] = ':';
   temp[ll + 1] = ' ';
@@ -402,17 +421,37 @@ get_subst_pattern (str, iptr, delimiter, is_rhs, lenptr)
      int *iptr, delimiter, is_rhs, *lenptr;
 {
   register int si, i, j, k;
-  char *s = (char *) NULL;
+  char *s;
+#if defined (HANDLE_MULTIBYTE)
+  mbstate_t ps;
+#endif
 
+  s = (char *)NULL;
   i = *iptr;
 
+#if defined (HANDLE_MULTIBYTE)
+  memset (&ps, 0, sizeof (mbstate_t));
+  _rl_adjust_point (str, i, &ps);
+#endif
+
   for (si = i; str[si] && str[si] != delimiter; si++)
-    if (str[si] == '\\' && str[si + 1] == delimiter)
-      si++;
+#if defined (HANDLE_MULTIBYTE)
+    if (MB_CUR_MAX > 1 && rl_byte_oriented == 0)
+      {
+	int v;
+	if ((v = _rl_get_char_len (str + si, &ps)) > 1)
+	  si += v - 1;
+	else if (str[si] == '\\' && str[si + 1] == delimiter)
+	  si++;
+      }
+    else
+#endif /* HANDLE_MULTIBYTE */
+      if (str[si] == '\\' && str[si + 1] == delimiter)
+	si++;
 
   if (si > i || is_rhs)
     {
-      s = xmalloc (si - i + 1);
+      s = (char *)xmalloc (si - i + 1);
       for (j = 0, k = i; k < si; j++, k++)
 	{
 	  /* Remove a backslash quoting the search string delimiter. */
@@ -439,13 +478,13 @@ postproc_subst_rhs ()
   char *new;
   int i, j, new_size;
 
-  new = xmalloc (new_size = subst_rhs_len + subst_lhs_len);
+  new = (char *)xmalloc (new_size = subst_rhs_len + subst_lhs_len);
   for (i = j = 0; i < subst_rhs_len; i++)
     {
       if (subst_rhs[i] == '&')
 	{
 	  if (j + subst_lhs_len >= new_size)
-	    new = xrealloc (new, (new_size = new_size * 2 + subst_lhs_len));
+	    new = (char *)xrealloc (new, (new_size = new_size * 2 + subst_lhs_len));
 	  strcpy (new + j, subst_lhs);
 	  j += subst_lhs_len;
 	}
@@ -455,7 +494,7 @@ postproc_subst_rhs ()
 	  if (subst_rhs[i] == '\\' && subst_rhs[i + 1] == '&')
 	    i++;
 	  if (j >= new_size)
-	    new = xrealloc (new, new_size *= 2);
+	    new = (char *)xrealloc (new, new_size *= 2);
 	  new[j++] = subst_rhs[i];
 	}
     }
@@ -481,8 +520,13 @@ history_expand_internal (string, start, end_index_ptr, ret_string, current_line)
   int substitute_globally, want_quotes, print_only;
   char *event, *temp, *result, *tstr, *t, c, *word_spec;
   int result_len;
+#if defined (HANDLE_MULTIBYTE)
+  mbstate_t ps;
 
-  result = xmalloc (result_len = 128);
+  memset (&ps, 0, sizeof (mbstate_t));
+#endif
+
+  result = (char *)xmalloc (result_len = 128);
 
   i = start;
 
@@ -511,11 +555,24 @@ history_expand_internal (string, start, end_index_ptr, ret_string, current_line)
 	 quote, then this expansion takes place inside of the
 	 quoted string.  If we have to search for some text ("!foo"),
 	 allow the delimiter to end the search string. */
-      if (i && (string[i - 1] == '\'' || string[i - 1] == '"'))
-	quoted_search_delimiter = string[i - 1];
+#if defined (HANDLE_MULTIBYTE)
+      if (MB_CUR_MAX > 1 && rl_byte_oriented == 0)
+	{
+	  int c, l;
+	  l = _rl_find_prev_mbchar (string, i, MB_FIND_ANY);
+	  c = string[l];
+	  /* XXX - original patch had i - 1 ???  If i == 0 it would fail. */
+	  if (i && (c == '\'' || c == '"'))
+	    quoted_search_delimiter = c;
+	}
+      else
+#endif /* HANDLE_MULTIBYTE */	  
+	if (i && (string[i - 1] == '\'' || string[i - 1] == '"'))
+	  quoted_search_delimiter = string[i - 1];
+
       event = get_history_event (string, &i, quoted_search_delimiter);
     }
-
+	  
   if (event == 0)
     {
       *ret_string = hist_error (string, start, i, EVENT_NOT_FOUND);
@@ -625,13 +682,26 @@ history_expand_internal (string, start, end_index_ptr, ret_string, current_line)
 	case '&':
 	case 's':
 	  {
-	    char *new_event, *t;
+	    char *new_event;
 	    int delimiter, failed, si, l_temp;
 
 	    if (c == 's')
 	      {
 		if (i + 2 < (int)strlen (string))
-		  delimiter = string[i + 2];
+		  {
+#if defined (HANDLE_MULTIBYTE)
+		    if (MB_CUR_MAX > 1 && rl_byte_oriented == 0)
+		      {
+			_rl_adjust_point (string, i + 2, &ps);
+			if (_rl_get_char_len (string + i + 2, &ps) > 1)
+			  delimiter = 0;
+			else
+			  delimiter = string[i + 2];
+		      }
+		    else
+#endif /* HANDLE_MULTIBYTE */
+		      delimiter = string[i + 2];
+		  }
 		else
 		  break;	/* no search delimiter */
 
@@ -695,7 +765,7 @@ history_expand_internal (string, start, end_index_ptr, ret_string, current_line)
 	      if (STREQN (temp+si, subst_lhs, subst_lhs_len))
 		{
 		  int len = subst_rhs_len - subst_lhs_len + l_temp;
-		  new_event = xmalloc (1 + len);
+		  new_event = (char *)xmalloc (1 + len);
 		  strncpy (new_event, temp, si);
 		  strncpy (new_event + si, subst_rhs, subst_rhs_len);
 		  strncpy (new_event + si + subst_rhs_len,
@@ -744,7 +814,7 @@ history_expand_internal (string, start, end_index_ptr, ret_string, current_line)
       char *x;
 
       if (want_quotes == 'q')
-	x = single_quote (temp);
+	x = sh_single_quote (temp);
       else if (want_quotes == 'x')
 	x = quote_breaks (temp);
       else
@@ -756,7 +826,7 @@ history_expand_internal (string, start, end_index_ptr, ret_string, current_line)
 
   n = strlen (temp);
   if (n >= result_len)
-    result = xrealloc (result, n + 2);
+    result = (char *)xrealloc (result, n + 2);
   strcpy (result, temp);
   free (temp);
 
@@ -787,7 +857,7 @@ history_expand_internal (string, start, end_index_ptr, ret_string, current_line)
 	      { \
 		while (j >= result_len) \
 		  result_len += 128; \
-		result = xrealloc (result, result_len); \
+		result = (char *)xrealloc (result, result_len); \
 	      } \
 	    strcpy (result + j - sl, s); \
 	  } \
@@ -797,7 +867,7 @@ history_expand_internal (string, start, end_index_ptr, ret_string, current_line)
 	do \
 	  { \
 	    if (j >= result_len - 1) \
-	      result = xrealloc (result, result_len += 64); \
+	      result = (char *)xrealloc (result, result_len += 64); \
 	    result[j++] = c; \
 	    result[j] = '\0'; \
 	  } \
@@ -816,9 +886,17 @@ history_expand (hstring, output)
   int result_len;
   char *result;
 
+#if defined (HANDLE_MULTIBYTE)
+  char mb[MB_LEN_MAX];
+  mbstate_t ps;
+#endif
+
   /* Used when adding the string. */
   char *temp;
 
+  if (output == 0)
+    return 0;
+
   /* Setting the history expansion character to 0 inhibits all
      history expansion. */
   if (history_expansion_char == 0)
@@ -826,9 +904,9 @@ history_expand (hstring, output)
       *output = savestring (hstring);
       return (0);
     }
-
+    
   /* Prepare the buffer for printing error messages. */
-  result = xmalloc (result_len = 256);
+  result = (char *)xmalloc (result_len = 256);
   result[0] = '\0';
 
   only_printing = modified = 0;
@@ -845,7 +923,7 @@ history_expand (hstring, output)
      that is the substitution that we do. */
   if (hstring[0] == history_subst_char)
     {
-      string = xmalloc (l + 5);
+      string = (char *)xmalloc (l + 5);
 
       string[0] = string[1] = history_expansion_char;
       string[2] = ':';
@@ -855,6 +933,10 @@ history_expand (hstring, output)
     }
   else
     {
+#if defined (HANDLE_MULTIBYTE)
+      memset (&ps, 0, sizeof (mbstate_t));
+#endif
+
       string = hstring;
       /* If not quick substitution, still maybe have to do expansion. */
 
@@ -862,13 +944,26 @@ history_expand (hstring, output)
 	 is NOT an expansion. */
       for (i = 0; string[i]; i++)
 	{
+#if defined (HANDLE_MULTIBYTE)
+	  if (MB_CUR_MAX > 1 && rl_byte_oriented == 0)
+	    {
+	      int v;
+	      v = _rl_get_char_len (string + i, &ps);
+	      if (v > 1)
+		{
+		  i += v - 1;
+		  continue;
+		}
+	    }
+#endif /* HANDLE_MULTIBYTE */
+
 	  cc = string[i + 1];
-	  /* The history_comment_char, if set, appearing that the beginning
+	  /* The history_comment_char, if set, appearing at the beginning
 	     of a word signifies that the rest of the line should not have
 	     history expansion performed on it.
 	     Skip the rest of the line and break out of the loop. */
 	  if (history_comment_char && string[i] == history_comment_char &&
-	      (i == 0 || member (string[i - 1], HISTORY_WORD_DELIMITERS)))
+	      (i == 0 || member (string[i - 1], history_word_delimiters)))
 	    {
 	      while (string[i])
 		i++;
@@ -905,7 +1000,7 @@ history_expand (hstring, output)
 		i++;
 	    }
 	}
-
+	  
       if (string[i] != history_expansion_char)
 	{
 	  free (result);
@@ -926,6 +1021,30 @@ history_expand (hstring, output)
 	  continue;
 	}
 
+#if defined (HANDLE_MULTIBYTE)
+      if (MB_CUR_MAX > 1 && rl_byte_oriented == 0)
+	{
+	  int k, c;
+
+	  c = tchar;
+	  memset (mb, 0, sizeof (mb));
+	  for (k = 0; k < MB_LEN_MAX; k++)
+	    {
+	      mb[k] = (char)c;
+	      memset (&ps, 0, sizeof (mbstate_t));
+	      if (_rl_get_char_len (mb, &ps) == -2)
+		c = string[++i];
+	      else
+		break;
+	    }
+	  if (strlen (mb) > 1)
+	    {
+	      ADD_STRING (mb);
+	      break;
+	    }
+	}
+#endif /* HANDLE_MULTIBYTE */
+
       if (tchar == history_expansion_char)
 	tchar = -3;
       else if (tchar == history_comment_char)
@@ -954,7 +1073,7 @@ history_expand (hstring, output)
 		hist_string_extract_single_quoted (string, &i);
 
 		slen = i - quote + 2;
-		temp = xmalloc (slen);
+		temp = (char *)xmalloc (slen);
 		strncpy (temp, string + quote, slen);
 		temp[slen - 1] = '\0';
 		ADD_STRING (temp);
@@ -966,9 +1085,9 @@ history_expand (hstring, output)
 	  }
 
 	case -2:		/* history_comment_char */
-	  if (i == 0 || member (string[i - 1], HISTORY_WORD_DELIMITERS))
+	  if (i == 0 || member (string[i - 1], history_word_delimiters))
 	    {
-	      temp = xmalloc (l - i + 1);
+	      temp = (char *)xmalloc (l - i + 1);
 	      strcpy (temp, string + i);
 	      ADD_STRING (temp);
 	      free (temp);
@@ -1000,7 +1119,7 @@ history_expand (hstring, output)
 	    {
 	      if (result)
 		{
-		  temp = xmalloc (1 + strlen (result));
+		  temp = (char *)xmalloc (1 + strlen (result));
 		  strcpy (temp, result);
 		  ADD_STRING (temp);
 		  free (temp);
@@ -1134,7 +1253,14 @@ get_history_word_specifier (spec, from, caller_index)
 	  i++;
 	  last = '$';
 	}
-      else if (!spec[i] || spec[i] == ':')  /* could be modifier separator */
+#if 0
+      else if (!spec[i] || spec[i] == ':')
+	/* check against `:' because there could be a modifier separator */
+#else
+      else
+	/* csh seems to allow anything to terminate the word spec here,
+	   leaving it as an abbreviation. */
+#endif
 	last = -1;		/* x- abbreviates x-$ omitting word `$' */
     }
 
@@ -1154,7 +1280,7 @@ get_history_word_specifier (spec, from, caller_index)
 char *
 history_arg_extract (first, last, string)
      int first, last;
-     char *string;
+     const char *string;
 {
   register int i, len;
   char *result;
@@ -1190,7 +1316,7 @@ history_arg_extract (first, last, string)
     {
       for (size = 0, i = first; i < last; i++)
 	size += strlen (list[i]) + 1;
-      result = xmalloc (size + 1);
+      result = (char *)xmalloc (size + 1);
       result[0] = '\0';
 
       for (i = first, offset = 0; i < last; i++)
@@ -1220,13 +1346,18 @@ history_arg_extract (first, last, string)
    *INDP. */
 static char **
 history_tokenize_internal (string, wind, indp)
-     char *string;
+     const char *string;
      int wind, *indp;
 {
   char **result;
   register int i, start, result_index, size;
   int len, delimiter;
 
+  /* If we're searching for a string that's not part of a word (e.g., " "),
+     make sure we set *INDP to a reasonable value. */
+  if (indp && wind != -1)
+    *indp = -1;
+
   /* Get a token, and stuff it into RESULT.  The tokens are split
      exactly where the shell would split them. */
   for (i = result_index = size = 0, result = (char **)NULL; string[i]; )
@@ -1240,7 +1371,7 @@ history_tokenize_internal (string, wind, indp)
 	return (result);
 
       start = i;
-
+      
       if (member (string[i], "()\n"))
 	{
 	  i++;
@@ -1301,7 +1432,7 @@ history_tokenize_internal (string, wind, indp)
 	      continue;
 	    }
 
-	  if (!delimiter && (member (string[i], HISTORY_WORD_DELIMITERS)))
+	  if (!delimiter && (member (string[i], history_word_delimiters)))
 	    break;
 
 	  if (!delimiter && member (string[i], HISTORY_QUOTE_CHARACTERS))
@@ -1318,7 +1449,7 @@ history_tokenize_internal (string, wind, indp)
       len = i - start;
       if (result_index + 2 >= size)
 	result = (char **)xrealloc (result, ((size += 10) * sizeof (char *)));
-      result[result_index] = xmalloc (1 + len);
+      result[result_index] = (char *)xmalloc (1 + len);
       strncpy (result[result_index], string + start, len);
       result[result_index][len] = '\0';
       result[++result_index] = (char *)NULL;
@@ -1331,7 +1462,7 @@ history_tokenize_internal (string, wind, indp)
    parsed out of STRING. */
 char **
 history_tokenize (string)
-     char *string;
+     const char *string;
 {
   return (history_tokenize_internal (string, -1, (int *)NULL));
 }
@@ -1348,7 +1479,7 @@ history_find_word (line, ind)
   int i, wind;
 
   words = history_tokenize_internal (line, ind, &wind);
-  if (wind == -1)
+  if (wind == -1 || words == 0)
     return ((char *)NULL);
   s = words[wind];
   for (i = 0; i < wind; i++)
diff --git a/readline/histfile.c b/readline/histfile.c
index 1da45b00b58eb40d192c07f787f7dd26b0e8589f..60a91251b7aec1a754ce02ca0623e7bde4c6b8fb 100644
--- a/readline/histfile.c
+++ b/readline/histfile.c
@@ -7,7 +7,7 @@
 
    The Library is free software; you can redistribute it and/or modify
    it under the terms of the GNU General Public License as published by
-   the Free Software Foundation; either version 1, or (at your option)
+   the Free Software Foundation; either version 2, or (at your option)
    any later version.
 
    The Library is distributed in the hope that it will be useful, but
@@ -18,7 +18,7 @@
    The GNU General Public License is often shipped with GNU software, and
    is generally kept in a file called COPYING or LICENSE.  If you do not
    have a copy of the license, write to the Free Software Foundation,
-   675 Mass Ave, Cambridge, MA 02139, USA. */
+   59 Temple Place, Suite 330, Boston, MA 02111 USA. */
 
 /* The goal is to make the implementation transparent, so that you
    don't have to know what data types are used, just what functions
@@ -35,7 +35,7 @@
 #ifndef _MINIX
 #  include <sys/file.h>
 #endif
-#include <sys/stat.h>
+#include "posixstat.h"
 #include <fcntl.h>
 
 #if defined (HAVE_STDLIB_H)
@@ -48,21 +48,39 @@
 #  include <unistd.h>
 #endif
 
-#if defined (HAVE_STRING_H)
-#  include <string.h>
-#else
-#  include <strings.h>
-#endif /* !HAVE_STRING_H */
+#if defined (__EMX__) || defined (__CYGWIN__)
+#  undef HAVE_MMAP
+#endif
+
+#ifdef HAVE_MMAP
+#  include <sys/mman.h>
+
+#  ifdef MAP_FILE
+#    define MAP_RFLAGS	(MAP_FILE|MAP_PRIVATE)
+#    define MAP_WFLAGS	(MAP_FILE|MAP_SHARED)
+#  else
+#    define MAP_RFLAGS	MAP_PRIVATE
+#    define MAP_WFLAGS	MAP_SHARED
+#  endif
+
+#  ifndef MAP_FAILED
+#    define MAP_FAILED	((void *)-1)
+#  endif
+
+#endif /* HAVE_MMAP */
 
-#if defined (__EMX__)
+/* If we're compiling for __EMX__ (OS/2) or __CYGWIN__ (cygwin32 environment
+   on win 95/98/nt), we want to open files with O_BINARY mode so that there
+   is no \n -> \r\n conversion performed.  On other systems, we don't want to
+   mess around with O_BINARY at all, so we ensure that it's defined to 0. */
+#if defined (__EMX__) || defined (__CYGWIN__)
 #  ifndef O_BINARY
 #    define O_BINARY 0
 #  endif
-#else /* !__EMX__ */
-   /* If we're not compiling for __EMX__, we don't want this at all.  Ever. */
+#else /* !__EMX__ && !__CYGWIN__ */
 #  undef O_BINARY
 #  define O_BINARY 0
-#endif /* !__EMX__ */
+#endif /* !__EMX__ && !__CYGWIN__ */
 
 #include <errno.h>
 #if !defined (errno)
@@ -72,17 +90,15 @@ extern int errno;
 #include "history.h"
 #include "histlib.h"
 
-/* Functions imported from shell.c */
-extern char *get_env_value ();
-
-extern char *xmalloc (), *xrealloc ();
+#include "rlshell.h"
+#include "xmalloc.h"
 
 /* Return the string that should be used in the place of this
    filename.  This only matters when you don't specify the
    filename to read_history (), or write_history (). */
 static char *
 history_filename (filename)
-     char *filename;
+     const char *filename;
 {
   char *return_val;
   const char *home;
@@ -92,8 +108,8 @@ history_filename (filename)
 
   if (return_val)
     return (return_val);
-
-  home = get_env_value ("HOME");
+  
+  home = sh_get_env_value ("HOME");
 
   if (home == 0)
     {
@@ -103,10 +119,14 @@ history_filename (filename)
   else
     home_len = strlen (home);
 
-  return_val = xmalloc (2 + home_len + 8); /* strlen(".history") == 8 */
+  return_val = (char *)xmalloc (2 + home_len + 8); /* strlen(".history") == 8 */
   strcpy (return_val, home);
   return_val[home_len] = '/';
+#if defined (__MSDOS__)
+  strcpy (return_val + home_len + 1, "_history");
+#else
   strcpy (return_val + home_len + 1, ".history");
+#endif
 
   return (return_val);
 }
@@ -116,7 +136,7 @@ history_filename (filename)
    successful, or errno if not. */
 int
 read_history (filename)
-     char *filename;
+     const char *filename;
 {
   return (read_history_range (filename, 0, -1));
 }
@@ -128,13 +148,14 @@ read_history (filename)
    ~/.history.  Returns 0 if successful, or errno if not. */
 int
 read_history_range (filename, from, to)
-     char *filename;
+     const char *filename;
      int from, to;
 {
-  char *input, *buffer;
-  int file, current_line;
+  register char *line_start, *line_end;
+  char *input, *buffer, *bufend;
+  int file, current_line, chars_read;
   struct stat finfo;
-  size_t line_start, line_end, file_size;
+  size_t file_size;
 
   buffer = (char *)NULL;
   input = history_filename (filename);
@@ -150,57 +171,67 @@ read_history_range (filename, from, to)
     {
 #if defined (EFBIG)
       errno = EFBIG;
+#elif defined (EOVERFLOW)
+      errno = EOVERFLOW;
 #endif
       goto error_and_exit;
     }
 
-  buffer = xmalloc (file_size + 1);
-#if 0
-  if (read (file, buffer, file_size) != file_size)
+#ifdef HAVE_MMAP
+  /* We map read/write and private so we can change newlines to NULs without
+     affecting the underlying object. */
+  buffer = (char *)mmap (0, file_size, PROT_READ|PROT_WRITE, MAP_RFLAGS, file, 0);
+  if ((void *)buffer == MAP_FAILED)
+    goto error_and_exit;
+  chars_read = file_size;
 #else
-  if (read (file, buffer, file_size) < 0)
+  buffer = (char *)malloc (file_size + 1);
+  if (buffer == 0)
+    goto error_and_exit;
+
+  chars_read = read (file, buffer, file_size);
 #endif
+  if (chars_read < 0)
     {
   error_and_exit:
+      chars_read = errno;
       if (file >= 0)
 	close (file);
 
       FREE (input);
+#ifndef HAVE_MMAP
       FREE (buffer);
+#endif
 
-      return (errno);
+      return (chars_read);
     }
 
   close (file);
 
   /* Set TO to larger than end of file if negative. */
   if (to < 0)
-    to = file_size;
+    to = chars_read;
 
   /* Start at beginning of file, work to end. */
-  line_start = line_end = current_line = 0;
+  bufend = buffer + chars_read;
+  current_line = 0;
 
   /* Skip lines until we are at FROM. */
-  while (line_start < file_size && current_line < from)
-    {
-      for (line_end = line_start; line_end < file_size; line_end++)
-	if (buffer[line_end] == '\n')
-	  {
-	    current_line++;
-	    line_start = line_end + 1;
-	    if (current_line == from)
-	      break;
-	  }
-    }
+  for (line_start = line_end = buffer; line_end < bufend && current_line < from; line_end++)
+    if (*line_end == '\n')
+      {
+	current_line++;
+	line_start = line_end + 1;
+      }
 
   /* If there are lines left to gobble, then gobble them now. */
-  for (line_end = line_start; line_end < file_size; line_end++)
-    if (buffer[line_end] == '\n')
+  for (line_end = line_start; line_end < bufend; line_end++)
+    if (*line_end == '\n')
       {
-	buffer[line_end] = '\0';
+	*line_end = '\0';
 
-	if (buffer[line_start])
-	  add_history (buffer + line_start);
+	if (*line_start)
+	  add_history (line_start);
 
 	current_line++;
 
@@ -211,30 +242,52 @@ read_history_range (filename, from, to)
       }
 
   FREE (input);
+#ifndef HAVE_MMAP
   FREE (buffer);
+#else
+  munmap (buffer, file_size);
+#endif
 
   return (0);
 }
 
 /* Truncate the history file FNAME, leaving only LINES trailing lines.
-   If FNAME is NULL, then use ~/.history. */
+   If FNAME is NULL, then use ~/.history.  Returns 0 on success, errno
+   on failure. */
 int
 history_truncate_file (fname, lines)
-     char *fname;
+     const char *fname;
      int lines;
 {
-  register int i;
-  int file, chars_read;
-  char *buffer, *filename;
+  char *buffer, *filename, *bp;
+  int file, chars_read, rv;
   struct stat finfo;
   size_t file_size;
 
   buffer = (char *)NULL;
   filename = history_filename (fname);
   file = open (filename, O_RDONLY|O_BINARY, 0666);
+  rv = 0;
 
+  /* Don't try to truncate non-regular files. */
   if (file == -1 || fstat (file, &finfo) == -1)
-    goto truncate_exit;
+    {
+      rv = errno;
+      if (file != -1)
+	close (file);
+      goto truncate_exit;
+    }
+
+  if (S_ISREG (finfo.st_mode) == 0)
+    {
+      close (file);
+#ifdef EFTYPE
+      rv = EFTYPE;
+#else
+      rv = EINVAL;
+#endif
+      goto truncate_exit;
+    }
 
   file_size = (size_t)finfo.st_size;
 
@@ -243,23 +296,36 @@ history_truncate_file (fname, lines)
     {
       close (file);
 #if defined (EFBIG)
-      errno = EFBIG;
+      rv = errno = EFBIG;
+#elif defined (EOVERFLOW)
+      rv = errno = EOVERFLOW;
+#else
+      rv = errno = EINVAL;
 #endif
       goto truncate_exit;
     }
 
-  buffer = xmalloc (file_size + 1);
+  buffer = (char *)malloc (file_size + 1);
+  if (buffer == 0)
+    {
+      close (file);
+      goto truncate_exit;
+    }
+
   chars_read = read (file, buffer, file_size);
   close (file);
 
   if (chars_read <= 0)
-    goto truncate_exit;
+    {
+      rv = (chars_read < 0) ? errno : 0;
+      goto truncate_exit;
+    }
 
   /* Count backwards from the end of buffer until we have passed
      LINES lines. */
-  for (i = chars_read - 1; lines && i; i--)
+  for (bp = buffer + chars_read - 1; lines && bp > buffer; bp--)
     {
-      if (buffer[i] == '\n')
+      if (*bp == '\n')
 	lines--;
     }
 
@@ -268,22 +334,22 @@ history_truncate_file (fname, lines)
      anything.  It's the first line if we don't find a newline between
      the current value of i and 0.  Otherwise, write from the start of
      this line until the end of the buffer. */
-  for ( ; i; i--)
-    if (buffer[i] == '\n')
+  for ( ; bp > buffer; bp--)
+    if (*bp == '\n')
       {
-	i++;
+	bp++;
 	break;
       }
 
   /* Write only if there are more lines in the file than we want to
      truncate to. */
-  if (i && ((file = open (filename, O_WRONLY|O_TRUNC|O_BINARY, 0600)) != -1))
+  if (bp > buffer && ((file = open (filename, O_WRONLY|O_TRUNC|O_BINARY, 0600)) != -1))
     {
-      write (file, buffer + i, file_size - i);
+      write (file, bp, chars_read - (bp - buffer));
 
 #if defined (__BEOS__)
       /* BeOS ignores O_TRUNC. */
-      ftruncate (file, file_size - i);
+      ftruncate (file, chars_read - (bp - buffer));
 #endif
 
       close (file);
@@ -294,7 +360,7 @@ history_truncate_file (fname, lines)
   FREE (buffer);
 
   free (filename);
-  return 0;
+  return rv;
 }
 
 /* Workhorse function for writing history.  Writes NELEMENT entries
@@ -302,15 +368,21 @@ history_truncate_file (fname, lines)
    wish to replace FILENAME with the entries. */
 static int
 history_do_write (filename, nelements, overwrite)
-     char *filename;
+     const char *filename;
      int nelements, overwrite;
 {
   register int i;
   char *output;
-  int file, mode;
+  int file, mode, rv;
+  size_t cursize;
 
+#ifdef HAVE_MMAP
+  mode = overwrite ? O_RDWR|O_CREAT|O_TRUNC|O_BINARY : O_RDWR|O_APPEND|O_BINARY;
+#else
   mode = overwrite ? O_WRONLY|O_CREAT|O_TRUNC|O_BINARY : O_WRONLY|O_APPEND|O_BINARY;
+#endif
   output = history_filename (filename);
+  rv = 0;
 
   if ((file = open (output, mode, 0600)) == -1)
     {
@@ -318,6 +390,10 @@ history_do_write (filename, nelements, overwrite)
       return (errno);
     }
 
+#ifdef HAVE_MMAP
+  cursize = overwrite ? 0 : lseek (file, 0, SEEK_END);
+#endif
+
   if (nelements > history_length)
     nelements = history_length;
 
@@ -335,7 +411,28 @@ history_do_write (filename, nelements, overwrite)
       buffer_size += 1 + strlen (the_history[i]->line);
 
     /* Allocate the buffer, and fill it. */
-    buffer = xmalloc (buffer_size);
+#ifdef HAVE_MMAP
+    if (ftruncate (file, buffer_size+cursize) == -1)
+      goto mmap_error;
+    buffer = (char *)mmap (0, buffer_size, PROT_READ|PROT_WRITE, MAP_WFLAGS, file, cursize);
+    if ((void *)buffer == MAP_FAILED)
+      {
+mmap_error:
+	rv = errno;
+	FREE (output);
+	close (file);
+	return rv;
+      }
+#else    
+    buffer = (char *)malloc (buffer_size);
+    if (buffer == 0)
+      {
+      	rv = errno;
+	FREE (output);
+	close (file);
+	return rv;
+      }
+#endif
 
     for (j = 0, i = history_length - nelements; i < history_length; i++)
       {
@@ -344,15 +441,21 @@ history_do_write (filename, nelements, overwrite)
 	buffer[j++] = '\n';
       }
 
-    write (file, buffer, buffer_size);
+#ifdef HAVE_MMAP
+    if (msync (buffer, buffer_size, 0) != 0 || munmap (buffer, buffer_size) != 0)
+      rv = errno;
+#else
+    if (write (file, buffer, buffer_size) < 0)
+      rv = errno;
     free (buffer);
+#endif
   }
 
   close (file);
 
   FREE (output);
 
-  return (0);
+  return (rv);
 }
 
 /* Append NELEMENT entries to FILENAME.  The entries appended are from
@@ -360,7 +463,7 @@ history_do_write (filename, nelements, overwrite)
 int
 append_history (nelements, filename)
      int nelements;
-     char *filename;
+     const char *filename;
 {
   return (history_do_write (filename, nelements, HISTORY_APPEND));
 }
@@ -370,7 +473,7 @@ append_history (nelements, filename)
    are as in read_history ().*/
 int
 write_history (filename)
-     char *filename;
+     const char *filename;
 {
   return (history_do_write (filename, history_length, HISTORY_OVERWRITE));
 }
diff --git a/readline/histlib.h b/readline/histlib.h
index 422cf5974db323b613f408e56e792c2b20b5dba9..c39af71814c81d5c7b73fe43497fc2e77ba7d333 100644
--- a/readline/histlib.h
+++ b/readline/histlib.h
@@ -6,7 +6,7 @@
 
    The Library is free software; you can redistribute it and/or modify
    it under the terms of the GNU General Public License as published by
-   the Free Software Foundation; either version 1, or (at your option)
+   the Free Software Foundation; either version 2, or (at your option)
    any later version.
 
    The Library is distributed in the hope that it will be useful, but
@@ -17,27 +17,24 @@
    The GNU General Public License is often shipped with GNU software, and
    is generally kept in a file called COPYING or LICENSE.  If you do not
    have a copy of the license, write to the Free Software Foundation,
-   675 Mass Ave, Cambridge, MA 02139, USA. */
+   59 Temple Place, Suite 330, Boston, MA 02111 USA. */
 
 #if !defined (_HISTLIB_H_)
 #define _HISTLIB_H_
 
-/* Function pointers can be declared as (Function *)foo. */
-#if !defined (_FUNCTION_DEF)
-#  define _FUNCTION_DEF
-typedef int Function ();
-typedef void VFunction ();
-typedef char *CPFunction ();
-typedef char **CPPFunction ();
-#endif /* _FUNCTION_DEF */
+#if defined (HAVE_STRING_H)
+#  include <string.h>
+#else
+#  include <strings.h>
+#endif /* !HAVE_STRING_H */
 
+#if !defined (STREQ)
 #define STREQ(a, b)	(((a)[0] == (b)[0]) && (strcmp ((a), (b)) == 0))
-#define STREQN(a, b, n)	(((a)[0] == (b)[0]) && (strncmp ((a), (b), (n)) == 0))
+#define STREQN(a, b, n) (((n) == 0) ? (1) \
+				    : ((a)[0] == (b)[0]) && (strncmp ((a), (b), (n)) == 0))
+#endif
 
 #ifndef savestring
-#  ifndef strcpy
-extern char *strcpy ();
-#  endif
 #define savestring(x) strcpy (xmalloc (1 + strlen (x)), (x))
 #endif
 
@@ -79,4 +76,7 @@ extern char *strchr ();
 #define HISTORY_APPEND 0
 #define HISTORY_OVERWRITE 1
 
+/* Some variable definitions shared across history source files. */
+extern int history_offset;
+
 #endif /* !_HISTLIB_H_ */
diff --git a/readline/history.c b/readline/history.c
index 804ffddcd89fa7d376f8f1d9b4ce5e980c969c5b..4242f33efe19e05dd120ec0aa9c2bc8946f49943 100644
--- a/readline/history.c
+++ b/readline/history.c
@@ -7,7 +7,7 @@
 
    The Library is free software; you can redistribute it and/or modify
    it under the terms of the GNU General Public License as published by
-   the Free Software Foundation; either version 1, or (at your option)
+   the Free Software Foundation; either version 2, or (at your option)
    any later version.
 
    The Library is distributed in the hope that it will be useful, but
@@ -18,7 +18,7 @@
    The GNU General Public License is often shipped with GNU software, and
    is generally kept in a file called COPYING or LICENSE.  If you do not
    have a copy of the license, write to the Free Software Foundation,
-   675 Mass Ave, Cambridge, MA 02139, USA. */
+   59 Temple Place, Suite 330, Boston, MA 02111 USA. */
 
 /* The goal is to make the implementation transparent, so that you
    don't have to know what data types are used, just what functions
@@ -44,16 +44,10 @@
 #  include <unistd.h>
 #endif
 
-#if defined (HAVE_STRING_H)
-#  include <string.h>
-#else
-#  include <strings.h>
-#endif /* !HAVE_STRING_H */
-
 #include "history.h"
 #include "histlib.h"
 
-extern char *xmalloc (), *xrealloc ();
+#include "xmalloc.h"
 
 /* The number of slots to increase the_history by. */
 #define DEFAULT_HISTORY_GROW_SIZE 50
@@ -71,9 +65,13 @@ static HIST_ENTRY **the_history = (HIST_ENTRY **)NULL;
    history that we save. */
 static int history_stifled;
 
+/* The current number of slots allocated to the input_history. */
+static int history_size;
+
 /* If HISTORY_STIFLED is non-zero, then this is the maximum number of
    entries to remember. */
-int max_input_history;
+int history_max_entries;
+int max_input_history;	/* backwards compatibility */
 
 /* The current location of the interactive history pointer.  Just makes
    life easier for outside callers. */
@@ -82,9 +80,6 @@ int history_offset;
 /* The number of strings currently stored in the history list. */
 int history_length;
 
-/* The current number of slots allocated to the input_history. */
-static int history_size;
-
 /* The logical `base' of the history array.  It defaults to 1. */
 int history_base = 1;
 
@@ -134,9 +129,7 @@ history_total_bytes ()
 {
   register int i, result;
 
-  result = 0;
-
-  for (i = 0; the_history && the_history[i]; i++)
+  for (i = result = 0; the_history && the_history[i]; i++)
     result += strlen (the_history[i]->line);
 
   return (result);
@@ -161,7 +154,7 @@ history_set_pos (pos)
   history_offset = pos;
   return (1);
 }
-
+ 
 /* Return the current history array.  The caller has to be carefull, since this
    is the actual array of data, and could be bashed or made corrupt easily.
    The array is terminated with a NULL pointer. */
@@ -217,16 +210,16 @@ history_get (offset)
    is  set to NULL. */
 void
 add_history (string)
-     char *string;
+     const char *string;
 {
   HIST_ENTRY *temp;
 
-  if (history_stifled && (history_length == max_input_history))
+  if (history_stifled && (history_length == history_max_entries))
     {
       register int i;
 
       /* If the history is stifled, and history_length is zero,
-	 and it equals max_input_history, we don't save items. */
+	 and it equals history_max_entries, we don't save items. */
       if (history_length == 0)
 	return;
 
@@ -277,15 +270,15 @@ add_history (string)
 HIST_ENTRY *
 replace_history_entry (which, line, data)
      int which;
-     char *line;
+     const char *line;
      histdata_t data;
 {
-  HIST_ENTRY *temp = (HIST_ENTRY *)xmalloc (sizeof (HIST_ENTRY));
-  HIST_ENTRY *old_value;
+  HIST_ENTRY *temp, *old_value;
 
   if (which >= history_length)
     return ((HIST_ENTRY *)NULL);
 
+  temp = (HIST_ENTRY *)xmalloc (sizeof (HIST_ENTRY));
   old_value = the_history[which];
 
   temp->line = savestring (line);
@@ -303,12 +296,12 @@ remove_history (which)
      int which;
 {
   HIST_ENTRY *return_value;
+  register int i;
 
   if (which >= history_length || !history_length)
     return_value = (HIST_ENTRY *)NULL;
   else
     {
-      register int i;
       return_value = the_history[which];
 
       for (i = which; i < history_length; i++)
@@ -325,13 +318,13 @@ void
 stifle_history (max)
      int max;
 {
+  register int i, j;
+
   if (max < 0)
     max = 0;
 
   if (history_length > max)
     {
-      register int i, j;
-
       /* This loses because we cannot free the data. */
       for (i = 0, j = history_length - max; i < j; i++)
 	{
@@ -347,22 +340,22 @@ stifle_history (max)
     }
 
   history_stifled = 1;
-  max_input_history = max;
+  max_input_history = history_max_entries = max;
 }
 
-/* Stop stifling the history.  This returns the previous amount the 
-   history was stifled by.  The value is positive if the history was
-   stifled,  negative if it wasn't. */
+/* Stop stifling the history.  This returns the previous maximum
+   number of history entries.  The value is positive if the history
+   was stifled,  negative if it wasn't. */
 int
 unstifle_history ()
 {
   if (history_stifled)
     {
       history_stifled = 0;
-      return (-max_input_history);
+      return (history_max_entries);
     }
-
-  return (max_input_history);
+  else
+    return (-history_max_entries);
 }
 
 int
diff --git a/readline/history.h b/readline/history.h
index 88bf471bb62b15f8eac9165f8d190b408f4928e6..afd8510455448ce2f7d5907dc084d74e859d6f70 100644
--- a/readline/history.h
+++ b/readline/history.h
@@ -6,7 +6,7 @@
 
    The Library is free software; you can redistribute it and/or modify
    it under the terms of the GNU General Public License as published by
-   the Free Software Foundation; either version 1, or (at your option)
+   the Free Software Foundation; either version 2, or (at your option)
    any later version.
 
    The Library is distributed in the hope that it will be useful, but
@@ -17,7 +17,7 @@
    The GNU General Public License is often shipped with GNU software, and
    is generally kept in a file called COPYING or LICENSE.  If you do not
    have a copy of the license, write to the Free Software Foundation,
-   675 Mass Ave, Cambridge, MA 02139, USA. */
+   59 Temple Place, Suite 330, Boston, MA 02111 USA. */
 
 #ifndef _HISTORY_H_
 #define _HISTORY_H_
@@ -28,16 +28,10 @@ extern "C" {
 
 #if defined READLINE_LIBRARY
 #  include "rlstdc.h"
+#  include "rltypedefs.h"
 #else
 #  include <readline/rlstdc.h>
-#endif
-
-#if !defined (_FUNCTION_DEF)
-#  define _FUNCTION_DEF
-typedef int Function ();
-typedef void VFunction ();
-typedef char *CPFunction ();
-typedef char **CPPFunction ();
+#  include <readline/rltypedefs.h>
 #endif
 
 #ifdef __STDC__
@@ -68,81 +62,81 @@ typedef struct _hist_state {
 
 /* Begin a session in which the history functions might be used.  This
    just initializes the interactive variables. */
-extern void using_history __P((void));
+extern void using_history PARAMS((void));
 
 /* Return the current HISTORY_STATE of the history. */
-extern HISTORY_STATE *history_get_history_state __P((void));
+extern HISTORY_STATE *history_get_history_state PARAMS((void));
 
 /* Set the state of the current history array to STATE. */
-extern void history_set_history_state __P((HISTORY_STATE *));
+extern void history_set_history_state PARAMS((HISTORY_STATE *));
 
 /* Manage the history list. */
 
 /* Place STRING at the end of the history list.
    The associated data field (if any) is set to NULL. */
-extern void add_history __P((char *));
+extern void add_history PARAMS((const char *));
 
 /* A reasonably useless function, only here for completeness.  WHICH
    is the magic number that tells us which element to delete.  The
    elements are numbered from 0. */
-extern HIST_ENTRY *remove_history __P((int));
+extern HIST_ENTRY *remove_history PARAMS((int));
 
 /* Make the history entry at WHICH have LINE and DATA.  This returns
    the old entry so you can dispose of the data.  In the case of an
    invalid WHICH, a NULL pointer is returned. */
-extern HIST_ENTRY *replace_history_entry __P((int, char *, histdata_t));
+extern HIST_ENTRY *replace_history_entry PARAMS((int, const char *, histdata_t));
 
 /* Clear the history list and start over. */
-extern void clear_history __P((void));
+extern void clear_history PARAMS((void));
 
 /* Stifle the history list, remembering only MAX number of entries. */
-extern void stifle_history __P((int));
+extern void stifle_history PARAMS((int));
 
 /* Stop stifling the history.  This returns the previous amount the
    history was stifled by.  The value is positive if the history was
    stifled, negative if it wasn't. */
-extern int unstifle_history __P((void));
+extern int unstifle_history PARAMS((void));
 
 /* Return 1 if the history is stifled, 0 if it is not. */
-extern int history_is_stifled __P((void));
+extern int history_is_stifled PARAMS((void));
 
 /* Information about the history list. */
 
 /* Return a NULL terminated array of HIST_ENTRY which is the current input
    history.  Element 0 of this list is the beginning of time.  If there
    is no history, return NULL. */
-extern HIST_ENTRY **history_list __P((void));
+extern HIST_ENTRY **history_list PARAMS((void));
 
 /* Returns the number which says what history element we are now
    looking at.  */
-extern int where_history __P((void));
-
+extern int where_history PARAMS((void));
+  
 /* Return the history entry at the current position, as determined by
    history_offset.  If there is no entry there, return a NULL pointer. */
-HIST_ENTRY *current_history __P((void));
+extern HIST_ENTRY *current_history PARAMS((void));
 
 /* Return the history entry which is logically at OFFSET in the history
    array.  OFFSET is relative to history_base. */
-extern HIST_ENTRY *history_get __P((int));
+extern HIST_ENTRY *history_get PARAMS((int));
 
 /* Return the number of bytes that the primary history entries are using.
    This just adds up the lengths of the_history->lines. */
-extern int history_total_bytes __P((void));
+extern int history_total_bytes PARAMS((void));
 
 /* Moving around the history list. */
 
 /* Set the position in the history list to POS. */
-int history_set_pos __P((int));
+extern int history_set_pos PARAMS((int));
 
 /* Back up history_offset to the previous history entry, and return
    a pointer to that entry.  If there is no previous entry, return
    a NULL pointer. */
-extern HIST_ENTRY *previous_history __P((void));
+extern HIST_ENTRY *previous_history PARAMS((void));
 
 /* Move history_offset forward to the next item in the input_history,
    and return the a pointer to that entry.  If there is no next entry,
    return a NULL pointer. */
-extern HIST_ENTRY *next_history __P((void));
+extern HIST_ENTRY *next_history PARAMS((void));
 
 /* Searching the history list. */
 
@@ -152,45 +146,45 @@ extern HIST_ENTRY *next_history __P((void));
    current_history () is the history entry, and the value of this function
    is the offset in the line of that history entry that the string was
    found in.  Otherwise, nothing is changed, and a -1 is returned. */
-extern int history_search __P((char *, int));
+extern int history_search PARAMS((const char *, int));
 
 /* Search the history for STRING, starting at history_offset.
    The search is anchored: matching lines must begin with string.
    DIRECTION is as in history_search(). */
-extern int history_search_prefix __P((char *, int));
+extern int history_search_prefix PARAMS((const char *, int));
 
 /* Search for STRING in the history list, starting at POS, an
    absolute index into the list.  DIR, if negative, says to search
    backwards from POS, else forwards.
    Returns the absolute index of the history element where STRING
    was found, or -1 otherwise. */
-extern int history_search_pos __P((char *, int, int));
+extern int history_search_pos PARAMS((const char *, int, int));
 
 /* Managing the history file. */
 
 /* Add the contents of FILENAME to the history list, a line at a time.
    If FILENAME is NULL, then read from ~/.history.  Returns 0 if
    successful, or errno if not. */
-extern int read_history __P((char *));
+extern int read_history PARAMS((const char *));
 
 /* Read a range of lines from FILENAME, adding them to the history list.
    Start reading at the FROM'th line and end at the TO'th.  If FROM
    is zero, start at the beginning.  If TO is less than FROM, read
    until the end of the file.  If FILENAME is NULL, then read from
    ~/.history.  Returns 0 if successful, or errno if not. */
-extern int read_history_range __P((char *, int, int));
+extern int read_history_range PARAMS((const char *, int, int));
 
 /* Write the current history to FILENAME.  If FILENAME is NULL,
    then write the history list to ~/.history.  Values returned
    are as in read_history ().  */
-extern int write_history __P((char *));
+extern int write_history PARAMS((const char *));
 
 /* Append NELEMENT entries to FILENAME.  The entries appended are from
    the end of the list minus NELEMENTs up to the end of the list. */
-int append_history __P((int, char *));
+extern int append_history PARAMS((int, const char *));
 
 /* Truncate the history file, leaving only the last NLINES lines. */
-extern int history_truncate_file __P((char *, int));
+extern int history_truncate_file PARAMS((const char *, int));
 
 /* History expansion. */
 
@@ -206,12 +200,12 @@ extern int history_truncate_file __P((char *, int));
 
   If an error ocurred in expansion, then OUTPUT contains a descriptive
   error message. */
-extern int history_expand __P((char *, char **));
+extern int history_expand PARAMS((char *, char **));
 
 /* Extract a string segment consisting of the FIRST through LAST
    arguments present in STRING.  Arguments are broken up as in
    the shell. */
-extern char *history_arg_extract __P((int, int, char *));
+extern char *history_arg_extract PARAMS((int, int, const char *));
 
 /* Return the text of the history event beginning at the current
    offset into STRING.  Pass STRING with *INDEX equal to the
@@ -219,27 +213,31 @@ extern char *history_arg_extract __P((int, int, char *));
    DELIMITING_QUOTE is a character that is allowed to end the string
    specification for what to search for in addition to the normal
    characters `:', ` ', `\t', `\n', and sometimes `?'. */
-extern char *get_history_event __P((char *, int *, int));
+extern char *get_history_event PARAMS((const char *, int *, int));
 
 /* Return an array of tokens, much as the shell might.  The tokens are
    parsed out of STRING. */
-extern char **history_tokenize __P((char *));
+extern char **history_tokenize PARAMS((const char *));
 
 /* Exported history variables. */
 extern int history_base;
 extern int history_length;
-extern int max_input_history;
+extern int history_max_entries;
 extern char history_expansion_char;
 extern char history_subst_char;
+extern const char *history_word_delimiters;
 extern char history_comment_char;
 extern const char *history_no_expand_chars;
-extern const char *history_search_delimiter_chars;
+extern char *history_search_delimiter_chars;
 extern int history_quotes_inhibit_expansion;
 
+/* Backwards compatibility */
+extern int max_input_history;
+
 /* If set, this function is called to decide whether or not a particular
    history expansion should be treated as a special case for the calling
    application and not expanded. */
-extern Function *history_inhibit_expansion_function;
+extern rl_linebuf_func_t *history_inhibit_expansion_function;
 
 #ifdef __cplusplus
 }
diff --git a/readline/histsearch.c b/readline/histsearch.c
index eb17e9332e86bc7f5876d7b02c5fe149453226d5..d94fd6cd9c656b1acdf8af91ae59e3529b201f97 100644
--- a/readline/histsearch.c
+++ b/readline/histsearch.c
@@ -7,7 +7,7 @@
 
    The Library is free software; you can redistribute it and/or modify
    it under the terms of the GNU General Public License as published by
-   the Free Software Foundation; either version 1, or (at your option)
+   the Free Software Foundation; either version 2, or (at your option)
    any later version.
 
    The Library is distributed in the hope that it will be useful, but
@@ -18,7 +18,7 @@
    The GNU General Public License is often shipped with GNU software, and
    is generally kept in a file called COPYING or LICENSE.  If you do not
    have a copy of the license, write to the Free Software Foundation,
-   675 Mass Ave, Cambridge, MA 02139, USA. */
+   59 Temple Place, Suite 330, Boston, MA 02111 USA. */
 
 #define READLINE_LIBRARY
 
@@ -32,27 +32,22 @@
 #else
 #  include "ansi_stdlib.h"
 #endif /* HAVE_STDLIB_H */
+
 #if defined (HAVE_UNISTD_H)
 #  ifdef _MINIX
 #    include <sys/types.h>
 #  endif
 #  include <unistd.h>
 #endif
-#if defined (HAVE_STRING_H)
-#  include <string.h>
-#else
-#  include <strings.h>
-#endif /* !HAVE_STRING_H */
 
 #include "history.h"
 #include "histlib.h"
 
-/* Variables imported from other history library files. */
-extern int history_offset;
-
 /* The list of alternate characters that can delimit a history search
    string. */
-const char *history_search_delimiter_chars = (char *)NULL;
+char *history_search_delimiter_chars = (char *)NULL;
+
+static int history_search_internal PARAMS((const char *, int, int));
 
 /* Search the history for STRING, starting at history_offset.
    If DIRECTION < 0, then the search is through previous entries, else
@@ -66,7 +61,7 @@ const char *history_search_delimiter_chars = (char *)NULL;
 
 static int
 history_search_internal (string, direction, anchored)
-     char *string;
+     const char *string;
      int direction, anchored;
 {
   register int i, reverse;
@@ -162,7 +157,7 @@ history_search_internal (string, direction, anchored)
 /* Do a non-anchored search for STRING through the history in DIRECTION. */
 int
 history_search (string, direction)
-     char *string;
+     const char *string;
      int direction;
 {
   return (history_search_internal (string, direction, NON_ANCHORED_SEARCH));
@@ -171,7 +166,7 @@ history_search (string, direction)
 /* Do an anchored search for string through the history in DIRECTION. */
 int
 history_search_prefix (string, direction)
-     char *string;
+     const char *string;
      int direction;
 {
   return (history_search_internal (string, direction, ANCHORED_SEARCH));
@@ -182,7 +177,7 @@ history_search_prefix (string, direction)
    which point to begin searching. */
 int
 history_search_pos (string, dir, pos)
-     char *string;
+     const char *string;
      int dir, pos;
 {
   int ret, old;
diff --git a/readline/input.c b/readline/input.c
index ea1342969b0ee44291e8509bb6d99dd7eeea64de..1442c5ef155fd7ffb83f9b5f8e7aa6235c4069b3 100644
--- a/readline/input.c
+++ b/readline/input.c
@@ -18,7 +18,7 @@
    The GNU General Public License is often shipped with GNU software, and
    is generally kept in a file called COPYING or LICENSE.  If you do not
    have a copy of the license, write to the Free Software Foundation,
-   675 Mass Ave, Cambridge, MA 02139, USA. */
+   59 Temple Place, Suite 330, Boston, MA 02111 USA. */
 #define READLINE_LIBRARY
 
 #if defined (HAVE_CONFIG_H)
@@ -42,7 +42,7 @@
 #endif /* HAVE_STDLIB_H */
 
 #if defined (HAVE_SELECT)
-#  if !defined (HAVE_SYS_SELECT_H) || !defined (M_UNIX) || defined(TIME_WITH_SYS_TIME)
+#  if !defined (HAVE_SYS_SELECT_H) || !defined (M_UNIX)
 #    include <sys/time.h>
 #  endif
 #endif /* HAVE_SELECT */
@@ -63,48 +63,31 @@ extern int errno;
 
 /* System-specific feature definitions and include files. */
 #include "rldefs.h"
+#include "rlmbutil.h"
 
 /* Some standard library routines. */
 #include "readline.h"
 
+#include "rlprivate.h"
+#include "rlshell.h"
+#include "xmalloc.h"
+
 /* What kind of non-blocking I/O do we have? */
 #if !defined (O_NDELAY) && defined (O_NONBLOCK)
 #  define O_NDELAY O_NONBLOCK	/* Posix style */
 #endif
 
-/* Functions imported from other files in the library. */
-extern char *xmalloc (), *xrealloc ();
-
-/* Variables and functions from macro.c. */
-extern void _rl_add_macro_char ();
-extern void _rl_with_macro_input ();
-extern int _rl_next_macro_key ();
-extern int _rl_defining_kbd_macro;
-
-#if defined (VI_MODE)
-extern void _rl_vi_set_last ();
-extern int _rl_vi_textmod_command ();
-#endif /* VI_MODE */
-
-extern FILE *rl_instream, *rl_outstream;
-extern Function *rl_last_func;
-extern int rl_key_sequence_length;
-extern int rl_pending_input;
-extern int rl_editing_mode;
-
-extern Keymap _rl_keymap;
-
-extern int _rl_convert_meta_chars_to_ascii;
-
-#if defined (__GO32__)
-#  include <pc.h>
-#endif /* __GO32__ */
-
 /* Non-null means it is a pointer to a function to run while waiting for
    character input. */
-Function *rl_event_hook = (Function *)NULL;
+rl_hook_func_t *rl_event_hook = (rl_hook_func_t *)NULL;
+
+rl_getc_func_t *rl_getc_function = rl_getc;
 
-Function *rl_getc_function = rl_getc;
+static int _keyboard_input_timeout = 100000;		/* 0.1 seconds; it's in usec */
+
+static int ibuffer_space PARAMS((void));
+static int rl_get_char PARAMS((int *));
+static int rl_gather_tyi PARAMS((void));
 
 /* **************************************************************** */
 /*								    */
@@ -156,8 +139,8 @@ rl_get_char (key)
 /* Stuff KEY into the *front* of the input buffer.
    Returns non-zero if successful, zero if there is
    no space left in the buffer. */
-static int
-rl_unget_char (key)
+int
+_rl_unget_char (key)
      int key;
 {
   if (ibuffer_space ())
@@ -171,33 +154,12 @@ rl_unget_char (key)
   return (0);
 }
 
-#if defined(__EMX__)
-int waiting_char = -1;
-#endif
-
-/* If a character is available to be read, then read it
-   and stuff it into IBUFFER.  Otherwise, just return. */
-static void
+/* If a character is available to be read, then read it and stuff it into
+   IBUFFER.  Otherwise, just return.  Returns number of characters read
+   (0 if none available) and -1 on error (EIO). */
+static int
 rl_gather_tyi ()
 {
-#if defined (__EMX__)
-  if (isatty (0) && (waiting_char = _read_kbd(0, 0, 0)) != -1 && ibuffer_space ())
-    {
-      int i;
-      i = (*rl_getc_function) (rl_instream);
-      rl_stuff_char (i);
-    }
-#elif defined (__GO32__)
-  char input;
-
-  if (isatty (0) && kbhit () && ibuffer_space ())
-    {
-      int i;
-      i = (*rl_getc_function) (rl_instream);
-      rl_stuff_char (i);
-    }
-#else /* !__GO32__ */
-
   int tty;
   register int tem, result;
   int chars_avail;
@@ -215,14 +177,18 @@ rl_gather_tyi ()
   FD_SET (tty, &readfds);
   FD_SET (tty, &exceptfds);
   timeout.tv_sec = 0;
-  timeout.tv_usec = 100000;	/* 0.1 seconds */
-  if (select (tty + 1, &readfds, (fd_set *)NULL, &exceptfds, &timeout) <= 0)
-    return;	/* Nothing to read. */
+  timeout.tv_usec = _keyboard_input_timeout;
+  result = select (tty + 1, &readfds, (fd_set *)NULL, &exceptfds, &timeout);
+  if (result <= 0)
+    return 0;	/* Nothing to read. */
 #endif
 
   result = -1;
 #if defined (FIONREAD)
+  errno = 0;
   result = ioctl (tty, FIONREAD, &chars_avail);
+  if (result == -1 && errno == EIO)
+    return -1;
 #endif
 
 #if defined (O_NDELAY)
@@ -235,14 +201,14 @@ rl_gather_tyi ()
 
       fcntl (tty, F_SETFL, tem);
       if (chars_avail == -1 && errno == EAGAIN)
-	return;
+	return 0;
     }
 #endif /* O_NDELAY */
 
   /* If there's nothing available, don't waste time trying to read
      something. */
   if (chars_avail <= 0)
-    return;
+    return 0;
 
   tem = ibuffer_space ();
 
@@ -266,23 +232,36 @@ rl_gather_tyi ()
       if (chars_avail)
 	rl_stuff_char (input);
     }
-#endif /* !__GO32__ */
+
+  return 1;
+}
+
+int
+rl_set_keyboard_input_timeout (u)
+     int u;
+{
+  int o;
+
+  o = _keyboard_input_timeout;
+  if (u > 0)
+    _keyboard_input_timeout = u;
+  return (o);
 }
 
 /* Is there input available to be read on the readline input file
-   descriptor?  Only works if the system has select(2) or FIONREAD. */
+   descriptor?  Only works if the system has select(2) or FIONREAD.
+   Uses the value of _keyboard_input_timeout as the timeout; if another
+   readline function wants to specify a timeout and not leave it up to
+   the user, it should use _rl_input_queued(timeout_value_in_microseconds)
+   instead. */
 int
 _rl_input_available ()
 {
-#if defined (__EMX__)
-  if (isatty (0) && (waiting_char = _read_kbd(0, 0, 0)) != -1)
-    return 1;
-#else /*  __EMX__ */
 #if defined(HAVE_SELECT)
   fd_set readfds, exceptfds;
   struct timeval timeout;
 #endif
-#if defined(FIONREAD)
+#if !defined (HAVE_SELECT) && defined(FIONREAD)
   int chars_avail;
 #endif
   int tty;
@@ -295,28 +274,41 @@ _rl_input_available ()
   FD_SET (tty, &readfds);
   FD_SET (tty, &exceptfds);
   timeout.tv_sec = 0;
-  timeout.tv_usec = 100000;	/* 0.1 seconds */
+  timeout.tv_usec = _keyboard_input_timeout;
   return (select (tty + 1, &readfds, (fd_set *)NULL, &exceptfds, &timeout) > 0);
-#endif
+#else
 
 #if defined (FIONREAD)
   if (ioctl (tty, FIONREAD, &chars_avail) == 0)
     return (chars_avail);
 #endif
-#endif /* !__EMX__ */
+
+#endif
 
   return 0;
 }
 
+int
+_rl_input_queued (t)
+     int t;
+{
+  int old_timeout, r;
+
+  old_timeout = rl_set_keyboard_input_timeout (t);
+  r = _rl_input_available ();
+  rl_set_keyboard_input_timeout (old_timeout);
+  return r;
+}
+
 void
 _rl_insert_typein (c)
      int c;     
-{
+{    	
   int key, t, i;
   char *string;
 
   i = key = 0;
-  string = xmalloc (ibuffer_len + 1);
+  string = (char *)xmalloc (ibuffer_len + 1);
   string[i++] = (char) c;
 
   while ((t = rl_get_char (&key)) &&
@@ -325,7 +317,7 @@ _rl_insert_typein (c)
     string[i++] = key;
 
   if (t)
-    rl_unget_char (key);
+    _rl_unget_char (key);
 
   string[i] = '\0';
   rl_insert_text (string);
@@ -345,6 +337,7 @@ rl_stuff_char (key)
     {
       key = NEWLINE;
       rl_pending_input = EOF;
+      RL_SETSTATE (RL_STATE_INPUTPENDING);
     }
   ibuffer[push_index++] = key;
   if (push_index >= ibuffer_len)
@@ -359,6 +352,16 @@ rl_execute_next (c)
      int c;
 {
   rl_pending_input = c;
+  RL_SETSTATE (RL_STATE_INPUTPENDING);
+  return 0;
+}
+
+/* Clear any pending input pushed with rl_execute_next() */
+int
+rl_clear_pending_input ()
+{
+  rl_pending_input = 0;
+  RL_UNSETSTATE (RL_STATE_INPUTPENDING);
   return 0;
 }
 
@@ -379,7 +382,7 @@ rl_read_key ()
   if (rl_pending_input)
     {
       c = rl_pending_input;
-      rl_pending_input = 0;
+      rl_clear_pending_input ();
     }
   else
     {
@@ -393,7 +396,13 @@ rl_read_key ()
 	  while (rl_event_hook && rl_get_char (&c) == 0)
 	    {
 	      (*rl_event_hook) ();
-	      rl_gather_tyi ();
+	      if (rl_done)		/* XXX - experimental */
+		return ('\n');
+	      if (rl_gather_tyi () < 0)	/* XXX - EIO */
+		{
+		  rl_done = 1;
+		  return ('\n');
+		}
 	    }
 	}
       else
@@ -410,96 +419,9 @@ int
 rl_getc (stream)
      FILE *stream;
 {
-  int result, flags;
+  int result;
   unsigned char c;
 
-#if defined (__EMX__)
-  if (isatty (0))
-  {
-    int key;
-
-    if (waiting_char != -1)
-    {
-      key = waiting_char;
-      waiting_char = -1;
-    }
-    else
-    {
-#ifdef __RSXNT__
-      pc_flush();
-#endif
-      key = _read_kbd(0, 1, 0);
-    }
-
-    while (key == 0)
-    {
-      key |= (_read_kbd(0, 1, 0) << 8);
-      /* printf("<%04X> ", key);
-      fflush(stdout); */
-
-      switch (key)
-      {
-      case 0x4B00: /* left arrow */
-	key = 'B' - 64;
-	break;
-      case 0x4D00: /* right arrow */
-	key = 'F' - 64;
-	break;
-      case 0x7300: /* ctrl left arrow */
-	key = 27;
-	waiting_char = 'B';
-	break;
-      case 0x7400: /* ctrl right arrow */
-	key = 27;
-	waiting_char = 'F';
-	break;
-      case 0x4800: /* up arrow */
-	key = 'P' - 64;
-	break;
-      case 0x5000: /* down arrow */
-	key = 'N' - 64;
-	break;
-      case 0x8D00: /* ctrl up arrow */
-	key = 'R' - 64;
-	break;
-      case 0x9100: /* ctrl down arrow */
-	key = 'S' - 64;
-	break;
-      case 0x4700: /* home key */
-	key = 'A' - 64;
-	break;
-      case 0x4F00: /* end key */
-	key = 'E' - 64;
-	break;
-      case 0x7700: /* ctrl home key */
-	key = 27;
-	waiting_char = '<';
-	break;
-      case 0x7500: /* ctrl end key */
-	key = 27;
-	waiting_char = '>';
-	break;
-      case 0x5300: /* delete key */
-	key = 'D' - 64;
-	break;
-      case 0x5200: /* insert key */
-	key = 'V' - 64;
-	break;
-      default: /* ignore all other special keys, read next */
-	key = _read_kbd(0, 1, 0);
-	break;
-      }
-    }
-
-    return (key & 0xFF);
-  }
-#endif /* __EMX__ */
-
-#if defined (__GO32__)
-  if (isatty (0))
-    return (getkey () & 0x7F);
-#endif /* __GO32__ */
-
   while (1)
     {
       result = read (fileno (stream), &c, sizeof (unsigned char));
@@ -518,40 +440,101 @@ rl_getc (stream)
 #endif
 
 #if defined (EWOULDBLOCK)
-      if (errno == EWOULDBLOCK)
+#  define X_EWOULDBLOCK EWOULDBLOCK
+#else
+#  define X_EWOULDBLOCK -99
+#endif
+
+#if defined (EAGAIN)
+#  define X_EAGAIN EAGAIN
+#else
+#  define X_EAGAIN -99
+#endif
+
+      if (errno == X_EWOULDBLOCK || errno == X_EAGAIN)
 	{
-	  if ((flags = fcntl (fileno (stream), F_GETFL, 0)) < 0)
+	  if (sh_unset_nodelay_mode (fileno (stream)) < 0)
 	    return (EOF);
-	  if (flags & O_NDELAY)
-	    {
-	      flags &= ~O_NDELAY;
-	      fcntl (fileno (stream), F_SETFL, flags);
-	      continue;
-	    }
 	  continue;
 	}
-#endif /* EWOULDBLOCK */
 
-#if defined (_POSIX_VERSION) && defined (EAGAIN) && defined (O_NONBLOCK)
-      if (errno == EAGAIN)
-	{
-	  if ((flags = fcntl (fileno (stream), F_GETFL, 0)) < 0)
-	    return (EOF);
-	  if (flags & O_NONBLOCK)
-	    {
-	      flags &= ~O_NONBLOCK;
-	      fcntl (fileno (stream), F_SETFL, flags);
-	      continue;
-	    }
-	}
-#endif /* _POSIX_VERSION && EAGAIN && O_NONBLOCK */
+#undef X_EWOULDBLOCK
+#undef X_EAGAIN
 
-#if !defined (__GO32__)
       /* If the error that we received was SIGINT, then try again,
 	 this is simply an interrupted system call to read ().
 	 Otherwise, some error ocurred, also signifying EOF. */
       if (errno != EINTR)
 	return (EOF);
-#endif /* !__GO32__ */
     }
 }
+
+#if defined (HANDLE_MULTIBYTE)
+/* read multibyte char */
+int
+_rl_read_mbchar (mbchar, size)
+     char *mbchar;
+     int size;
+{
+  int mb_len = 0;
+  size_t mbchar_bytes_length;
+  wchar_t wc;
+  mbstate_t ps, ps_back;
+
+  memset(&ps, 0, sizeof (mbstate_t));
+  memset(&ps_back, 0, sizeof (mbstate_t));
+  
+  while (mb_len < size)
+    {
+      RL_SETSTATE(RL_STATE_MOREINPUT);
+      mbchar[mb_len++] = rl_read_key ();
+      RL_UNSETSTATE(RL_STATE_MOREINPUT);
+
+      mbchar_bytes_length = mbrtowc (&wc, mbchar, mb_len, &ps);
+      if (mbchar_bytes_length == (size_t)(-1))
+	break;		/* invalid byte sequence for the current locale */
+      else if (mbchar_bytes_length == (size_t)(-2))
+	{
+	  /* shorted bytes */
+	  ps = ps_back;
+	  continue;
+	} 
+      else if (mbchar_bytes_length > (size_t)(0))
+	break;
+    }
+
+  return mb_len;
+}
+
+/* Read a multibyte-character string whose first character is FIRST into
+   the buffer MB of length MBLEN.  Returns the last character read, which
+   may be FIRST.  Used by the search functions, among others.  Very similar
+   to _rl_read_mbchar. */
+int
+_rl_read_mbstring (first, mb, mblen)
+     int first;
+     char *mb;
+     int mblen;
+{
+  int i, c;
+  mbstate_t ps;
+
+  c = first;
+  memset (mb, 0, mblen);
+  for (i = 0; i < mblen; i++)
+    {
+      mb[i] = (char)c;
+      memset (&ps, 0, sizeof (mbstate_t));
+      if (_rl_get_char_len (mb, &ps) == -2)
+	{
+	  /* Read more for multibyte character */
+	  RL_SETSTATE (RL_STATE_MOREINPUT);
+	  c = rl_read_key ();
+	  RL_UNSETSTATE (RL_STATE_MOREINPUT);
+	}
+      else
+	break;
+    }
+  return c;
+}
+#endif /* HANDLE_MULTIBYTE */
diff --git a/readline/isearch.c b/readline/isearch.c
index a4a294b6b204dac34abfab483d9da0d7803b1cf5..137842a841facfe3715321f7c06257aac830297c 100644
--- a/readline/isearch.c
+++ b/readline/isearch.c
@@ -4,7 +4,7 @@
 /*								    */
 /* **************************************************************** */
 
-/* Copyright (C) 1987,1989 Free Software Foundation, Inc.
+/* Copyright (C) 1987-2002 Free Software Foundation, Inc.
 
    This file contains the Readline Library (the Library), a set of
    routines for providing Emacs style line input to programs that ask
@@ -12,7 +12,7 @@
 
    The Library is free software; you can redistribute it and/or modify
    it under the terms of the GNU General Public License as published by
-   the Free Software Foundation; either version 1, or (at your option)
+   the Free Software Foundation; either version 2, or (at your option)
    any later version.
 
    The Library is distributed in the hope that it will be useful, but
@@ -23,7 +23,7 @@
    The GNU General Public License is often shipped with GNU software, and
    is generally kept in a file called COPYING or LICENSE.  If you do not
    have a copy of the license, write to the Free Software Foundation,
-   675 Mass Ave, Cambridge, MA 02139, USA. */
+   59 Temple Place, Suite 330, Boston, MA 02111 USA. */
 #define READLINE_LIBRARY
 
 #if defined (HAVE_CONFIG_H)
@@ -45,32 +45,33 @@
 #endif
 
 #include "rldefs.h"
+#include "rlmbutil.h"
+
 #include "readline.h"
 #include "history.h"
 
+#include "rlprivate.h"
+#include "xmalloc.h"
+
 /* Variables exported to other files in the readline library. */
-unsigned char *_rl_isearch_terminators = (unsigned char *)NULL;
+char *_rl_isearch_terminators = (char *)NULL;
 
 /* Variables imported from other files in the readline library. */
-extern Keymap _rl_keymap;
-extern HIST_ENTRY *saved_line_for_history;
-extern int rl_line_buffer_len;
-extern int rl_point, rl_end;
-extern char *rl_line_buffer;
-
-extern int rl_execute_next ();
-extern void rl_extend_line_buffer ();
-
-extern int _rl_input_available ();
+extern HIST_ENTRY *_rl_saved_line_for_history;
 
-extern char *xmalloc (), *xrealloc ();
-
-static int rl_search_history ();
+/* Forward declarations */
+static int rl_search_history PARAMS((int, int));
 
 /* Last line found by the current incremental search, so we don't `find'
    identical lines many times in a row. */
 static char *prev_line_found;
 
+/* Last search string and its length. */
+static char *last_isearch_string;
+static int last_isearch_string_len;
+
+static const char *default_isearch_terminators = "\033\012";
+
 /* Search backwards through the history looking for a string which is typed
    interactively.  Start with the current line. */
 int
@@ -97,15 +98,14 @@ rl_forward_search_history (sign, key)
 static void
 rl_display_search (search_string, reverse_p, where)
      char *search_string;
-     int reverse_p;
-     int where __attribute__((unused));
+     int reverse_p, where __attribute__((unused));
 {
   char *message;
   int msglen, searchlen;
 
   searchlen = (search_string && *search_string) ? strlen (search_string) : 0;
 
-  message = xmalloc (searchlen + 33);
+  message = (char *)xmalloc (searchlen + 33);
   msglen = 0;
 
 #if defined (NOTDEF)
@@ -135,7 +135,7 @@ rl_display_search (search_string, reverse_p, where)
 
   strcpy (message + msglen, "': ");
 
-  rl_message ("%s", message, 0);
+  rl_message ("%s", message);
   free (message);
   (*rl_redisplay_function) ();
 }
@@ -145,7 +145,8 @@ rl_display_search (search_string, reverse_p, where)
    DIRECTION is which direction to search; >= 0 means forward, < 0 means
    backwards. */
 static int
-rl_search_history (int direction, int invoking_key __attribute__((unused)))
+rl_search_history (direction, invoking_key)
+     int direction, invoking_key __attribute__((unused));
 {
   /* The string that the user types in to search for. */
   char *search_string;
@@ -166,8 +167,12 @@ rl_search_history (int direction, int invoking_key __attribute__((unused)))
   HIST_ENTRY **hlist;
 
   register int i;
-  int orig_point, orig_line, last_found_line;
+  int orig_point, orig_mark, orig_line, last_found_line;
   int c, found, failed, sline_len;
+  int n, wstart, wlen;
+#if defined (HANDLE_MULTIBYTE)
+  char mb[MB_LEN_MAX];
+#endif
 
   /* The line currently being searched. */
   char *sline;
@@ -181,19 +186,21 @@ rl_search_history (int direction, int invoking_key __attribute__((unused)))
   /* The list of characters which terminate the search, but are not
      subsequently executed.  If the variable isearch-terminators has
      been set, we use that value, otherwise we use ESC and C-J. */
-  unsigned char *isearch_terminators;
+  const char *isearch_terminators;
 
+  RL_SETSTATE(RL_STATE_ISEARCH);
   orig_point = rl_point;
+  orig_mark = rl_mark;
   last_found_line = orig_line = where_history ();
   reverse = direction < 0;
   hlist = history_list ();
   allocated_line = (char *)NULL;
 
   isearch_terminators = _rl_isearch_terminators ? _rl_isearch_terminators
-						: (unsigned char *)"\033\012";
+						: default_isearch_terminators;
 
   /* Create an arrary of pointers to the lines that we want to search. */
-  maybe_replace_line ();
+  rl_maybe_replace_line ();
   i = 0;
   if (hlist)
     for (i = 0; hlist[i]; i++);
@@ -204,12 +211,12 @@ rl_search_history (int direction, int invoking_key __attribute__((unused)))
   for (i = 0; i < hlen; i++)
     lines[i] = hlist[i]->line;
 
-  if (saved_line_for_history)
-    lines[i] = saved_line_for_history->line;
+  if (_rl_saved_line_for_history)
+    lines[i] = _rl_saved_line_for_history->line;
   else
     {
       /* Keep track of this so we can free it. */
-      allocated_line = xmalloc (1 + strlen (rl_line_buffer));
+      allocated_line = (char *)xmalloc (1 + strlen (rl_line_buffer));
       strcpy (allocated_line, &rl_line_buffer[0]);
       lines[i] = allocated_line;
     }
@@ -222,7 +229,7 @@ rl_search_history (int direction, int invoking_key __attribute__((unused)))
   rl_save_prompt ();
 
   /* Initialize search parameters. */
-  search_string = xmalloc (search_string_size = 128);
+  search_string = (char *)xmalloc (search_string_size = 128);
   *search_string = '\0';
   search_string_index = 0;
   prev_line_found = (char *)0;		/* XXX */
@@ -239,12 +246,20 @@ rl_search_history (int direction, int invoking_key __attribute__((unused)))
   found = failed = 0;
   for (;;)
     {
-      Function *f = (Function *)NULL;
+      rl_command_func_t *f = (rl_command_func_t *)NULL;
 
       /* Read a key and decide how to proceed. */
+      RL_SETSTATE(RL_STATE_MOREINPUT);
       c = rl_read_key ();
+      RL_UNSETSTATE(RL_STATE_MOREINPUT);
 
-      if (_rl_keymap[c].type == ISFUNC)
+#if defined (HANDLE_MULTIBYTE)
+      if (MB_CUR_MAX > 1 && rl_byte_oriented == 0)
+	c = _rl_read_mbstring (c, mb, MB_LEN_MAX);
+#endif
+
+      /* Translate the keys we do something with to opcodes. */
+      if (c >= 0 && _rl_keymap[c].type == ISFUNC)
 	{
 	  f = _rl_keymap[c].function;
 
@@ -252,34 +267,56 @@ rl_search_history (int direction, int invoking_key __attribute__((unused)))
 	    c = reverse ? -1 : -2;
 	  else if (f == rl_forward_search_history)
 	    c =  !reverse ? -1 : -2;
+	  else if (f == rl_rubout)
+	    c = -3;
+	  else if (c == CTRL ('G'))
+	    c = -4;
+	  else if (c == CTRL ('W'))	/* XXX */
+	    c = -5;
+	  else if (c == CTRL ('Y'))	/* XXX */
+	    c = -6;
 	}
 
-#if 0
-      /* Let NEWLINE (^J) terminate the search for people who don't like
-	 using ESC.  ^M can still be used to terminate the search and
-	 immediately execute the command. */
-      if (c == ESC || c == NEWLINE)
-#else
       /* The characters in isearch_terminators (set from the user-settable
 	 variable isearch-terminators) are used to terminate the search but
 	 not subsequently execute the character as a command.  The default
 	 value is "\033\012" (ESC and C-J). */
-      if (strchr((char*) isearch_terminators, c))
-#endif
+      if (strchr (isearch_terminators, c))
 	{
 	  /* ESC still terminates the search, but if there is pending
 	     input or if input arrives within 0.1 seconds (on systems
 	     with select(2)) it is used as a prefix character
 	     with rl_execute_next.  WATCH OUT FOR THIS!  This is intended
 	     to allow the arrow keys to be used like ^F and ^B are used
-	     to terminate the search and execute the movement command. */
-	  if (c == ESC && _rl_input_available ())	/* XXX */
+	     to terminate the search and execute the movement command.
+	     XXX - since _rl_input_available depends on the application-
+	     settable keyboard timeout value, this could alternatively
+	     use _rl_input_queued(100000) */
+	  if (c == ESC && _rl_input_available ())
 	    rl_execute_next (ESC);
 	  break;
 	}
 
-      if (c >= 0 && (CTRL_CHAR (c) || META_CHAR (c) || c == RUBOUT) && c != CTRL ('G'))
+#define ENDSRCH_CHAR(c) \
+  ((CTRL_CHAR (c) || META_CHAR (c) || (c) == RUBOUT) && ((c) != CTRL ('G')))
+
+#if defined (HANDLE_MULTIBYTE)
+      if (MB_CUR_MAX > 1 && rl_byte_oriented == 0)
 	{
+	  if (c >= 0 && strlen (mb) == 1 && ENDSRCH_CHAR (c))
+	    {
+	      /* This sets rl_pending_input to c; it will be picked up the next
+		 time rl_read_key is called. */
+	      rl_execute_next (c);
+	      break;
+	    }
+	}
+      else
+#endif
+      if (c >= 0 && ENDSRCH_CHAR (c))
+	{
+	  /* This sets rl_pending_input to c; it will be picked up the next
+	     time rl_read_key is called. */
 	  rl_execute_next (c);
 	  break;
 	}
@@ -288,13 +325,24 @@ rl_search_history (int direction, int invoking_key __attribute__((unused)))
 	{
 	case -1:
 	  if (search_string_index == 0)
-	    continue;
+	    {
+	      if (last_isearch_string)
+		{
+		  search_string_size = 64 + last_isearch_string_len;
+		  search_string = (char *)xrealloc (search_string, search_string_size);
+		  strcpy (search_string, last_isearch_string);
+		  search_string_index = last_isearch_string_len;
+		  rl_display_search (search_string, reverse, -1);
+		  break;
+		}
+	      continue;
+	    }
 	  else if (reverse)
 	    --line_index;
 	  else if (line_index != sline_len)
 	    ++line_index;
 	  else
-	    ding ();
+	    rl_ding ();
 	  break;
 
 	  /* switch directions */
@@ -303,40 +351,96 @@ rl_search_history (int direction, int invoking_key __attribute__((unused)))
 	  reverse = direction < 0;
 	  break;
 
-	case CTRL ('G'):
-	  strcpy (rl_line_buffer, lines[orig_line]);
+	/* delete character from search string. */
+	case -3:	/* C-H, DEL */
+	  /* This is tricky.  To do this right, we need to keep a
+	     stack of search positions for the current search, with
+	     sentinels marking the beginning and end.  But this will
+	     do until we have a real isearch-undo. */
+	  if (search_string_index == 0)
+	    rl_ding ();
+	  else
+	    search_string[--search_string_index] = '\0';
+
+	  break;
+
+	case -4:	/* C-G */
+	  rl_replace_line (lines[orig_line], 0);
 	  rl_point = orig_point;
-	  rl_end = strlen (rl_line_buffer);
+	  rl_mark = orig_mark;
 	  rl_restore_prompt();
 	  rl_clear_message ();
 	  if (allocated_line)
 	    free (allocated_line);
 	  free (lines);
+	  RL_UNSETSTATE(RL_STATE_ISEARCH);
 	  return 0;
 
-#if 0
-	/* delete character from search string. */
-	case -3:
-	  if (search_string_index == 0)
-	    ding ();
-	  else
+	case -5:	/* C-W */
+	  /* skip over portion of line we already matched */
+	  wstart = rl_point + search_string_index;
+	  if (wstart >= rl_end)
+	    {
+	      rl_ding ();
+	      break;
+	    }
+
+	  /* if not in a word, move to one. */
+	  if (rl_alphabetic(rl_line_buffer[wstart]) == 0)
+	    {
+	      rl_ding ();
+	      break;
+	    }
+	  n = wstart;
+	  while (n < rl_end && rl_alphabetic(rl_line_buffer[n]))
+	    n++;
+	  wlen = n - wstart + 1;
+	  if (search_string_index + wlen + 1 >= search_string_size)
 	    {
-	      search_string[--search_string_index] = '\0';
-	      /* This is tricky.  To do this right, we need to keep a
-		 stack of search positions for the current search, with
-		 sentinels marking the beginning and end. */
+	      search_string_size += wlen + 1;
+	      search_string = (char *)xrealloc (search_string, search_string_size);
 	    }
+	  for (; wstart < n; wstart++)
+	    search_string[search_string_index++] = rl_line_buffer[wstart];
+	  search_string[search_string_index] = '\0';
+	  break;
+
+	case -6:	/* C-Y */
+	  /* skip over portion of line we already matched */
+	  wstart = rl_point + search_string_index;
+	  if (wstart >= rl_end)
+	    {
+	      rl_ding ();
+	      break;
+	    }
+	  n = rl_end - wstart + 1;
+	  if (search_string_index + n + 1 >= search_string_size)
+	    {
+	      search_string_size += n + 1;
+	      search_string = (char *)xrealloc (search_string, search_string_size);
+	    }
+	  for (n = wstart; n < rl_end; n++)
+	    search_string[search_string_index++] = rl_line_buffer[n];
+	  search_string[search_string_index] = '\0';
 	  break;
-#endif
 
 	default:
 	  /* Add character to search string and continue search. */
 	  if (search_string_index + 2 >= search_string_size)
 	    {
 	      search_string_size += 128;
-	      search_string = xrealloc (search_string, search_string_size);
+	      search_string = (char *)xrealloc (search_string, search_string_size);
+	    }
+#if defined (HANDLE_MULTIBYTE)
+	  if (MB_CUR_MAX > 1 && rl_byte_oriented == 0)
+	    {
+	      int j, l;
+	      for (j = 0, l = strlen (mb); j < l; )
+		search_string[search_string_index++] = mb[j++];
 	    }
-	  search_string[search_string_index++] = c;
+	  else
+#endif
+	    search_string[search_string_index++] = c;
 	  search_string[search_string_index] = '\0';
 	  break;
 	}
@@ -391,7 +495,7 @@ rl_search_history (int direction, int invoking_key __attribute__((unused)))
       if (failed)
 	{
 	  /* We cannot find the search string.  Ding the bell. */
-	  ding ();
+	  rl_ding ();
 	  i = last_found_line;
 	  continue; 		/* XXX - was break */
 	}
@@ -401,17 +505,9 @@ rl_search_history (int direction, int invoking_key __attribute__((unused)))
 	 the location. */
       if (found)
 	{
-	  int line_len;
-
 	  prev_line_found = lines[i];
-	  line_len = strlen (lines[i]);
-
-	  if (line_len >= rl_line_buffer_len)
-	    rl_extend_line_buffer (line_len);
-
-	  strcpy (rl_line_buffer, lines[i]);
+	  rl_replace_line (lines[i], 0);
 	  rl_point = line_index;
-	  rl_end = line_len;
 	  last_found_line = i;
 	  rl_display_search (search_string, reverse, (i == orig_line) ? -1 : i);
 	}
@@ -427,23 +523,38 @@ rl_search_history (int direction, int invoking_key __attribute__((unused)))
 
   rl_restore_prompt ();
 
-  /* Free the search string. */
-  free (search_string);
+  /* Save the search string for possible later use. */
+  FREE (last_isearch_string);
+  last_isearch_string = search_string;
+  last_isearch_string_len = search_string_index;
 
   if (last_found_line < orig_line)
     rl_get_previous_history (orig_line - last_found_line, 0);
   else
     rl_get_next_history (last_found_line - orig_line, 0);
 
-  /* If the string was not found, put point at the end of the line. */
+  /* If the string was not found, put point at the end of the last matching
+     line.  If last_found_line == orig_line, we didn't find any matching
+     history lines at all, so put point back in its original position. */
   if (line_index < 0)
-    line_index = strlen (rl_line_buffer);
+    {
+      if (last_found_line == orig_line)
+	line_index = orig_point;
+      else
+	line_index = strlen (rl_line_buffer);
+      rl_mark = orig_mark;
+    }
+
   rl_point = line_index;
+  /* Don't worry about where to put the mark here; rl_get_previous_history
+     and rl_get_next_history take care of it. */
+
   rl_clear_message ();
 
-  if (allocated_line)
-    free (allocated_line);
+  FREE (allocated_line);
   free (lines);
 
+  RL_UNSETSTATE(RL_STATE_ISEARCH);
+
   return 0;
 }
diff --git a/readline/keymaps.c b/readline/keymaps.c
index c73666bf273af65a449cbf5d86d58d3950047be4..12506d3aab2e87f5233d16219e087b514b2535cb 100644
--- a/readline/keymaps.c
+++ b/readline/keymaps.c
@@ -7,7 +7,7 @@
 
    Readline is free software; you can redistribute it and/or modify it
    under the terms of the GNU General Public License as published by the
-   Free Software Foundation; either version 1, or (at your option) any
+   Free Software Foundation; either version 2, or (at your option) any
    later version.
 
    Readline is distributed in the hope that it will be useful, but
@@ -17,7 +17,7 @@
 
    You should have received a copy of the GNU General Public License
    along with Readline; see the file COPYING.  If not, write to the Free
-   Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. */
+   Software Foundation, 59 Temple Place, Suite 330, Boston, MA 02111 USA. */
 #define READLINE_LIBRARY
 
 #if defined (HAVE_CONFIG_H)
@@ -30,18 +30,18 @@
 #  include "ansi_stdlib.h"
 #endif /* HAVE_STDLIB_H */
 
+#include <stdio.h>	/* for FILE * definition for readline.h */
+
+#include "readline.h"
 #include "rlconf.h"
-#include "keymaps.h"
+
 #include "emacs_keymap.c"
 
 #if defined (VI_MODE)
 #include "vi_keymap.c"
 #endif
 
-extern int rl_do_lowercase_version ();
-extern int rl_rubout (), rl_insert ();
-
-extern char *xmalloc (), *xrealloc ();
+#include "xmalloc.h"
 
 /* **************************************************************** */
 /*								    */
@@ -61,7 +61,7 @@ rl_make_bare_keymap ()
   for (i = 0; i < KEYMAP_SIZE; i++)
     {
       keymap[i].type = ISFUNC;
-      keymap[i].function = (Function *)NULL;
+      keymap[i].function = (rl_command_func_t *)NULL;
     }
 
   for (i = 'A'; i < ('Z' + 1); i++)
diff --git a/readline/keymaps.h b/readline/keymaps.h
index 5dff46f56c2dc006d3fd749cf7ca99a2d430e451..66fa2a5ec14a07650b6a195dc4402be63066ecf2 100644
--- a/readline/keymaps.h
+++ b/readline/keymaps.h
@@ -7,7 +7,7 @@
 
    The GNU Readline Library is free software; you can redistribute it
    and/or modify it under the terms of the GNU General Public License
-   as published by the Free Software Foundation; either version 1, or
+   as published by the Free Software Foundation; either version 2, or
    (at your option) any later version.
 
    The GNU Readline Library is distributed in the hope that it will be
@@ -18,25 +18,23 @@
    The GNU General Public License is often shipped with GNU software, and
    is generally kept in a file called COPYING or LICENSE.  If you do not
    have a copy of the license, write to the Free Software Foundation,
-   675 Mass Ave, Cambridge, MA 02139, USA. */
+   59 Temple Place, Suite 330, Boston, MA 02111 USA. */
 
 #ifndef _KEYMAPS_H_
 #define _KEYMAPS_H_
 
+#ifdef __cplusplus
+extern "C" {
+#endif
+
 #if defined (READLINE_LIBRARY)
 #  include "rlstdc.h"
 #  include "chardefs.h"
+#  include "rltypedefs.h"
 #else
 #  include <readline/rlstdc.h>
 #  include <readline/chardefs.h>
-#endif
-
-#if !defined (_FUNCTION_DEF)
-#  define _FUNCTION_DEF
-typedef int Function ();
-typedef void VFunction ();
-typedef char *CPFunction ();
-typedef char **CPPFunction ();
+#  include <readline/rltypedefs.h>
 #endif
 
 /* A keymap contains one entry for each key in the ASCII set.
@@ -46,16 +44,17 @@ typedef char **CPPFunction ();
    TYPE says which kind of thing FUNCTION is. */
 typedef struct _keymap_entry {
   char type;
-  Function *function;
+  rl_command_func_t *function;
 } KEYMAP_ENTRY;
 
 /* This must be large enough to hold bindings for all of the characters
    in a desired character set (e.g, 128 for ASCII, 256 for ISO Latin-x,
-   and so on). */
-#define KEYMAP_SIZE 256
+   and so on) plus one for subsequence matching. */
+#define KEYMAP_SIZE 257
+#define ANYOTHERKEY KEYMAP_SIZE-1
 
 /* I wanted to make the above structure contain a union of:
-   union { Function *function; struct _keymap_entry *keymap; } value;
+   union { rl_command_func_t *function; struct _keymap_entry *keymap; } value;
    but this made it impossible for me to create a static array.
    Maybe I need C lessons. */
 
@@ -72,29 +71,33 @@ extern KEYMAP_ENTRY_ARRAY vi_insertion_keymap, vi_movement_keymap;
 
 /* Return a new, empty keymap.
    Free it with free() when you are done. */
-extern Keymap rl_make_bare_keymap __P((void));
+extern Keymap rl_make_bare_keymap PARAMS((void));
 
 /* Return a new keymap which is a copy of MAP. */
-extern Keymap rl_copy_keymap __P((Keymap));
+extern Keymap rl_copy_keymap PARAMS((Keymap));
 
 /* Return a new keymap with the printing characters bound to rl_insert,
    the lowercase Meta characters bound to run their equivalents, and
    the Meta digits bound to produce numeric arguments. */
-extern Keymap rl_make_keymap __P((void));
+extern Keymap rl_make_keymap PARAMS((void));
 
 /* Free the storage associated with a keymap. */
-extern void rl_discard_keymap __P((Keymap));
+extern void rl_discard_keymap PARAMS((Keymap));
 
 /* These functions actually appear in bind.c */
 
 /* Return the keymap corresponding to a given name.  Names look like
    `emacs' or `emacs-meta' or `vi-insert'.  */
-extern Keymap rl_get_keymap_by_name __P((char *));
+extern Keymap rl_get_keymap_by_name PARAMS((const char *));
 
 /* Return the current keymap. */
-extern Keymap rl_get_keymap __P((void));
+extern Keymap rl_get_keymap PARAMS((void));
 
 /* Set the current keymap to MAP. */
-extern void rl_set_keymap __P((Keymap));
+extern void rl_set_keymap PARAMS((Keymap));
+
+#ifdef __cplusplus
+}
+#endif
 
 #endif /* _KEYMAPS_H_ */
diff --git a/readline/kill.c b/readline/kill.c
index 78387e138c237c48348a0b5fac8daa862a98c0d0..f8c6961bbd3d2680be55dc2fc8f2cf00f54c13fb 100644
--- a/readline/kill.c
+++ b/readline/kill.c
@@ -7,7 +7,7 @@
 
    The GNU Readline Library is free software; you can redistribute it
    and/or modify it under the terms of the GNU General Public License
-   as published by the Free Software Foundation; either version 1, or
+   as published by the Free Software Foundation; either version 2, or
    (at your option) any later version.
 
    The GNU Readline Library is distributed in the hope that it will be
@@ -18,7 +18,7 @@
    The GNU General Public License is often shipped with GNU software, and
    is generally kept in a file called COPYING or LICENSE.  If you do not
    have a copy of the license, write to the Free Software Foundation,
-   675 Mass Ave, Cambridge, MA 02139, USA. */
+   59 Temple Place, Suite 330, Boston, MA 02111 USA. */
 #define READLINE_LIBRARY
 
 #if defined (HAVE_CONFIG_H)
@@ -46,17 +46,8 @@
 #include "readline.h"
 #include "history.h"
 
-extern int _rl_last_command_was_kill;
-extern int rl_editing_mode;
-extern int rl_explicit_arg;
-extern Function *rl_last_func;
-
-extern void _rl_init_argument ();
-extern int _rl_set_mark_at_pos ();
-extern void _rl_fix_point ();
-extern void _rl_abort_internal ();
-
-extern char *xmalloc (), *xrealloc ();
+#include "rlprivate.h"
+#include "xmalloc.h"
 
 /* **************************************************************** */
 /*								    */
@@ -79,10 +70,16 @@ static int rl_kill_index;
 /* How many slots we have in the kill ring. */
 static int rl_kill_ring_length;
 
+static int _rl_copy_to_kill_ring PARAMS((char *, int));
+static int region_kill_internal PARAMS((int));
+static int _rl_copy_word_as_kill PARAMS((int, int));
+static int rl_yank_nth_arg_internal PARAMS((int, int, int));
+
 /* How to say that you only want to save a certain amount
    of kill material. */
 int
-rl_set_retained_kills (int num __attribute__((unused)))
+rl_set_retained_kills (num)
+     int num __attribute__((unused));
 {
   return 0;
 }
@@ -137,7 +134,7 @@ _rl_copy_to_kill_ring (text, append)
   if (_rl_last_command_was_kill && rl_editing_mode != vi_mode)
     {
       old = rl_kill_ring[slot];
-      new = xmalloc (1 + strlen (old) + strlen (text));
+      new = (char *)xmalloc (1 + strlen (old) + strlen (text));
 
       if (append)
 	{
@@ -204,18 +201,21 @@ int
 rl_kill_word (count, key)
      int count, key;
 {
-  int orig_point = rl_point;
+  int orig_point;
 
   if (count < 0)
     return (rl_backward_kill_word (-count, key));
   else
     {
+      orig_point = rl_point;
       rl_forward_word (count, key);
 
       if (rl_point != orig_point)
 	rl_kill_text (orig_point, rl_point);
 
       rl_point = orig_point;
+      if (rl_editing_mode == emacs_mode)
+	rl_mark = rl_point;
     }
   return 0;
 }
@@ -225,16 +225,20 @@ int
 rl_backward_kill_word (count, ignore)
      int count, ignore;
 {
-  int orig_point = rl_point;
+  int orig_point;
 
   if (count < 0)
     return (rl_kill_word (-count, ignore));
   else
     {
+      orig_point = rl_point;
       rl_backward_word (count, ignore);
 
       if (rl_point != orig_point)
 	rl_kill_text (orig_point, rl_point);
+
+      if (rl_editing_mode == emacs_mode)
+	rl_mark = rl_point;
     }
   return 0;
 }
@@ -245,16 +249,19 @@ int
 rl_kill_line (direction, ignore)
      int direction, ignore;
 {
-  int orig_point = rl_point;
+  int orig_point;
 
   if (direction < 0)
     return (rl_backward_kill_line (1, ignore));
   else
     {
+      orig_point = rl_point;
       rl_end_of_line (1, ignore);
       if (orig_point != rl_point)
 	rl_kill_text (orig_point, rl_point);
       rl_point = orig_point;
+      if (rl_editing_mode == emacs_mode)
+	rl_mark = rl_point;
     }
   return 0;
 }
@@ -265,18 +272,22 @@ int
 rl_backward_kill_line (direction, ignore)
      int direction, ignore;
 {
-  int orig_point = rl_point;
+  int orig_point;
 
   if (direction < 0)
     return (rl_kill_line (1, ignore));
   else
     {
       if (!rl_point)
-	ding ();
+	rl_ding ();
       else
 	{
+	  orig_point = rl_point;
 	  rl_beg_of_line (1, ignore);
-	  rl_kill_text (orig_point, rl_point);
+	  if (rl_point != orig_point)
+	    rl_kill_text (orig_point, rl_point);
+	  if (rl_editing_mode == emacs_mode)
+	    rl_mark = rl_point;
 	}
     }
   return 0;
@@ -284,12 +295,13 @@ rl_backward_kill_line (direction, ignore)
 
 /* Kill the whole line, no matter where point is. */
 int
-rl_kill_full_line (int count __attribute__((unused)),
-		   int ignore __attribute__((unused)))
+rl_kill_full_line (count, ignore)
+     int count __attribute__((unused)), ignore __attribute__((unused));
 {
   rl_begin_undo_group ();
   rl_point = 0;
   rl_kill_text (rl_point, rl_end);
+  rl_mark = 0;
   rl_end_undo_group ();
   return 0;
 }
@@ -301,12 +313,13 @@ rl_kill_full_line (int count __attribute__((unused)),
 /* This does what C-w does in Unix.  We can't prevent people from
    using behaviour that they expect. */
 int
-rl_unix_word_rubout (int count, int key __attribute__((unused)))
+rl_unix_word_rubout (count, key)
+     int count, key __attribute__((unused));
 {
   int orig_point;
 
   if (rl_point == 0)
-    ding ();
+    rl_ding ();
   else
     {
       orig_point = rl_point;
@@ -323,6 +336,8 @@ rl_unix_word_rubout (int count, int key __attribute__((unused)))
 	}
 
       rl_kill_text (orig_point, rl_point);
+      if (rl_editing_mode == emacs_mode)
+	rl_mark = rl_point;
     }
   return 0;
 }
@@ -334,15 +349,17 @@ rl_unix_word_rubout (int count, int key __attribute__((unused)))
    into the line at all, and if you aren't, then you know what you are
    doing. */
 int
-rl_unix_line_discard (int count __attribute__((unused)),
-		      int key __attribute__((unused)))
+rl_unix_line_discard (count, key)
+     int count __attribute__((unused)), key __attribute__((unused));
 {
   if (rl_point == 0)
-    ding ();
+    rl_ding ();
   else
     {
       rl_kill_text (rl_point, 0);
       rl_point = 0;
+      if (rl_editing_mode == emacs_mode)
+	rl_mark = rl_point;
     }
   return 0;
 }
@@ -355,38 +372,37 @@ region_kill_internal (delete)
 {
   char *text;
 
-  if (rl_mark == rl_point)
+  if (rl_mark != rl_point)
     {
-      _rl_last_command_was_kill++;
-      return 0;
+      text = rl_copy_text (rl_point, rl_mark);
+      if (delete)
+	rl_delete_text (rl_point, rl_mark);
+      _rl_copy_to_kill_ring (text, rl_point < rl_mark);
     }
 
-  text = rl_copy_text (rl_point, rl_mark);
-  if (delete)
-    rl_delete_text (rl_point, rl_mark);
-  _rl_copy_to_kill_ring (text, rl_point < rl_mark);
-
   _rl_last_command_was_kill++;
   return 0;
 }
 
 /* Copy the text in the region to the kill ring. */
 int
-rl_copy_region_to_kill (int count __attribute__((unused)),
-			int key __attribute__((unused)))
+rl_copy_region_to_kill (count, ignore)
+     int count __attribute__((unused)), ignore __attribute__((unused));
 {
   return (region_kill_internal (0));
 }
 
 /* Kill the text between the point and mark. */
 int
-rl_kill_region (int count __attribute__((unused)),
-		int key __attribute__((unused)))
+rl_kill_region (count, ignore)
+     int count __attribute__((unused)), ignore __attribute__((unused));
 {
-  int r;
+  int r, npoint;
 
+  npoint = (rl_point < rl_mark) ? rl_point : rl_mark;
   r = region_kill_internal (1);
   _rl_fix_point (1);
+  rl_point = npoint;
   return r;
 }
 
@@ -440,11 +456,11 @@ rl_copy_backward_word (count, key)
 
   return (_rl_copy_word_as_kill (count, -1));
 }
-
+  
 /* Yank back the last killed text.  This ignores arguments. */
 int
-rl_yank (int count __attribute__((unused)),
-	 int key __attribute__((unused)))
+rl_yank (count, ignore)
+     int count __attribute__((unused)), ignore __attribute__((unused));
 {
   if (rl_kill_ring == 0)
     {
@@ -462,8 +478,8 @@ rl_yank (int count __attribute__((unused)),
    delete that text from the line, rotate the index down, and
    yank back some other text. */
 int
-rl_yank_pop (int count __attribute__((unused)),
-	     int key __attribute__((unused)))
+rl_yank_pop (count, key)
+     int count __attribute__((unused)), key __attribute__((unused));
 {
   int l, n;
 
@@ -501,7 +517,9 @@ rl_yank_nth_arg_internal (count, ignore, history_skip)
 {
   register HIST_ENTRY *entry;
   char *arg;
-  int i;
+  int i, pos;
+
+  pos = where_history ();
 
   if (history_skip)
     {
@@ -510,30 +528,26 @@ rl_yank_nth_arg_internal (count, ignore, history_skip)
     }
 
   entry = previous_history ();
-  if (entry)
-    {
-      if (history_skip)
-	{
-	  for (i = 0; i < history_skip; i++)
-	    next_history ();
-	}
-      next_history ();
-    }
-  else
+
+  history_set_pos (pos);
+
+  if (entry == 0)
     {
-      ding ();
+      rl_ding ();
       return -1;
     }
 
   arg = history_arg_extract (count, count, entry->line);
   if (!arg || !*arg)
     {
-      ding ();
+      rl_ding ();
       return -1;
     }
 
   rl_begin_undo_group ();
 
+  _rl_set_mark_at_pos (rl_point);
+
 #if defined (VI_MODE)
   /* Vi mode always inserts a space before yanking the argument, and it
      inserts it right *after* rl_point. */
@@ -590,7 +604,7 @@ rl_yank_last_arg (count, key)
       if (history_skip < 0)
 	history_skip = 0;
     }
-
+ 
   if (explicit_arg_p)
     retval = rl_yank_nth_arg_internal (count_passed, key, history_skip);
   else
@@ -601,7 +615,7 @@ rl_yank_last_arg (count, key)
 }
 
 /* A special paste command for users of Cygnus's cygwin32. */
-#if defined (__CYGWIN32__)
+#if defined (__CYGWIN__)
 #include <windows.h>
 
 int
@@ -621,12 +635,13 @@ rl_paste_from_clipboard (count, key)
       if (ptr)
 	{
 	  len = ptr - data;
-	  ptr = xmalloc (len + 1);
+	  ptr = (char *)xmalloc (len + 1);
 	  ptr[len] = '\0';
 	  strncpy (ptr, data, len);
 	}
       else
         ptr = data;
+      _rl_set_mark_at_pos (rl_point);
       rl_insert_text (ptr);
       if (ptr != data)
 	free (ptr);
@@ -634,4 +649,4 @@ rl_paste_from_clipboard (count, key)
     }
   return (0);
 }
-#endif /* __CYGWIN32__ */
+#endif /* __CYGWIN__ */
diff --git a/readline/macro.c b/readline/macro.c
index b4d7835c6310310c2298265c6827c4870848c464..7ab4b6ca65746e0d7b5526b7d313b001ebe0e136 100644
--- a/readline/macro.c
+++ b/readline/macro.c
@@ -7,7 +7,7 @@
 
    The GNU Readline Library is free software; you can redistribute it
    and/or modify it under the terms of the GNU General Public License
-   as published by the Free Software Foundation; either version 1, or
+   as published by the Free Software Foundation; either version 2, or
    (at your option) any later version.
 
    The GNU Readline Library is distributed in the hope that it will be
@@ -18,7 +18,7 @@
    The GNU General Public License is often shipped with GNU software, and
    is generally kept in a file called COPYING or LICENSE.  If you do not
    have a copy of the license, write to the Free Software Foundation,
-   675 Mass Ave, Cambridge, MA 02139, USA. */
+   59 Temple Place, Suite 330, Boston, MA 02111 USA. */
 #define READLINE_LIBRARY
 
 #if defined (HAVE_CONFIG_H)
@@ -46,19 +46,8 @@
 #include "readline.h"
 #include "history.h"
 
-#define SWAP(s, e)  do { int t; t = s; s = e; e = t; } while (0)
-
-/* Forward definitions. */
-void _rl_push_executing_macro (), _rl_pop_executing_macro ();
-void _rl_add_macro_char ();
-
-/* Extern declarations. */
-extern int rl_explicit_arg;
-extern int rl_key_sequence_length;
-
-extern void _rl_abort_internal ();
-
-extern char *xmalloc (), *xrealloc ();
+#include "rlprivate.h"
+#include "xmalloc.h"
 
 /* **************************************************************** */
 /*								    */
@@ -66,12 +55,9 @@ extern char *xmalloc (), *xrealloc ();
 /*								    */
 /* **************************************************************** */
 
-/* Non-zero means to save keys that we dispatch on in a kbd macro. */
-int _rl_defining_kbd_macro = 0;
-
 /* The currently executing macro string.  If this is non-zero,
    then it is a malloc ()'ed string where input is coming from. */
-char *_rl_executing_macro = (char *)NULL;
+char *rl_executing_macro = (char *)NULL;
 
 /* The offset in the above string to the next character to be read. */
 static int executing_macro_index;
@@ -90,7 +76,7 @@ static int current_macro_index;
    It is a linked list of string/index for each saved macro. */
 struct saved_macro {
   struct saved_macro *next;
-  const char *string;
+  char *string;
   int sindex;
 };
 
@@ -100,11 +86,13 @@ static struct saved_macro *macro_list = (struct saved_macro *)NULL;
 /* Set up to read subsequent input from STRING.
    STRING is free ()'ed when we are done with it. */
 void
-_rl_with_macro_input (const char *string)
+_rl_with_macro_input (string)
+     char *string;
 {
   _rl_push_executing_macro ();
-  _rl_executing_macro = (char*) string;
+  rl_executing_macro = string;
   executing_macro_index = 0;
+  RL_SETSTATE(RL_STATE_MACROINPUT);
 }
 
 /* Return the next character available from a macro, or 0 if
@@ -112,16 +100,16 @@ _rl_with_macro_input (const char *string)
 int
 _rl_next_macro_key ()
 {
-  if (_rl_executing_macro == 0)
+  if (rl_executing_macro == 0)
     return (0);
 
-  if (_rl_executing_macro[executing_macro_index] == 0)
+  if (rl_executing_macro[executing_macro_index] == 0)
     {
       _rl_pop_executing_macro ();
       return (_rl_next_macro_key ());
     }
 
-  return (_rl_executing_macro[executing_macro_index++]);
+  return (rl_executing_macro[executing_macro_index++]);
 }
 
 /* Save the currently executing macro on a stack of saved macros. */
@@ -133,7 +121,7 @@ _rl_push_executing_macro ()
   saver = (struct saved_macro *)xmalloc (sizeof (struct saved_macro));
   saver->next = macro_list;
   saver->sindex = executing_macro_index;
-  saver->string = _rl_executing_macro;
+  saver->string = rl_executing_macro;
 
   macro_list = saver;
 }
@@ -145,20 +133,21 @@ _rl_pop_executing_macro ()
 {
   struct saved_macro *macro;
 
-  if (_rl_executing_macro)
-    free (_rl_executing_macro);
-
-  _rl_executing_macro = (char *)NULL;
+  FREE (rl_executing_macro);
+  rl_executing_macro = (char *)NULL;
   executing_macro_index = 0;
 
   if (macro_list)
     {
       macro = macro_list;
-      _rl_executing_macro = (char*) macro_list->string;
+      rl_executing_macro = macro_list->string;
       executing_macro_index = macro_list->sindex;
       macro_list = macro_list->next;
       free (macro);
     }
+
+  if (rl_executing_macro == 0)
+    RL_UNSETSTATE(RL_STATE_MACROINPUT);
 }
 
 /* Add a character to the macro being built. */
@@ -169,9 +158,9 @@ _rl_add_macro_char (c)
   if (current_macro_index + 1 >= current_macro_size)
     {
       if (current_macro == 0)
-	current_macro = xmalloc (current_macro_size = 25);
+	current_macro = (char *)xmalloc (current_macro_size = 25);
       else
-	current_macro = xrealloc (current_macro, current_macro_size += 25);
+	current_macro = (char *)xrealloc (current_macro, current_macro_size += 25);
     }
 
   current_macro[current_macro_index++] = c;
@@ -188,14 +177,11 @@ _rl_kill_kbd_macro ()
     }
   current_macro_size = current_macro_index = 0;
 
-  if (_rl_executing_macro)
-    {
-      free (_rl_executing_macro);
-      _rl_executing_macro = (char *) NULL;
-    }
+  FREE (rl_executing_macro);
+  rl_executing_macro = (char *) NULL;
   executing_macro_index = 0;
 
-  _rl_defining_kbd_macro = 0;
+  RL_UNSETSTATE(RL_STATE_MACRODEF);
 }
 
 /* Begin defining a keyboard macro.
@@ -205,10 +191,10 @@ _rl_kill_kbd_macro ()
    definition to the end of the existing macro, and start by
    re-executing the existing macro. */
 int
-rl_start_kbd_macro (int count __attribute__((unused)),
-		    int key __attribute__((unused)))
+rl_start_kbd_macro (ignore1, ignore2)
+     int ignore1 __attribute__((unused)), ignore2 __attribute__((unused));
 {
-  if (_rl_defining_kbd_macro)
+  if (RL_ISSTATE (RL_STATE_MACRODEF))
     {
       _rl_abort_internal ();
       return -1;
@@ -222,7 +208,7 @@ rl_start_kbd_macro (int count __attribute__((unused)),
   else
     current_macro_index = 0;
 
-  _rl_defining_kbd_macro = 1;
+  RL_SETSTATE(RL_STATE_MACRODEF);
   return 0;
 }
 
@@ -230,9 +216,10 @@ rl_start_kbd_macro (int count __attribute__((unused)),
    A numeric argument says to execute the macro right now,
    that many times, counting the definition as the first time. */
 int
-rl_end_kbd_macro (int count, int ignore __attribute__((unused)))
+rl_end_kbd_macro (count, ignore)
+     int count, ignore __attribute__((unused));
 {
-  if (_rl_defining_kbd_macro == 0)
+  if (RL_ISSTATE (RL_STATE_MACRODEF) == 0)
     {
       _rl_abort_internal ();
       return -1;
@@ -241,7 +228,7 @@ rl_end_kbd_macro (int count, int ignore __attribute__((unused)))
   current_macro_index -= rl_key_sequence_length - 1;
   current_macro[current_macro_index] = '\0';
 
-  _rl_defining_kbd_macro = 0;
+  RL_UNSETSTATE(RL_STATE_MACRODEF);
 
   return (rl_call_last_kbd_macro (--count, 0));
 }
@@ -249,14 +236,15 @@ rl_end_kbd_macro (int count, int ignore __attribute__((unused)))
 /* Execute the most recently defined keyboard macro.
    COUNT says how many times to execute it. */
 int
-rl_call_last_kbd_macro (int count, int key __attribute__((unused)))
+rl_call_last_kbd_macro (count, ignore)
+     int count, ignore __attribute__((unused));
 {
   if (current_macro == 0)
     _rl_abort_internal ();
 
-  if (_rl_defining_kbd_macro)
+  if (RL_ISSTATE (RL_STATE_MACRODEF))
     {
-      ding ();		/* no recursive macros */
+      rl_ding ();		/* no recursive macros */
       current_macro[--current_macro_index] = '\0';	/* erase this char */
       return 0;
     }
diff --git a/readline/mbutil.c b/readline/mbutil.c
new file mode 100644
index 0000000000000000000000000000000000000000..debad6320cea2d909c78aa360844f36dad10b714
--- /dev/null
+++ b/readline/mbutil.c
@@ -0,0 +1,337 @@
+/* mbutil.c -- readline multibyte character utility functions */
+
+/* Copyright (C) 2001 Free Software Foundation, Inc.
+
+   This file is part of the GNU Readline Library, a library for
+   reading lines of text with interactive input and history editing.
+
+   The GNU Readline Library is free software; you can redistribute it
+   and/or modify it under the terms of the GNU General Public License
+   as published by the Free Software Foundation; either version 2, or
+   (at your option) any later version.
+
+   The GNU Readline Library is distributed in the hope that it will be
+   useful, but WITHOUT ANY WARRANTY; without even the implied warranty
+   of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+   GNU General Public License for more details.
+
+   The GNU General Public License is often shipped with GNU software, and
+   is generally kept in a file called COPYING or LICENSE.  If you do not
+   have a copy of the license, write to the Free Software Foundation,
+   59 Temple Place, Suite 330, Boston, MA 02111 USA. */
+#define READLINE_LIBRARY
+
+#if defined (HAVE_CONFIG_H)
+#  include <config.h>
+#endif
+
+#include <sys/types.h>
+#include <fcntl.h>
+#include "posixjmp.h"
+
+#if defined (HAVE_UNISTD_H)
+#  include <unistd.h>	   /* for _POSIX_VERSION */
+#endif /* HAVE_UNISTD_H */
+
+#if defined (HAVE_STDLIB_H)
+#  include <stdlib.h>
+#else
+#  include "ansi_stdlib.h"
+#endif /* HAVE_STDLIB_H */
+
+#include <stdio.h>
+#include <ctype.h>
+
+/* System-specific feature definitions and include files. */
+#include "rldefs.h"
+#include "rlmbutil.h"
+
+#if defined (TIOCSTAT_IN_SYS_IOCTL)
+#  include <sys/ioctl.h>
+#endif /* TIOCSTAT_IN_SYS_IOCTL */
+
+/* Some standard library routines. */
+#include "readline.h"
+
+#include "rlprivate.h"
+#include "xmalloc.h"
+
+/* Declared here so it can be shared between the readline and history
+   libraries. */
+#if defined (HANDLE_MULTIBYTE)
+int rl_byte_oriented = 0;
+#else
+int rl_byte_oriented = 1;
+#endif
+
+/* **************************************************************** */
+/*								    */
+/*		Multibyte Character Utility Functions		    */
+/*								    */
+/* **************************************************************** */
+
+#if defined(HANDLE_MULTIBYTE)
+
+static int
+_rl_find_next_mbchar_internal (string, seed, count, find_non_zero)
+     char *string;
+     int seed, count, find_non_zero;
+{
+  size_t tmp = 0;
+  mbstate_t ps;
+  int point = 0;
+  wchar_t wc;
+
+  memset(&ps, 0, sizeof (mbstate_t));
+  if (seed < 0)
+    seed = 0;
+  if (count <= 0)
+    return seed;
+
+  point = seed + _rl_adjust_point(string, seed, &ps);
+  /* if this is true, means that seed was not pointed character
+     started byte.  So correct the point and consume count */
+  if (seed < point)
+    count --;
+
+  while (count > 0)  
+    {
+      tmp = mbrtowc (&wc, string+point, strlen(string + point), &ps);
+      if ((size_t)(tmp) == (size_t)-1 || (size_t)(tmp) == (size_t)-2)
+	{
+	  /* invalid bytes. asume a byte represents a character */
+	  point++;
+	  count--;
+	  /* reset states. */
+	  memset(&ps, 0, sizeof(mbstate_t));
+	}
+      else if (tmp == (size_t)0)
+	/* found '\0' char */
+	break;
+      else
+	{
+	  /* valid bytes */
+	  point += tmp;
+	  if (find_non_zero)
+	    {
+	      if (wcwidth (wc) == 0)
+		continue;
+	      else
+		count--;
+	    }
+	  else
+	    count--;
+	}
+    }
+
+  if (find_non_zero)
+    {
+      tmp = mbrtowc (&wc, string + point, strlen (string + point), &ps);
+      while (wcwidth (wc) == 0)
+	{
+	  point += tmp;
+	  tmp = mbrtowc (&wc, string + point, strlen (string + point), &ps);
+	  if (tmp == (size_t)(0) || tmp == (size_t)(-1) || tmp == (size_t)(-2))
+	    break;
+	}
+    }
+    return point;
+}
+
+static int
+_rl_find_prev_mbchar_internal (string, seed, find_non_zero)
+     char *string;
+     int seed, find_non_zero;
+{
+  mbstate_t ps;
+  int prev, non_zero_prev, point, length;
+  size_t tmp;
+  wchar_t wc;
+
+  memset(&ps, 0, sizeof(mbstate_t));
+  length = strlen(string);
+  
+  if (seed < 0)
+    return 0;
+  else if (length < seed)
+    return length;
+
+  prev = non_zero_prev = point = 0;
+  while (point < seed)
+    {
+      tmp = mbrtowc (&wc, string + point, length - point, &ps);
+      if ((size_t)(tmp) == (size_t)-1 || (size_t)(tmp) == (size_t)-2)
+	{
+	  /* in this case, bytes are invalid or shorted to compose
+	     multibyte char, so assume that the first byte represents
+	     a single character anyway. */
+	  tmp = 1;
+	  /* clear the state of the byte sequence, because
+	     in this case effect of mbstate is undefined  */
+	  memset(&ps, 0, sizeof (mbstate_t));
+	}
+      else if (tmp == 0)
+	break;			/* Found '\0' char.  Can this happen? */
+      else
+	{
+	  if (find_non_zero)
+	    {
+	      if (wcwidth (wc) != 0)
+		prev = point;
+	    }
+	  else
+	    prev = point;  
+	}
+
+      point += tmp;
+    }
+
+  return prev;
+}
+
+/* return the number of bytes parsed from the multibyte sequence starting
+   at src, if a non-L'\0' wide character was recognized. It returns 0, 
+   if a L'\0' wide character was recognized. It  returns (size_t)(-1), 
+   if an invalid multibyte sequence was encountered. It returns (size_t)(-2) 
+   if it couldn't parse a complete  multibyte character.  */
+int
+_rl_get_char_len (src, ps)
+     const char *src;
+     mbstate_t *ps;
+{
+  size_t tmp;
+
+  tmp = mbrlen((const char *)src, (size_t)strlen (src), ps);
+  if (tmp == (size_t)(-2))
+    {
+      /* shorted to compose multibyte char */
+      memset (ps, 0, sizeof(mbstate_t));
+      return -2;
+    }
+  else if (tmp == (size_t)(-1))
+    {
+      /* invalid to compose multibyte char */
+      /* initialize the conversion state */
+      memset (ps, 0, sizeof(mbstate_t));
+      return -1;
+    }
+  else if (tmp == (size_t)0)
+    return 0;
+  else
+    return (int)tmp;
+}
+
+/* compare the specified two characters. If the characters matched,
+   return 1. Otherwise return 0. */
+int
+_rl_compare_chars (buf1, pos1, ps1, buf2, pos2, ps2)
+     char *buf1, *buf2;
+     mbstate_t *ps1, *ps2;
+     int pos1, pos2;
+{
+  int i, w1, w2;
+
+  if ((w1 = _rl_get_char_len (&buf1[pos1], ps1)) <= 0 || 
+	(w2 = _rl_get_char_len (&buf2[pos2], ps2)) <= 0 ||
+	(w1 != w2) ||
+	(buf1[pos1] != buf2[pos2]))
+    return 0;
+
+  for (i = 1; i < w1; i++)
+    if (buf1[pos1+i] != buf2[pos2+i])
+      return 0;
+
+  return 1;
+}
+
+/* adjust pointed byte and find mbstate of the point of string.
+   adjusted point will be point <= adjusted_point, and returns
+   differences of the byte(adjusted_point - point).
+   if point is invalied (point < 0 || more than string length),
+   it returns -1 */
+int
+_rl_adjust_point(string, point, ps)
+     const char *string;
+     int point;
+     mbstate_t *ps;
+{
+  size_t tmp = 0;
+  int length;
+  int pos = 0;
+
+  length = strlen(string);
+  if (point < 0)
+    return -1;
+  if (length < point)
+    return -1;
+  
+  while (pos < point)
+    {
+      tmp = mbrlen (string + pos, length - pos, ps);
+      if((size_t)(tmp) == (size_t)-1 || (size_t)(tmp) == (size_t)-2)
+	{
+	  /* in this case, bytes are invalid or shorted to compose
+	     multibyte char, so assume that the first byte represents
+	     a single character anyway. */
+	  pos++;
+	  /* clear the state of the byte sequence, because
+	     in this case effect of mbstate is undefined  */
+	  memset (ps, 0, sizeof (mbstate_t));
+	}
+      else
+	pos += tmp;
+    }
+
+  return (pos - point);
+}
+
+int
+_rl_is_mbchar_matched (string, seed, end, mbchar, length)
+     char *string;
+     int seed, end;
+     char *mbchar;
+     int length;
+{
+  int i;
+
+  if ((end - seed) < length)
+    return 0;
+
+  for (i = 0; i < length; i++)
+    if (string[seed + i] != mbchar[i])
+      return 0;
+  return 1;
+}
+#endif /* HANDLE_MULTIBYTE */
+
+/* Find next `count' characters started byte point of the specified seed.
+   If flags is MB_FIND_NONZERO, we look for non-zero-width multibyte
+   characters. */
+#undef _rl_find_next_mbchar
+int
+_rl_find_next_mbchar (string, seed, count, flags)
+     char *string __attribute__((unused));
+     int seed, count, flags __attribute__((unused));
+{
+#if defined (HANDLE_MULTIBYTE)
+  return _rl_find_next_mbchar_internal (string, seed, count, flags);
+#else
+  return (seed + count);
+#endif
+}
+
+/* Find previous character started byte point of the specified seed.
+   Returned point will be point <= seed.  If flags is MB_FIND_NONZERO,
+   we look for non-zero-width multibyte characters. */
+#undef _rl_find_prev_mbchar
+int
+_rl_find_prev_mbchar (string, seed, flags)
+     char *string __attribute__((unused));
+     int seed, flags __attribute__((unused));
+{
+#if defined (HANDLE_MULTIBYTE)
+  return _rl_find_prev_mbchar_internal (string, seed, flags);
+#else
+  return ((seed == 0) ? seed : seed - 1);
+#endif
+}
diff --git a/readline/misc.c b/readline/misc.c
new file mode 100644
index 0000000000000000000000000000000000000000..94ad433473bf0ca7487b0054533931e72304e932
--- /dev/null
+++ b/readline/misc.c
@@ -0,0 +1,496 @@
+/* misc.c -- miscellaneous bindable readline functions. */
+
+/* Copyright (C) 1987-2002 Free Software Foundation, Inc.
+
+   This file is part of the GNU Readline Library, a library for
+   reading lines of text with interactive input and history editing.
+
+   The GNU Readline Library is free software; you can redistribute it
+   and/or modify it under the terms of the GNU General Public License
+   as published by the Free Software Foundation; either version 2, or
+   (at your option) any later version.
+
+   The GNU Readline Library is distributed in the hope that it will be
+   useful, but WITHOUT ANY WARRANTY; without even the implied warranty
+   of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+   GNU General Public License for more details.
+
+   The GNU General Public License is often shipped with GNU software, and
+   is generally kept in a file called COPYING or LICENSE.  If you do not
+   have a copy of the license, write to the Free Software Foundation,
+   59 Temple Place, Suite 330, Boston, MA 02111 USA. */
+#define READLINE_LIBRARY
+
+#if defined (HAVE_CONFIG_H)
+#  include <config.h>
+#endif
+
+#if defined (HAVE_UNISTD_H)
+#  include <unistd.h>
+#endif /* HAVE_UNISTD_H */
+
+#if defined (HAVE_STDLIB_H)
+#  include <stdlib.h>
+#else
+#  include "ansi_stdlib.h"
+#endif /* HAVE_STDLIB_H */
+
+#if defined (HAVE_LOCALE_H)
+#  include <locale.h>
+#endif
+
+#include <stdio.h>
+
+/* System-specific feature definitions and include files. */
+#include "rldefs.h"
+#include "rlmbutil.h"
+
+/* Some standard library routines. */
+#include "readline.h"
+#include "history.h"
+
+#include "rlprivate.h"
+#include "rlshell.h"
+#include "xmalloc.h"
+
+static int rl_digit_loop PARAMS((void));
+static void _rl_history_set_point PARAMS((void));
+
+/* Forward declarations used in this file */
+void _rl_free_history_entry PARAMS((HIST_ENTRY *));
+
+/* If non-zero, rl_get_previous_history and rl_get_next_history attempt
+   to preserve the value of rl_point from line to line. */
+int _rl_history_preserve_point = 0;
+
+/* Saved target point for when _rl_history_preserve_point is set.  Special
+   value of -1 means that point is at the end of the line. */
+int _rl_history_saved_point = -1;
+
+/* **************************************************************** */
+/*								    */
+/*			Numeric Arguments			    */
+/*								    */
+/* **************************************************************** */
+
+/* Handle C-u style numeric args, as well as M--, and M-digits. */
+static int
+rl_digit_loop ()
+{
+  int key, c, sawminus, sawdigits;
+
+  rl_save_prompt ();
+
+  RL_SETSTATE(RL_STATE_NUMERICARG);
+  sawminus = sawdigits = 0;
+  while (1)
+    {
+      if (rl_numeric_arg > 1000000)
+	{
+	  sawdigits = rl_explicit_arg = rl_numeric_arg = 0;
+	  rl_ding ();
+	  rl_restore_prompt ();
+	  rl_clear_message ();
+	  RL_UNSETSTATE(RL_STATE_NUMERICARG);
+	  return 1;
+	}
+      rl_message ("(arg: %d) ", rl_arg_sign * rl_numeric_arg);
+      RL_SETSTATE(RL_STATE_MOREINPUT);
+      key = c = rl_read_key ();
+      RL_UNSETSTATE(RL_STATE_MOREINPUT);
+
+      if (c < 0)
+	{
+	  _rl_abort_internal ();
+	  return -1;
+	}
+
+      /* If we see a key bound to `universal-argument' after seeing digits,
+	 it ends the argument but is otherwise ignored. */
+      if (_rl_keymap[c].type == ISFUNC &&
+	  _rl_keymap[c].function == rl_universal_argument)
+	{
+	  if (sawdigits == 0)
+	    {
+	      rl_numeric_arg *= 4;
+	      continue;
+	    }
+	  else
+	    {
+	      RL_SETSTATE(RL_STATE_MOREINPUT);
+	      key = rl_read_key ();
+	      RL_UNSETSTATE(RL_STATE_MOREINPUT);
+	      rl_restore_prompt ();
+	      rl_clear_message ();
+	      RL_UNSETSTATE(RL_STATE_NUMERICARG);
+	      return (_rl_dispatch (key, _rl_keymap));
+	    }
+	}
+
+      c = UNMETA (c);
+
+      if (_rl_digit_p (c))
+	{
+	  rl_numeric_arg = rl_explicit_arg ? (rl_numeric_arg * 10) + c - '0' : c - '0';
+	  sawdigits = rl_explicit_arg = 1;
+	}
+      else if (c == '-' && rl_explicit_arg == 0)
+	{
+	  rl_numeric_arg = sawminus = 1;
+	  rl_arg_sign = -1;
+	}
+      else
+	{
+	  /* Make M-- command equivalent to M--1 command. */
+	  if (sawminus && rl_numeric_arg == 1 && rl_explicit_arg == 0)
+	    rl_explicit_arg = 1;
+	  rl_restore_prompt ();
+	  rl_clear_message ();
+	  RL_UNSETSTATE(RL_STATE_NUMERICARG);
+	  return (_rl_dispatch (key, _rl_keymap));
+	}
+    }
+
+  /*NOTREACHED*/
+}
+
+/* Add the current digit to the argument in progress. */
+int
+rl_digit_argument (ignore, key)
+     int ignore __attribute__((unused)), key;
+{
+  rl_execute_next (key);
+  return (rl_digit_loop ());
+}
+
+/* What to do when you abort reading an argument. */
+int
+rl_discard_argument ()
+{
+  rl_ding ();
+  rl_clear_message ();
+  _rl_init_argument ();
+  return 0;
+}
+
+/* Create a default argument. */
+int
+_rl_init_argument ()
+{
+  rl_numeric_arg = rl_arg_sign = 1;
+  rl_explicit_arg = 0;
+  return 0;
+}
+
+/* C-u, universal argument.  Multiply the current argument by 4.
+   Read a key.  If the key has nothing to do with arguments, then
+   dispatch on it.  If the key is the abort character then abort. */
+int
+rl_universal_argument (count, key)
+     int count __attribute__((unused)), key __attribute__((unused));
+{
+  rl_numeric_arg *= 4;
+  return (rl_digit_loop ());
+}
+
+/* **************************************************************** */
+/*								    */
+/*			History Utilities			    */
+/*								    */
+/* **************************************************************** */
+
+/* We already have a history library, and that is what we use to control
+   the history features of readline.  This is our local interface to
+   the history mechanism. */
+
+/* While we are editing the history, this is the saved
+   version of the original line. */
+HIST_ENTRY *_rl_saved_line_for_history = (HIST_ENTRY *)NULL;
+
+/* Set the history pointer back to the last entry in the history. */
+void
+_rl_start_using_history ()
+{
+  using_history ();
+  if (_rl_saved_line_for_history)
+    _rl_free_history_entry (_rl_saved_line_for_history);
+
+  _rl_saved_line_for_history = (HIST_ENTRY *)NULL;
+}
+
+/* Free the contents (and containing structure) of a HIST_ENTRY. */
+void
+_rl_free_history_entry (entry)
+     HIST_ENTRY *entry;
+{
+  if (entry == 0)
+    return;
+  if (entry->line)
+    free (entry->line);
+  free (entry);
+}
+
+/* Perhaps put back the current line if it has changed. */
+int
+rl_maybe_replace_line ()
+{
+  HIST_ENTRY *temp;
+
+  temp = current_history ();
+  /* If the current line has changed, save the changes. */
+  if (temp && ((UNDO_LIST *)(temp->data) != rl_undo_list))
+    {
+      temp = replace_history_entry (where_history (), rl_line_buffer, (histdata_t)rl_undo_list);
+      free (temp->line);
+      free (temp);
+    }
+  return 0;
+}
+
+/* Restore the _rl_saved_line_for_history if there is one. */
+int
+rl_maybe_unsave_line ()
+{
+  if (_rl_saved_line_for_history)
+    {
+      rl_replace_line (_rl_saved_line_for_history->line, 0);
+      rl_undo_list = (UNDO_LIST *)_rl_saved_line_for_history->data;
+      _rl_free_history_entry (_rl_saved_line_for_history);
+      _rl_saved_line_for_history = (HIST_ENTRY *)NULL;
+      rl_point = rl_end;	/* rl_replace_line sets rl_end */
+    }
+  else
+    rl_ding ();
+  return 0;
+}
+
+/* Save the current line in _rl_saved_line_for_history. */
+int
+rl_maybe_save_line ()
+{
+  if (_rl_saved_line_for_history == 0)
+    {
+      _rl_saved_line_for_history = (HIST_ENTRY *)xmalloc (sizeof (HIST_ENTRY));
+      _rl_saved_line_for_history->line = savestring (rl_line_buffer);
+      _rl_saved_line_for_history->data = (char *)rl_undo_list;
+    }
+  return 0;
+}
+
+int
+_rl_free_saved_history_line ()
+{
+  if (_rl_saved_line_for_history)
+    {
+      _rl_free_history_entry (_rl_saved_line_for_history);
+      _rl_saved_line_for_history = (HIST_ENTRY *)NULL;
+    }
+  return 0;
+}
+
+static void
+_rl_history_set_point ()
+{
+  rl_point = (_rl_history_preserve_point && _rl_history_saved_point != -1)
+		? _rl_history_saved_point
+		: rl_end;
+  if (rl_point > rl_end)
+    rl_point = rl_end;
+
+#if defined (VI_MODE)
+  if (rl_editing_mode == vi_mode)
+    rl_point = 0;
+#endif /* VI_MODE */
+
+  if (rl_editing_mode == emacs_mode)
+    rl_mark = (rl_point == rl_end ? 0 : rl_end);
+}
+
+void
+rl_replace_from_history (entry, flags)
+     HIST_ENTRY *entry;
+     int flags __attribute__((unused));			/* currently unused */
+{
+  rl_replace_line (entry->line, 0);
+  rl_undo_list = (UNDO_LIST *)entry->data;
+  rl_point = rl_end;
+  rl_mark = 0;
+
+#if defined (VI_MODE)
+  if (rl_editing_mode == vi_mode)
+    {
+      rl_point = 0;
+      rl_mark = rl_end;
+    }
+#endif
+}  
+
+/* **************************************************************** */
+/*								    */
+/*			History Commands			    */
+/*								    */
+/* **************************************************************** */
+
+/* Meta-< goes to the start of the history. */
+int
+rl_beginning_of_history (count, key)
+     int count __attribute__((unused)), key;
+{
+  return (rl_get_previous_history (1 + where_history (), key));
+}
+
+/* Meta-> goes to the end of the history.  (The current line). */
+int
+rl_end_of_history (count, key)
+     int count __attribute__((unused)), key __attribute__((unused));
+{
+  rl_maybe_replace_line ();
+  using_history ();
+  rl_maybe_unsave_line ();
+  return 0;
+}
+
+/* Move down to the next history line. */
+int
+rl_get_next_history (count, key)
+     int count, key;
+{
+  HIST_ENTRY *temp;
+
+  if (count < 0)
+    return (rl_get_previous_history (-count, key));
+
+  if (count == 0)
+    return 0;
+
+  rl_maybe_replace_line ();
+
+  /* either not saved by rl_newline or at end of line, so set appropriately. */
+  if (_rl_history_saved_point == -1 && (rl_point || rl_end))
+    _rl_history_saved_point = (rl_point == rl_end) ? -1 : rl_point;
+
+  temp = (HIST_ENTRY *)NULL;
+  while (count)
+    {
+      temp = next_history ();
+      if (!temp)
+	break;
+      --count;
+    }
+
+  if (temp == 0)
+    rl_maybe_unsave_line ();
+  else
+    {
+      rl_replace_from_history (temp, 0);
+      _rl_history_set_point ();
+    }
+  return 0;
+}
+
+/* Get the previous item out of our interactive history, making it the current
+   line.  If there is no previous history, just ding. */
+int
+rl_get_previous_history (count, key)
+     int count, key;
+{
+  HIST_ENTRY *old_temp, *temp;
+
+  if (count < 0)
+    return (rl_get_next_history (-count, key));
+
+  if (count == 0)
+    return 0;
+
+  /* either not saved by rl_newline or at end of line, so set appropriately. */
+  if (_rl_history_saved_point == -1 && (rl_point || rl_end))
+    _rl_history_saved_point = (rl_point == rl_end) ? -1 : rl_point;
+
+  /* If we don't have a line saved, then save this one. */
+  rl_maybe_save_line ();
+
+  /* If the current line has changed, save the changes. */
+  rl_maybe_replace_line ();
+
+  temp = old_temp = (HIST_ENTRY *)NULL;
+  while (count)
+    {
+      temp = previous_history ();
+      if (temp == 0)
+	break;
+
+      old_temp = temp;
+      --count;
+    }
+
+  /* If there was a large argument, and we moved back to the start of the
+     history, that is not an error.  So use the last value found. */
+  if (!temp && old_temp)
+    temp = old_temp;
+
+  if (temp == 0)
+    rl_ding ();
+  else
+    {
+      rl_replace_from_history (temp, 0);
+      _rl_history_set_point ();
+    }
+  return 0;
+}
+
+/* **************************************************************** */
+/*								    */
+/*			    Editing Modes			    */
+/*								    */
+/* **************************************************************** */
+/* How to toggle back and forth between editing modes. */
+int
+rl_vi_editing_mode (count, key)
+     int count __attribute__((unused)), key;
+{
+#if defined (VI_MODE)
+  _rl_set_insert_mode (RL_IM_INSERT, 1);	/* vi mode ignores insert mode */
+  rl_editing_mode = vi_mode;
+  rl_vi_insertion_mode (1, key);
+#endif /* VI_MODE */
+
+  return 0;
+}
+
+int
+rl_emacs_editing_mode (count, key)
+     int count __attribute__((unused)), key __attribute__((unused));
+{
+  rl_editing_mode = emacs_mode;
+  _rl_set_insert_mode (RL_IM_INSERT, 1); /* emacs mode default is insert mode */
+  _rl_keymap = emacs_standard_keymap;
+  return 0;
+}
+
+/* Function for the rest of the library to use to set insert/overwrite mode. */
+void
+_rl_set_insert_mode (im, force)
+     int im, force __attribute__((unused));
+{
+#ifdef CURSOR_MODE
+  _rl_set_cursor (im, force);
+#endif
+
+  rl_insert_mode = im;
+}
+
+/* Toggle overwrite mode.  A positive explicit argument selects overwrite
+   mode.  A negative or zero explicit argument selects insert mode. */
+int
+rl_overwrite_mode (count, key)
+     int count, key __attribute__((unused));
+{
+  if (rl_explicit_arg == 0)
+    _rl_set_insert_mode (rl_insert_mode ^ 1, 0);
+  else if (count > 0)
+    _rl_set_insert_mode (RL_IM_OVERWRITE, 0);
+  else
+    _rl_set_insert_mode (RL_IM_INSERT, 0);
+
+  return 0;
+}
diff --git a/readline/nls.c b/readline/nls.c
index f2d413d59d5a1d3a03217b598c226573c9693d2c..706c8195c1047bde36d26ff34622a133fb7cc980 100644
--- a/readline/nls.c
+++ b/readline/nls.c
@@ -7,7 +7,7 @@
 
    The GNU Readline Library is free software; you can redistribute it
    and/or modify it under the terms of the GNU General Public License
-   as published by the Free Software Foundation; either version 1, or
+   as published by the Free Software Foundation; either version 2, or
    (at your option) any later version.
 
    The GNU Readline Library is distributed in the hope that it will be
@@ -18,7 +18,7 @@
    The GNU General Public License is often shipped with GNU software, and
    is generally kept in a file called COPYING or LICENSE.  If you do not
    have a copy of the license, write to the Free Software Foundation,
-   675 Mass Ave, Cambridge, MA 02139, USA. */
+   59 Temple Place, Suite 330, Boston, MA 02111 USA. */
 #define READLINE_LIBRARY
 
 #if defined (HAVE_CONFIG_H)
@@ -27,6 +27,8 @@
 
 #include <sys/types.h>
 
+#include <stdio.h>
+
 #if defined (HAVE_UNISTD_H)
 #  include <unistd.h>
 #endif /* HAVE_UNISTD_H */
@@ -44,13 +46,9 @@
 #include <ctype.h>
 
 #include "rldefs.h"
-
-extern int _rl_convert_meta_chars_to_ascii;
-extern int _rl_output_meta_chars;
-extern int _rl_meta_flag;
-
-/* Functions imported from shell.c */
-extern char *get_env_value ();
+#include "readline.h"
+#include "rlshell.h"
+#include "rlprivate.h"
 
 #if !defined (HAVE_SETLOCALE)    
 /* A list of legal values for the LANG or LC_CTYPE environment variables.
@@ -70,12 +68,11 @@ static char *legal_lang_values[] =
  "iso88599",
  "iso885910",
  "koi8r",
- "koi8-r", 
   0
 };
 
-static char *normalize_codeset ();
-static char *find_codeset ();
+static char *normalize_codeset PARAMS((char *));
+static char *find_codeset PARAMS((char *, size_t *));
 #endif /* !HAVE_SETLOCALE */
 
 /* Check for LC_ALL, LC_CTYPE, and LANG and use the first with a value
@@ -108,9 +105,9 @@ _rl_init_eightbit ()
   /* We don't have setlocale.  Finesse it.  Check the environment for the
      appropriate variables and set eight-bit mode if they have the right
      values. */
-  lspec = get_env_value ("LC_ALL");
-  if (lspec == 0) lspec = get_env_value ("LC_CTYPE");
-  if (lspec == 0) lspec = get_env_value ("LANG");
+  lspec = sh_get_env_value ("LC_ALL");
+  if (lspec == 0) lspec = sh_get_env_value ("LC_CTYPE");
+  if (lspec == 0) lspec = sh_get_env_value ("LANG");
   if (lspec == 0 || (t = normalize_codeset (lspec)) == 0)
     return (0);
   for (i = 0; t && legal_lang_values[i]; i++)
@@ -144,10 +141,10 @@ normalize_codeset (codeset)
   all_digits = 1;
   for (len = 0, i = 0; i < namelen; i++)
     {
-      if (isalnum (codeset[i]))
+      if (ISALNUM ((unsigned char)codeset[i]))
 	{
 	  len++;
-	  all_digits &= isdigit (codeset[i]);
+	  all_digits &= _rl_digit_p (codeset[i]);
 	}
     }
 
@@ -165,9 +162,9 @@ normalize_codeset (codeset)
     }
 
   for (i = 0; i < namelen; i++)
-    if (isalpha (codeset[i]))
-      *wp++ = (isupper (codeset[i])) ? tolower (codeset[i]) : codeset[i];
-    else if (isdigit (codeset[i]))
+    if (ISALPHA ((unsigned char)codeset[i]))
+      *wp++ = _rl_to_lower (codeset[i]);
+    else if (_rl_digit_p (codeset[i]))
       *wp++ = codeset[i];
   *wp = '\0';
 
diff --git a/readline/parens.c b/readline/parens.c
index a500c0afac717c6ef17c39cb6194cea758ed0c70..54ef1f3695faf8ff4545139fe46357949134f42d 100644
--- a/readline/parens.c
+++ b/readline/parens.c
@@ -7,7 +7,7 @@
 
    The GNU Readline Library is free software; you can redistribute it
    and/or modify it under the terms of the GNU General Public License
-   as published by the Free Software Foundation; either version 1, or
+   as published by the Free Software Foundation; either version 2, or
    (at your option) any later version.
 
    The GNU Readline Library is distributed in the hope that it will be
@@ -18,23 +18,11 @@
    The GNU General Public License is often shipped with GNU software, and
    is generally kept in a file called COPYING or LICENSE.  If you do not
    have a copy of the license, write to the Free Software Foundation,
-   675 Mass Ave, Cambridge, MA 02139, USA. */
+   59 Temple Place, Suite 330, Boston, MA 02111 USA. */
 #define READLINE_LIBRARY
 
 #include "rlconf.h"
 
-#if !defined (PAREN_MATCHING)
-extern int rl_insert ();
-
-int
-rl_insert_close (count, invoking_key)
-     int count, invoking_key;
-{
-  return (rl_insert (count, invoking_key));
-}
-
-#else /* PAREN_MATCHING */
-
 #if defined (HAVE_CONFIG_H)
 #  include <config.h>
 #endif
@@ -42,6 +30,10 @@ rl_insert_close (count, invoking_key)
 #include <stdio.h>
 #include <sys/types.h>
 
+#if defined (HAVE_UNISTD_H)
+#  include <unistd.h>
+#endif
+
 #if defined (FD_SET) && !defined (HAVE_SELECT)
 #  define HAVE_SELECT
 #endif
@@ -64,8 +56,9 @@ extern char *strchr (), *strrchr ();
 #endif /* !strchr && !__STDC__ */
 
 #include "readline.h"
+#include "rlprivate.h"
 
-extern int rl_explicit_arg;
+static int find_matching_open PARAMS((char *, int, int));
 
 /* Non-zero means try to blink the matching open parenthesis when the
    close parenthesis is inserted. */
@@ -75,14 +68,46 @@ int rl_blink_matching_paren = 1;
 int rl_blink_matching_paren = 0;
 #endif /* !HAVE_SELECT */
 
-static int find_matching_open ();
+static int _paren_blink_usec = 500000;
+
+/* Change emacs_standard_keymap to have bindings for paren matching when
+   ON_OR_OFF is 1, change them back to self_insert when ON_OR_OFF == 0. */
+void
+_rl_enable_paren_matching (on_or_off)
+     int on_or_off;
+{
+  if (on_or_off)
+    {	/* ([{ */
+      rl_bind_key_in_map (')', rl_insert_close, emacs_standard_keymap);
+      rl_bind_key_in_map (']', rl_insert_close, emacs_standard_keymap);
+      rl_bind_key_in_map ('}', rl_insert_close, emacs_standard_keymap);
+    }
+  else
+    {	/* ([{ */
+      rl_bind_key_in_map (')', rl_insert, emacs_standard_keymap);
+      rl_bind_key_in_map (']', rl_insert, emacs_standard_keymap);
+      rl_bind_key_in_map ('}', rl_insert, emacs_standard_keymap);
+    }
+}
+
+int
+rl_set_paren_blink_timeout (u)
+     int u;
+{
+  int o;
+
+  o = _paren_blink_usec;
+  if (u > 0)
+    _paren_blink_usec = u;
+  return (o);
+}
 
 int
 rl_insert_close (count, invoking_key)
      int count, invoking_key;
 {
   if (rl_explicit_arg || !rl_blink_matching_paren)
-    rl_insert (count, invoking_key);
+    _rl_insert_char (count, invoking_key);
   else
     {
 #if defined (HAVE_SELECT)
@@ -90,7 +115,7 @@ rl_insert_close (count, invoking_key)
       struct timeval timer;
       fd_set readfds;
 
-      rl_insert (1, invoking_key);
+      _rl_insert_char (1, invoking_key);
       (*rl_redisplay_function) ();
       match_point =
 	find_matching_open (rl_line_buffer, rl_point - 2, invoking_key);
@@ -102,7 +127,7 @@ rl_insert_close (count, invoking_key)
       FD_ZERO (&readfds);
       FD_SET (fileno (rl_instream), &readfds);
       timer.tv_sec = 0;
-      timer.tv_usec = 500000;
+      timer.tv_usec = _paren_blink_usec;
 
       orig_point = rl_point;
       rl_point = match_point;
@@ -110,7 +135,7 @@ rl_insert_close (count, invoking_key)
       ready = select (1, &readfds, (fd_set *)NULL, (fd_set *)NULL, &timer);
       rl_point = orig_point;
 #else /* !HAVE_SELECT */
-      rl_insert (count, invoking_key);
+      _rl_insert_char (count, invoking_key);
 #endif /* !HAVE_SELECT */
     }
   return 0;
@@ -152,5 +177,3 @@ find_matching_open (string, from, closer)
     }
   return (i);
 }
-
-#endif /* PAREN_MATCHING */
diff --git a/readline/posixdir.h b/readline/posixdir.h
index 7480a93d5dbefb08934e82ea926695f8ffd0ff14..505e27954f1683671ed12b7e1a140fb9ae9e7ba4 100644
--- a/readline/posixdir.h
+++ b/readline/posixdir.h
@@ -6,7 +6,7 @@
 
    Bash is free software; you can redistribute it and/or modify it
    under the terms of the GNU General Public License as published by
-   the Free Software Foundation; either version 1, or (at your option)
+   the Free Software Foundation; either version 2, or (at your option)
    any later version.
 
    Bash is distributed in the hope that it will be useful, but WITHOUT
@@ -16,7 +16,7 @@
 
    You should have received a copy of the GNU General Public License
    along with Bash; see the file COPYING.  If not, write to the Free
-   Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. */
+   Software Foundation, 59 Temple Place, Suite 330, Boston, MA 02111 USA. */
 
 /* This file should be included instead of <dirent.h> or <sys/dir.h>. */
 
@@ -46,4 +46,12 @@
 #  define d_fileno d_ino
 #endif
 
+#if defined (_POSIX_SOURCE) && (!defined (STRUCT_DIRENT_HAS_D_INO) || defined (BROKEN_DIRENT_D_INO))
+/* Posix does not require that the d_ino field be present, and some
+   systems do not provide it. */
+#  define REAL_DIR_ENTRY(dp) 1
+#else
+#  define REAL_DIR_ENTRY(dp) (dp->d_ino != 0)
+#endif /* _POSIX_SOURCE */
+
 #endif /* !_POSIXDIR_H_ */
diff --git a/readline/posixjmp.h b/readline/posixjmp.h
index 1347cc07ebc507bc31b2fbb1eec3f6d6c0865218..b52aa00332b66881b88d793207e9865a05d7ed32 100644
--- a/readline/posixjmp.h
+++ b/readline/posixjmp.h
@@ -1,5 +1,23 @@
 /* posixjmp.h -- wrapper for setjmp.h with changes for POSIX systems. */
 
+/* Copyright (C) 1987,1991 Free Software Foundation, Inc.
+
+   This file is part of GNU Bash, the Bourne Again SHell.
+
+   Bash is free software; you can redistribute it and/or modify it
+   under the terms of the GNU General Public License as published by
+   the Free Software Foundation; either version 2, or (at your option)
+   any later version.
+
+   Bash is distributed in the hope that it will be useful, but WITHOUT
+   ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
+   or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public
+   License for more details.
+
+   You should have received a copy of the GNU General Public License
+   along with Bash; see the file COPYING.  If not, write to the Free
+   Software Foundation, 59 Temple Place, Suite 330, Boston, MA 02111 USA. */
+
 #ifndef _POSIXJMP_H_
 #define _POSIXJMP_H_
 
diff --git a/readline/posixstat.h b/readline/posixstat.h
index bfce8c04fef1096c778a0815758c8c775c0a2f4e..c93b52887e9dfc5b0405153cc9c3658f0281ac1c 100644
--- a/readline/posixstat.h
+++ b/readline/posixstat.h
@@ -7,7 +7,7 @@
 
    Bash is free software; you can redistribute it and/or modify it
    under the terms of the GNU General Public License as published by
-   the Free Software Foundation; either version 1, or (at your option)
+   the Free Software Foundation; either version 2, or (at your option)
    any later version.
 
    Bash is distributed in the hope that it will be useful, but WITHOUT
@@ -17,7 +17,7 @@
 
    You should have received a copy of the GNU General Public License
    along with Bash; see the file COPYING.  If not, write to the Free
-   Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. */
+   Software Foundation, 59 Temple Place, Suite 330, Boston, MA 02111 USA. */
 
 /* This file should be included instead of <sys/stat.h>.
    It relies on the local sys/stat.h to work though. */
diff --git a/readline/readline.c b/readline/readline.c
index 1da73250773ffd936913d0f8f07b438909f930e4..28801f19dfc1ea1036258440ee690a1b1438ffd7 100644
--- a/readline/readline.c
+++ b/readline/readline.c
@@ -1,14 +1,14 @@
 /* readline.c -- a general facility for reading lines of input
    with emacs style editing and completion. */
 
-/* Copyright (C) 1987, 1989, 1992 Free Software Foundation, Inc.
+/* Copyright (C) 1987-2002 Free Software Foundation, Inc.
 
    This file is part of the GNU Readline Library, a library for
    reading lines of text with interactive input and history editing.
 
    The GNU Readline Library is free software; you can redistribute it
    and/or modify it under the terms of the GNU General Public License
-   as published by the Free Software Foundation; either version 1, or
+   as published by the Free Software Foundation; either version 2, or
    (at your option) any later version.
 
    The GNU Readline Library is distributed in the hope that it will be
@@ -19,7 +19,7 @@
    The GNU General Public License is often shipped with GNU software, and
    is generally kept in a file called COPYING or LICENSE.  If you do not
    have a copy of the license, write to the Free Software Foundation,
-   675 Mass Ave, Cambridge, MA 02139, USA. */
+   59 Temple Place, Suite 330, Boston, MA 02111 USA. */
 #define READLINE_LIBRARY
 
 #if defined (HAVE_CONFIG_H)
@@ -47,12 +47,12 @@
 #  include <locale.h>
 #endif
 
-#include <signal.h>
 #include <stdio.h>
 #include "posixjmp.h"
 
 /* System-specific feature definitions and include files. */
 #include "rldefs.h"
+#include "rlmbutil.h"
 
 #if defined (__EMX__)
 #  define INCL_DOSPROCESS
@@ -63,117 +63,28 @@
 #include "readline.h"
 #include "history.h"
 
+#include "rlprivate.h"
+#include "rlshell.h"
+#include "xmalloc.h"
+
 #ifndef RL_LIBRARY_VERSION
-#  define RL_LIBRARY_VERSION "4.0"
+#  define RL_LIBRARY_VERSION "4.3"
 #endif
 
-/* Evaluates its arguments multiple times. */
-#define SWAP(s, e)  do { int t; t = s; s = e; e = t; } while (0)
-
-/* NOTE: Functions and variables prefixed with `_rl_' are
-   pseudo-global: they are global so they can be shared
-   between files in the readline library, but are not intended
-   to be visible to readline callers. */
-
-/* Variables and functions imported from terminal.c */
-extern int _rl_init_terminal_io ();
-extern void _rl_enable_meta_key ();
-#ifdef _MINIX
-extern void _rl_output_character_function ();
-#else
-extern int _rl_output_character_function ();
+#ifndef RL_READLINE_VERSION
+#  define RL_READLINE_VERSION	0x0403
 #endif
 
-extern int _rl_enable_meta;
-extern int _rl_term_autowrap;
-extern int screenwidth, screenheight, screenchars;
-
-/* Variables and functions imported from rltty.c. */
-extern void rl_prep_terminal (), rl_deprep_terminal ();
-extern void rltty_set_default_bindings ();
-
-/* Functions imported from util.c. */
-extern void _rl_abort_internal ();
-extern void rl_extend_line_buffer ();
-extern int alphabetic ();
-
-/* Functions imported from bind.c. */
-extern void _rl_bind_if_unbound ();
-
-/* Functions imported from input.c. */
-extern int _rl_any_typein ();
-extern void _rl_insert_typein ();
-extern int rl_read_key ();
-
-/* Functions imported from nls.c */
-extern int _rl_init_eightbit ();
-
-/* Functions imported from shell.c */
-extern char *get_env_value ();
-
-/* External redisplay functions and variables from display.c */
-extern void _rl_move_vert ();
-extern void _rl_update_final ();
-extern void _rl_clear_to_eol ();
-extern void _rl_clear_screen ();
-extern void _rl_erase_entire_line ();
-
-extern void _rl_erase_at_end_of_line ();
-extern void _rl_move_cursor_relative ();
-
-extern int _rl_vis_botlin;
-extern int _rl_last_c_pos;
-extern int _rl_horizontal_scroll_mode;
-extern int rl_display_fixed;
-extern int _rl_suppress_redisplay;
-extern char *rl_display_prompt;
-
-/* Variables imported from complete.c. */
-extern const char *rl_completer_word_break_characters;
-extern const char *rl_basic_word_break_characters;
-extern int rl_completion_query_items;
-extern int rl_complete_with_tilde_expansion;
-
-/* Variables and functions from macro.c. */
-extern void _rl_add_macro_char ();
-extern void _rl_with_macro_input ();
-extern int _rl_next_macro_key ();
-extern int _rl_defining_kbd_macro;
-
-#if defined (VI_MODE)
-/* Functions imported from vi_mode.c. */
-extern void _rl_vi_set_last ();
-extern void _rl_vi_reset_last ();
-extern void _rl_vi_done_inserting ();
-extern int _rl_vi_textmod_command ();
-extern void _rl_vi_initialize_line ();
-#endif /* VI_MODE */
-
-extern UNDO_LIST *rl_undo_list;
-extern int _rl_doing_an_undo;
+extern void _rl_free_history_entry PARAMS((HIST_ENTRY *));
 
 /* Forward declarations used in this file. */
-void _rl_free_history_entry ();
+static char *readline_internal PARAMS((void));
+static void readline_initialize_everything PARAMS((void));
 
-int _rl_dispatch ();
-int _rl_init_argument ();
+static void bind_arrow_keys_internal PARAMS((Keymap));
+static void bind_arrow_keys PARAMS((void));
 
-static char *readline_internal ();
-static void readline_initialize_everything ();
-static void start_using_history ();
-static void bind_arrow_keys ();
-
-#if !defined (__GO32__)
-static void readline_default_bindings ();
-#endif /* !__GO32__ */
-
-#if defined (__GO32__)
-#  include <go32.h>
-#  include <pc.h>
-#  undef HANDLE_SIGNALS
-#endif /* __GO32__ */
-
-extern char *xmalloc (), *xrealloc ();
+static void readline_default_bindings PARAMS((void));
 
 /* **************************************************************** */
 /*								    */
@@ -183,6 +94,11 @@ extern char *xmalloc (), *xrealloc ();
 
 const char *rl_library_version = RL_LIBRARY_VERSION;
 
+int rl_readline_version = RL_READLINE_VERSION;
+
+/* True if this is `real' readline as opposed to some stub substitute. */
+int rl_gnu_readline_p = 1;
+
 /* A pointer to the keymap that is currently in use.
    By default, it is the standard emacs keymap. */
 Keymap _rl_keymap = emacs_standard_keymap;
@@ -190,6 +106,9 @@ Keymap _rl_keymap = emacs_standard_keymap;
 /* The current style of editing. */
 int rl_editing_mode = emacs_mode;
 
+/* The current insert mode:  input (the default) or overwrite */
+int rl_insert_mode = RL_IM_DEFAULT;
+
 /* Non-zero if we called this function from _rl_dispatch().  It's present
    so functions can find out whether they were called from a key binding
    or directly from an application. */
@@ -210,8 +129,13 @@ int rl_arg_sign = 1;
 /* Non-zero means we have been called at least once before. */
 static int rl_initialized;
 
+#if 0
 /* If non-zero, this program is running in an EMACS buffer. */
 static int running_in_emacs;
+#endif
+
+/* Flags word encapsulating the current readline state. */
+int rl_readline_state = RL_STATE_NONE;
 
 /* The current offset in the current input line. */
 int rl_point;
@@ -226,7 +150,7 @@ int rl_end;
 int rl_done;
 
 /* The last function executed by readline. */
-Function *rl_last_func = (Function *)NULL;
+rl_command_func_t *rl_last_func = (rl_command_func_t *)NULL;
 
 /* Top level environment for readline_internal (). */
 procenv_t readline_top_level;
@@ -238,24 +162,31 @@ FILE *_rl_in_stream, *_rl_out_stream;
 FILE *rl_instream = (FILE *)NULL;
 FILE *rl_outstream = (FILE *)NULL;
 
-/* Non-zero means echo characters as they are read. */
-int readline_echoing_p = 1;
+/* Non-zero means echo characters as they are read.  Defaults to no echo;
+   set to 1 if there is a controlling terminal, we can get its attributes,
+   and the attributes include `echo'.  Look at rltty.c:prepare_terminal_settings
+   for the code that sets it. */
+int readline_echoing_p = 0;
 
 /* Current prompt. */
-char *rl_prompt;
+char *rl_prompt = (char *)NULL;
 int rl_visible_prompt_length = 0;
 
+/* Set to non-zero by calling application if it has already printed rl_prompt
+   and does not want readline to do it the first time. */
+int rl_already_prompted = 0;
+
 /* The number of characters read in order to type this complete command. */
 int rl_key_sequence_length = 0;
 
 /* If non-zero, then this is the address of a function to call just
    before readline_internal_setup () prints the first prompt. */
-Function *rl_startup_hook = (Function *)NULL;
+rl_hook_func_t *rl_startup_hook = (rl_hook_func_t *)NULL;
 
 /* If non-zero, this is the address of a function to call just before
    readline_internal_setup () returns and readline_internal starts
    reading input characters. */
-Function *rl_pre_input_hook = (Function *)NULL;
+rl_hook_func_t *rl_pre_input_hook = (rl_hook_func_t *)NULL;
 
 /* What we use internally.  You should always refer to RL_LINE_BUFFER. */
 static char *the_line;
@@ -268,7 +199,7 @@ int _rl_eof_char = CTRL ('D');
 int rl_pending_input = 0;
 
 /* Pointer to a useful terminal name. */
-char *rl_terminal_name = (char *)NULL;
+const char *rl_terminal_name = (const char *)NULL;
 
 /* Non-zero means to always use horizontal scrolling in line display. */
 int _rl_horizontal_scroll_mode = 0;
@@ -280,7 +211,7 @@ int _rl_mark_modified_lines = 0;
 /* The style of `bell' notification preferred.  This can be set to NO_BELL,
    AUDIBLE_BELL, or VISIBLE_BELL. */
 int _rl_bell_preference = AUDIBLE_BELL;
-
+     
 /* String inserted into the line by rl_insert_comment (). */
 char *_rl_comment_begin;
 
@@ -290,11 +221,15 @@ Keymap rl_executing_keymap;
 /* Non-zero means to erase entire line, including prompt, on empty input lines. */
 int rl_erase_empty_line = 0;
 
+/* Non-zero means to read only this many characters rather than up to a
+   character bound to accept-line. */
+int rl_num_chars_to_read;
+
 /* Line buffer and maintenence. */
 char *rl_line_buffer = (char *)NULL;
 int rl_line_buffer_len = 0;
 
-/* Forward declarations used by the display and termcap code. */
+/* Forward declarations used by the display, termcap, and history code. */
 
 /* **************************************************************** */
 /*								    */
@@ -324,24 +259,35 @@ int _rl_output_meta_chars = 0;
 /* Non-zero means treat 0200 bit in terminal input as Meta bit. */
 int _rl_meta_flag = 0;	/* Forward declaration */
 
+/* Set up the prompt and expand it.  Called from readline() and
+   rl_callback_handler_install (). */
+int
+rl_set_prompt (prompt)
+     const char *prompt;
+{
+  FREE (rl_prompt);
+  rl_prompt = prompt ? savestring (prompt) : (char *)NULL;
+
+  rl_visible_prompt_length = rl_expand_prompt (rl_prompt);
+  return 0;
+}
+  
 /* Read a line of input.  Prompt with PROMPT.  An empty PROMPT means
    none.  A return value of NULL means that EOF was encountered. */
 char *
 readline (prompt)
-     char *prompt;
+     const char *prompt;
 {
   char *value;
 
-  rl_prompt = prompt;
-
   /* If we are at EOF return a NULL string. */
   if (rl_pending_input == EOF)
     {
-      rl_pending_input = 0;
+      rl_clear_pending_input ();
       return ((char *)NULL);
     }
 
-  rl_visible_prompt_length = rl_expand_prompt (rl_prompt);
+  rl_set_prompt (prompt);
 
   rl_initialize ();
   (*rl_prep_term_function) (_rl_meta_flag);
@@ -369,29 +315,40 @@ readline (prompt)
 STATIC_CALLBACK void
 readline_internal_setup ()
 {
+  char *nprompt;
+
   _rl_in_stream = rl_instream;
   _rl_out_stream = rl_outstream;
 
   if (rl_startup_hook)
     (*rl_startup_hook) ();
 
-  if (readline_echoing_p == 0)
+  /* If we're not echoing, we still want to at least print a prompt, because
+     rl_redisplay will not do it for us.  If the calling application has a
+     custom redisplay function, though, let that function handle it. */
+  if (readline_echoing_p == 0 && rl_redisplay_function == rl_redisplay)
     {
-      if (rl_prompt)
+      if (rl_prompt && rl_already_prompted == 0)
 	{
-	  fprintf (_rl_out_stream, "%s", rl_prompt);
+	  nprompt = _rl_strip_prompt (rl_prompt);
+	  fprintf (_rl_out_stream, "%s", nprompt);
 	  fflush (_rl_out_stream);
+	  free (nprompt);
 	}
     }
   else
     {
-      rl_on_new_line ();
+      if (rl_prompt && rl_already_prompted)
+	rl_on_new_line_with_prompt ();
+      else
+	rl_on_new_line ();
       (*rl_redisplay_function) ();
+    }
+
 #if defined (VI_MODE)
-      if (rl_editing_mode == vi_mode)
-	rl_vi_insertion_mode (1, 0);
+  if (rl_editing_mode == vi_mode)
+    rl_vi_insertion_mode (1, 0);
 #endif /* VI_MODE */
-    }
 
   if (rl_pre_input_hook)
     (*rl_pre_input_hook) ();
@@ -422,7 +379,10 @@ readline_internal_teardown (eof)
   /* At any rate, it is highly likely that this line has an undo list.  Get
      rid of it now. */
   if (rl_undo_list)
-    free_undo_list ();
+    rl_free_undo_list ();
+
+  /* Restore normal cursor, if available. */
+  _rl_set_insert_mode (RL_IM_INSERT, 0);
 
   return (eof ? (char *)NULL : savestring (the_line));
 }
@@ -458,7 +418,9 @@ readline_internal_charloop ()
 	  rl_key_sequence_length = 0;
 	}
 
+      RL_SETSTATE(RL_STATE_READCMD);
       c = rl_read_key ();
+      RL_UNSETSTATE(RL_STATE_READCMD);
 
       /* EOF typed to a non-blank line is a <NL>. */
       if (c == EOF && rl_end)
@@ -469,6 +431,7 @@ readline_internal_charloop ()
       if (((c == _rl_eof_char && lastc != c) || c == EOF) && !rl_end)
 	{
 #if defined (READLINE_CALLBACKS)
+	  RL_SETSTATE(RL_STATE_DONE);
 	  return (rl_done = 1);
 #else
 	  eof_found = 1;
@@ -477,7 +440,7 @@ readline_internal_charloop ()
 	}
 
       lastc = c;
-      _rl_dispatch (c, _rl_keymap);
+      _rl_dispatch ((unsigned char)c, _rl_keymap);
 
       /* If there was no change in _rl_last_command_was_kill, then no kill
 	 has taken place.  Note that if input is pending we are reading
@@ -492,6 +455,12 @@ readline_internal_charloop ()
 	rl_vi_check ();
 #endif /* VI_MODE */
 
+      if (rl_num_chars_to_read && rl_end >= rl_num_chars_to_read)
+        {
+          (*rl_redisplay_function) ();
+          rl_newline (1, '\n');
+        }
+
       if (rl_done == 0)
 	(*rl_redisplay_function) ();
 
@@ -538,7 +507,7 @@ readline_internal ()
 void
 _rl_init_line_state ()
 {
-  rl_point = rl_end = 0;
+  rl_point = rl_end = rl_mark = 0;
   the_line = rl_line_buffer;
   the_line[0] = 0;
 }
@@ -556,16 +525,25 @@ int
 _rl_dispatch (key, map)
      register int key;
      Keymap map;
+{
+  return _rl_dispatch_subseq (key, map, 0);
+}
+
+int
+_rl_dispatch_subseq (key, map, got_subseq)
+     register int key;
+     Keymap map;
+     int got_subseq;
 {
   int r, newkey;
   char *macro;
-  Function *func;
+  rl_command_func_t *func;
 
   if (META_CHAR (key) && _rl_convert_meta_chars_to_ascii)
     {
       if (map[ESC].type == ISKMAP)
 	{
-	  if (_rl_defining_kbd_macro)
+	  if (RL_ISSTATE (RL_STATE_MACRODEF))
 	    _rl_add_macro_char (ESC);
 	  map = FUNCTION_TO_KEYMAP (map, ESC);
 	  key = UNMETA (key);
@@ -573,11 +551,11 @@ _rl_dispatch (key, map)
 	  return (_rl_dispatch (key, map));
 	}
       else
-	ding ();
+	rl_ding ();
       return 0;
     }
 
-  if (_rl_defining_kbd_macro)
+  if (RL_ISSTATE (RL_STATE_MACRODEF))
     _rl_add_macro_char (key);
 
   r = 0;
@@ -585,7 +563,7 @@ _rl_dispatch (key, map)
     {
     case ISFUNC:
       func = map[key].function;
-      if (func != (Function *)NULL)
+      if (func)
 	{
 	  /* Special case rl_do_lowercase_version (). */
 	  if (func == rl_do_lowercase_version)
@@ -598,15 +576,34 @@ _rl_dispatch (key, map)
 #endif
 
 	  rl_dispatching = 1;
+	  RL_SETSTATE(RL_STATE_DISPATCHING);
 	  r = (*map[key].function)(rl_numeric_arg * rl_arg_sign, key);
+	  RL_UNSETSTATE(RL_STATE_DISPATCHING);
 	  rl_dispatching = 0;
 
 	  /* If we have input pending, then the last command was a prefix
 	     command.  Don't change the state of rl_last_func.  Otherwise,
 	     remember the last command executed in this variable. */
-	  if (!rl_pending_input && map[key].function != rl_digit_argument)
+	  if (rl_pending_input == 0 && map[key].function != rl_digit_argument)
 	    rl_last_func = map[key].function;
 	}
+      else if (map[ANYOTHERKEY].function)
+	{
+	  /* OK, there's no function bound in this map, but there is a
+	     shadow function that was overridden when the current keymap
+	     was created.  Return -2 to note  that. */
+	  _rl_unget_char  (key);
+	  return -2;
+	}
+      else if (got_subseq)
+	{
+	  /* Return -1 to note that we're in a subsequence, but  we don't
+	     have a matching key, nor was one overridden.  This means
+	     we need to back up the recursion chain and find the last
+	     subsequence that is bound to a function. */
+	  _rl_unget_char (key);
+	  return -1;
+	}
       else
 	{
 	  _rl_abort_internal ();
@@ -615,11 +612,59 @@ _rl_dispatch (key, map)
       break;
 
     case ISKMAP:
-      if (map[key].function != (Function *)NULL)
+      if (map[key].function != 0)
 	{
+#if defined (VI_MODE)
+	  /* The only way this test will be true is if a subsequence has been
+	     bound starting with ESC, generally the arrow keys.  What we do is
+	     check whether there's input in the queue, which there generally
+	     will be if an arrow key has been pressed, and, if there's not,
+	     just dispatch to (what we assume is) rl_vi_movement_mode right
+	     away.  This is essentially an input test with a zero timeout. */
+	  if (rl_editing_mode == vi_mode && key == ESC && map == vi_insertion_keymap
+	      && _rl_input_queued (0) == 0)
+	    return (_rl_dispatch (ANYOTHERKEY, FUNCTION_TO_KEYMAP (map, key)));
+#endif
+
 	  rl_key_sequence_length++;
+
+	  if (key == ESC)
+	    RL_SETSTATE(RL_STATE_METANEXT);
+	  RL_SETSTATE(RL_STATE_MOREINPUT);
 	  newkey = rl_read_key ();
-	  r = _rl_dispatch (newkey, FUNCTION_TO_KEYMAP (map, key));
+	  RL_UNSETSTATE(RL_STATE_MOREINPUT);
+	  if (key == ESC)
+	    RL_UNSETSTATE(RL_STATE_METANEXT);
+
+	  if (newkey < 0)
+	    {
+	      _rl_abort_internal ();
+	      return -1;
+	    }
+
+	  r = _rl_dispatch_subseq (newkey, FUNCTION_TO_KEYMAP (map, key), got_subseq || map[ANYOTHERKEY].function);
+
+	  if (r == -2)
+	    /* We didn't match anything, and the keymap we're indexed into
+	       shadowed a function previously bound to that prefix.  Call
+	       the function.  The recursive call to _rl_dispatch_subseq has
+	       already taken care of pushing any necessary input back onto
+	       the input queue with _rl_unget_char. */
+	    r = _rl_dispatch (ANYOTHERKEY, FUNCTION_TO_KEYMAP (map, key));
+	  else if (r && map[ANYOTHERKEY].function)
+	    {
+	      /* We didn't match (r is probably -1), so return something to
+		 tell the caller that it should try ANYOTHERKEY for an
+		 overridden function. */
+	      _rl_unget_char (key);
+	      return -2;
+	    }
+	  else if (r && got_subseq)
+	    {
+	      /* OK, back up the chain. */
+	      _rl_unget_char (key);
+	      return -1;
+	    }
 	}
       else
 	{
@@ -629,7 +674,7 @@ _rl_dispatch (key, map)
       break;
 
     case ISMACR:
-      if (map[key].function != (Function *)NULL)
+      if (map[key].function != 0)
 	{
 	  macro = savestring ((char *)map[key].function);
 	  _rl_with_macro_input (macro);
@@ -659,8 +704,11 @@ rl_initialize ()
      terminal and data structures. */
   if (!rl_initialized)
     {
+      RL_SETSTATE(RL_STATE_INITIALIZING);
       readline_initialize_everything ();
+      RL_UNSETSTATE(RL_STATE_INITIALIZING);
       rl_initialized++;
+      RL_SETSTATE(RL_STATE_INITIALIZED);
     }
 
   /* Initalize the current line information. */
@@ -668,15 +716,16 @@ rl_initialize ()
 
   /* We aren't done yet.  We haven't even gotten started yet! */
   rl_done = 0;
+  RL_UNSETSTATE(RL_STATE_DONE);
 
   /* Tell the history routines what is going on. */
-  start_using_history ();
+  _rl_start_using_history ();
 
   /* Make the display buffer match the state of the line. */
   rl_reset_line_state ();
 
   /* No such function typed yet. */
-  rl_last_func = (Function *)NULL;
+  rl_last_func = (rl_command_func_t *)NULL;
 
   /* Parsing of key-bindings begins in an enabled state. */
   _rl_parsing_conditionalized_out = 0;
@@ -686,9 +735,13 @@ rl_initialize ()
     _rl_vi_initialize_line ();
 #endif
 
+  /* Each line starts in insert mode (the default). */
+  _rl_set_insert_mode (RL_IM_DEFAULT, 1);
+
   return 0;
 }
 
+#if 0
 #if defined (__EMX__)
 static void
 _emx_build_environ ()
@@ -712,18 +765,23 @@ _emx_build_environ ()
   *tp = 0;
 }
 #endif /* __EMX__ */
+#endif
 
 /* Initialize the entire state of the world. */
 static void
 readline_initialize_everything ()
 {
+#if 0
 #if defined (__EMX__)
   if (environ == 0)
     _emx_build_environ ();
 #endif
+#endif
 
-  /* Find out if we are running in Emacs. */
-  running_in_emacs = get_env_value ("EMACS") != (char *)0;
+#if 0
+  /* Find out if we are running in Emacs -- UNUSED. */
+  running_in_emacs = sh_get_env_value ("EMACS") != (char *)0;
+#endif
 
   /* Set up input and output if they are not already set up. */
   if (!rl_instream)
@@ -740,30 +798,30 @@ readline_initialize_everything ()
 
   /* Allocate data structures. */
   if (rl_line_buffer == 0)
-    rl_line_buffer = xmalloc (rl_line_buffer_len = DEFAULT_BUFFER_SIZE);
+    rl_line_buffer = (char *)xmalloc (rl_line_buffer_len = DEFAULT_BUFFER_SIZE);
 
   /* Initialize the terminal interface. */
-  _rl_init_terminal_io ((char *)NULL);
+  if (rl_terminal_name == 0)
+    rl_terminal_name = sh_get_env_value ("TERM");
+  _rl_init_terminal_io (rl_terminal_name);
 
-#if !defined (__GO32__)
   /* Bind tty characters to readline functions. */
   readline_default_bindings ();
-#endif /* !__GO32__ */
 
   /* Initialize the function names. */
   rl_initialize_funmap ();
 
   /* Decide whether we should automatically go into eight-bit mode. */
   _rl_init_eightbit ();
-
+      
   /* Read in the init file. */
   rl_read_init_file ((char *)NULL);
 
   /* XXX */
   if (_rl_horizontal_scroll_mode && _rl_term_autowrap)
     {
-      screenwidth--;
-      screenchars -= screenheight;
+      _rl_screenwidth--;
+      _rl_screenchars -= _rl_screenheight;
     }
 
   /* Override the effect of any `set keymap' assignments in the
@@ -789,1367 +847,127 @@ readline_initialize_everything ()
 static void
 readline_default_bindings ()
 {
-  rltty_set_default_bindings (_rl_keymap);
-}
-
-static void
-bind_arrow_keys_internal ()
-{
-  Function *f;
-
-  f = rl_function_of_keyseq ("\033[A", _rl_keymap, (int *)NULL);
-  if (!f || f == rl_do_lowercase_version)
-    {
-      _rl_bind_if_unbound ("\033[A", rl_get_previous_history);
-      _rl_bind_if_unbound ("\033[B", rl_get_next_history);
-      _rl_bind_if_unbound ("\033[C", rl_forward);
-      _rl_bind_if_unbound ("\033[D", rl_backward);
-    }
-
-  f = rl_function_of_keyseq ("\033OA", _rl_keymap, (int *)NULL);
-  if (!f || f == rl_do_lowercase_version)
-    {
-      _rl_bind_if_unbound ("\033OA", rl_get_previous_history);
-      _rl_bind_if_unbound ("\033OB", rl_get_next_history);
-      _rl_bind_if_unbound ("\033OC", rl_forward);
-      _rl_bind_if_unbound ("\033OD", rl_backward);
-    }
+  rl_tty_set_default_bindings (_rl_keymap);
 }
 
-/* Try and bind the common arrow key prefix after giving termcap and
-   the inputrc file a chance to bind them and create `real' keymaps
-   for the arrow key prefix. */
+/* Bind some common arrow key sequences in MAP. */
 static void
-bind_arrow_keys ()
+bind_arrow_keys_internal (map)
+     Keymap map;
 {
   Keymap xkeymap;
 
   xkeymap = _rl_keymap;
+  _rl_keymap = map;
 
-  _rl_keymap = emacs_standard_keymap;
-  bind_arrow_keys_internal ();
-
-#if defined (VI_MODE)
-  _rl_keymap = vi_movement_keymap;
-  bind_arrow_keys_internal ();
+#if defined (__MSDOS__)
+   _rl_bind_if_unbound ("\033[0A", rl_get_previous_history);
+   _rl_bind_if_unbound ("\033[0B", rl_backward_char);
+   _rl_bind_if_unbound ("\033[0C", rl_forward_char);
+   _rl_bind_if_unbound ("\033[0D", rl_get_next_history);
 #endif
 
-  _rl_keymap = xkeymap;
-}
-
-
-/* **************************************************************** */
-/*								    */
-/*			Numeric Arguments			    */
-/*								    */
-/* **************************************************************** */
-
-/* Handle C-u style numeric args, as well as M--, and M-digits. */
-static int
-rl_digit_loop ()
-{
-  int key, c, sawminus, sawdigits;
-
-  rl_save_prompt ();
-
-  sawminus = sawdigits = 0;
-  while (1)
-    {
-      if (rl_numeric_arg > 1000000)
-	{
-	  sawdigits = rl_explicit_arg = rl_numeric_arg = 0;
-	  ding ();
-	  rl_restore_prompt ();
-	  rl_clear_message ();
-	  return 1;
-	}
-      rl_message ("(arg: %d) ", rl_arg_sign * rl_numeric_arg);
-      key = c = rl_read_key ();
-
-      /* If we see a key bound to `universal-argument' after seeing digits,
-	 it ends the argument but is otherwise ignored. */
-      if (_rl_keymap[c].type == ISFUNC &&
-	  _rl_keymap[c].function == rl_universal_argument)
-	{
-	  if (sawdigits == 0)
-	    {
-	      rl_numeric_arg *= 4;
-	      continue;
-	    }
-	  else
-	    {
-	      key = rl_read_key ();
-	      rl_restore_prompt ();
-	      rl_clear_message ();
-	      return (_rl_dispatch (key, _rl_keymap));
-	    }
-	}
-
-      c = UNMETA (c);
-
-      if (_rl_digit_p (c))
-	{
-	  rl_numeric_arg = rl_explicit_arg ? (rl_numeric_arg * 10) + c - '0' : c - '0';
-	  sawdigits = rl_explicit_arg = 1;
-	}
-      else if (c == '-' && rl_explicit_arg == 0)
-	{
-	  rl_numeric_arg = sawminus = 1;
-	  rl_arg_sign = -1;
-	}
-      else
-	{
-	  /* Make M-- command equivalent to M--1 command. */
-	  if (sawminus && rl_numeric_arg == 1 && rl_explicit_arg == 0)
-	    rl_explicit_arg = 1;
-	  rl_restore_prompt ();
-	  rl_clear_message ();
-	  return (_rl_dispatch (key, _rl_keymap));
-	}
-    }
-
-  return 0;
-}
-
-/* Add the current digit to the argument in progress. */
-int
-rl_digit_argument (ignore, key)
-     int ignore __attribute__((unused)), key;
-{
-  rl_pending_input = key;
-  return (rl_digit_loop ());
-}
-
-/* What to do when you abort reading an argument. */
-int
-rl_discard_argument ()
-{
-  ding ();
-  rl_clear_message ();
-  _rl_init_argument ();
-  return 0;
-}
-
-/* Create a default argument. */
-int
-_rl_init_argument ()
-{
-  rl_numeric_arg = rl_arg_sign = 1;
-  rl_explicit_arg = 0;
-  return 0;
-}
-
-/* C-u, universal argument.  Multiply the current argument by 4.
-   Read a key.  If the key has nothing to do with arguments, then
-   dispatch on it.  If the key is the abort character then abort. */
-int
-rl_universal_argument (count, key)
-     int count __attribute__((unused)), key __attribute__((unused));
-{
-  rl_numeric_arg *= 4;
-  return (rl_digit_loop ());
-}
-
-/* **************************************************************** */
-/*								    */
-/*			Insert and Delete			    */
-/*								    */
-/* **************************************************************** */
-
-/* Insert a string of text into the line at point.  This is the only
-   way that you should do insertion.  rl_insert () calls this
-   function. */
-int
-rl_insert_text (const char *string)
-{
-  register int i, l = strlen (string);
-
-  if (rl_end + l >= rl_line_buffer_len)
-    rl_extend_line_buffer (rl_end + l);
-
-  for (i = rl_end; i >= rl_point; i--)
-    the_line[i + l] = the_line[i];
-  strncpy (the_line + rl_point, string, l);
-
-  /* Remember how to undo this if we aren't undoing something. */
-  if (!_rl_doing_an_undo)
-    {
-      /* If possible and desirable, concatenate the undos. */
-      if ((l == 1) &&
-	  rl_undo_list &&
-	  (rl_undo_list->what == UNDO_INSERT) &&
-	  (rl_undo_list->end == rl_point) &&
-	  (rl_undo_list->end - rl_undo_list->start < 20))
-	rl_undo_list->end++;
-      else
-	rl_add_undo (UNDO_INSERT, rl_point, rl_point + l, (char *)NULL);
-    }
-  rl_point += l;
-  rl_end += l;
-  the_line[rl_end] = '\0';
-  return l;
-}
-
-/* Delete the string between FROM and TO.  FROM is
-   inclusive, TO is not. */
-int
-rl_delete_text (from, to)
-     int from, to;
-{
-  register char *text;
-  register int diff, i;
-
-  /* Fix it if the caller is confused. */
-  if (from > to)
-    SWAP (from, to);
-
-  /* fix boundaries */
-  if (to > rl_end)
-    {
-      to = rl_end;
-      if (from > to)
-        from = to;
-    }
-
-  text = rl_copy_text (from, to);
+  _rl_bind_if_unbound ("\033[A", rl_get_previous_history);
+  _rl_bind_if_unbound ("\033[B", rl_get_next_history);
+  _rl_bind_if_unbound ("\033[C", rl_forward_char);
+  _rl_bind_if_unbound ("\033[D", rl_backward_char);
+  _rl_bind_if_unbound ("\033[H", rl_beg_of_line);
+  _rl_bind_if_unbound ("\033[F", rl_end_of_line);
 
-  /* Some versions of strncpy() can't handle overlapping arguments. */
-  diff = to - from;
-  for (i = from; i < rl_end - diff; i++)
-    the_line[i] = the_line[i + diff];
+  _rl_bind_if_unbound ("\033OA", rl_get_previous_history);
+  _rl_bind_if_unbound ("\033OB", rl_get_next_history);
+  _rl_bind_if_unbound ("\033OC", rl_forward_char);
+  _rl_bind_if_unbound ("\033OD", rl_backward_char);
+  _rl_bind_if_unbound ("\033OH", rl_beg_of_line);
+  _rl_bind_if_unbound ("\033OF", rl_end_of_line);
 
-  /* Remember how to undo this delete. */
-  if (_rl_doing_an_undo == 0)
-    rl_add_undo (UNDO_DELETE, from, to, text);
-  else
-    free (text);
-
-  rl_end -= diff;
-  the_line[rl_end] = '\0';
-  return (diff);
+  _rl_keymap = xkeymap;
 }
 
-/* Fix up point so that it is within the line boundaries after killing
-   text.  If FIX_MARK_TOO is non-zero, the mark is forced within line
-   boundaries also. */
-
-#define _RL_FIX_POINT(x) \
-	do { \
-	if (x > rl_end) \
-	  x = rl_end; \
-	else if (x < 0) \
-	  x = 0; \
-	} while (0)
-
-void
-_rl_fix_point (fix_mark_too)
-     int fix_mark_too;
+/* Try and bind the common arrow key prefixes after giving termcap and
+   the inputrc file a chance to bind them and create `real' keymaps
+   for the arrow key prefix. */
+static void
+bind_arrow_keys ()
 {
-  _RL_FIX_POINT (rl_point);
-  if (fix_mark_too)
-    _RL_FIX_POINT (rl_mark);
-}
-#undef _RL_FIX_POINT
+  bind_arrow_keys_internal (emacs_standard_keymap);
 
-void
-_rl_replace_text (text, start, end)
-     char *text;
-     int start, end;
-{
-  rl_begin_undo_group ();
-  rl_delete_text (start, end + 1);
-  rl_point = start;
-  rl_insert_text (text);
-  rl_end_undo_group ();
+#if defined (VI_MODE)
+  bind_arrow_keys_internal (vi_movement_keymap);
+  bind_arrow_keys_internal (vi_insertion_keymap);
+#endif
 }
 
 /* **************************************************************** */
 /*								    */
-/*			Readline character functions		    */
-/*								    */
-/* **************************************************************** */
-
-/* This is not a gap editor, just a stupid line input routine.  No hair
-   is involved in writing any of the functions, and none should be. */
-
-/* Note that:
-
-   rl_end is the place in the string that we would place '\0';
-   i.e., it is always safe to place '\0' there.
-
-   rl_point is the place in the string where the cursor is.  Sometimes
-   this is the same as rl_end.
-
-   Any command that is called interactively receives two arguments.
-   The first is a count: the numeric arg pased to this command.
-   The second is the key which invoked this command.
-*/
-
-/* **************************************************************** */
-/*								    */
-/*			Movement Commands			    */
+/*		Saving and Restoring Readline's state		    */
 /*								    */
 /* **************************************************************** */
 
-/* Note that if you `optimize' the display for these functions, you cannot
-   use said functions in other functions which do not do optimizing display.
-   I.e., you will have to update the data base for rl_redisplay, and you
-   might as well let rl_redisplay do that job. */
-
-/* Move forward COUNT characters. */
-int
-rl_forward (count, key)
-     int count, key;
-{
-  if (count < 0)
-    rl_backward (-count, key);
-  else if (count > 0)
-    {
-      int end = rl_point + count;
-#if defined (VI_MODE)
-      int lend = rl_end - (rl_editing_mode == vi_mode);
-#else
-      int lend = rl_end;
-#endif
-
-      if (end > lend)
-	{
-	  rl_point = lend;
-	  ding ();
-	}
-      else
-	rl_point = end;
-    }
-  return 0;
-}
-
-/* Move backward COUNT characters. */
-int
-rl_backward (count, key)
-     int count, key;
-{
-  if (count < 0)
-    rl_forward (-count, key);
-  else if (count > 0)
-    {
-      if (rl_point < count)
-	{
-	  rl_point = 0;
-	  ding ();
-	}
-      else
-        rl_point -= count;
-    }
-  return 0;
-}
-
-/* Move to the beginning of the line. */
-int
-rl_beg_of_line (count, key)
-     int count __attribute__((unused)), key __attribute__((unused));
-{
-  rl_point = 0;
-  return 0;
-}
-
-/* Move to the end of the line. */
-int
-rl_end_of_line (count, key)
-     int count __attribute__((unused)), key __attribute__((unused));
-{
-  rl_point = rl_end;
-  return 0;
-}
-
-/* Move forward a word.  We do what Emacs does. */
 int
-rl_forward_word (count, key)
-     int count, key;
+rl_save_state (sp)
+     struct readline_state *sp;
 {
-  int c;
-
-  if (count < 0)
-    {
-      rl_backward_word (-count, key);
-      return 0;
-    }
+  if (sp == 0)
+    return -1;
 
-  while (count)
-    {
-      if (rl_point == rl_end)
-	return 0;
+  sp->point = rl_point;
+  sp->end = rl_end;
+  sp->mark = rl_mark;
+  sp->buffer = rl_line_buffer;
+  sp->buflen = rl_line_buffer_len;
+  sp->ul = rl_undo_list;
+  sp->prompt = rl_prompt;
+
+  sp->rlstate = rl_readline_state;
+  sp->done = rl_done;
+  sp->kmap = _rl_keymap;
+
+  sp->lastfunc = rl_last_func;
+  sp->insmode = rl_insert_mode;
+  sp->edmode = rl_editing_mode;
+  sp->kseqlen = rl_key_sequence_length;
+  sp->inf = rl_instream;
+  sp->outf = rl_outstream;
+  sp->pendingin = rl_pending_input;
+  sp->macro = rl_executing_macro;
+
+  sp->catchsigs = rl_catch_signals;
+  sp->catchsigwinch = rl_catch_sigwinch;
 
-      /* If we are not in a word, move forward until we are in one.
-	 Then, move forward until we hit a non-alphabetic character. */
-      c = the_line[rl_point];
-      if (alphabetic (c) == 0)
-	{
-	  while (++rl_point < rl_end)
-	    {
-	      c = the_line[rl_point];
-	      if (alphabetic (c))
-		break;
-	    }
-	}
-      if (rl_point == rl_end)
-	return 0;
-      while (++rl_point < rl_end)
-	{
-	  c = the_line[rl_point];
-	  if (alphabetic (c) == 0)
-	    break;
-	}
-      --count;
-    }
-  return 0;
+  return (0);
 }
 
-/* Move backward a word.  We do what Emacs does. */
 int
-rl_backward_word (count, key)
-     int count, key;
+rl_restore_state (sp)
+     struct readline_state *sp;
 {
-  int c;
-
-  if (count < 0)
-    {
-      rl_forward_word (-count, key);
-      return 0;
-    }
-
-  while (count)
-    {
-      if (!rl_point)
-	return 0;
-
-      /* Like rl_forward_word (), except that we look at the characters
-	 just before point. */
-
-      c = the_line[rl_point - 1];
-      if (alphabetic (c) == 0)
-	{
-	  while (--rl_point)
-	    {
-	      c = the_line[rl_point - 1];
-	      if (alphabetic (c))
-		break;
-	    }
-	}
+  if (sp == 0)
+    return -1;
 
-      while (rl_point)
-	{
-	  c = the_line[rl_point - 1];
-	  if (alphabetic (c) == 0)
-	    break;
-	  else
-	    --rl_point;
-	}
-      --count;
-    }
-  return 0;
-}
+  rl_point = sp->point;
+  rl_end = sp->end;
+  rl_mark = sp->mark;
+  the_line = rl_line_buffer = sp->buffer;
+  rl_line_buffer_len = sp->buflen;
+  rl_undo_list = sp->ul;
+  rl_prompt = sp->prompt;
+
+  rl_readline_state = sp->rlstate;
+  rl_done = sp->done;
+  _rl_keymap = sp->kmap;
+
+  rl_last_func = sp->lastfunc;
+  rl_insert_mode = sp->insmode;
+  rl_editing_mode = sp->edmode;
+  rl_key_sequence_length = sp->kseqlen;
+  rl_instream = sp->inf;
+  rl_outstream = sp->outf;
+  rl_pending_input = sp->pendingin;
+  rl_executing_macro = sp->macro;
+
+  rl_catch_signals = sp->catchsigs;
+  rl_catch_sigwinch = sp->catchsigwinch;
 
-/* Clear the current line.  Numeric argument to C-l does this. */
-int
-rl_refresh_line (ignore1, ignore2)
-     int ignore1 __attribute__((unused)), ignore2 __attribute__((unused));
-{
-  int curr_line, nleft;
-
-  /* Find out whether or not there might be invisible characters in the
-     editing buffer. */
-  if (rl_display_prompt == rl_prompt)
-    nleft = _rl_last_c_pos - screenwidth - rl_visible_prompt_length;
-  else
-    nleft = _rl_last_c_pos - screenwidth;
-
-  if (nleft > 0)
-    curr_line = 1 + nleft / screenwidth;
-  else
-    curr_line = 0;
-
-  _rl_move_vert (curr_line);
-  _rl_move_cursor_relative (0, the_line);   /* XXX is this right */
-
-#if defined (__GO32__)
-  {
-    int row, col, width, row_start;
-
-    ScreenGetCursor (&row, &col);
-    width = ScreenCols ();
-    row_start = ScreenPrimary + (row * width);
-    memset (row_start + col, 0, (width - col) * 2);
-  }
-#else /* !__GO32__ */
-  _rl_clear_to_eol (0);		/* arg of 0 means to not use spaces */
-#endif /* !__GO32__ */
-
-  rl_forced_update_display ();
-  rl_display_fixed = 1;
-
-  return 0;
-}
-
-/* C-l typed to a line without quoting clears the screen, and then reprints
-   the prompt and the current input line.  Given a numeric arg, redraw only
-   the current line. */
-int
-rl_clear_screen (count, key)
-     int count, key;
-{
-  if (rl_explicit_arg)
-    {
-      rl_refresh_line (count, key);
-      return 0;
-    }
-
-  _rl_clear_screen ();		/* calls termcap function to clear screen */
-  rl_forced_update_display ();
-  rl_display_fixed = 1;
-
-  return 0;
-}
-
-int
-rl_arrow_keys (count, c)
-     int count, c __attribute__((unused));
-{
-  int ch;
-
-  ch = rl_read_key ();
-
-  switch (_rl_to_upper (ch))
-    {
-    case 'A':
-      rl_get_previous_history (count, ch);
-      break;
-
-    case 'B':
-      rl_get_next_history (count, ch);
-      break;
-
-    case 'C':
-      rl_forward (count, ch);
-      break;
-
-    case 'D':
-      rl_backward (count, ch);
-      break;
-
-    default:
-      ding ();
-    }
-  return 0;
-}
-
-
-/* **************************************************************** */
-/*								    */
-/*			Text commands				    */
-/*								    */
-/* **************************************************************** */
-
-/* Insert the character C at the current location, moving point forward. */
-int
-rl_insert (count, c)
-     int count, c;
-{
-  register int i;
-  char *string;
-
-  if (count <= 0)
-    return 0;
-
-  /* If we can optimize, then do it.  But don't let people crash
-     readline because of extra large arguments. */
-  if (count > 1 && count <= 1024)
-    {
-      string = xmalloc (1 + count);
-
-      for (i = 0; i < count; i++)
-	string[i] = c;
-
-      string[i] = '\0';
-      rl_insert_text (string);
-      free (string);
-
-      return 0;
-    }
-
-  if (count > 1024)
-    {
-      int decreaser;
-      char str[1024+1];
-
-      for (i = 0; i < 1024; i++)
-	str[i] = c;
-
-      while (count)
-	{
-	  decreaser = (count > 1024 ? 1024 : count);
-	  str[decreaser] = '\0';
-	  rl_insert_text (str);
-	  count -= decreaser;
-	}
-
-      return 0;
-    }
-
-  /* We are inserting a single character.
-     If there is pending input, then make a string of all of the
-     pending characters that are bound to rl_insert, and insert
-     them all. */
-  if (_rl_any_typein ())
-    _rl_insert_typein (c);
-  else
-    {
-      /* Inserting a single character. */
-      char str[2];
-
-      str[1] = '\0';
-      str[0] = c;
-      rl_insert_text (str);
-    }
-  return 0;
-}
-
-/* Insert the next typed character verbatim. */
-int
-rl_quoted_insert (count, key)
-     int count, key __attribute__((unused));
-{
-  int c;
-
-  c = rl_read_key ();
-  return (rl_insert (count, c));  
-}
-
-/* Insert a tab character. */
-int
-rl_tab_insert (count, key)
-     int count, key __attribute__((unused));
-{
-  return (rl_insert (count, '\t'));
-}
-
-/* What to do when a NEWLINE is pressed.  We accept the whole line.
-   KEY is the key that invoked this command.  I guess it could have
-   meaning in the future. */
-int
-rl_newline (count, key)
-     int count __attribute__((unused)), key __attribute__((unused));
-{
-  rl_done = 1;
-
-#if defined (VI_MODE)
-  if (rl_editing_mode == vi_mode)
-    {
-      _rl_vi_done_inserting ();
-      _rl_vi_reset_last ();
-    }
-#endif /* VI_MODE */
-
-  /* If we've been asked to erase empty lines, suppress the final update,
-     since _rl_update_final calls crlf(). */
-  if (rl_erase_empty_line && rl_point == 0 && rl_end == 0)
-    return 0;
-
-  if (readline_echoing_p)
-    _rl_update_final ();
-  return 0;
-}
-
-/* What to do for some uppercase characters, like meta characters,
-   and some characters appearing in emacs_ctlx_keymap.  This function
-   is just a stub, you bind keys to it and the code in _rl_dispatch ()
-   is special cased. */
-int
-rl_do_lowercase_version (ignore1, ignore2)
-     int ignore1 __attribute__((unused)), ignore2 __attribute__((unused));
-{
-  return 0;
-}
-
-/* Rubout the character behind point. */
-int
-rl_rubout (count, key)
-     int count, key;
-{
-  if (count < 0)
-    {
-      rl_delete (-count, key);
-      return 0;
-    }
-
-  if (!rl_point)
-    {
-      ding ();
-      return -1;
-    }
-
-  if (count > 1 || rl_explicit_arg)
-    {
-      int orig_point = rl_point;
-      rl_backward (count, key);
-      rl_kill_text (orig_point, rl_point);
-    }
-  else
-    {
-      int c = the_line[--rl_point];
-      rl_delete_text (rl_point, rl_point + 1);
-
-      if (rl_point == rl_end && isprint (c) && _rl_last_c_pos)
-	{
-	  int l;
-	  l = rl_character_len (c, rl_point);
-	  _rl_erase_at_end_of_line (l);
-	}
-    }
-  return 0;
-}
-
-/* Delete the character under the cursor.  Given a numeric argument,
-   kill that many characters instead. */
-int
-rl_delete (count, key)
-     int count, key;
-{
-  if (count < 0)
-    return (rl_rubout (-count, key));
-
-  if (rl_point == rl_end)
-    {
-      ding ();
-      return -1;
-    }
-
-  if (count > 1 || rl_explicit_arg)
-    {
-      int orig_point = rl_point;
-      rl_forward (count, key);
-      rl_kill_text (orig_point, rl_point);
-      rl_point = orig_point;
-      return 0;
-    }
-  else
-    return (rl_delete_text (rl_point, rl_point + 1));
-}
-
-/* Delete the character under the cursor, unless the insertion
-   point is at the end of the line, in which case the character
-   behind the cursor is deleted.  COUNT is obeyed and may be used
-   to delete forward or backward that many characters. */      
-int
-rl_rubout_or_delete (count, key)
-     int count, key;
-{
-  if (rl_end != 0 && rl_point == rl_end)
-    return (rl_rubout (count, key));
-  else
-    return (rl_delete (count, key));
-}
-
-/* Delete all spaces and tabs around point. */
-int
-rl_delete_horizontal_space (count, ignore)
-     int count __attribute__((unused)), ignore __attribute__((unused));
-{
-  int start = rl_point;
-
-  while (rl_point && whitespace (the_line[rl_point - 1]))
-    rl_point--;
-
-  start = rl_point;
-
-  while (rl_point < rl_end && whitespace (the_line[rl_point]))
-    rl_point++;
-
-  if (start != rl_point)
-    {
-      rl_delete_text (start, rl_point);
-      rl_point = start;
-    }
-  return 0;
-}
-
-/* Like the tcsh editing function delete-char-or-list.  The eof character
-   is caught before this is invoked, so this really does the same thing as
-   delete-char-or-list-or-eof, as long as it's bound to the eof character. */
-int
-rl_delete_or_show_completions (count, key)
-     int count, key;
-{
-  if (rl_end != 0 && rl_point == rl_end)
-    return (rl_possible_completions (count, key));
-  else
-    return (rl_delete (count, key));
-}
-
-#ifndef RL_COMMENT_BEGIN_DEFAULT
-#define RL_COMMENT_BEGIN_DEFAULT "#"
-#endif
-
-/* Turn the current line into a comment in shell history.
-   A K*rn shell style function. */
-int
-rl_insert_comment (count, key)
-     int count __attribute__((unused)), key;
-{
-  rl_beg_of_line (1, key);
-  rl_insert_text (_rl_comment_begin ? _rl_comment_begin
-				    : RL_COMMENT_BEGIN_DEFAULT);
-  (*rl_redisplay_function) ();
-  rl_newline (1, '\n');
   return (0);
 }
-
-/* **************************************************************** */
-/*								    */
-/*			Changing Case				    */
-/*								    */
-/* **************************************************************** */
-
-/* The three kinds of things that we know how to do. */
-#define UpCase 1
-#define DownCase 2
-#define CapCase 3
-
-static int rl_change_case ();
-
-/* Uppercase the word at point. */
-int
-rl_upcase_word (count, key)
-     int count, key __attribute__((unused));
-{
-  return (rl_change_case (count, UpCase));
-}
-
-/* Lowercase the word at point. */
-int
-rl_downcase_word (count, key)
-     int count, key __attribute__((unused));
-{
-  return (rl_change_case (count, DownCase));
-}
-
-/* Upcase the first letter, downcase the rest. */
-int
-rl_capitalize_word (count, key)
-     int count, key __attribute__((unused));
-{
- return (rl_change_case (count, CapCase));
-}
-
-/* The meaty function.
-   Change the case of COUNT words, performing OP on them.
-   OP is one of UpCase, DownCase, or CapCase.
-   If a negative argument is given, leave point where it started,
-   otherwise, leave it where it moves to. */
-static int
-rl_change_case (count, op)
-     int count, op;
-{
-  register int start, end;
-  int inword, c;
-
-  start = rl_point;
-  rl_forward_word (count, 0);
-  end = rl_point;
-
-  if (count < 0)
-    SWAP (start, end);
-
-  /* We are going to modify some text, so let's prepare to undo it. */
-  rl_modifying (start, end);
-
-  for (inword = 0; start < end; start++)
-    {
-      c = the_line[start];
-      switch (op)
-	{
-	case UpCase:
-	  the_line[start] = _rl_to_upper (c);
-	  break;
-
-	case DownCase:
-	  the_line[start] = _rl_to_lower (c);
-	  break;
-
-	case CapCase:
-	  the_line[start] = (inword == 0) ? _rl_to_upper (c) : _rl_to_lower (c);
-	  inword = alphabetic (the_line[start]);
-	  break;
-
-	default:
-	  ding ();
-	  return -1;
-	}
-    }
-  rl_point = end;
-  return 0;
-}
-
-/* **************************************************************** */
-/*								    */
-/*			Transposition				    */
-/*								    */
-/* **************************************************************** */
-
-/* Transpose the words at point. */
-int
-rl_transpose_words (count, key)
-     int count, key;
-{
-  char *word1, *word2;
-  int w1_beg, w1_end, w2_beg, w2_end;
-  int orig_point = rl_point;
-
-  if (!count)
-    return 0;
-
-  /* Find the two words. */
-  rl_forward_word (count, key);
-  w2_end = rl_point;
-  rl_backward_word (1, key);
-  w2_beg = rl_point;
-  rl_backward_word (count, key);
-  w1_beg = rl_point;
-  rl_forward_word (1, key);
-  w1_end = rl_point;
-
-  /* Do some check to make sure that there really are two words. */
-  if ((w1_beg == w2_beg) || (w2_beg < w1_end))
-    {
-      ding ();
-      rl_point = orig_point;
-      return -1;
-    }
-
-  /* Get the text of the words. */
-  word1 = rl_copy_text (w1_beg, w1_end);
-  word2 = rl_copy_text (w2_beg, w2_end);
-
-  /* We are about to do many insertions and deletions.  Remember them
-     as one operation. */
-  rl_begin_undo_group ();
-
-  /* Do the stuff at word2 first, so that we don't have to worry
-     about word1 moving. */
-  rl_point = w2_beg;
-  rl_delete_text (w2_beg, w2_end);
-  rl_insert_text (word1);
-
-  rl_point = w1_beg;
-  rl_delete_text (w1_beg, w1_end);
-  rl_insert_text (word2);
-
-  /* This is exactly correct since the text before this point has not
-     changed in length. */
-  rl_point = w2_end;
-
-  /* I think that does it. */
-  rl_end_undo_group ();
-  free (word1);
-  free (word2);
-
-  return 0;
-}
-
-/* Transpose the characters at point.  If point is at the end of the line,
-   then transpose the characters before point. */
-int
-rl_transpose_chars (count, key)
-     int count, key __attribute__((unused));
-{
-  char dummy[2];
-
-  if (!count)
-    return 0;
-
-  if (!rl_point || rl_end < 2)
-    {
-      ding ();
-      return -1;
-    }
-
-  rl_begin_undo_group ();
-
-  if (rl_point == rl_end)
-    {
-      --rl_point;
-      count = 1;
-    }
-  rl_point--;
-
-  dummy[0] = the_line[rl_point];
-  dummy[1] = '\0';
-
-  rl_delete_text (rl_point, rl_point + 1);
-
-  rl_point += count;
-  _rl_fix_point (0);
-  rl_insert_text (dummy);
-
-  rl_end_undo_group ();
-  return 0;
-}
-
-/* **************************************************************** */
-/*								    */
-/*			Character Searching			    */
-/*								    */
-/* **************************************************************** */
-
-int
-_rl_char_search_internal (count, dir, schar)
-     int count, dir, schar;
-{
-  int pos, inc;
-
-  pos = rl_point;
-  inc = (dir < 0) ? -1 : 1;
-  while (count)
-    {
-      if ((dir < 0 && pos <= 0) || (dir > 0 && pos >= rl_end))
-	{
-	  ding ();
-	  return -1;
-	}
-
-      pos += inc;
-      do
-	{
-	  if (rl_line_buffer[pos] == schar)
-	    {
-	      count--;
-	      if (dir < 0)
-	        rl_point = (dir == BTO) ? pos + 1 : pos;
-	      else
-		rl_point = (dir == FTO) ? pos - 1 : pos;
-	      break;
-	    }
-	}
-      while ((dir < 0) ? pos-- : ++pos < rl_end);
-    }
-  return (0);
-}
-
-/* Search COUNT times for a character read from the current input stream.
-   FDIR is the direction to search if COUNT is non-negative; otherwise
-   the search goes in BDIR. */
-static int
-_rl_char_search (count, fdir, bdir)
-     int count, fdir, bdir;
-{
-  int c;
-
-  c = rl_read_key ();
-  if (count < 0)
-    return (_rl_char_search_internal (-count, bdir, c));
-  else
-    return (_rl_char_search_internal (count, fdir, c));
-}
-
-int
-rl_char_search (count, key)
-     int count, key __attribute__((unused));
-{
-  return (_rl_char_search (count, FFIND, BFIND));
-}
-
-int
-rl_backward_char_search (count, key)
-     int count, key __attribute__((unused));
-{
-  return (_rl_char_search (count, BFIND, FFIND));
-}
-
-/* **************************************************************** */
-/*								    */
-/*			History Utilities			    */
-/*								    */
-/* **************************************************************** */
-
-/* We already have a history library, and that is what we use to control
-   the history features of readline.  This is our local interface to
-   the history mechanism. */
-
-/* While we are editing the history, this is the saved
-   version of the original line. */
-HIST_ENTRY *saved_line_for_history = (HIST_ENTRY *)NULL;
-
-/* Set the history pointer back to the last entry in the history. */
-static void
-start_using_history ()
-{
-  using_history ();
-  if (saved_line_for_history)
-    _rl_free_history_entry (saved_line_for_history);
-
-  saved_line_for_history = (HIST_ENTRY *)NULL;
-}
-
-/* Free the contents (and containing structure) of a HIST_ENTRY. */
-void
-_rl_free_history_entry (entry)
-     HIST_ENTRY *entry;
-{
-  if (entry == 0)
-    return;
-  if (entry->line)
-    free (entry->line);
-  free (entry);
-}
-
-/* Perhaps put back the current line if it has changed. */
-int
-maybe_replace_line ()
-{
-  HIST_ENTRY *temp;
-
-  temp = current_history ();
-  /* If the current line has changed, save the changes. */
-  if (temp && ((UNDO_LIST *)(temp->data) != rl_undo_list))
-    {
-      temp = replace_history_entry (where_history (), the_line, (histdata_t)rl_undo_list);
-      free (temp->line);
-      free (temp);
-    }
-  return 0;
-}
-
-/* Put back the saved_line_for_history if there is one. */
-int
-maybe_unsave_line ()
-{
-  int line_len;
-
-  if (saved_line_for_history)
-    {
-      line_len = strlen (saved_line_for_history->line);
-
-      if (line_len >= rl_line_buffer_len)
-	rl_extend_line_buffer (line_len);
-
-      strcpy (the_line, saved_line_for_history->line);
-      rl_undo_list = (UNDO_LIST *)saved_line_for_history->data;
-      _rl_free_history_entry (saved_line_for_history);
-      saved_line_for_history = (HIST_ENTRY *)NULL;
-      rl_end = rl_point = strlen (the_line);
-    }
-  else
-    ding ();
-  return 0;
-}
-
-/* Save the current line in saved_line_for_history. */
-int
-maybe_save_line ()
-{
-  if (saved_line_for_history == 0)
-    {
-      saved_line_for_history = (HIST_ENTRY *)xmalloc (sizeof (HIST_ENTRY));
-      saved_line_for_history->line = savestring (the_line);
-      saved_line_for_history->data = (char *)rl_undo_list;
-    }
-  return 0;
-}
-
-/* **************************************************************** */
-/*								    */
-/*			History Commands			    */
-/*								    */
-/* **************************************************************** */
-
-/* Meta-< goes to the start of the history. */
-int
-rl_beginning_of_history (count, key)
-     int count __attribute__((unused)), key;
-{
-  return (rl_get_previous_history (1 + where_history (), key));
-}
-
-/* Meta-> goes to the end of the history.  (The current line). */
-int
-rl_end_of_history (count, key)
-     int count __attribute__((unused)), key __attribute__((unused));
-{
-  maybe_replace_line ();
-  using_history ();
-  maybe_unsave_line ();
-  return 0;
-}
-
-/* Move down to the next history line. */
-int
-rl_get_next_history (count, key)
-     int count, key;
-{
-  HIST_ENTRY *temp;
-  int line_len;
-
-  if (count < 0)
-    return (rl_get_previous_history (-count, key));
-
-  if (count == 0)
-    return 0;
-
-  maybe_replace_line ();
-
-  temp = (HIST_ENTRY *)NULL;
-  while (count)
-    {
-      temp = next_history ();
-      if (!temp)
-	break;
-      --count;
-    }
-
-  if (temp == 0)
-    maybe_unsave_line ();
-  else
-    {
-      line_len = strlen (temp->line);
-
-      if (line_len >= rl_line_buffer_len)
-	rl_extend_line_buffer (line_len);
-
-      strcpy (the_line, temp->line);
-      rl_undo_list = (UNDO_LIST *)temp->data;
-      rl_end = rl_point = strlen (the_line);
-#if defined (VI_MODE)
-      if (rl_editing_mode == vi_mode)
-	rl_point = 0;
-#endif /* VI_MODE */
-    }
-  return 0;
-}
-
-/* Get the previous item out of our interactive history, making it the current
-   line.  If there is no previous history, just ding. */
-int
-rl_get_previous_history (count, key)
-     int count, key;
-{
-  HIST_ENTRY *old_temp, *temp;
-  int line_len;
-
-  if (count < 0)
-    return (rl_get_next_history (-count, key));
-
-  if (count == 0)
-    return 0;
-
-  /* If we don't have a line saved, then save this one. */
-  maybe_save_line ();
-
-  /* If the current line has changed, save the changes. */
-  maybe_replace_line ();
-
-  temp = old_temp = (HIST_ENTRY *)NULL;
-  while (count)
-    {
-      temp = previous_history ();
-      if (temp == 0)
-	break;
-
-      old_temp = temp;
-      --count;
-    }
-
-  /* If there was a large argument, and we moved back to the start of the
-     history, that is not an error.  So use the last value found. */
-  if (!temp && old_temp)
-    temp = old_temp;
-
-  if (temp == 0)
-    ding ();
-  else
-    {
-      line_len = strlen (temp->line);
-
-      if (line_len >= rl_line_buffer_len)
-	rl_extend_line_buffer (line_len);
-
-      strcpy (the_line, temp->line);
-      rl_undo_list = (UNDO_LIST *)temp->data;
-      rl_end = rl_point = line_len;
-
-#if defined (VI_MODE)
-      if (rl_editing_mode == vi_mode)
-	rl_point = 0;
-#endif /* VI_MODE */
-    }
-  return 0;
-}
-
-/* **************************************************************** */
-/*								    */
-/*		   The Mark and the Region.			    */
-/*								    */
-/* **************************************************************** */
-
-/* Set the mark at POSITION. */
-int
-_rl_set_mark_at_pos (position)
-     int position;
-{
-  if (position > rl_end)
-    return -1;
-
-  rl_mark = position;
-  return 0;
-}
-
-/* A bindable command to set the mark. */
-int
-rl_set_mark (count, key)
-     int count, key __attribute__((unused));
-{
-  return (_rl_set_mark_at_pos (rl_explicit_arg ? count : rl_point));
-}
-
-/* Exchange the position of mark and point. */
-int
-rl_exchange_point_and_mark (count, key)
-     int count __attribute__((unused)), key __attribute__((unused));
-{
-  if (rl_mark > rl_end)
-    rl_mark = -1;
-
-  if (rl_mark == -1)
-    {
-      ding ();
-      return -1;
-    }
-  else
-    SWAP (rl_point, rl_mark);
-
-  return 0;
-}
-
-/* **************************************************************** */
-/*								    */
-/*			    Editing Modes			    */
-/*								    */
-/* **************************************************************** */
-/* How to toggle back and forth between editing modes. */
-int
-rl_vi_editing_mode (count, key)
-     int count __attribute__((unused)), key;
-{
-#if defined (VI_MODE)
-  rl_editing_mode = vi_mode;
-  rl_vi_insertion_mode (1, key);
-#endif /* VI_MODE */
-  return 0;
-}
-
-int
-rl_emacs_editing_mode (count, key)
-     int count __attribute__((unused)), key __attribute__((unused));
-{
-  rl_editing_mode = emacs_mode;
-  _rl_keymap = emacs_standard_keymap;
-  return 0;
-}
diff --git a/readline/readline.h b/readline/readline.h
index 7804d31efb1ad467a3e6a1ef14558e542f97604d..9425de50aefe53871475d57575f800eb414c6adb 100644
--- a/readline/readline.h
+++ b/readline/readline.h
@@ -7,7 +7,7 @@
 
    The GNU Readline Library is free software; you can redistribute it
    and/or modify it under the terms of the GNU General Public License
-   as published by the Free Software Foundation; either version 1, or
+   as published by the Free Software Foundation; either version 2, or
    (at your option) any later version.
 
    The GNU Readline Library is distributed in the hope that it will be
@@ -18,7 +18,7 @@
    The GNU General Public License is often shipped with GNU software, and
    is generally kept in a file called COPYING or LICENSE.  If you do not
    have a copy of the license, write to the Free Software Foundation,
-   675 Mass Ave, Cambridge, MA 02139, USA. */
+   59 Temple Place, Suite 330, Boston, MA 02111 USA. */
 
 #if !defined (_READLINE_H_)
 #define _READLINE_H_
@@ -29,14 +29,21 @@ extern "C" {
 
 #if defined (READLINE_LIBRARY)
 #  include "rlstdc.h"
+#  include "rltypedefs.h"
 #  include "keymaps.h"
 #  include "tilde.h"
 #else
 #  include <readline/rlstdc.h>
+#  include <readline/rltypedefs.h>
 #  include <readline/keymaps.h>
 #  include <readline/tilde.h>
 #endif
 
+/* Hex-encoded Readline version number. */
+#define RL_READLINE_VERSION	0x0403		/* Readline 4.3 */
+#define RL_VERSION_MAJOR	4
+#define RL_VERSION_MINOR	3
+
 /* Readline data structures. */
 
 /* Maintaining the state of undo.  We remember individual deletes and inserts
@@ -61,7 +68,7 @@ extern UNDO_LIST *rl_undo_list;
 /* The data structure for mapping textual names to code addresses. */
 typedef struct _funmap {
   const char *name;
-  Function *function;
+  rl_command_func_t *function;
 } FUNMAP;
 
 extern FUNMAP **funmap;
@@ -73,184 +80,191 @@ extern FUNMAP **funmap;
 /* **************************************************************** */
 
 /* Bindable commands for numeric arguments. */
-extern int rl_digit_argument __P((int, int));
-extern int rl_universal_argument __P((int, int));
+extern int rl_digit_argument PARAMS((int, int));
+extern int rl_universal_argument PARAMS((int, int));
 
 /* Bindable commands for moving the cursor. */
-extern int rl_forward __P((int, int));
-extern int rl_backward __P((int, int));
-extern int rl_beg_of_line __P((int, int));
-extern int rl_end_of_line __P((int, int));
-extern int rl_forward_word __P((int, int));
-extern int rl_backward_word __P((int, int));
-extern int rl_refresh_line __P((int, int));
-extern int rl_clear_screen __P((int, int));
-extern int rl_arrow_keys __P((int, int));
+extern int rl_forward_byte PARAMS((int, int));
+extern int rl_forward_char PARAMS((int, int));
+extern int rl_forward PARAMS((int, int));
+extern int rl_backward_byte PARAMS((int, int));
+extern int rl_backward_char PARAMS((int, int));
+extern int rl_backward PARAMS((int, int));
+extern int rl_beg_of_line PARAMS((int, int));
+extern int rl_end_of_line PARAMS((int, int));
+extern int rl_forward_word PARAMS((int, int));
+extern int rl_backward_word PARAMS((int, int));
+extern int rl_refresh_line PARAMS((int, int));
+extern int rl_clear_screen PARAMS((int, int));
+extern int rl_arrow_keys PARAMS((int, int));
 
 /* Bindable commands for inserting and deleting text. */
-extern int rl_insert __P((int, int));
-extern int rl_quoted_insert __P((int, int));
-extern int rl_tab_insert __P((int, int));
-extern int rl_newline __P((int, int));
-extern int rl_do_lowercase_version __P((int, int));
-extern int rl_rubout __P((int, int));
-extern int rl_delete __P((int, int));
-extern int rl_rubout_or_delete __P((int, int));
-extern int rl_delete_horizontal_space __P((int, int));
-extern int rl_delete_or_show_completions __P((int, int));
-extern int rl_insert_comment __P((int, int));
+extern int rl_insert PARAMS((int, int));
+extern int rl_quoted_insert PARAMS((int, int));
+extern int rl_tab_insert PARAMS((int, int));
+extern int rl_newline PARAMS((int, int));
+extern int rl_do_lowercase_version PARAMS((int, int));
+extern int rl_rubout PARAMS((int, int));
+extern int rl_delete PARAMS((int, int));
+extern int rl_rubout_or_delete PARAMS((int, int));
+extern int rl_delete_horizontal_space PARAMS((int, int));
+extern int rl_delete_or_show_completions PARAMS((int, int));
+extern int rl_insert_comment PARAMS((int, int));
 
 /* Bindable commands for changing case. */
-extern int rl_upcase_word __P((int, int));
-extern int rl_downcase_word __P((int, int));
-extern int rl_capitalize_word __P((int, int));
+extern int rl_upcase_word PARAMS((int, int));
+extern int rl_downcase_word PARAMS((int, int));
+extern int rl_capitalize_word PARAMS((int, int));
 
 /* Bindable commands for transposing characters and words. */
-extern int rl_transpose_words __P((int, int));
-extern int rl_transpose_chars __P((int, int));
+extern int rl_transpose_words PARAMS((int, int));
+extern int rl_transpose_chars PARAMS((int, int));
 
 /* Bindable commands for searching within a line. */
-extern int rl_char_search __P((int, int));
-extern int rl_backward_char_search __P((int, int));
+extern int rl_char_search PARAMS((int, int));
+extern int rl_backward_char_search PARAMS((int, int));
 
 /* Bindable commands for readline's interface to the command history. */
-extern int rl_beginning_of_history __P((int, int));
-extern int rl_end_of_history __P((int, int));
-extern int rl_get_next_history __P((int, int));
-extern int rl_get_previous_history __P((int, int));
+extern int rl_beginning_of_history PARAMS((int, int));
+extern int rl_end_of_history PARAMS((int, int));
+extern int rl_get_next_history PARAMS((int, int));
+extern int rl_get_previous_history PARAMS((int, int));
 
 /* Bindable commands for managing the mark and region. */
-extern int rl_set_mark __P((int, int));
-extern int rl_exchange_point_and_mark __P((int, int));
+extern int rl_set_mark PARAMS((int, int));
+extern int rl_exchange_point_and_mark PARAMS((int, int));
 
 /* Bindable commands to set the editing mode (emacs or vi). */
-extern int rl_vi_editing_mode __P((int, int));
-extern int rl_emacs_editing_mode __P((int, int));
+extern int rl_vi_editing_mode PARAMS((int, int));
+extern int rl_emacs_editing_mode PARAMS((int, int));
+
+/* Bindable commands to change the insert mode (insert or overwrite) */
+extern int rl_overwrite_mode PARAMS((int, int));
 
 /* Bindable commands for managing key bindings. */
-extern int rl_re_read_init_file __P((int, int));
-extern int rl_dump_functions __P((int, int));
-extern int rl_dump_macros __P((int, int));
-extern int rl_dump_variables __P((int, int));
+extern int rl_re_read_init_file PARAMS((int, int));
+extern int rl_dump_functions PARAMS((int, int));
+extern int rl_dump_macros PARAMS((int, int));
+extern int rl_dump_variables PARAMS((int, int));
 
 /* Bindable commands for word completion. */
-extern int rl_complete __P((int, int));
-extern int rl_possible_completions __P((int, int));
-extern int rl_insert_completions __P((int, int));
-extern int rl_menu_complete __P((int, int));
+extern int rl_complete PARAMS((int, int));
+extern int rl_possible_completions PARAMS((int, int));
+extern int rl_insert_completions PARAMS((int, int));
+extern int rl_menu_complete PARAMS((int, int));
 
 /* Bindable commands for killing and yanking text, and managing the kill ring. */
-extern int rl_kill_word __P((int, int));
-extern int rl_backward_kill_word __P((int, int));
-extern int rl_kill_line __P((int, int));
-extern int rl_backward_kill_line __P((int, int));
-extern int rl_kill_full_line __P((int, int));
-extern int rl_unix_word_rubout __P((int, int));
-extern int rl_unix_line_discard __P((int, int));
-extern int rl_copy_region_to_kill __P((int, int));
-extern int rl_kill_region __P((int, int));
-extern int rl_copy_forward_word __P((int, int));
-extern int rl_copy_backward_word __P((int, int));
-extern int rl_yank __P((int, int));
-extern int rl_yank_pop __P((int, int));
-extern int rl_yank_nth_arg __P((int, int));
-extern int rl_yank_last_arg __P((int, int));
-/* Not available unless __CYGWIN32__ is defined. */
-#ifdef __CYGWIN32__
-extern int rl_paste_from_clipboard __P((int, int));
+extern int rl_kill_word PARAMS((int, int));
+extern int rl_backward_kill_word PARAMS((int, int));
+extern int rl_kill_line PARAMS((int, int));
+extern int rl_backward_kill_line PARAMS((int, int));
+extern int rl_kill_full_line PARAMS((int, int));
+extern int rl_unix_word_rubout PARAMS((int, int));
+extern int rl_unix_line_discard PARAMS((int, int));
+extern int rl_copy_region_to_kill PARAMS((int, int));
+extern int rl_kill_region PARAMS((int, int));
+extern int rl_copy_forward_word PARAMS((int, int));
+extern int rl_copy_backward_word PARAMS((int, int));
+extern int rl_yank PARAMS((int, int));
+extern int rl_yank_pop PARAMS((int, int));
+extern int rl_yank_nth_arg PARAMS((int, int));
+extern int rl_yank_last_arg PARAMS((int, int));
+/* Not available unless __CYGWIN__ is defined. */
+#ifdef __CYGWIN__
+extern int rl_paste_from_clipboard PARAMS((int, int));
 #endif
 
 /* Bindable commands for incremental searching. */
-extern int rl_reverse_search_history __P((int, int));
-extern int rl_forward_search_history __P((int, int));
+extern int rl_reverse_search_history PARAMS((int, int));
+extern int rl_forward_search_history PARAMS((int, int));
 
 /* Bindable keyboard macro commands. */
-extern int rl_start_kbd_macro __P((int, int));
-extern int rl_end_kbd_macro __P((int, int));
-extern int rl_call_last_kbd_macro __P((int, int));
+extern int rl_start_kbd_macro PARAMS((int, int));
+extern int rl_end_kbd_macro PARAMS((int, int));
+extern int rl_call_last_kbd_macro PARAMS((int, int));
 
 /* Bindable undo commands. */
-extern int rl_revert_line __P((int, int));
-extern int rl_undo_command __P((int, int));
+extern int rl_revert_line PARAMS((int, int));
+extern int rl_undo_command PARAMS((int, int));
 
 /* Bindable tilde expansion commands. */
-extern int rl_tilde_expand __P((int, int));
+extern int rl_tilde_expand PARAMS((int, int));
 
 /* Bindable terminal control commands. */
-extern int rl_restart_output __P((int, int));
-extern int rl_stop_output __P((int, int));
+extern int rl_restart_output PARAMS((int, int));
+extern int rl_stop_output PARAMS((int, int));
 
 /* Miscellaneous bindable commands. */
-extern int rl_abort __P((int, int));
-extern int rl_tty_status __P((int, int));
+extern int rl_abort PARAMS((int, int));
+extern int rl_tty_status PARAMS((int, int));
 
 /* Bindable commands for incremental and non-incremental history searching. */
-extern int rl_history_search_forward __P((int, int));
-extern int rl_history_search_backward __P((int, int));
-extern int rl_noninc_forward_search __P((int, int));
-extern int rl_noninc_reverse_search __P((int, int));
-extern int rl_noninc_forward_search_again __P((int, int));
-extern int rl_noninc_reverse_search_again __P((int, int));
+extern int rl_history_search_forward PARAMS((int, int));
+extern int rl_history_search_backward PARAMS((int, int));
+extern int rl_noninc_forward_search PARAMS((int, int));
+extern int rl_noninc_reverse_search PARAMS((int, int));
+extern int rl_noninc_forward_search_again PARAMS((int, int));
+extern int rl_noninc_reverse_search_again PARAMS((int, int));
 
-/* Not available unless readline is compiled -DPAREN_MATCHING. */
-extern int rl_insert_close __P((int, int));
+/* Bindable command used when inserting a matching close character. */
+extern int rl_insert_close PARAMS((int, int));
 
 /* Not available unless READLINE_CALLBACKS is defined. */
-extern void rl_callback_handler_install __P((char *, VFunction *));
-extern void rl_callback_read_char __P((void));
-extern void rl_callback_handler_remove __P((void));
+extern void rl_callback_handler_install PARAMS((const char *, rl_vcpfunc_t *));
+extern void rl_callback_read_char PARAMS((void));
+extern void rl_callback_handler_remove PARAMS((void));
 
 /* Things for vi mode. Not available unless readline is compiled -DVI_MODE. */
 /* VI-mode bindable commands. */
-extern int rl_vi_redo __P((int, int));
-extern int rl_vi_undo __P((int, int));
-extern int rl_vi_yank_arg __P((int, int));
-extern int rl_vi_fetch_history __P((int, int));
-extern int rl_vi_search_again __P((int, int));
-extern int rl_vi_search __P((int, int));
-extern int rl_vi_complete __P((int, int));
-extern int rl_vi_tilde_expand __P((int, int));
-extern int rl_vi_prev_word __P((int, int));
-extern int rl_vi_next_word __P((int, int));
-extern int rl_vi_end_word __P((int, int));
-extern int rl_vi_insert_beg __P((int, int));
-extern int rl_vi_append_mode __P((int, int));
-extern int rl_vi_append_eol __P((int, int));
-extern int rl_vi_eof_maybe __P((int, int));
-extern int rl_vi_insertion_mode __P((int, int));
-extern int rl_vi_movement_mode __P((int, int));
-extern int rl_vi_arg_digit __P((int, int));
-extern int rl_vi_change_case __P((int, int));
-extern int rl_vi_put __P((int, int));
-extern int rl_vi_column __P((int, int));
-extern int rl_vi_delete_to __P((int, int));
-extern int rl_vi_change_to __P((int, int));
-extern int rl_vi_yank_to __P((int, int));
-extern int rl_vi_delete __P((int, int));
-extern int rl_vi_back_to_indent __P((int, int));
-extern int rl_vi_first_print __P((int, int));
-extern int rl_vi_char_search __P((int, int));
-extern int rl_vi_match __P((int, int));
-extern int rl_vi_change_char __P((int, int));
-extern int rl_vi_subst __P((int, int));
-extern int rl_vi_overstrike __P((int, int));
-extern int rl_vi_overstrike_delete __P((int, int));
-extern int rl_vi_replace __P((int, int));
-extern int rl_vi_set_mark __P((int, int));
-extern int rl_vi_goto_mark __P((int, int));
+extern int rl_vi_redo PARAMS((int, int));
+extern int rl_vi_undo PARAMS((int, int));
+extern int rl_vi_yank_arg PARAMS((int, int));
+extern int rl_vi_fetch_history PARAMS((int, int));
+extern int rl_vi_search_again PARAMS((int, int));
+extern int rl_vi_search PARAMS((int, int));
+extern int rl_vi_complete PARAMS((int, int));
+extern int rl_vi_tilde_expand PARAMS((int, int));
+extern int rl_vi_prev_word PARAMS((int, int));
+extern int rl_vi_next_word PARAMS((int, int));
+extern int rl_vi_end_word PARAMS((int, int));
+extern int rl_vi_insert_beg PARAMS((int, int));
+extern int rl_vi_append_mode PARAMS((int, int));
+extern int rl_vi_append_eol PARAMS((int, int));
+extern int rl_vi_eof_maybe PARAMS((int, int));
+extern int rl_vi_insertion_mode PARAMS((int, int));
+extern int rl_vi_movement_mode PARAMS((int, int));
+extern int rl_vi_arg_digit PARAMS((int, int));
+extern int rl_vi_change_case PARAMS((int, int));
+extern int rl_vi_put PARAMS((int, int));
+extern int rl_vi_column PARAMS((int, int));
+extern int rl_vi_delete_to PARAMS((int, int));
+extern int rl_vi_change_to PARAMS((int, int));
+extern int rl_vi_yank_to PARAMS((int, int));
+extern int rl_vi_delete PARAMS((int, int));
+extern int rl_vi_back_to_indent PARAMS((int, int));
+extern int rl_vi_first_print PARAMS((int, int));
+extern int rl_vi_char_search PARAMS((int, int));
+extern int rl_vi_match PARAMS((int, int));
+extern int rl_vi_change_char PARAMS((int, int));
+extern int rl_vi_subst PARAMS((int, int));
+extern int rl_vi_overstrike PARAMS((int, int));
+extern int rl_vi_overstrike_delete PARAMS((int, int));
+extern int rl_vi_replace PARAMS((int, int));
+extern int rl_vi_set_mark PARAMS((int, int));
+extern int rl_vi_goto_mark PARAMS((int, int));
 
 /* VI-mode utility functions. */
-extern int rl_vi_check __P((void));
-extern int rl_vi_domove __P((int, int *));
-extern int rl_vi_bracktype __P((int));
+extern int rl_vi_check PARAMS((void));
+extern int rl_vi_domove PARAMS((int, int *));
+extern int rl_vi_bracktype PARAMS((int));
 
 /* VI-mode pseudo-bindable commands, used as utility functions. */
-extern int rl_vi_fWord __P((int, int));
-extern int rl_vi_bWord __P((int, int));
-extern int rl_vi_eWord __P((int, int));
-extern int rl_vi_fword __P((int, int));
-extern int rl_vi_bword __P((int, int));
-extern int rl_vi_eword __P((int, int));
+extern int rl_vi_fWord PARAMS((int, int));
+extern int rl_vi_bWord PARAMS((int, int));
+extern int rl_vi_eWord PARAMS((int, int));
+extern int rl_vi_fword PARAMS((int, int));
+extern int rl_vi_bword PARAMS((int, int));
+extern int rl_vi_eword PARAMS((int, int));
 
 /* **************************************************************** */
 /*								    */
@@ -260,141 +274,176 @@ extern int rl_vi_eword __P((int, int));
 
 /* Readline functions. */
 /* Read a line of input.  Prompt with PROMPT.  A NULL PROMPT means none. */
-extern char *readline __P((char *));
+extern char *readline PARAMS((const char *));
 
-extern int rl_initialize __P((void));
+extern int rl_set_prompt PARAMS((const char *));
+extern int rl_expand_prompt PARAMS((char *));
 
-extern int rl_discard_argument __P((void));
+extern int rl_initialize PARAMS((void));
+
+/* Undocumented; unused by readline */
+extern int rl_discard_argument PARAMS((void));
 
 /* Utility functions to bind keys to readline commands. */
-extern int rl_add_defun __P((char *, Function *, int));
-extern int rl_bind_key __P((int, Function *));
-extern int rl_bind_key_in_map __P((int, Function *, Keymap));
-extern int rl_unbind_key __P((int));
-extern int rl_unbind_key_in_map __P((int, Keymap));
-extern int rl_unbind_function_in_map __P((Function *, Keymap));
-extern int rl_unbind_command_in_map __P((char *, Keymap));
-extern int rl_set_key __P((char *, Function *, Keymap));
-extern int rl_generic_bind __P((int, char *, char *, Keymap));
-extern int rl_variable_bind __P((char *, char *));
+extern int rl_add_defun PARAMS((const char *, rl_command_func_t *, int));
+extern int rl_bind_key PARAMS((int, rl_command_func_t *));
+extern int rl_bind_key_in_map PARAMS((int, rl_command_func_t *, Keymap));
+extern int rl_unbind_key PARAMS((int));
+extern int rl_unbind_key_in_map PARAMS((int, Keymap));
+extern int rl_unbind_function_in_map PARAMS((rl_command_func_t *, Keymap));
+extern int rl_unbind_command_in_map PARAMS((const char *, Keymap));
+extern int rl_set_key PARAMS((const char *, rl_command_func_t *, Keymap));
+extern int rl_generic_bind PARAMS((int, const char *, char *, Keymap));
+extern int rl_variable_bind PARAMS((const char *, const char *));
 
 /* Backwards compatibility, use rl_generic_bind instead. */
-extern int rl_macro_bind __P((char *, char *, Keymap));
+extern int rl_macro_bind PARAMS((const char *, const char *, Keymap));
 
 /* Undocumented in the texinfo manual; not really useful to programs. */
-extern int rl_translate_keyseq __P((char *, char *, int *));
-extern char *rl_untranslate_keyseq __P((int));
-
-extern Function *rl_named_function __P((char *));
-extern Function *rl_function_of_keyseq __P((const char *, Keymap, int *));
+extern int rl_translate_keyseq PARAMS((const char *, char *, int *));
+extern char *rl_untranslate_keyseq PARAMS((int));
 
-extern void rl_list_funmap_names __P((void));
-extern char **rl_invoking_keyseqs_in_map __P((Function *, Keymap));
-extern char **rl_invoking_keyseqs __P((Function *));
+extern rl_command_func_t *rl_named_function PARAMS((const char *));
+extern rl_command_func_t *rl_function_of_keyseq PARAMS((const char *, Keymap, int *));
 
-extern void rl_function_dumper __P((int));
-extern void rl_macro_dumper __P((int));
-extern void rl_variable_dumper __P((int));
+extern void rl_list_funmap_names PARAMS((void));
+extern char **rl_invoking_keyseqs_in_map PARAMS((rl_command_func_t *, Keymap));
+extern char **rl_invoking_keyseqs PARAMS((rl_command_func_t *));
+ 
+extern void rl_function_dumper PARAMS((int));
+extern void rl_macro_dumper PARAMS((int));
+extern void rl_variable_dumper PARAMS((int));
 
-extern int rl_read_init_file __P((const char *));
-extern int rl_parse_and_bind __P((char *));
+extern int rl_read_init_file PARAMS((const char *));
+extern int rl_parse_and_bind PARAMS((char *));
 
 /* Functions for manipulating keymaps. */
-extern Keymap rl_make_bare_keymap __P((void));
-extern Keymap rl_copy_keymap __P((Keymap));
-extern Keymap rl_make_keymap __P((void));
-extern void rl_discard_keymap __P((Keymap));
-
-extern Keymap rl_get_keymap_by_name __P((char *));
-extern const char *rl_get_keymap_name __P((Keymap));
-extern void rl_set_keymap __P((Keymap));
-extern Keymap rl_get_keymap __P((void));
-extern void rl_set_keymap_from_edit_mode __P((void));
-extern const char *rl_get_keymap_name_from_edit_mode __P((void));
+extern Keymap rl_make_bare_keymap PARAMS((void));
+extern Keymap rl_copy_keymap PARAMS((Keymap));
+extern Keymap rl_make_keymap PARAMS((void));
+extern void rl_discard_keymap PARAMS((Keymap));
+
+extern Keymap rl_get_keymap_by_name PARAMS((const char *));
+extern char *rl_get_keymap_name PARAMS((Keymap));
+extern void rl_set_keymap PARAMS((Keymap));
+extern Keymap rl_get_keymap PARAMS((void));
+/* Undocumented; used internally only. */
+extern void rl_set_keymap_from_edit_mode PARAMS((void));
+extern const char *rl_get_keymap_name_from_edit_mode PARAMS((void));
 
 /* Functions for manipulating the funmap, which maps command names to functions. */
-extern int rl_add_funmap_entry __P((const char *, Function *));
-extern void rl_initialize_funmap __P((void));
-extern char **rl_funmap_names __P((void));
+extern int rl_add_funmap_entry PARAMS((const char *, rl_command_func_t *));
+extern const char **rl_funmap_names PARAMS((void));
+/* Undocumented, only used internally -- there is only one funmap, and this
+   function may be called only once. */
+extern void rl_initialize_funmap PARAMS((void));
 
 /* Utility functions for managing keyboard macros. */
-extern void rl_push_macro_input __P((char *));
+extern void rl_push_macro_input PARAMS((char *));
 
 /* Functions for undoing, from undo.c */
-extern void rl_add_undo __P((enum undo_code, int, int, char *));
-extern void free_undo_list __P((void));
-extern int rl_do_undo __P((void));
-extern int rl_begin_undo_group __P((void));
-extern int rl_end_undo_group __P((void));
-extern int rl_modifying __P((int, int));
+extern void rl_add_undo PARAMS((enum undo_code, int, int, char *));
+extern void rl_free_undo_list PARAMS((void));
+extern int rl_do_undo PARAMS((void));
+extern int rl_begin_undo_group PARAMS((void));
+extern int rl_end_undo_group PARAMS((void));
+extern int rl_modifying PARAMS((int, int));
 
 /* Functions for redisplay. */
-extern void rl_redisplay __P((void));
-extern int rl_on_new_line __P((void));
-extern int rl_forced_update_display __P((void));
-extern int rl_clear_message __P((void));
-extern int rl_reset_line_state __P((void));
-
-#if defined (__STDC__) && defined (USE_VARARGS) && defined (PREFER_STDARG)
-extern int rl_message (const char *, ...);
+extern void rl_redisplay PARAMS((void));
+extern int rl_on_new_line PARAMS((void));
+extern int rl_on_new_line_with_prompt PARAMS((void));
+extern int rl_forced_update_display PARAMS((void));
+extern int rl_clear_message PARAMS((void));
+extern int rl_reset_line_state PARAMS((void));
+extern int rl_crlf PARAMS((void));
+
+#if (defined (__STDC__) || defined (__cplusplus)) && defined (USE_VARARGS) && defined (PREFER_STDARG)
+extern int rl_message (const char *, ...)  __attribute__((__format__ (printf, 1, 2)));
 #else
 extern int rl_message ();
 #endif
 
+extern int rl_show_char PARAMS((int));
+
 /* Undocumented in texinfo manual. */
-extern int rl_show_char __P((int));
-extern int rl_character_len __P((int, int));
-extern int crlf __P((void));
+extern int rl_character_len PARAMS((int, int));
 
 /* Save and restore internal prompt redisplay information. */
-extern void rl_save_prompt __P((void));
-extern void rl_restore_prompt __P((void));
+extern void rl_save_prompt PARAMS((void));
+extern void rl_restore_prompt PARAMS((void));
 
 /* Modifying text. */
-extern int rl_insert_text __P((const char *));
-extern int rl_delete_text __P((int, int));
-extern int rl_kill_text __P((int, int));
-extern char *rl_copy_text __P((int, int));
+extern void rl_replace_line PARAMS((const char *, int));
+extern int rl_insert_text PARAMS((const char *));
+extern int rl_delete_text PARAMS((int, int));
+extern int rl_kill_text PARAMS((int, int));
+extern char *rl_copy_text PARAMS((int, int));
 
 /* Terminal and tty mode management. */
-extern void rl_prep_terminal __P((int));
-extern void rl_deprep_terminal __P((void));
-extern void rltty_set_default_bindings __P((Keymap));
+extern void rl_prep_terminal PARAMS((int));
+extern void rl_deprep_terminal PARAMS((void));
+extern void rl_tty_set_default_bindings PARAMS((Keymap));
 
-extern int rl_reset_terminal __P((char *));
-extern void rl_resize_terminal __P((void));
+extern int rl_reset_terminal PARAMS((const char *));
+extern void rl_resize_terminal PARAMS((void));
+extern void rl_set_screen_size PARAMS((int, int));
+extern void rl_get_screen_size PARAMS((int *, int *));
 
-/* `Public' utility functions . */
-extern void rl_extend_line_buffer __P((int));
-extern int ding __P((void));
+extern const char *rl_get_termcap PARAMS((const char *));
 
 /* Functions for character input. */
-extern int rl_stuff_char __P((int));
-extern int rl_execute_next __P((int));
-extern int rl_read_key __P((void));
-extern int rl_getc __P((FILE *));
+extern int rl_stuff_char PARAMS((int));
+extern int rl_execute_next PARAMS((int));
+extern int rl_clear_pending_input PARAMS((void));
+extern int rl_read_key PARAMS((void));
+extern int rl_getc PARAMS((FILE *));
+extern int rl_set_keyboard_input_timeout PARAMS((int));
+
+/* `Public' utility functions . */
+extern void rl_extend_line_buffer PARAMS((int));
+extern int rl_ding PARAMS((void));
+extern int rl_alphabetic PARAMS((int));
 
 /* Readline signal handling, from signals.c */
-extern int rl_set_signals __P((void));
-extern int rl_clear_signals __P((void));
-extern void rl_cleanup_after_signal __P((void));
-extern void rl_reset_after_signal __P((void));
-extern void rl_free_line_state __P((void));
+extern int rl_set_signals PARAMS((void));
+extern int rl_clear_signals PARAMS((void));
+extern void rl_cleanup_after_signal PARAMS((void));
+extern void rl_reset_after_signal PARAMS((void));
+extern void rl_free_line_state PARAMS((void));
+ 
+extern int rl_set_paren_blink_timeout PARAMS((int));
 
 /* Undocumented. */
-extern int rl_expand_prompt __P((char *));
-
-extern int maybe_save_line __P((void));
-extern int maybe_unsave_line __P((void));
-extern int maybe_replace_line __P((void));
+extern int rl_maybe_save_line PARAMS((void));
+extern int rl_maybe_unsave_line PARAMS((void));
+extern int rl_maybe_replace_line PARAMS((void));
 
 /* Completion functions. */
-extern int rl_complete_internal __P((int));
-extern void rl_display_match_list __P((char **, int, int));
+extern int rl_complete_internal PARAMS((int));
+extern void rl_display_match_list PARAMS((char **, int, int));
+
+extern char **rl_completion_matches PARAMS((const char *, rl_compentry_func_t *));
+extern char *rl_username_completion_function PARAMS((const char *, int));
+extern char *rl_filename_completion_function PARAMS((const char *, int));
+
+extern int rl_completion_mode PARAMS((rl_command_func_t *));
+
+#if 0
+/* Backwards compatibility (compat.c).  These will go away sometime. */
+extern void free_undo_list PARAMS((void));
+extern int maybe_save_line PARAMS((void));
+extern int maybe_unsave_line PARAMS((void));
+extern int maybe_replace_line PARAMS((void));
 
-extern char **completion_matches __P((const char *, CPFunction *));
-extern char *username_completion_function __P((const char *, int));
-extern char *filename_completion_function __P((const char *, int));
+extern int ding PARAMS((void));
+extern int alphabetic PARAMS((int));
+extern int crlf PARAMS((void));
+
+extern char **completion_matches PARAMS((char *, rl_compentry_func_t *));
+extern char *username_completion_function PARAMS((const char *, int));
+extern char *filename_completion_function PARAMS((const char *, int));
+#endif
 
 /* **************************************************************** */
 /*								    */
@@ -403,7 +452,22 @@ extern char *filename_completion_function __P((const char *, int));
 /* **************************************************************** */
 
 /* The version of this incarnation of the readline library. */
-extern const char *rl_library_version;
+extern const char *rl_library_version;		/* e.g., "4.2" */
+extern int rl_readline_version;			/* e.g., 0x0402 */
+
+/* True if this is real GNU readline. */
+extern int rl_gnu_readline_p;
+
+/* Flags word encapsulating the current readline state. */
+extern int rl_readline_state;
+
+/* Says which editing mode readline is currently using.  1 means emacs mode;
+   0 means vi mode. */
+extern int rl_editing_mode;
+
+/* Insert or overwrite mode for emacs mode.  1 means insert mode; 0 means
+   overwrite mode.  Reset to insert mode on each input line. */
+extern int rl_insert_mode;
 
 /* The name of the calling program.  You should initialize this to
    whatever was in argv[0].  It is used when parsing conditionals. */
@@ -417,7 +481,8 @@ extern char *rl_prompt;
 extern char *rl_line_buffer;
 
 /* The location of point, and end. */
-extern int rl_point, rl_end;
+extern int rl_point;
+extern int rl_end;
 
 /* The mark, or saved cursor position. */
 extern int rl_mark;
@@ -434,29 +499,44 @@ extern int rl_pending_input;
    or directly from an application. */
 extern int rl_dispatching;
 
+/* Non-zero if the user typed a numeric argument before executing the
+   current function. */
+extern int rl_explicit_arg;
+
+/* The current value of the numeric argument specified by the user. */
+extern int rl_numeric_arg;
+
+/* The address of the last command function Readline executed. */
+extern rl_command_func_t *rl_last_func;
+
 /* The name of the terminal to use. */
-extern char *rl_terminal_name;
+extern const char *rl_terminal_name;
 
 /* The input and output streams. */
-extern FILE *rl_instream, *rl_outstream;
+extern FILE *rl_instream;
+extern FILE *rl_outstream;
 
 /* If non-zero, then this is the address of a function to call just
    before readline_internal () prints the first prompt. */
-extern Function *rl_startup_hook;
+extern rl_hook_func_t *rl_startup_hook;
 
 /* If non-zero, this is the address of a function to call just before
    readline_internal_setup () returns and readline_internal starts
    reading input characters. */
-extern Function *rl_pre_input_hook;
-
+extern rl_hook_func_t *rl_pre_input_hook;
+      
 /* The address of a function to call periodically while Readline is
    awaiting character input, or NULL, for no event handling. */
-extern Function *rl_event_hook;
+extern rl_hook_func_t *rl_event_hook;
+
+/* The address of the function to call to fetch a character from the current
+   Readline input stream */
+extern rl_getc_func_t *rl_getc_function;
+
+extern rl_voidfunc_t *rl_redisplay_function;
 
-extern Function *rl_getc_function;
-extern VFunction *rl_redisplay_function;
-extern VFunction *rl_prep_term_function;
-extern VFunction *rl_deprep_term_function;
+extern rl_vintfunc_t *rl_prep_term_function;
+extern rl_voidfunc_t *rl_deprep_term_function;
 
 /* Dispatch variables. */
 extern Keymap rl_executing_keymap;
@@ -468,6 +548,18 @@ extern Keymap rl_binding_keymap;
    rl_newline. */
 extern int rl_erase_empty_line;
 
+/* If non-zero, the application has already printed the prompt (rl_prompt)
+   before calling readline, so readline should not output it the first time
+   redisplay is done. */
+extern int rl_already_prompted;
+
+/* A non-zero value means to read only this many characters rather than
+   up to a character bound to accept-line. */
+extern int rl_num_chars_to_read;
+
+/* The text of a currently-executing keyboard macro. */
+extern char *rl_executing_macro;
+
 /* Variables to control readline signal handling. */
 /* If non-zero, readline will install its own signal handlers for
    SIGINT, SIGTERM, SIGQUIT, SIGALRM, SIGTSTP, SIGTTIN, and SIGTTOU. */
@@ -482,9 +574,9 @@ extern int rl_catch_sigwinch;
 
 /* Completion variables. */
 /* Pointer to the generator function for completion_matches ().
-   NULL means to use filename_entry_function (), the default filename
-   completer. */
-extern Function *rl_completion_entry_function;
+   NULL means to use rl_filename_completion_function (), the default
+   filename completer. */
+extern rl_compentry_func_t *rl_completion_entry_function;
 
 /* If rl_ignore_some_completions_function is non-NULL it is the address
    of a function to call after all of the possible matches have been
@@ -492,7 +584,7 @@ extern Function *rl_completion_entry_function;
    The function is called with one argument; a NULL terminated array
    of (char *).  If your function removes any of the elements, they
    must be free()'ed. */
-extern Function *rl_ignore_some_completions_function;
+extern rl_compignore_func_t *rl_ignore_some_completions_function;
 
 /* Pointer to alternative function to create matches.
    Function is called with TEXT, START, and END.
@@ -501,7 +593,7 @@ extern Function *rl_ignore_some_completions_function;
    If this function exists and returns NULL then call the value of
    rl_completion_entry_function to try to match, otherwise use the
    array of strings returned. */
-extern CPPFunction *rl_attempted_completion_function;
+extern rl_completion_func_t *rl_attempted_completion_function;
 
 /* The basic list of characters that signal a break between words for the
    completer routine.  The initial contents of this variable is what
@@ -517,23 +609,34 @@ extern const char *rl_completer_word_break_characters;
    Completion occurs on the entire substring, and within the substring   
    rl_completer_word_break_characters are treated as any other character,
    unless they also appear within this list. */
-extern char *rl_completer_quote_characters;
+extern const char *rl_completer_quote_characters;
 
 /* List of quote characters which cause a word break. */
 extern const char *rl_basic_quote_characters;
 
 /* List of characters that need to be quoted in filenames by the completer. */
-extern char *rl_filename_quote_characters;
+extern const char *rl_filename_quote_characters;
 
 /* List of characters that are word break characters, but should be left
    in TEXT when it is passed to the completion function.  The shell uses
    this to help determine what kind of completing to do. */
-extern char *rl_special_prefixes;
+extern const char *rl_special_prefixes;
 
 /* If non-zero, then this is the address of a function to call when
    completing on a directory name.  The function is called with
-   the address of a string (the current directory name) as an arg. */
-extern Function *rl_directory_completion_hook;
+   the address of a string (the current directory name) as an arg.  It
+   changes what is displayed when the possible completions are printed
+   or inserted. */
+extern rl_icppfunc_t *rl_directory_completion_hook;
+
+/* If non-zero, this is the address of a function to call when completing
+   a directory name.  This function takes the address of the directory name
+   to be modified as an argument.  Unlike rl_directory_completion_hook, it
+   only modifies the directory name used in opendir(2), not what is displayed
+   when the possible completions are printed or inserted.  It is called
+   before rl_directory_completion_hook.  I'm not happy with how this works
+   yet, so it's undocumented. */
+extern rl_icppfunc_t *rl_directory_rewrite_hook;
 
 /* Backwards compatibility with previous versions of readline. */
 #define rl_symbolic_link_hook rl_directory_completion_hook
@@ -545,7 +648,7 @@ extern Function *rl_directory_completion_hook;
    where MATCHES is the array of strings that matched, NUM_MATCHES is the
    number of strings in that array, and MAX_LENGTH is the length of the
    longest string in that array. */
-extern VFunction *rl_completion_display_matches_hook;
+extern rl_compdisp_func_t *rl_completion_display_matches_hook;
 
 /* Non-zero means that the results of the matches are to be treated
    as filenames.  This is ALWAYS zero on entry, and can only be changed
@@ -563,17 +666,17 @@ extern int rl_filename_quoting_desired;
    Called with the text to quote, the type of match found (single or multiple)
    and a pointer to the quoting character to be used, which the function can
    reset if desired. */
-extern CPFunction *rl_filename_quoting_function;
+extern rl_quote_func_t *rl_filename_quoting_function;
 
 /* Function to call to remove quoting characters from a filename.  Called
    before completion is attempted, so the embedded quotes do not interfere
    with matching names in the file system. */
-extern CPFunction *rl_filename_dequoting_function;
+extern rl_dequote_func_t *rl_filename_dequoting_function;
 
 /* Function to call to decide whether or not a word break character is
    quoted.  If a character is quoted, it does not break words for the
    completer. */
-extern Function *rl_char_is_quoted_p;
+extern rl_linebuf_func_t *rl_char_is_quoted_p;
 
 /* Non-zero means to suppress normal filename completion after the
    user-specified completion function has been called. */
@@ -588,11 +691,26 @@ extern int rl_completion_type;
    default is a space.  Nothing is added if this is '\0'. */
 extern int rl_completion_append_character;
 
+/* If set to non-zero by an application completion function,
+   rl_completion_append_character will not be appended. */
+extern int rl_completion_suppress_append;
+
 /* Up to this many items will be displayed in response to a
    possible-completions call.  After that, we ask the user if she
    is sure she wants to see them all.  The default value is 100. */
 extern int rl_completion_query_items;
 
+/* If non-zero, a slash will be appended to completed filenames that are
+   symbolic links to directory names, subject to the value of the
+   mark-directories variable (which is user-settable).  This exists so
+   that application completion functions can override the user's preference
+   (set via the mark-symlinked-directories variable) if appropriate.
+   It's set to the value of _rl_complete_mark_symlink_dirs in
+   rl_complete_internal before any application-specific completion
+   function is called, so without that function doing anything, the user's
+   preferences are honored. */
+extern int rl_completion_mark_symlink_dirs;
+
 /* If non-zero, then disallow duplicates in the matches. */
 extern int rl_ignore_completion_duplicates;
 
@@ -610,9 +728,69 @@ extern int rl_inhibit_completion;
 #define SINGLE_MATCH    1
 #define MULT_MATCH      2
 
-#if !defined (savestring)
-extern char *savestring ();	/* XXX backwards compatibility */
-#endif
+/* Possible state values for rl_readline_state */
+#define RL_STATE_NONE		0x00000		/* no state; before first call */
+
+#define RL_STATE_INITIALIZING	0x00001		/* initializing */
+#define RL_STATE_INITIALIZED	0x00002		/* initialization done */
+#define RL_STATE_TERMPREPPED	0x00004		/* terminal is prepped */
+#define RL_STATE_READCMD	0x00008		/* reading a command key */
+#define RL_STATE_METANEXT	0x00010		/* reading input after ESC */
+#define RL_STATE_DISPATCHING	0x00020		/* dispatching to a command */
+#define RL_STATE_MOREINPUT	0x00040		/* reading more input in a command function */
+#define RL_STATE_ISEARCH	0x00080		/* doing incremental search */
+#define RL_STATE_NSEARCH	0x00100		/* doing non-inc search */
+#define RL_STATE_SEARCH		0x00200		/* doing a history search */
+#define RL_STATE_NUMERICARG	0x00400		/* reading numeric argument */
+#define RL_STATE_MACROINPUT	0x00800		/* getting input from a macro */
+#define RL_STATE_MACRODEF	0x01000		/* defining keyboard macro */
+#define RL_STATE_OVERWRITE	0x02000		/* overwrite mode */
+#define RL_STATE_COMPLETING	0x04000		/* doing completion */
+#define RL_STATE_SIGHANDLER	0x08000		/* in readline sighandler */
+#define RL_STATE_UNDOING	0x10000		/* doing an undo */
+#define RL_STATE_INPUTPENDING	0x20000		/* rl_execute_next called */
+
+#define RL_STATE_DONE		0x80000		/* done; accepted line */
+
+#define RL_SETSTATE(x)		(rl_readline_state |= (x))
+#define RL_UNSETSTATE(x)	(rl_readline_state &= ~(x))
+#define RL_ISSTATE(x)		(rl_readline_state & (x))
+
+struct readline_state {
+  /* line state */
+  int point;
+  int end;
+  int mark;
+  char *buffer;
+  int buflen;
+  UNDO_LIST *ul;
+  char *prompt;
+
+  /* global state */
+  int rlstate;
+  int done;
+  Keymap kmap;
+
+  /* input state */
+  rl_command_func_t *lastfunc;
+  int insmode;
+  int edmode;
+  int kseqlen;
+  FILE *inf;
+  FILE *outf;
+  int pendingin;
+  char *macro;
+
+  /* signal state */
+  int catchsigs;
+  int catchsigwinch;
+
+  /* reserved for future expansion, so the struct size doesn't change */
+  char reserved[64];
+};
+
+extern int rl_save_state PARAMS((struct readline_state *));
+extern int rl_restore_state PARAMS((struct readline_state *));
 
 #ifdef __cplusplus
 }
diff --git a/readline/rlconf.h b/readline/rlconf.h
index 1356fd87924e374e40b978ffd25c3bc19e831ce5..c651fd8b41f66ad39807ee1e18e714fcb8dae961 100644
--- a/readline/rlconf.h
+++ b/readline/rlconf.h
@@ -8,7 +8,7 @@
 
    The Library is free software; you can redistribute it and/or modify
    it under the terms of the GNU General Public License as published by
-   the Free Software Foundation; either version 1, or (at your option)
+   the Free Software Foundation; either version 2, or (at your option)
    any later version.
 
    The Library is distributed in the hope that it will be useful, but
@@ -19,7 +19,7 @@
    The GNU General Public License is often shipped with GNU software, and
    is generally kept in a file called COPYING or LICENSE.  If you do not
    have a copy of the license, write to the Free Software Foundation,
-   675 Mass Ave, Cambridge, MA 02139, USA. */
+   59 Temple Place, Suite 330, Boston, MA 02111 USA. */
 
 #if !defined (_RLCONF_H_)
 #define _RLCONF_H_
@@ -30,10 +30,6 @@
 /* Define this to get an indication of file type when listing completions. */
 #define VISIBLE_STATS
 
-/* If defined, readline shows opening parens and braces when closing
-   paren or brace entered. */
-/* #define PAREN_MATCHING */
-
 /* This definition is needed by readline.c, rltty.c, and signals.c. */
 /* If on, then readline handles signals in a way that doesn't screw. */
 #define HANDLE_SIGNALS
@@ -58,4 +54,7 @@
    X `callback' style. */
 #define READLINE_CALLBACKS
 
+/* Define this if you want the cursor to indicate insert or overwrite mode. */
+/* #define CURSOR_MODE */
+
 #endif /* _RLCONF_H_ */
diff --git a/readline/rldefs.h b/readline/rldefs.h
index d4aced43e2a2efee537ae022f1cf43046d02bb4a..5cba9a5ac3249274e4c42b9f0c2a4b72b4ff7c66 100644
--- a/readline/rldefs.h
+++ b/readline/rldefs.h
@@ -10,7 +10,7 @@
 
    The Library is free software; you can redistribute it and/or modify
    it under the terms of the GNU General Public License as published by
-   the Free Software Foundation; either version 1, or (at your option)
+   the Free Software Foundation; either version 2, or (at your option)
    any later version.
 
    The Library is distributed in the hope that it will be useful, but
@@ -21,7 +21,7 @@
    The GNU General Public License is often shipped with GNU software, and
    is generally kept in a file called COPYING or LICENSE.  If you do not
    have a copy of the license, write to the Free Software Foundation,
-   675 Mass Ave, Cambridge, MA 02139, USA. */
+   59 Temple Place, Suite 330, Boston, MA 02111 USA. */
 
 #if !defined (_RLDEFS_H_)
 #define _RLDEFS_H_
@@ -30,6 +30,12 @@
 #  include "config.h"
 #endif
 
+#include "rlstdc.h"
+
+#if !defined(__attribute__) && (defined(__cplusplus) || !defined(__GNUC__)  || __GNUC__ == 2 && __GNUC_MINOR__ <8)
+#define __attribute__(A)
+#endif
+
 #if defined (_POSIX_VERSION) && !defined (TERMIOS_MISSING)
 #  define TERMIOS_TTY_DRIVER
 #else
@@ -71,7 +77,14 @@ extern char *strchr (), *strrchr ();
 #define _rl_stricmp strcasecmp
 #define _rl_strnicmp strncasecmp
 #else
-extern int _rl_stricmp (), _rl_strnicmp ();
+extern int _rl_stricmp PARAMS((char *, char *));
+extern int _rl_strnicmp PARAMS((char *, char *, int));
+#endif
+
+#if defined (HAVE_STRPBRK)
+#  define _rl_strpbrk(a,b)	strpbrk((a),(b))
+#else
+extern char *_rl_strpbrk PARAMS((const char *, const char *));
 #endif
 
 #if !defined (emacs_mode)
@@ -80,6 +93,13 @@ extern int _rl_stricmp (), _rl_strnicmp ();
 #  define emacs_mode 1
 #endif
 
+#if !defined (RL_IM_INSERT)
+#  define RL_IM_INSERT		1
+#  define RL_IM_OVERWRITE	0
+#
+#  define RL_IM_DEFAULT		RL_IM_INSERT
+#endif
+
 /* If you cast map[key].function to type (Keymap) on a Cray,
    the compiler takes the value of map[key].function and
    divides it by 4 to convert between pointer types (pointers
@@ -87,15 +107,14 @@ extern int _rl_stricmp (), _rl_strnicmp ();
    This is not what is wanted. */
 #if defined (CRAY)
 #  define FUNCTION_TO_KEYMAP(map, key)	(Keymap)((int)map[key].function)
-#  define KEYMAP_TO_FUNCTION(data)	(Function *)((int)(data))
+#  define KEYMAP_TO_FUNCTION(data)	(rl_command_func_t *)((int)(data))
 #else
 #  define FUNCTION_TO_KEYMAP(map, key)	(Keymap)(map[key].function)
-#  define KEYMAP_TO_FUNCTION(data)	(Function *)(data)
+#  define KEYMAP_TO_FUNCTION(data)	(rl_command_func_t *)(data)
 #endif
 
 #ifndef savestring
-extern char *xmalloc ();
-#define savestring(x) strcpy (xmalloc (1 + strlen (x)), (x))
+#define savestring(x) strcpy ((char *)xmalloc (1 + strlen (x)), (x))
 #endif
 
 /* Possible values for _rl_bell_preference. */
@@ -113,22 +132,28 @@ extern char *xmalloc ();
 /* Possible values for the found_quote flags word used by the completion
    functions.  It says what kind of (shell-like) quoting we found anywhere
    in the line. */
-#define RL_QF_SINGLE_QUOTE	0x1
-#define RL_QF_DOUBLE_QUOTE	0x2
-#define RL_QF_BACKSLASH		0x4
+#define RL_QF_SINGLE_QUOTE	0x01
+#define RL_QF_DOUBLE_QUOTE	0x02
+#define RL_QF_BACKSLASH		0x04
+#define RL_QF_OTHER_QUOTE	0x08
 
 /* Default readline line buffer length. */
 #define DEFAULT_BUFFER_SIZE 256
 
 #if !defined (STREQ)
 #define STREQ(a, b)	(((a)[0] == (b)[0]) && (strcmp ((a), (b)) == 0))
-#define STREQN(a, b, n)	(((a)[0] == (b)[0]) && (strncmp ((a), (b), (n)) == 0))
+#define STREQN(a, b, n)	(((n) == 0) ? (1) \
+				    : ((a)[0] == (b)[0]) && (strncmp ((a), (b), (n)) == 0))
 #endif
 
 #if !defined (FREE)
 #  define FREE(x)	if (x) free (x)
 #endif
 
+#if !defined (SWAP)
+#  define SWAP(s, e)  do { int t; t = s; s = e; e = t; } while (0)
+#endif
+
 /* CONFIGURATION SECTION */
 #include "rlconf.h"
 
diff --git a/readline/rlmbutil.h b/readline/rlmbutil.h
new file mode 100644
index 0000000000000000000000000000000000000000..4660a72fce5a37cd0c4592d4869f5c221f82644b
--- /dev/null
+++ b/readline/rlmbutil.h
@@ -0,0 +1,108 @@
+/* rlmbutil.h -- utility functions for multibyte characters. */
+
+/* Copyright (C) 2001 Free Software Foundation, Inc.
+
+   This file is part of the GNU Readline Library, a library for
+   reading lines of text with interactive input and history editing.
+
+   The GNU Readline Library is free software; you can redistribute it
+   and/or modify it under the terms of the GNU General Public License
+   as published by the Free Software Foundation; either version 2, or
+   (at your option) any later version.
+
+   The GNU Readline Library is distributed in the hope that it will be
+   useful, but WITHOUT ANY WARRANTY; without even the implied warranty
+   of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+   GNU General Public License for more details.
+
+   The GNU General Public License is often shipped with GNU software, and
+   is generally kept in a file called COPYING or LICENSE.  If you do not
+   have a copy of the license, write to the Free Software Foundation,
+   59 Temple Place, Suite 330, Boston, MA 02111 USA. */
+
+#if !defined (_RL_MBUTIL_H_)
+#define _RL_MBUTIL_H_
+
+#include "rlstdc.h"
+
+/************************************************/
+/* check multibyte capability for I18N code     */
+/************************************************/
+
+/* For platforms which support the ISO C amendement 1 functionality we
+   support user defined character classes.  */
+   /* Solaris 2.5 has a bug: <wchar.h> must be included before <wctype.h>.  */
+#if defined (HAVE_WCTYPE_H) && defined (HAVE_WCHAR_H)
+#  include <wchar.h>
+#  include <wctype.h>
+#  if defined (HAVE_MBSRTOWCS) /* system is supposed to support XPG5 */
+#    define HANDLE_MULTIBYTE      1
+#  endif
+#endif
+
+/* Some systems, like BeOS, have multibyte encodings but lack mbstate_t.  */
+#if HANDLE_MULTIBYTE && !defined (HAVE_MBSTATE_T)
+#  define wcsrtombs(dest, src, len, ps) (wcsrtombs) (dest, src, len, 0)
+#  define mbsrtowcs(dest, src, len, ps) (mbsrtowcs) (dest, src, len, 0)
+#  define wcrtomb(s, wc, ps) (wcrtomb) (s, wc, 0)
+#  define mbrtowc(pwc, s, n, ps) (mbrtowc) (pwc, s, n, 0)
+#  define mbrlen(s, n, ps) (mbrlen) (s, n, 0)
+#  define mbstate_t int
+#endif
+
+/* Make sure MB_LEN_MAX is at least 16 on systems that claim to be able to
+   handle multibyte chars (some systems define MB_LEN_MAX as 1) */
+#ifdef HANDLE_MULTIBYTE
+#  include <limits.h>
+#  if defined(MB_LEN_MAX) && (MB_LEN_MAX < 16)
+#    undef MB_LEN_MAX
+#  endif
+#  if !defined (MB_LEN_MAX)
+#    define MB_LEN_MAX 16
+#  endif
+#endif
+
+/************************************************/
+/* end of multibyte capability checks for I18N  */
+/************************************************/
+
+/*
+ * Flags for _rl_find_prev_mbchar and _rl_find_next_mbchar:
+ *
+ * MB_FIND_ANY		find any multibyte character
+ * MB_FIND_NONZERO	find a non-zero-width multibyte character
+ */
+
+#define MB_FIND_ANY	0x00
+#define MB_FIND_NONZERO	0x01
+
+extern int _rl_find_prev_mbchar PARAMS((char *, int, int));
+extern int _rl_find_next_mbchar PARAMS((char *, int, int, int));
+
+#ifdef HANDLE_MULTIBYTE
+
+extern int _rl_compare_chars PARAMS((char *, int, mbstate_t *, char *, int, mbstate_t *));
+extern int _rl_get_char_len PARAMS((const char *, mbstate_t *));
+extern int _rl_adjust_point PARAMS((const char *, int, mbstate_t *));
+
+extern int _rl_read_mbchar PARAMS((char *, int));
+extern int _rl_read_mbstring PARAMS((int, char *, int));
+
+extern int _rl_is_mbchar_matched PARAMS((char *, int, int, char *, int));
+
+#else /* !HANDLE_MULTIBYTE */
+
+#undef MB_LEN_MAX
+#undef MB_CUR_MAX
+
+#define MB_LEN_MAX	1
+#define MB_CUR_MAX	1
+
+#define _rl_find_prev_mbchar(b, i, f)		(((i) == 0) ? (i) : ((i) - 1))
+#define _rl_find_next_mbchar(b, i1, i2, f)	((i1) + (i2))
+
+#endif /* !HANDLE_MULTIBYTE */
+
+extern int rl_byte_oriented;
+
+#endif /* _RL_MBUTIL_H_ */
diff --git a/readline/rlprivate.h b/readline/rlprivate.h
new file mode 100644
index 0000000000000000000000000000000000000000..36645fb4a65764fb279cb11a38fb3fe71c1a3819
--- /dev/null
+++ b/readline/rlprivate.h
@@ -0,0 +1,284 @@
+/* rlprivate.h -- functions and variables global to the readline library,
+		  but not intended for use by applications. */
+
+/* Copyright (C) 1999 Free Software Foundation, Inc.
+
+   This file is part of the GNU Readline Library, a library for
+   reading lines of text with interactive input and history editing.
+
+   The GNU Readline Library is free software; you can redistribute it
+   and/or modify it under the terms of the GNU General Public License
+   as published by the Free Software Foundation; either version 2, or
+   (at your option) any later version.
+
+   The GNU Readline Library is distributed in the hope that it will be
+   useful, but WITHOUT ANY WARRANTY; without even the implied warranty
+   of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+   GNU General Public License for more details.
+
+   The GNU General Public License is often shipped with GNU software, and
+   is generally kept in a file called COPYING or LICENSE.  If you do not
+   have a copy of the license, write to the Free Software Foundation,
+   59 Temple Place, Suite 330, Boston, MA 02111 USA. */
+
+#if !defined (_RL_PRIVATE_H_)
+#define _RL_PRIVATE_H_
+
+#include "rlconf.h"	/* for VISIBLE_STATS */
+#include "rlstdc.h"
+#include "posixjmp.h"	/* defines procenv_t */
+
+/*************************************************************************
+ *									 *
+ * Global functions undocumented in texinfo manual and not in readline.h *
+ *									 *
+ *************************************************************************/
+
+/*************************************************************************
+ *									 *
+ * Global variables undocumented in texinfo manual and not in readline.h *
+ *									 *
+ *************************************************************************/
+
+/* complete.c */
+extern int rl_complete_with_tilde_expansion;
+#if defined (VISIBLE_STATS)
+extern int rl_visible_stats;
+#endif /* VISIBLE_STATS */
+
+/* readline.c */
+extern int rl_line_buffer_len;
+extern int rl_arg_sign;
+extern int rl_visible_prompt_length;
+extern int readline_echoing_p;
+extern int rl_key_sequence_length;
+extern int rl_byte_oriented;
+
+/* display.c */
+extern int rl_display_fixed;
+
+/* parens.c */
+extern int rl_blink_matching_paren;
+
+/*************************************************************************
+ *									 *
+ * Global functions and variables unsed and undocumented		 *
+ *									 *
+ *************************************************************************/
+
+/* kill.c */
+extern int rl_set_retained_kills PARAMS((int));
+
+/* terminal.c */
+extern void _rl_set_screen_size PARAMS((int, int));
+
+/* undo.c */
+extern int _rl_fix_last_undo_of_type PARAMS((unsigned int, int, int));
+
+/* util.c */
+extern char *_rl_savestring PARAMS((const char *));
+
+/*************************************************************************
+ *									 *
+ * Functions and variables private to the readline library		 *
+ *									 *
+ *************************************************************************/
+
+/* NOTE: Functions and variables prefixed with `_rl_' are
+   pseudo-global: they are global so they can be shared
+   between files in the readline library, but are not intended
+   to be visible to readline callers. */
+
+/*************************************************************************
+ * Undocumented private functions					 *
+ *************************************************************************/
+
+#if defined(READLINE_CALLBACKS)
+
+/* readline.c */
+extern void readline_internal_setup PARAMS((void));
+extern char *readline_internal_teardown PARAMS((int));
+extern int readline_internal_char PARAMS((void));
+
+#endif /* READLINE_CALLBACKS */
+
+/* bind.c */
+extern void _rl_bind_if_unbound PARAMS((const char *, rl_command_func_t *));
+
+/* complete.c */
+extern char _rl_find_completion_word PARAMS((int *, int *));
+extern void _rl_free_match_list PARAMS((char **));
+
+/* display.c */
+extern char *_rl_strip_prompt PARAMS((char *));
+extern void _rl_move_cursor_relative PARAMS((int, const char *));
+extern void _rl_move_vert PARAMS((int));
+extern void _rl_save_prompt PARAMS((void));
+extern void _rl_restore_prompt PARAMS((void));
+extern char *_rl_make_prompt_for_search PARAMS((int));
+extern void _rl_erase_at_end_of_line PARAMS((int));
+extern void _rl_clear_to_eol PARAMS((int));
+extern void _rl_clear_screen PARAMS((void));
+extern void _rl_update_final PARAMS((void));
+extern void _rl_redisplay_after_sigwinch PARAMS((void));
+extern void _rl_clean_up_for_exit PARAMS((void));
+extern void _rl_erase_entire_line PARAMS((void));
+extern int _rl_current_display_line PARAMS((void));
+
+/* input.c */
+extern int _rl_any_typein PARAMS((void));
+extern int _rl_input_available PARAMS((void));
+extern int _rl_input_queued PARAMS((int));
+extern void _rl_insert_typein PARAMS((int));
+extern int _rl_unget_char PARAMS((int));
+
+/* macro.c */
+extern void _rl_with_macro_input PARAMS((char *));
+extern int _rl_next_macro_key PARAMS((void));
+extern void _rl_push_executing_macro PARAMS((void));
+extern void _rl_pop_executing_macro PARAMS((void));
+extern void _rl_add_macro_char PARAMS((int));
+extern void _rl_kill_kbd_macro PARAMS((void));
+
+/* misc.c */
+extern int _rl_init_argument PARAMS((void));
+extern void _rl_start_using_history PARAMS((void));
+extern int _rl_free_saved_history_line PARAMS((void));
+extern void _rl_set_insert_mode PARAMS((int, int));
+
+/* nls.c */
+extern int _rl_init_eightbit PARAMS((void));
+
+/* parens.c */
+extern void _rl_enable_paren_matching PARAMS((int));
+
+/* readline.c */
+extern void _rl_init_line_state PARAMS((void));
+extern void _rl_set_the_line PARAMS((void));
+extern int _rl_dispatch PARAMS((int, Keymap));
+extern int _rl_dispatch_subseq PARAMS((int, Keymap, int));
+
+/* rltty.c */
+extern int _rl_disable_tty_signals PARAMS((void));
+extern int _rl_restore_tty_signals PARAMS((void));
+
+/* terminal.c */
+extern void _rl_get_screen_size PARAMS((int, int));
+extern int _rl_init_terminal_io PARAMS((const char *));
+#ifdef _MINIX
+extern void _rl_output_character_function PARAMS((int));
+#else
+extern int _rl_output_character_function PARAMS((int));
+#endif
+extern void _rl_output_some_chars PARAMS((const char *, int));
+extern int _rl_backspace PARAMS((int));
+extern void _rl_enable_meta_key PARAMS((void));
+extern void _rl_control_keypad PARAMS((int));
+extern void _rl_set_cursor PARAMS((int, int));
+
+/* text.c */
+extern void _rl_fix_point PARAMS((int));
+extern int _rl_replace_text PARAMS((const char *, int, int));
+extern int _rl_insert_char PARAMS((int, int));
+extern int _rl_overwrite_char PARAMS((int, int));
+extern int _rl_overwrite_rubout PARAMS((int, int));
+extern int _rl_rubout_char PARAMS((int, int));
+#if defined (HANDLE_MULTIBYTE)
+extern int _rl_char_search_internal PARAMS((int, int, char *, int));
+#else
+extern int _rl_char_search_internal PARAMS((int, int, int));
+#endif
+extern int _rl_set_mark_at_pos PARAMS((int));
+
+/* util.c */
+extern int _rl_abort_internal PARAMS((void));
+extern char *_rl_strindex PARAMS((const char *, const char *));
+extern int _rl_qsort_string_compare PARAMS((char **, char **));
+extern int (_rl_uppercase_p) PARAMS((int));
+extern int (_rl_lowercase_p) PARAMS((int));
+extern int (_rl_pure_alphabetic) PARAMS((int));
+extern int (_rl_digit_p) PARAMS((int));
+extern int (_rl_to_lower) PARAMS((int));
+extern int (_rl_to_upper) PARAMS((int));
+extern int (_rl_digit_value) PARAMS((int));
+
+/* vi_mode.c */
+extern void _rl_vi_initialize_line PARAMS((void));
+extern void _rl_vi_reset_last PARAMS((void));
+extern void _rl_vi_set_last PARAMS((int, int, int));
+extern int _rl_vi_textmod_command PARAMS((int));
+extern void _rl_vi_done_inserting PARAMS((void));
+
+/*************************************************************************
+ * Undocumented private variables					 *
+ *************************************************************************/
+
+/* bind.c */
+extern const char *_rl_possible_control_prefixes[];
+extern const char *_rl_possible_meta_prefixes[];
+
+/* complete.c */
+extern int _rl_complete_show_all;
+extern int _rl_complete_mark_directories;
+extern int _rl_complete_mark_symlink_dirs;
+extern int _rl_print_completions_horizontally;
+extern int _rl_completion_case_fold;
+extern int _rl_match_hidden_files;
+extern int _rl_page_completions;
+
+/* display.c */
+extern int _rl_vis_botlin;
+extern int _rl_last_c_pos;
+extern int _rl_suppress_redisplay;
+extern const char *rl_display_prompt;
+
+/* isearch.c */
+extern char *_rl_isearch_terminators;
+
+/* macro.c */
+extern char *_rl_executing_macro;
+
+/* misc.c */
+extern int _rl_history_preserve_point;
+extern int _rl_history_saved_point;
+
+/* readline.c */
+extern int _rl_horizontal_scroll_mode;
+extern int _rl_mark_modified_lines;
+extern int _rl_bell_preference;
+extern int _rl_meta_flag;
+extern int _rl_convert_meta_chars_to_ascii;
+extern int _rl_output_meta_chars;
+extern char *_rl_comment_begin;
+extern unsigned char _rl_parsing_conditionalized_out;
+extern Keymap _rl_keymap;
+extern FILE *_rl_in_stream;
+extern FILE *_rl_out_stream;
+extern int _rl_last_command_was_kill;
+extern int _rl_eof_char;
+extern procenv_t readline_top_level;
+
+/* terminal.c */
+extern int _rl_enable_keypad;
+extern int _rl_enable_meta;
+extern const char *_rl_term_clreol;
+extern const char *_rl_term_clrpag;
+extern const char *_rl_term_im;
+extern const char *_rl_term_ic;
+extern const char *_rl_term_ei;
+extern const char *_rl_term_DC;
+extern const char *_rl_term_up;
+extern const char *_rl_term_dc;
+extern const char *_rl_term_cr;
+extern const char *_rl_term_IC;
+extern int _rl_screenheight;
+extern int _rl_screenwidth;
+extern int _rl_screenchars;
+extern int _rl_terminal_can_insert;
+extern int _rl_term_autowrap;
+
+/* undo.c */
+extern int _rl_doing_an_undo;
+extern int _rl_undo_group_level;
+
+#endif /* _RL_PRIVATE_H_ */
diff --git a/readline/rlshell.h b/readline/rlshell.h
new file mode 100644
index 0000000000000000000000000000000000000000..3c03fbad5765e8e8ebabf64c7f88bdaca86c64b4
--- /dev/null
+++ b/readline/rlshell.h
@@ -0,0 +1,34 @@
+/* rlshell.h -- utility functions normally provided by bash. */
+
+/* Copyright (C) 1999 Free Software Foundation, Inc.
+
+   This file is part of the GNU Readline Library, a library for
+   reading lines of text with interactive input and history editing.
+
+   The GNU Readline Library is free software; you can redistribute it
+   and/or modify it under the terms of the GNU General Public License
+   as published by the Free Software Foundation; either version 2, or
+   (at your option) any later version.
+
+   The GNU Readline Library is distributed in the hope that it will be
+   useful, but WITHOUT ANY WARRANTY; without even the implied warranty
+   of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+   GNU General Public License for more details.
+
+   The GNU General Public License is often shipped with GNU software, and
+   is generally kept in a file called COPYING or LICENSE.  If you do not
+   have a copy of the license, write to the Free Software Foundation,
+   59 Temple Place, Suite 330, Boston, MA 02111 USA. */
+
+#if !defined (_RL_SHELL_H_)
+#define _RL_SHELL_H_
+
+#include "rlstdc.h"
+
+extern char *sh_single_quote PARAMS((char *));
+extern void sh_set_lines_and_columns PARAMS((int, int));
+extern char *sh_get_env_value PARAMS((const char *));
+extern char *sh_get_home_dir PARAMS((void));
+extern int sh_unset_nodelay_mode PARAMS((int));
+
+#endif /* _RL_SHELL_H_ */
diff --git a/readline/rlstdc.h b/readline/rlstdc.h
index f79cf89fe76b6c5b3d71f213fbde4af296c2b82a..d6a22b3742c0af87f23f061b1ffef41f93d76664 100644
--- a/readline/rlstdc.h
+++ b/readline/rlstdc.h
@@ -7,7 +7,7 @@
 
    Bash is free software; you can redistribute it and/or modify it
    under the terms of the GNU General Public License as published by
-   the Free Software Foundation; either version 1, or (at your option)
+   the Free Software Foundation; either version 2, or (at your option)
    any later version.
 
    Bash is distributed in the hope that it will be useful, but WITHOUT
@@ -17,7 +17,7 @@
 
    You should have received a copy of the GNU General Public License
    along with Bash; see the file COPYING.  If not, write to the Free
-   Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. */
+   Software Foundation, 59 Temple Place, Suite 330, Boston, MA 02111 USA. */
 
 #if !defined (_RL_STDC_H_)
 #define _RL_STDC_H_
@@ -26,58 +26,20 @@
 
 /* A function can be defined using prototypes and compile on both ANSI C
    and traditional C compilers with something like this:
-	extern char *func __P((char *, char *, int)); */
+	extern char *func PARAMS((char *, char *, int)); */
 
-#if defined (__STDC__) || defined(__cplusplus)
-
-#  if !defined (__P)
-#    define __P(protos) protos
-#  endif
-#  define __STRING(x) #x
-
-#  if !defined (__GNUC__) && !defined(__cplusplus) && !defined(inline)
-#    define inline
-#  endif
-
-#else /* !__STDC__ */
-
-#  if !defined (__P)
-#    define __P(protos) ()
+#if !defined (PARAMS)
+#  if defined (__STDC__) || defined (__GNUC__) || defined (__cplusplus)
+#    define PARAMS(protos) protos
+#  else
+#    define PARAMS(protos) ()
 #  endif
-#  define __STRING(x) "x"
+#endif
 
-#if defined (__GNUC__)		/* gcc with -traditional */
-#  if !defined (const)
-#    define const  __const
-#  endif
-#  if !defined (inline)
-#    define inline __inline
+#ifndef __attribute__
+#  if __GNUC__ < 2 || (__GNUC__ == 2 && __GNUC_MINOR__ < 8) || __STRICT_ANSI__
+#    define __attribute__(x)
 #  endif
-#  if !defined (signed)
-#    define signed __signed
-#  endif
-#  if !defined (volatile)
-#    define volatile __volatile
-#  endif
-#else /* !__GNUC__ */
-#  if !defined (const)
-#    define const
-#  endif
-#  if !defined (inline)
-#    define inline
-#  endif
-#  if !defined (signed)
-#    define signed
-#  endif
-#  if !defined (volatile)
-#    define volatile
-#  endif
-#endif /* !__GNUC__ */
-
-#endif /* !__STDC__ */
-
-#if !defined(__attribute__) && (defined(__cplusplus) || !defined(__GNUC__)  || __GNUC__ == 2 && __GNUC_MINOR__ < 8)
-#define __attribute__(A)
 #endif
 
 #endif /* !_RL_STDC_H_ */
diff --git a/readline/rltty.c b/readline/rltty.c
index f87c1c9747f7d7acfd8e4db7b53b60ae3a2d8cd3..09702e9e75510d3017cc1809e96c6c4bb202c0a8 100644
--- a/readline/rltty.c
+++ b/readline/rltty.c
@@ -8,7 +8,7 @@
 
    The GNU Readline Library is free software; you can redistribute it
    and/or modify it under the terms of the GNU General Public License
-   as published by the Free Software Foundation; either version 1, or
+   as published by the Free Software Foundation; either version 2, or
    (at your option) any later version.
 
    The GNU Readline Library is distributed in the hope that it will be
@@ -19,7 +19,7 @@
    The GNU General Public License is often shipped with GNU software, and
    is generally kept in a file called COPYING or LICENSE.  If you do not
    have a copy of the license, write to the Free Software Foundation,
-   675 Mass Ave, Cambridge, MA 02139, USA. */
+   59 Temple Place, Suite 330, Boston, MA 02111 USA. */
 #define READLINE_LIBRARY
 
 #if defined (HAVE_CONFIG_H)
@@ -43,28 +43,19 @@
 
 #include "rltty.h"
 #include "readline.h"
+#include "rlprivate.h"
 
 #if !defined (errno)
 extern int errno;
 #endif /* !errno */
 
-extern int readline_echoing_p;
-extern int _rl_eof_char;
+rl_vintfunc_t *rl_prep_term_function = rl_prep_terminal;
+rl_voidfunc_t *rl_deprep_term_function = rl_deprep_terminal;
 
-extern int _rl_enable_keypad, _rl_enable_meta;
+static void block_sigint PARAMS((void));
+static void release_sigint PARAMS((void));
 
-extern void _rl_control_keypad ();
-
-#if defined (__GO32__)
-#  include <pc.h>
-#  undef HANDLE_SIGNALS
-#endif /* __GO32__ */
-
-/* Indirect functions to allow apps control over terminal management. */
-extern void rl_prep_terminal (), rl_deprep_terminal ();
-
-VFunction *rl_prep_term_function = rl_prep_terminal;
-VFunction *rl_deprep_term_function = rl_deprep_terminal;
+static void set_winsize PARAMS((int));
 
 /* **************************************************************** */
 /*								    */
@@ -104,6 +95,7 @@ block_sigint ()
 #    endif /* HAVE_USG_SIGHOLD */
 #  endif /* !HAVE_BSD_SIGNALS */
 #endif /* !HAVE_POSIX_SIGNALS */
+
   sigint_blocked = 1;
 }
 
@@ -111,7 +103,7 @@ block_sigint ()
 static void
 release_sigint ()
 {
-  if (!sigint_blocked)
+  if (sigint_blocked == 0)
     return;
 
 #if defined (HAVE_POSIX_SIGNALS)
@@ -138,32 +130,27 @@ release_sigint ()
 /* Non-zero means that the terminal is in a prepped state. */
 static int terminal_prepped;
 
+static _RL_TTY_CHARS _rl_tty_chars, _rl_last_tty_chars;
+
 /* If non-zero, means that this process has called tcflow(fd, TCOOFF)
    and output is suspended. */
 #if defined (__ksr1__)
 static int ksrflow;
 #endif
 
-#if defined (TIOCGWINSZ)
 /* Dummy call to force a backgrounded readline to stop before it tries
    to get the tty settings. */
 static void
 set_winsize (tty)
      int tty;
 {
+#if defined (TIOCGWINSZ)
   struct winsize w;
 
   if (ioctl (tty, TIOCGWINSZ, &w) == 0)
       (void) ioctl (tty, TIOCSWINSZ, &w);
-}
-#else
-static void
-set_winsize (tty)
-     int tty;
-{
-// dummy function, required by other code. What should be doing?
-}
 #endif /* TIOCGWINSZ */
+}
 
 #if defined (NEW_TTY_DRIVER)
 
@@ -191,6 +178,50 @@ struct bsdtty {
 
 static TIOTYPE otio;
 
+static void save_tty_chars PARAMS((TIOTYPE *));
+static int _get_tty_settings PARAMS((int, TIOTYPE *));
+static int get_tty_settings PARAMS((int, TIOTYPE *));
+static int _set_tty_settings PARAMS((int, TIOTYPE *));
+static int set_tty_settings PARAMS((int, TIOTYPE *));
+
+static void prepare_terminal_settings PARAMS((int, TIOTYPE, TIOTYPE *));
+
+static void
+save_tty_chars (tiop)
+     TIOTYPE *tiop;
+{
+  _rl_last_tty_chars = _rl_tty_chars;
+
+  if (tiop->flags & SGTTY_SET)
+    {
+      _rl_tty_chars.t_erase = tiop->sgttyb.sg_erase;
+      _rl_tty_chars.t_kill = tiop->sgttyb.sg_kill;
+    }
+
+  if (tiop->flags & TCHARS_SET)
+    {
+      _rl_tty_chars.t_intr = tiop->tchars.t_intrc;
+      _rl_tty_chars.t_quit = tiop->tchars.t_quitc;
+      _rl_tty_chars.t_start = tiop->tchars.t_startc;
+      _rl_tty_chars.t_stop = tiop->tchars.t_stopc;
+      _rl_tty_chars.t_eof = tiop->tchars.t_eofc;
+      _rl_tty_chars.t_eol = '\n';
+      _rl_tty_chars.t_eol2 = tiop->tchars.t_brkc;
+    }
+
+  if (tiop->flags & LTCHARS_SET)
+    {
+      _rl_tty_chars.t_susp = tiop->ltchars.t_suspc;
+      _rl_tty_chars.t_dsusp = tiop->ltchars.t_dsuspc;
+      _rl_tty_chars.t_reprint = tiop->ltchars.t_rprntc;
+      _rl_tty_chars.t_flush = tiop->ltchars.t_flushc;
+      _rl_tty_chars.t_werase = tiop->ltchars.t_werasc;
+      _rl_tty_chars.t_lnext = tiop->ltchars.t_lnextc;
+    }
+
+  _rl_tty_chars.t_status = -1;
+}
+
 static int
 get_tty_settings (tty, tiop)
      int tty;
@@ -200,22 +231,23 @@ get_tty_settings (tty, tiop)
 
   tiop->flags = tiop->lflag = 0;
 
-  ioctl (tty, TIOCGETP, &(tiop->sgttyb));
+  if (ioctl (tty, TIOCGETP, &(tiop->sgttyb)) < 0)
+    return -1;
   tiop->flags |= SGTTY_SET;
 
 #if defined (TIOCLGET)
-  ioctl (tty, TIOCLGET, &(tiop->lflag));
-  tiop->flags |= LFLAG_SET;
+  if (ioctl (tty, TIOCLGET, &(tiop->lflag)) == 0)
+    tiop->flags |= LFLAG_SET;
 #endif
 
 #if defined (TIOCGETC)
-  ioctl (tty, TIOCGETC, &(tiop->tchars));
-  tiop->flags |= TCHARS_SET;
+  if (ioctl (tty, TIOCGETC, &(tiop->tchars)) == 0)
+    tiop->flags |= TCHARS_SET;
 #endif
 
 #if defined (TIOCGLTC)
-  ioctl (tty, TIOCGLTC, &(tiop->ltchars));
-  tiop->flags |= LTCHARS_SET;
+  if (ioctl (tty, TIOCGLTC, &(tiop->ltchars)) == 0)
+    tiop->flags |= LTCHARS_SET;
 #endif
 
   return 0;
@@ -261,24 +293,23 @@ set_tty_settings (tty, tiop)
 }
 
 static void
-prepare_terminal_settings (meta_flag, otio, tiop)
+prepare_terminal_settings (meta_flag, oldtio, tiop)
      int meta_flag;
-     TIOTYPE otio, *tiop;
+     TIOTYPE oldtio, *tiop;
 {
-#if !defined (__GO32__)
-  readline_echoing_p = (otio.sgttyb.sg_flags & ECHO);
+  readline_echoing_p = (oldtio.sgttyb.sg_flags & ECHO);
 
   /* Copy the original settings to the structure we're going to use for
      our settings. */
-  tiop->sgttyb = otio.sgttyb;
-  tiop->lflag = otio.lflag;
+  tiop->sgttyb = oldtio.sgttyb;
+  tiop->lflag = oldtio.lflag;
 #if defined (TIOCGETC)
-  tiop->tchars = otio.tchars;
+  tiop->tchars = oldtio.tchars;
 #endif
 #if defined (TIOCGLTC)
-  tiop->ltchars = otio.ltchars;
+  tiop->ltchars = oldtio.ltchars;
 #endif
-  tiop->flags = otio.flags;
+  tiop->flags = oldtio.flags;
 
   /* First, the basic settings to put us into character-at-a-time, no-echo
      input mode. */
@@ -291,8 +322,8 @@ prepare_terminal_settings (meta_flag, otio, tiop)
 #if !defined (ANYP)
 #  define ANYP (EVENP | ODDP)
 #endif
-  if (((otio.sgttyb.sg_flags & ANYP) == ANYP) ||
-      ((otio.sgttyb.sg_flags & ANYP) == 0))
+  if (((oldtio.sgttyb.sg_flags & ANYP) == ANYP) ||
+      ((oldtio.sgttyb.sg_flags & ANYP) == 0))
     {
       tiop->sgttyb.sg_flags |= ANYP;
 
@@ -311,13 +342,13 @@ prepare_terminal_settings (meta_flag, otio, tiop)
   tiop->tchars.t_startc = -1; /* C-q */
 
   /* If there is an XON character, bind it to restart the output. */
-  if (otio.tchars.t_startc != -1)
-    rl_bind_key (otio.tchars.t_startc, rl_restart_output);
+  if (oldtio.tchars.t_startc != -1)
+    rl_bind_key (oldtio.tchars.t_startc, rl_restart_output);
 #  endif /* USE_XON_XOFF */
 
   /* If there is an EOF char, bind _rl_eof_char to it. */
-  if (otio.tchars.t_eofc != -1)
-    _rl_eof_char = otio.tchars.t_eofc;
+  if (oldtio.tchars.t_eofc != -1)
+    _rl_eof_char = oldtio.tchars.t_eofc;
 
 #  if defined (NO_KILL_INTR)
   /* Get rid of terminal-generated SIGQUIT and SIGINT. */
@@ -331,7 +362,6 @@ prepare_terminal_settings (meta_flag, otio, tiop)
   tiop->ltchars.t_dsuspc = -1;	/* C-y */
   tiop->ltchars.t_lnextc = -1;	/* C-v */
 #endif /* TIOCGLTC */
-#endif /* !__GO32__ */
 }
 
 #else  /* !defined (NEW_TTY_DRIVER) */
@@ -357,18 +387,71 @@ prepare_terminal_settings (meta_flag, otio, tiop)
 #  define TIOTYPE struct termio
 #  define DRAIN_OUTPUT(fd)
 #  define GETATTR(tty, tiop)	(ioctl (tty, TCGETA, tiop))
-#  define SETATTR(tty, tiop)	(ioctl (tty, TCSETA, tiop))
+#  define SETATTR(tty, tiop)	(ioctl (tty, TCSETAW, tiop))
 #endif /* !TERMIOS_TTY_DRIVER */
 
 static TIOTYPE otio;
 
+static void save_tty_chars PARAMS((TIOTYPE *));
+static int _get_tty_settings PARAMS((int, TIOTYPE *));
+static int get_tty_settings PARAMS((int, TIOTYPE *));
+static int _set_tty_settings PARAMS((int, TIOTYPE *));
+static int set_tty_settings PARAMS((int, TIOTYPE *));
+
+static void prepare_terminal_settings PARAMS((int, TIOTYPE, TIOTYPE *));
+
 #if defined (FLUSHO)
 #  define OUTPUT_BEING_FLUSHED(tp)  (tp->c_lflag & FLUSHO)
 #else
 #  define OUTPUT_BEING_FLUSHED(tp)  0
 #endif
 
-#if defined (_AIX) || (defined (FLUSHO) && defined (_AIX41))
+static void
+save_tty_chars (tiop)
+     TIOTYPE *tiop;
+{
+  _rl_last_tty_chars = _rl_tty_chars;
+
+  _rl_tty_chars.t_eof = tiop->c_cc[VEOF];
+  _rl_tty_chars.t_eol = tiop->c_cc[VEOL];
+#ifdef VEOL2
+  _rl_tty_chars.t_eol2 = tiop->c_cc[VEOL2];
+#endif
+  _rl_tty_chars.t_erase = tiop->c_cc[VERASE];
+#ifdef VWERASE
+  _rl_tty_chars.t_werase = tiop->c_cc[VWERASE];
+#endif
+  _rl_tty_chars.t_kill = tiop->c_cc[VKILL];
+#ifdef VREPRINT
+  _rl_tty_chars.t_reprint = tiop->c_cc[VREPRINT];
+#endif
+  _rl_tty_chars.t_intr = tiop->c_cc[VINTR];
+  _rl_tty_chars.t_quit = tiop->c_cc[VQUIT];
+#ifdef VSUSP
+  _rl_tty_chars.t_susp = tiop->c_cc[VSUSP];
+#endif
+#ifdef VDSUSP
+  _rl_tty_chars.t_dsusp = tiop->c_cc[VDSUSP];
+#endif
+#ifdef VSTART
+  _rl_tty_chars.t_start = tiop->c_cc[VSTART];
+#endif
+#ifdef VSTOP
+  _rl_tty_chars.t_stop = tiop->c_cc[VSTOP];
+#endif
+#ifdef VLNEXT
+  _rl_tty_chars.t_lnext = tiop->c_cc[VLNEXT];
+#endif
+#ifdef VDISCARD
+  _rl_tty_chars.t_flush = tiop->c_cc[VDISCARD];
+#endif
+#ifdef VSTATUS
+  _rl_tty_chars.t_status = tiop->c_cc[VSTATUS];
+#endif
+}
+
+#if defined (_AIX) || defined (_AIX41)
+/* Currently this is only used on AIX */
 static void
 rltty_warning (msg)
      char *msg;
@@ -377,7 +460,6 @@ rltty_warning (msg)
 }
 #endif
 
-
 #if defined (_AIX)
 void
 setopost(tp)
@@ -392,14 +474,12 @@ TIOTYPE *tp;
 #endif
 
 static int
-get_tty_settings (tty, tiop)
+_get_tty_settings (tty, tiop)
      int tty;
      TIOTYPE *tiop;
 {
   int ioctl_ret;
 
-  set_winsize (tty);
-
   while (1)
     {
       ioctl_ret = GETATTR (tty, tiop);
@@ -423,6 +503,19 @@ get_tty_settings (tty, tiop)
       break;
     }
 
+  return 0;
+}
+
+static int
+get_tty_settings (tty, tiop)
+     int tty;
+     TIOTYPE *tiop;
+{
+  set_winsize (tty);
+
+  if (_get_tty_settings (tty, tiop) < 0)
+    return -1;
+
 #if defined (_AIX)
   setopost(tiop);
 #endif
@@ -431,7 +524,7 @@ get_tty_settings (tty, tiop)
 }
 
 static int
-set_tty_settings (tty, tiop)
+_set_tty_settings (tty, tiop)
      int tty;
      TIOTYPE *tiop;
 {
@@ -441,7 +534,17 @@ set_tty_settings (tty, tiop)
 	return -1;
       errno = 0;
     }
+  return 0;
+}
 
+static int
+set_tty_settings (tty, tiop)
+     int tty;
+     TIOTYPE *tiop;
+{
+  if (_set_tty_settings (tty, tiop) < 0)
+    return -1;
+    
 #if 0
 
 #if defined (TERMIOS_TTY_DRIVER)
@@ -458,22 +561,22 @@ set_tty_settings (tty, tiop)
   ioctl (tty, TCXONC, 1);	/* Simulate a ^Q. */
 #endif /* !TERMIOS_TTY_DRIVER */
 
-#endif
+#endif /* 0 */
 
   return 0;
 }
 
 static void
-prepare_terminal_settings (meta_flag, otio, tiop)
+prepare_terminal_settings (meta_flag, oldtio, tiop)
      int meta_flag;
-     TIOTYPE otio, *tiop;
+     TIOTYPE oldtio, *tiop;
 {
-  readline_echoing_p = (otio.c_lflag & ECHO);
+  readline_echoing_p = (oldtio.c_lflag & ECHO);
 
   tiop->c_lflag &= ~(ICANON | ECHO);
 
-  if ((unsigned char) otio.c_cc[VEOF] != (unsigned char) _POSIX_VDISABLE)
-    _rl_eof_char = otio.c_cc[VEOF];
+  if ((unsigned char) oldtio.c_cc[VEOF] != (unsigned char) _POSIX_VDISABLE)
+    _rl_eof_char = oldtio.c_cc[VEOF];
 
 #if defined (USE_XON_XOFF)
 #if defined (IXANY)
@@ -504,7 +607,7 @@ prepare_terminal_settings (meta_flag, otio, tiop)
   if (OUTPUT_BEING_FLUSHED (tiop))
     {
       tiop->c_lflag &= ~FLUSHO;
-      otio.c_lflag &= ~FLUSHO;
+      oldtio.c_lflag &= ~FLUSHO;
     }
 #endif
 
@@ -530,7 +633,6 @@ void
 rl_prep_terminal (meta_flag)
      int meta_flag;
 {
-#if !defined (__GO32__)
   int tty;
   TIOTYPE tio;
 
@@ -550,6 +652,8 @@ rl_prep_terminal (meta_flag)
 
   otio = tio;
 
+  save_tty_chars (&otio);
+
   prepare_terminal_settings (meta_flag, otio, &tio);
 
   if (set_tty_settings (tty, &tio) < 0)
@@ -563,16 +667,15 @@ rl_prep_terminal (meta_flag)
 
   fflush (rl_outstream);
   terminal_prepped = 1;
+  RL_SETSTATE(RL_STATE_TERMPREPPED);
 
   release_sigint ();
-#endif /* !__GO32__ */
 }
 
 /* Restore the terminal's normal settings and modes. */
 void
 rl_deprep_terminal ()
 {
-#if !defined (__GO32__)
   int tty;
 
   if (!terminal_prepped)
@@ -595,9 +698,9 @@ rl_deprep_terminal ()
     }
 
   terminal_prepped = 0;
+  RL_UNSETSTATE(RL_STATE_TERMPREPPED);
 
   release_sigint ();
-#endif /* !__GO32__ */
 }
 
 /* **************************************************************** */
@@ -607,8 +710,8 @@ rl_deprep_terminal ()
 /* **************************************************************** */
 
 int
-rl_restart_output (int count __attribute__((unused)),
-		   int key __attribute__((unused)))
+rl_restart_output (count, key)
+     int count __attribute__((unused)), key __attribute__((unused));
 {
   int fildes = fileno (rl_outstream);
 #if defined (TIOCSTART)
@@ -640,8 +743,8 @@ rl_restart_output (int count __attribute__((unused)),
 }
 
 int
-rl_stop_output (int count __attribute__((unused)),
-		int key __attribute__((unused)))
+rl_stop_output (count, key)
+     int count __attribute__((unused)), key __attribute__((unused));
 {
   int fildes = fileno (rl_instream);
 
@@ -672,6 +775,9 @@ rl_stop_output (int count __attribute__((unused)),
 /*			Default Key Bindings			    */
 /*								    */
 /* **************************************************************** */
+
+/* Set the system's default editing characters to their readline equivalents
+   in KMAP.  Should be static, now that we have rl_tty_set_default_bindings. */
 void
 rltty_set_default_bindings (kmap)
      Keymap kmap;
@@ -686,8 +792,8 @@ rltty_set_default_bindings (kmap)
     { \
       int ic; \
       ic = sc; \
-      if (ic != -1 && kmap[ic].type == ISFUNC) \
-	kmap[ic].function = func; \
+      if (ic != -1 && kmap[(unsigned char)ic].type == ISFUNC) \
+	kmap[(unsigned char)ic].function = func; \
     } \
   while (0)
 
@@ -735,3 +841,71 @@ rltty_set_default_bindings (kmap)
     }
 #endif /* !NEW_TTY_DRIVER */
 }
+
+/* New public way to set the system default editing chars to their readline
+   equivalents. */
+void
+rl_tty_set_default_bindings (kmap)
+     Keymap kmap;
+{
+  rltty_set_default_bindings (kmap);
+}
+
+#if defined (HANDLE_SIGNALS)
+
+#if defined (NEW_TTY_DRIVER)
+int
+_rl_disable_tty_signals ()
+{
+  return 0;
+}
+
+int
+_rl_restore_tty_signals ()
+{
+  return 0;
+}
+#else
+
+static TIOTYPE sigstty, nosigstty;
+static int tty_sigs_disabled = 0;
+
+int
+_rl_disable_tty_signals ()
+{
+  if (tty_sigs_disabled)
+    return 0;
+
+  if (_get_tty_settings (fileno (rl_instream), &sigstty) < 0)
+    return -1;
+
+  nosigstty = sigstty;
+
+  nosigstty.c_lflag &= ~ISIG;
+  nosigstty.c_iflag &= ~IXON;
+
+  if (_set_tty_settings (fileno (rl_instream), &nosigstty) < 0)
+    return (_set_tty_settings (fileno (rl_instream), &sigstty));
+
+  tty_sigs_disabled = 1;
+  return 0;
+}
+
+int
+_rl_restore_tty_signals ()
+{
+  int r;
+
+  if (tty_sigs_disabled == 0)
+    return 0;
+
+  r = _set_tty_settings (fileno (rl_instream), &sigstty);
+
+  if (r == 0)
+    tty_sigs_disabled = 0;
+
+  return r;
+}
+#endif /* !NEW_TTY_DRIVER */
+
+#endif /* HANDLE_SIGNALS */
diff --git a/readline/rltty.h b/readline/rltty.h
index fe783463f6a2a36f85e39ded7ea4318949be55ee..029a3fbc0e1fb6d93ce8945eb6b2ff3d65c48925 100644
--- a/readline/rltty.h
+++ b/readline/rltty.h
@@ -8,7 +8,7 @@
 
    The Library is free software; you can redistribute it and/or modify
    it under the terms of the GNU General Public License as published by
-   the Free Software Foundation; either version 1, or (at your option)
+   the Free Software Foundation; either version 2, or (at your option)
    any later version.
 
    The Library is distributed in the hope that it will be useful, but
@@ -19,10 +19,10 @@
    The GNU General Public License is often shipped with GNU software, and
    is generally kept in a file called COPYING or LICENSE.  If you do not
    have a copy of the license, write to the Free Software Foundation,
-   675 Mass Ave, Cambridge, MA 02139, USA. */
+   59 Temple Place, Suite 330, Boston, MA 02111 USA. */
 
 #if !defined (_RLTTY_H_)
-#define _RLTTY_H
+#define _RLTTY_H_
 
 /* Posix systems use termios and the Posix signal functions. */
 #if defined (TERMIOS_TTY_DRIVER)
@@ -60,4 +60,23 @@
 #  endif /* !_SVR4_DISABLE */
 #endif /* !NEW_TTY_DRIVER && !_POSIX_VDISABLE */
 
+typedef struct _rl_tty_chars {
+  char t_eof;
+  char t_eol;
+  char t_eol2;
+  char t_erase;
+  char t_werase;
+  char t_kill;
+  char t_reprint;
+  char t_intr;
+  char t_quit;
+  char t_susp;
+  char t_dsusp;
+  char t_start;
+  char t_stop;
+  char t_lnext;
+  char t_flush;
+  char t_status;
+} _RL_TTY_CHARS;
+
 #endif /* _RLTTY_H_ */
diff --git a/readline/rltypedefs.h b/readline/rltypedefs.h
new file mode 100644
index 0000000000000000000000000000000000000000..f3280e9fce079e2d388a70d5b7ffb1ebf7727880
--- /dev/null
+++ b/readline/rltypedefs.h
@@ -0,0 +1,88 @@
+/* rltypedefs.h -- Type declarations for readline functions. */
+
+/* Copyright (C) 2000 Free Software Foundation, Inc.
+
+   This file is part of the GNU Readline Library, a library for
+   reading lines of text with interactive input and history editing.
+
+   The GNU Readline Library is free software; you can redistribute it
+   and/or modify it under the terms of the GNU General Public License
+   as published by the Free Software Foundation; either version 2, or
+   (at your option) any later version.
+
+   The GNU Readline Library is distributed in the hope that it will be
+   useful, but WITHOUT ANY WARRANTY; without even the implied warranty
+   of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+   GNU General Public License for more details.
+
+   The GNU General Public License is often shipped with GNU software, and
+   is generally kept in a file called COPYING or LICENSE.  If you do not
+   have a copy of the license, write to the Free Software Foundation,
+   59 Temple Place, Suite 330, Boston, MA 02111 USA. */
+
+#ifndef _RL_TYPEDEFS_H_
+#define _RL_TYPEDEFS_H_
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+/* Old-style */
+
+#if !defined (_FUNCTION_DEF)
+#  define _FUNCTION_DEF
+
+typedef int Function ();
+typedef void VFunction ();
+typedef char *CPFunction ();
+typedef char **CPPFunction ();
+
+#endif /* _FUNCTION_DEF */
+
+/* New style. */
+
+#if !defined (_RL_FUNCTION_TYPEDEF)
+#  define _RL_FUNCTION_TYPEDEF
+
+/* Bindable functions */
+typedef int rl_command_func_t PARAMS((int, int));
+
+/* Typedefs for the completion system */
+typedef char *rl_compentry_func_t PARAMS((const char *, int));
+typedef char **rl_completion_func_t PARAMS((const char *, int, int));
+
+typedef char *rl_quote_func_t PARAMS((char *, int, char *));
+typedef char *rl_dequote_func_t PARAMS((char *, int));
+
+typedef int rl_compignore_func_t PARAMS((char **));
+
+typedef void rl_compdisp_func_t PARAMS((char **, int, int));
+
+/* Type for input and pre-read hook functions like rl_event_hook */
+typedef int rl_hook_func_t PARAMS((void));
+
+/* Input function type */
+typedef int rl_getc_func_t PARAMS((FILE *));
+
+/* Generic function that takes a character buffer (which could be the readline
+   line buffer) and an index into it (which could be rl_point) and returns
+   an int. */
+typedef int rl_linebuf_func_t PARAMS((char *, int));
+
+/* `Generic' function pointer typedefs */
+typedef int rl_intfunc_t PARAMS((int));
+#define rl_ivoidfunc_t rl_hook_func_t
+typedef int rl_icpfunc_t PARAMS((char *));
+typedef int rl_icppfunc_t PARAMS((char **));
+
+typedef void rl_voidfunc_t PARAMS((void));
+typedef void rl_vintfunc_t PARAMS((int));
+typedef void rl_vcpfunc_t PARAMS((char *));
+typedef void rl_vcppfunc_t PARAMS((char **));
+#endif /* _RL_FUNCTION_TYPEDEF */
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* _RL_TYPEDEFS_H_ */
diff --git a/readline/rlwinsize.h b/readline/rlwinsize.h
index 92b3de174bfc92eda54edbf15395df4a46eb9b0b..7838154d0233d63b743cfa4af6284e8d6e0ed43b 100644
--- a/readline/rlwinsize.h
+++ b/readline/rlwinsize.h
@@ -9,7 +9,7 @@
 
    The Library is free software; you can redistribute it and/or modify
    it under the terms of the GNU General Public License as published by
-   the Free Software Foundation; either version 1, or (at your option)
+   the Free Software Foundation; either version 2, or (at your option)
    any later version.
 
    The Library is distributed in the hope that it will be useful, but
@@ -20,7 +20,7 @@
    The GNU General Public License is often shipped with GNU software, and
    is generally kept in a file called COPYING or LICENSE.  If you do not
    have a copy of the license, write to the Free Software Foundation,
-   675 Mass Ave, Cambridge, MA 02139, USA. */
+   59 Temple Place, Suite 330, Boston, MA 02111 USA. */
 
 #if !defined (_RLWINSIZE_H_)
 #define _RLWINSIZE_H_
@@ -55,4 +55,3 @@
 
 #endif /* _RL_WINSIZE_H */
 
-
diff --git a/readline/search.c b/readline/search.c
index 0179d8da2f1ef43687c374a6231092ddaef9aee0..ac47596a3f86d4032448b82598241ab820c18528 100644
--- a/readline/search.c
+++ b/readline/search.c
@@ -8,7 +8,7 @@
 
    The Library is free software; you can redistribute it and/or modify
    it under the terms of the GNU General Public License as published by
-   the Free Software Foundation; either version 1, or (at your option)
+   the Free Software Foundation; either version 2, or (at your option)
    any later version.
 
    The Library is distributed in the hope that it will be useful, but
@@ -19,7 +19,7 @@
    The GNU General Public License is often shipped with GNU software, and
    is generally kept in a file called COPYING or LICENSE.  If you do not
    have a copy of the license, write to the Free Software Foundation,
-   675 Mass Ave, Cambridge, MA 02139, USA. */
+   59 Temple Place, Suite 330, Boston, MA 02111 USA. */
 #define READLINE_LIBRARY
 
 #if defined (HAVE_CONFIG_H)
@@ -40,33 +40,56 @@
 #endif
 
 #include "rldefs.h"
+#include "rlmbutil.h"
+
 #include "readline.h"
 #include "history.h"
 
+#include "rlprivate.h"
+#include "xmalloc.h"
+
 #ifdef abs
 #  undef abs
 #endif
 #define abs(x)		(((x) >= 0) ? (x) : -(x))
 
-extern char *xmalloc (), *xrealloc ();
-
-/* Variables imported from readline.c */
-extern int rl_point, rl_end, rl_line_buffer_len;
-extern int rl_editing_mode;
-extern char *rl_prompt;
-extern char *rl_line_buffer;
-extern HIST_ENTRY *saved_line_for_history;
-extern Function *rl_last_func;
+extern HIST_ENTRY *_rl_saved_line_for_history;
 
 /* Functions imported from the rest of the library. */
-extern int _rl_free_history_entry ();
-extern char *_rl_make_prompt_for_search ();
-extern void rl_extend_line_buffer ();
+extern int _rl_free_history_entry PARAMS((HIST_ENTRY *));
 
 static char *noninc_search_string = (char *) NULL;
 static int noninc_history_pos;
+
 static char *prev_line_found = (char *) NULL;
 
+static int rl_history_search_len;
+static int rl_history_search_pos;
+static char *history_search_string;
+static int history_string_size;
+
+static void make_history_line_current PARAMS((HIST_ENTRY *));
+static int noninc_search_from_pos PARAMS((char *, int, int));
+static void noninc_dosearch PARAMS((char *, int));
+static void noninc_search PARAMS((int, int));
+static int rl_history_search_internal PARAMS((int, int));
+static void rl_history_search_reinit PARAMS((void));
+
+/* Make the data from the history entry ENTRY be the contents of the
+   current line.  This doesn't do anything with rl_point; the caller
+   must set it. */
+static void
+make_history_line_current (entry)
+     HIST_ENTRY *entry;
+{
+  rl_replace_line (entry->line, 0);
+  rl_undo_list = (UNDO_LIST *)entry->data;
+
+  if (_rl_saved_line_for_history)
+    _rl_free_history_entry (_rl_saved_line_for_history);
+  _rl_saved_line_for_history = (HIST_ENTRY *)NULL;
+}
+
 /* Search the history list for STRING starting at absolute history position
    POS.  If STRING begins with `^', the search must match STRING at the
    beginning of a history line, otherwise a full substring match is performed
@@ -79,13 +102,19 @@ noninc_search_from_pos (string, pos, dir)
 {
   int ret, old;
 
+  if (pos < 0)
+    return -1;
+
   old = where_history ();
-  history_set_pos (pos);
+  if (history_set_pos (pos) == 0)
+    return -1;
 
+  RL_SETSTATE(RL_STATE_SEARCH);
   if (*string == '^')
     ret = history_search_prefix (string + 1, dir);
   else
     ret = history_search (string, dir);
+  RL_UNSETSTATE(RL_STATE_SEARCH);
 
   if (ret != -1)
     ret = where_history ();
@@ -102,12 +131,12 @@ noninc_dosearch (string, dir)
      char *string;
      int dir;
 {
-  int oldpos, pos, line_len;
+  int oldpos, pos;
   HIST_ENTRY *entry;
 
   if (string == 0 || *string == '\0' || noninc_history_pos < 0)
     {
-      ding ();
+      rl_ding ();
       return;
     }
 
@@ -115,10 +144,10 @@ noninc_dosearch (string, dir)
   if (pos == -1)
     {
       /* Search failed, current history position unchanged. */
-      maybe_unsave_line ();
+      rl_maybe_unsave_line ();
       rl_clear_message ();
       rl_point = 0;
-      ding ();
+      rl_ding ();
       return;
     }
 
@@ -132,19 +161,12 @@ noninc_dosearch (string, dir)
 #endif
   history_set_pos (oldpos);
 
-  line_len = strlen (entry->line);
-  if (line_len >= rl_line_buffer_len)
-    rl_extend_line_buffer (line_len);
-  strcpy (rl_line_buffer, entry->line);
+  make_history_line_current (entry);
 
-  rl_undo_list = (UNDO_LIST *)entry->data;
-  rl_end = strlen (rl_line_buffer);
   rl_point = 0;
-  rl_clear_message ();
+  rl_mark = rl_end;
 
-  if (saved_line_for_history)
-    _rl_free_history_entry (saved_line_for_history);
-  saved_line_for_history = (HIST_ENTRY *)NULL;
+  rl_clear_message ();
 }
 
 /* Search non-interactively through the history list.  DIR < 0 means to
@@ -157,11 +179,15 @@ noninc_search (dir, pchar)
      int dir;
      int pchar;
 {
-  int saved_point, c;
+  int saved_point, saved_mark, c;
   char *p;
+#if defined (HANDLE_MULTIBYTE)
+  char mb[MB_LEN_MAX];
+#endif
 
-  maybe_save_line ();
+  rl_maybe_save_line ();
   saved_point = rl_point;
+  saved_mark = rl_mark;
 
   /* Use the line buffer to read the search string. */
   rl_line_buffer[0] = 0;
@@ -171,23 +197,37 @@ noninc_search (dir, pchar)
   rl_message (p, 0, 0);
   free (p);
 
-#define SEARCH_RETURN rl_restore_prompt (); return
+#define SEARCH_RETURN rl_restore_prompt (); RL_UNSETSTATE(RL_STATE_NSEARCH); return
 
+  RL_SETSTATE(RL_STATE_NSEARCH);
   /* Read the search string. */
-  while ((c = rl_read_key ()))
+  while (1)
     {
+      RL_SETSTATE(RL_STATE_MOREINPUT);
+      c = rl_read_key ();
+      RL_UNSETSTATE(RL_STATE_MOREINPUT);
+
+#if defined (HANDLE_MULTIBYTE)
+      if (MB_CUR_MAX > 1 && rl_byte_oriented == 0)
+	c = _rl_read_mbstring (c, mb, MB_LEN_MAX);
+#endif
+
+      if (c == 0)
+	break;
+
       switch (c)
 	{
 	case CTRL('H'):
 	case RUBOUT:
 	  if (rl_point == 0)
 	    {
-	      maybe_unsave_line ();
+	      rl_maybe_unsave_line ();
 	      rl_clear_message ();
 	      rl_point = saved_point;
+	      rl_mark = saved_mark;
 	      SEARCH_RETURN;
 	    }
-	  rl_rubout (1, c);
+	  _rl_rubout_char (1, c);
 	  break;
 
 	case CTRL('W'):
@@ -206,20 +246,28 @@ noninc_search (dir, pchar)
 
 	case CTRL('C'):
 	case CTRL('G'):
-	  maybe_unsave_line ();
+	  rl_maybe_unsave_line ();
 	  rl_clear_message ();
 	  rl_point = saved_point;
-	  ding ();
+	  rl_mark = saved_mark;
+	  rl_ding ();
 	  SEARCH_RETURN;
 
 	default:
-	  rl_insert (1, c);
+#if defined (HANDLE_MULTIBYTE)
+	  if (MB_CUR_MAX > 1 && rl_byte_oriented == 0)
+	    rl_insert_text (mb);
+	  else
+#endif
+	    _rl_insert_char (1, c);
 	  break;
 	}
       (*rl_redisplay_function) ();
     }
 
  dosearch:
+  rl_mark = saved_mark;
+
   /* If rl_point == 0, we want to re-use the previous search string and
      start from the saved history position.  If there's no previous search
      string, punt. */
@@ -227,7 +275,7 @@ noninc_search (dir, pchar)
     {
       if (!noninc_search_string)
 	{
-	  ding ();
+	  rl_ding ();
 	  SEARCH_RETURN;
 	}
     }
@@ -235,19 +283,20 @@ noninc_search (dir, pchar)
     {
       /* We want to start the search from the current history position. */
       noninc_history_pos = where_history ();
-      if (noninc_search_string)
-	free (noninc_search_string);
+      FREE (noninc_search_string);
       noninc_search_string = savestring (rl_line_buffer);
     }
 
   rl_restore_prompt ();
   noninc_dosearch (noninc_search_string, dir);
+  RL_UNSETSTATE(RL_STATE_NSEARCH);
 }
 
 /* Search forward through the history list for a string.  If the vi-mode
    code calls this, KEY will be `?'. */
 int
-rl_noninc_forward_search (int count __attribute__((unused)), int key)
+rl_noninc_forward_search (count, key)
+     int count __attribute__((unused)), key __attribute__((unused));
 {
   noninc_search (1, (key == '?') ? '?' : 0);
   return 0;
@@ -256,7 +305,8 @@ rl_noninc_forward_search (int count __attribute__((unused)), int key)
 /* Reverse search the history list for a string.  If the vi-mode code
    calls this, KEY will be `/'. */
 int
-rl_noninc_reverse_search (int count __attribute__((unused)), int key)
+rl_noninc_reverse_search (count, key)
+     int count __attribute__((unused)), key __attribute__((unused));
 {
   noninc_search (-1, (key == '/') ? '/' : 0);
   return 0;
@@ -265,12 +315,12 @@ rl_noninc_reverse_search (int count __attribute__((unused)), int key)
 /* Search forward through the history list for the last string searched
    for.  If there is no saved search string, abort. */
 int
-rl_noninc_forward_search_again (int count __attribute__((unused)),
-				int key __attribute__((unused)))
+rl_noninc_forward_search_again (count, key)
+     int count __attribute__((unused)), key __attribute__((unused));
 {
   if (!noninc_search_string)
     {
-      ding ();
+      rl_ding ();
       return (-1);
     }
   noninc_dosearch (noninc_search_string, 1);
@@ -280,12 +330,12 @@ rl_noninc_forward_search_again (int count __attribute__((unused)),
 /* Reverse search in the history list for the last string searched
    for.  If there is no saved search string, abort. */
 int
-rl_noninc_reverse_search_again (int count __attribute__((unused)),
-				int key __attribute__((unused)))
+rl_noninc_reverse_search_again (count, key)
+     int count __attribute__((unused)), key __attribute__((unused));
 {
   if (!noninc_search_string)
     {
-      ding ();
+      rl_ding ();
       return (-1);
     }
   noninc_dosearch (noninc_search_string, -1);
@@ -293,69 +343,105 @@ rl_noninc_reverse_search_again (int count __attribute__((unused)),
 }
 
 static int
-rl_history_search_internal (count, direction)
-     int count, direction;
+rl_history_search_internal (count, dir)
+     int count, dir;
 {
-  HIST_ENTRY *temp, *old_temp;
-  int line_len;
+  HIST_ENTRY *temp;
+  int ret, oldpos;
 
-  maybe_save_line ();
+  rl_maybe_save_line ();
+  temp = (HIST_ENTRY *)NULL;
 
-  temp = old_temp = (HIST_ENTRY *)NULL;
+  /* Search COUNT times through the history for a line whose prefix
+     matches history_search_string.  When this loop finishes, TEMP,
+     if non-null, is the history line to copy into the line buffer. */
   while (count)
     {
-      temp = (direction < 0) ? previous_history () : next_history ();
-      if (temp == 0)
-        break;
-      /* On an empty prefix, make this the same as previous-history. */
-      if (rl_point == 0)
-	{
-	  count--;
-	  continue;
-	}
-      if (STREQN (rl_line_buffer, temp->line, rl_point))
-	{
-	  /* Don't find multiple instances of the same line. */
-	  if (prev_line_found && STREQ (prev_line_found, temp->line))
-	    continue;
-          if (direction < 0)
-            old_temp = temp;
-          prev_line_found = temp->line;
-          count--;
-	}
+      ret = noninc_search_from_pos (history_search_string, rl_history_search_pos + dir, dir);
+      if (ret == -1)
+	break;
+
+      /* Get the history entry we found. */
+      rl_history_search_pos = ret;
+      oldpos = where_history ();
+      history_set_pos (rl_history_search_pos);
+      temp = current_history ();
+      history_set_pos (oldpos);
+
+      /* Don't find multiple instances of the same line. */
+      if (prev_line_found && STREQ (prev_line_found, temp->line))
+        continue;
+      prev_line_found = temp->line;
+      count--;
     }
 
+  /* If we didn't find anything at all, return. */
   if (temp == 0)
     {
-      if (direction < 0 && old_temp)
-	temp = old_temp;
-      else
-	{
-	  maybe_unsave_line ();
-	  ding ();
-	  return 1;
-	}
+      rl_maybe_unsave_line ();
+      rl_ding ();
+      /* If you don't want the saved history line (last match) to show up
+         in the line buffer after the search fails, change the #if 0 to
+         #if 1 */
+#if 0
+      if (rl_point > rl_history_search_len)
+        {
+          rl_point = rl_end = rl_history_search_len;
+          rl_line_buffer[rl_end] = '\0';
+          rl_mark = 0;
+        }
+#else
+      rl_point = rl_history_search_len;	/* rl_maybe_unsave_line changes it */
+      rl_mark = rl_end;
+#endif
+      return 1;
     }
 
-  line_len = strlen (temp->line);
-  if (line_len >= rl_line_buffer_len)
-    rl_extend_line_buffer (line_len);
-  strcpy (rl_line_buffer, temp->line);
-  rl_undo_list = (UNDO_LIST *)temp->data;
-  rl_end = line_len;
+  /* Copy the line we found into the current line buffer. */
+  make_history_line_current (temp);
+
+  rl_point = rl_history_search_len;
+  rl_mark = rl_end;
+
   return 0;
 }
 
+static void
+rl_history_search_reinit ()
+{
+  rl_history_search_pos = where_history ();
+  rl_history_search_len = rl_point;
+  prev_line_found = (char *)NULL;
+  if (rl_point)
+    {
+      if (rl_history_search_len >= history_string_size - 2)
+	{
+	  history_string_size = rl_history_search_len + 2;
+	  history_search_string = (char *)xrealloc (history_search_string, history_string_size);
+	}
+      history_search_string[0] = '^';
+      strncpy (history_search_string + 1, rl_line_buffer, rl_point);
+      history_search_string[rl_point + 1] = '\0';
+    }
+  _rl_free_saved_history_line ();
+}
+
 /* Search forward in the history for the string of characters
    from the start of the line to rl_point.  This is a non-incremental
    search. */
 int
-rl_history_search_forward (int count, int ignore __attribute__((unused)))
+rl_history_search_forward (count, ignore)
+     int count, ignore;
 {
   if (count == 0)
     return (0);
-  if (rl_last_func != rl_history_search_forward)
-    prev_line_found = (char *)NULL;
+
+  if (rl_last_func != rl_history_search_forward &&
+      rl_last_func != rl_history_search_backward)
+    rl_history_search_reinit ();
+
+  if (rl_history_search_len == 0)
+    return (rl_get_next_history (count, ignore));
   return (rl_history_search_internal (abs (count), (count > 0) ? 1 : -1));
 }
 
@@ -363,11 +449,17 @@ rl_history_search_forward (int count, int ignore __attribute__((unused)))
    from the start of the line to rl_point.  This is a non-incremental
    search. */
 int
-rl_history_search_backward (int count, int ignore __attribute__((unused)))
+rl_history_search_backward (count, ignore)
+     int count, ignore;
 {
   if (count == 0)
     return (0);
-  if (rl_last_func != rl_history_search_backward)
-    prev_line_found = (char *)NULL;
+
+  if (rl_last_func != rl_history_search_forward &&
+      rl_last_func != rl_history_search_backward)
+    rl_history_search_reinit ();
+
+  if (rl_history_search_len == 0)
+    return (rl_get_previous_history (count, ignore));
   return (rl_history_search_internal (abs (count), (count > 0) ? -1 : 1));
 }
diff --git a/readline/shell.c b/readline/shell.c
index becd66e0f9a32163bda8dbb9ef9522404d3b2379..ad27cc14884b8fbb09404705fff9761a53366ab8 100644
--- a/readline/shell.c
+++ b/readline/shell.c
@@ -8,7 +8,7 @@
 
    The GNU Readline Library is free software; you can redistribute it
    and/or modify it under the terms of the GNU General Public License
-   as published by the Free Software Foundation; either version 1, or
+   as published by the Free Software Foundation; either version 2, or
    (at your option) any later version.
 
    The GNU Readline Library is distributed in the hope that it will be
@@ -19,14 +19,13 @@
    The GNU General Public License is often shipped with GNU software, and
    is generally kept in a file called COPYING or LICENSE.  If you do not
    have a copy of the license, write to the Free Software Foundation,
-   675 Mass Ave, Cambridge, MA 02139, USA. */
+   59 Temple Place, Suite 330, Boston, MA 02111 USA. */
 #define READLINE_LIBRARY
 
 #if defined (HAVE_CONFIG_H)
 #  include <config.h>
 #endif
 
-#include <stdio.h>
 #include <sys/types.h>
 
 #if defined (HAVE_UNISTD_H)
@@ -39,36 +38,61 @@
 #  include "ansi_stdlib.h"
 #endif /* HAVE_STDLIB_H */
 
-#if defined (HAVE_STDIO_H)
-#  include <stdio.h>
-#endif /* HAVE_STDIO_H */
-
 #if defined (HAVE_STRING_H)
 #  include <string.h>
 #else
 #  include <strings.h>
 #endif /* !HAVE_STRING_H */
 
+#if defined (HAVE_LIMITS_H)
+#  include <limits.h>
+#endif
+
+#include <fcntl.h>
 #include <pwd.h>
 
+#include <stdio.h>
+
+#include "rlstdc.h"
+#include "rlshell.h"
+#include "xmalloc.h"
+
 #if !defined (HAVE_GETPW_DECLS)
-extern struct passwd *getpwuid ();
+extern struct passwd *getpwuid PARAMS((uid_t));
 #endif /* !HAVE_GETPW_DECLS */
 
-extern char *xmalloc ();
+#ifndef NULL
+#  define NULL 0
+#endif
+
+#ifndef CHAR_BIT
+#  define CHAR_BIT 8
+#endif
+
+/* Nonzero if the integer type T is signed.  */
+#define TYPE_SIGNED(t) (! ((t) 0 < (t) -1))
+
+/* Bound on length of the string representing an integer value of type T.
+   Subtract one for the sign bit if T is signed;
+   302 / 1000 is log10 (2) rounded up;
+   add one for integer division truncation;
+   add one more for a minus sign if t is signed.  */
+#define INT_STRLEN_BOUND(t) \
+  ((sizeof (t) * CHAR_BIT - TYPE_SIGNED (t)) * 302 / 1000 \
+   + 1 + TYPE_SIGNED (t))
 
 /* All of these functions are resolved from bash if we are linking readline
    as part of bash. */
 
 /* Does shell-like quoting using single quotes. */
 char *
-single_quote (string)
+sh_single_quote (string)
      char *string;
 {
   register int c;
   char *result, *r, *s;
 
-  result = (char *)xmalloc (3 + (3 * strlen (string)));
+  result = (char *)xmalloc (3 + (4 * strlen (string)));
   r = result;
   *r++ = '\'';
 
@@ -93,24 +117,24 @@ single_quote (string)
 /* Set the environment variables LINES and COLUMNS to lines and cols,
    respectively. */
 void
-set_lines_and_columns (lines, cols)
+sh_set_lines_and_columns (lines, cols)
      int lines, cols;
 {
   char *b;
 
 #if defined (HAVE_PUTENV)
-  b = xmalloc (24);
+  b = (char *)xmalloc (INT_STRLEN_BOUND (int) + sizeof ("LINES=") + 1);
   sprintf (b, "LINES=%d", lines);
   putenv (b);
-  b = xmalloc (24);
+  b = (char *)xmalloc (INT_STRLEN_BOUND (int) + sizeof ("COLUMNS=") + 1);
   sprintf (b, "COLUMNS=%d", cols);
   putenv (b);
 #else /* !HAVE_PUTENV */
 #  if defined (HAVE_SETENV)
-  b = xmalloc (8);
+  b = (char *)xmalloc (INT_STRLEN_BOUND (int) + 1);
   sprintf (b, "%d", lines);
   setenv ("LINES", b, 1);
-  b = xmalloc (8);
+  b = (char *)xmalloc (INT_STRLEN_BOUND (int) + 1);
   sprintf (b, "%d", cols);
   setenv ("COLUMNS", b, 1);
 #  endif /* HAVE_SETENV */
@@ -118,14 +142,14 @@ set_lines_and_columns (lines, cols)
 }
 
 char *
-get_env_value (varname)
-     char *varname;
+sh_get_env_value (varname)
+     const char *varname;
 {
   return ((char *)getenv (varname));
 }
 
 char *
-get_home_dir ()
+sh_get_home_dir ()
 {
   char *home_dir;
   struct passwd *entry;
@@ -136,3 +160,37 @@ get_home_dir ()
     home_dir = entry->pw_dir;
   return (home_dir);
 }
+
+#if !defined (O_NDELAY)
+#  if defined (FNDELAY)
+#    define O_NDELAY FNDELAY
+#  endif
+#endif
+
+int
+sh_unset_nodelay_mode (fd)
+     int fd;
+{
+  int flags, bflags;
+
+  if ((flags = fcntl (fd, F_GETFL, 0)) < 0)
+    return -1;
+
+  bflags = 0;
+
+#ifdef O_NONBLOCK
+  bflags |= O_NONBLOCK;
+#endif
+
+#ifdef O_NDELAY
+  bflags |= O_NDELAY;
+#endif
+
+  if (flags & bflags)
+    {
+      flags &= ~bflags;
+      return (fcntl (fd, F_SETFL, flags));
+    }
+
+  return 0;
+}
diff --git a/readline/signals.c b/readline/signals.c
index 3a34432f14317fcbc0297b5abab29ed82f0911f7..0a1468b6b2a5db9f446cdff80fc82fd620cc25b0 100644
--- a/readline/signals.c
+++ b/readline/signals.c
@@ -7,7 +7,7 @@
 
    The GNU Readline Library is free software; you can redistribute it
    and/or modify it under the terms of the GNU General Public License
-   as published by the Free Software Foundation; either version 1, or
+   as published by the Free Software Foundation; either version 2, or
    (at your option) any later version.
 
    The GNU Readline Library is distributed in the hope that it will be
@@ -18,7 +18,7 @@
    The GNU General Public License is often shipped with GNU software, and
    is generally kept in a file called COPYING or LICENSE.  If you do not
    have a copy of the license, write to the Free Software Foundation,
-   675 Mass Ave, Cambridge, MA 02139, USA. */
+   59 Temple Place, Suite 330, Boston, MA 02111 USA. */
 #define READLINE_LIBRARY
 
 #if defined (HAVE_CONFIG_H)
@@ -40,15 +40,13 @@
 #  include <sys/ioctl.h>
 #endif /* GWINSZ_IN_SYS_IOCTL */
 
-#if defined (__GO32__)
-#  undef HANDLE_SIGNALS
-#endif /* __GO32__ */
-
 #if defined (HANDLE_SIGNALS)
 /* Some standard library routines. */
 #include "readline.h"
 #include "history.h"
 
+#include "rlprivate.h"
+
 #if !defined (RETSIGTYPE)
 #  if defined (VOID_SIGHANDLER)
 #    define RETSIGTYPE void
@@ -63,23 +61,20 @@
 #  define SIGHANDLER_RETURN return (0)
 #endif
 
-/* This typedef is equivalant to the one for Function; it allows us
+/* This typedef is equivalent to the one for Function; it allows us
    to say SigHandler *foo = signal (SIGKILL, SIG_IGN); */
 typedef RETSIGTYPE SigHandler ();
 
-extern int readline_echoing_p;
-extern int rl_pending_input;
-extern int _rl_meta_flag;
-
-extern void free_undo_list ();
-extern void _rl_get_screen_size ();
-extern void _rl_redisplay_after_sigwinch ();
-extern void _rl_clean_up_for_exit ();
-extern void _rl_kill_kbd_macro ();
-extern void _rl_init_argument ();
-extern void rl_deprep_terminal (), rl_prep_terminal ();
+#if defined (HAVE_POSIX_SIGNALS)
+typedef struct sigaction sighandler_cxt;
+#  define rl_sigaction(s, nh, oh)	sigaction(s, nh, oh)
+#else
+typedef struct { SigHandler *sa_handler; int sa_mask, sa_flags; } sighandler_cxt;
+#  define sigemptyset(m)
+#endif /* !HAVE_POSIX_SIGNALS */
 
-static SigHandler *rl_set_sighandler ();
+static SigHandler *rl_set_sighandler PARAMS((int, SigHandler *, sighandler_cxt *));
+static void rl_maybe_set_sighandler PARAMS((int, SigHandler *, sighandler_cxt *));
 
 /* Exported variables for use by applications. */
 
@@ -101,14 +96,6 @@ static int sigwinch_set_flag;
 /*								    */
 /* **************************************************************** */
 
-#if defined (HAVE_POSIX_SIGNALS)
-typedef struct sigaction sighandler_cxt;
-#  define rl_sigaction(s, nh, oh)	sigaction(s, nh, oh)
-#else
-typedef struct { SigHandler *sa_handler; int sa_mask, sa_flags; } sighandler_cxt;
-#  define sigemptyset(m)
-#endif /* !HAVE_POSIX_SIGNALS */
-
 static sighandler_cxt old_int, old_term, old_alrm, old_quit;
 #if defined (SIGTSTP)
 static sighandler_cxt old_tstp, old_ttou, old_ttin;
@@ -133,6 +120,8 @@ rl_signal_handler (sig)
 #  endif /* !HAVE_BSD_SIGNALS */
 #endif /* !HAVE_POSIX_SIGNALS */
 
+  RL_SETSTATE(RL_STATE_SIGHANDLER);
+
 #if !defined (HAVE_BSD_SIGNALS) && !defined (HAVE_POSIX_SIGNALS)
   /* Since the signal will not be blocked while we are in the signal
      handler, ignore it until rl_clear_signals resets the catcher. */
@@ -165,6 +154,10 @@ rl_signal_handler (sig)
 #  endif /* HAVE_BSD_SIGNALS */
 #endif /* !HAVE_POSIX_SIGNALS */
 
+#if defined (__EMX__)
+      signal (sig, SIG_ACK);
+#endif
+
       kill (getpid (), sig);
 
       /* Let the signal that we just sent through.  */
@@ -179,6 +172,7 @@ rl_signal_handler (sig)
       rl_reset_after_signal ();
     }
 
+  RL_UNSETSTATE(RL_STATE_SIGHANDLER);
   SIGHANDLER_RETURN;
 }
 
@@ -199,6 +193,7 @@ rl_sigwinch_handler (sig)
   rl_set_sighandler (SIGWINCH, rl_sigwinch_handler, &dummy_winch);
 #endif
 
+  RL_SETSTATE(RL_STATE_SIGHANDLER);
   rl_resize_terminal ();
 
   /* If another sigwinch handler has been installed, call it. */
@@ -206,6 +201,7 @@ rl_sigwinch_handler (sig)
   if (oh &&  oh != (SigHandler *)SIG_IGN && oh != (SigHandler *)SIG_DFL)
     (*oh) (sig);
 
+  RL_UNSETSTATE(RL_STATE_SIGHANDLER);
   SIGHANDLER_RETURN;
 }
 #endif  /* SIGWINCH */
@@ -232,17 +228,25 @@ rl_set_sighandler (sig, handler, ohandler)
      SigHandler *handler;
      sighandler_cxt *ohandler;
 {
+  sighandler_cxt old_handler;
 #if defined (HAVE_POSIX_SIGNALS)
   struct sigaction act;
 
   act.sa_handler = handler;
-  act.sa_flags = 0;
+  act.sa_flags = 0;	/* XXX - should we set SA_RESTART for SIGWINCH? */
   sigemptyset (&act.sa_mask);
   sigemptyset (&ohandler->sa_mask);
-  sigaction (sig, &act, ohandler);
+  sigaction (sig, &act, &old_handler);
 #else
-  ohandler->sa_handler = (SigHandler *)signal (sig, handler);
+  old_handler.sa_handler = (SigHandler *)signal (sig, handler);
 #endif /* !HAVE_POSIX_SIGNALS */
+
+  /* XXX -- assume we have memcpy */
+  /* If rl_set_signals is called twice in a row, don't set the old handler to
+     rl_signal_handler, because that would cause infinite recursion. */
+  if (handler != rl_signal_handler || old_handler.sa_handler != rl_signal_handler)
+    memcpy (ohandler, &old_handler, sizeof (sighandler_cxt));
+
   return (ohandler->sa_handler);
 }
 
@@ -360,7 +364,7 @@ rl_cleanup_after_signal ()
   _rl_clean_up_for_exit ();
   (*rl_deprep_term_function) ();
   rl_clear_signals ();
-  rl_pending_input = 0;
+  rl_clear_pending_input ();
 }
 
 /* Reset the terminal and readline state after a signal handler returns. */
@@ -380,7 +384,7 @@ rl_free_line_state ()
 {
   register HIST_ENTRY *entry;
 
-  free_undo_list ();
+  rl_free_undo_list ();
 
   entry = current_history ();
   if (entry)
diff --git a/readline/tcap.h b/readline/tcap.h
index acb2d76ab486d4668c6e2cfbdaf0c215c3ecbd25..4606520bf876bae02b209ec4c0cd2f21b65a76e5 100644
--- a/readline/tcap.h
+++ b/readline/tcap.h
@@ -8,7 +8,7 @@
 
    The Library is free software; you can redistribute it and/or modify
    it under the terms of the GNU General Public License as published by
-   the Free Software Foundation; either version 1, or (at your option)
+   the Free Software Foundation; either version 2, or (at your option)
    any later version.
 
    The Library is distributed in the hope that it will be useful, but
@@ -19,7 +19,7 @@
    The GNU General Public License is often shipped with GNU software, and
    is generally kept in a file called COPYING or LICENSE.  If you do not
    have a copy of the license, write to the Free Software Foundation,
-   675 Mass Ave, Cambridge, MA 02139, USA. */
+   59 Temple Place, Suite 330, Boston, MA 02111 USA. */
 
 #if !defined (_RLTCAP_H_)
 #define _RLTCAP_H_
@@ -42,7 +42,7 @@
 #endif
 
 extern char PC;
-extern char *UP, *BC;
+extern const char *UP, *BC;
 
 extern short ospeed;
 
diff --git a/readline/terminal.c b/readline/terminal.c
index 1d2fead7768be540ae1e5972dadac38282a37e60..9ca4d6e43c5ac155eaed4bbce71c5286128cddd1 100644
--- a/readline/terminal.c
+++ b/readline/terminal.c
@@ -7,7 +7,7 @@
 
    The GNU Readline Library is free software; you can redistribute it
    and/or modify it under the terms of the GNU General Public License
-   as published by the Free Software Foundation; either version 1, or
+   as published by the Free Software Foundation; either version 2, or
    (at your option) any later version.
 
    The GNU Readline Library is distributed in the hope that it will be
@@ -18,7 +18,7 @@
    The GNU General Public License is often shipped with GNU software, and
    is generally kept in a file called COPYING or LICENSE.  If you do not
    have a copy of the license, write to the Free Software Foundation,
-   675 Mass Ave, Cambridge, MA 02139, USA. */
+   59 Temple Place, Suite 330, Boston, MA 02111 USA. */
 #define READLINE_LIBRARY
 
 #if defined (HAVE_CONFIG_H)
@@ -46,9 +46,7 @@
 #  include <locale.h>
 #endif
 
-#include <signal.h>
 #include <stdio.h>
-#include <setjmp.h>
 
 /* System-specific feature definitions and include files. */
 #include "rldefs.h"
@@ -64,18 +62,12 @@
 #include "readline.h"
 #include "history.h"
 
-/* Variables and functions imported from readline.c */
-extern FILE *_rl_in_stream, *_rl_out_stream;
-extern int readline_echoing_p;
-extern int _rl_bell_preference;
-extern Keymap _rl_keymap;
+#include "rlprivate.h"
+#include "rlshell.h"
+#include "xmalloc.h"
 
-/* Functions imported from bind.c */
-extern void _rl_bind_if_unbound ();
-
-/* Functions imported from shell.c */
-extern void set_lines_and_columns ();
-extern char *get_env_value ();
+#define CUSTOM_REDISPLAY_FUNC() (rl_redisplay_function != rl_redisplay)
+#define CUSTOM_INPUT_FUNC() (rl_getc_function != rl_getc)
 
 /* **************************************************************** */
 /*								    */
@@ -88,38 +80,45 @@ static char *term_string_buffer = (char *)NULL;
 
 static int tcap_initialized;
 
-/* Non-zero means this terminal can't really do anything. */
-static int dumb_term;
-
 #if !defined (__linux__)
 #  if defined (__EMX__) || defined (NEED_EXTERN_PC)
 extern 
 #  endif /* __EMX__ || NEED_EXTERN_PC */
-char PC, *BC, *UP;
+const char PC;
+const char *BC, *UP;
 #endif /* __linux__ */
 
 /* Some strings to control terminal actions.  These are output by tputs (). */
-char *term_goto, *term_clreol, *term_clrpag, *term_backspace;
-char *term_cr, *term_pc;
+const char *_rl_term_clreol;
+const char *_rl_term_clrpag;
+const char *_rl_term_cr;
+const char *_rl_term_backspace;
+const char *_rl_term_goto;
+const char *_rl_term_pc;
 
 /* Non-zero if we determine that the terminal can do character insertion. */
-int terminal_can_insert = 0;
+int _rl_terminal_can_insert = 0;
 
 /* How to insert characters. */
-char *term_im, *term_ei, *term_ic, *term_ip, *term_IC;
+const char *_rl_term_im;
+const char *_rl_term_ei;
+const char *_rl_term_ic;
+const char *_rl_term_ip;
+const char *_rl_term_IC;
 
 /* How to delete characters. */
-char *term_dc, *term_DC;
+const char *_rl_term_dc;
+const char *_rl_term_DC;
 
 #if defined (HACK_TERMCAP_MOTION)
-char *term_forward_char;
+char *_rl_term_forward_char;
 #endif  /* HACK_TERMCAP_MOTION */
 
 /* How to go up a line. */
-char *term_up;
+const char *_rl_term_up;
 
-/* A visible bell, if the terminal can be made to flash the screen. */
-static char *visible_bell;
+/* A visible bell; char if the terminal can be made to flash the screen. */
+static const char *_rl_visible_bell;
 
 /* Non-zero means the terminal can auto-wrap lines. */
 int _rl_term_autowrap;
@@ -128,20 +127,36 @@ int _rl_term_autowrap;
 static int term_has_meta;
 
 /* The sequences to write to turn on and off the meta key, if this
-   terminal    has one. */
-static char *term_mm, *term_mo;
+   terminal has one. */
+static const char *_rl_term_mm;
+static const char *_rl_term_mo;
 
 /* The key sequences output by the arrow keys, if this terminal has any. */
-static char *term_ku, *term_kd, *term_kr, *term_kl;
+static const char *_rl_term_ku;
+static const char *_rl_term_kd;
+static const char *_rl_term_kr;
+static const char *_rl_term_kl;
 
 /* How to initialize and reset the arrow keys, if this terminal has any. */
-static char *term_ks, *term_ke;
+static const char *_rl_term_ks;
+static const char *_rl_term_ke;
 
 /* The key sequences sent by the Home and End keys, if any. */
-static char *term_kh, *term_kH;
+static const char *_rl_term_kh;
+static const char *_rl_term_kH;
+static const char *_rl_term_at7;	/* @7 */
+
+/* Insert key */
+static const char *_rl_term_kI;
+
+/* Cursor control */
+static const char *_rl_term_vs;	/* very visible */
+static const char *_rl_term_ve;	/* normal */
+
+static void bind_termcap_arrow_keys PARAMS((Keymap));
 
 /* Variables that hold the screen dimensions, used by the display code. */
-int screenwidth, screenheight, screenchars;
+int _rl_screenwidth, _rl_screenheight, _rl_screenchars;
 
 /* Non-zero means the user wants to enable the keypad. */
 int _rl_enable_keypad;
@@ -149,6 +164,22 @@ int _rl_enable_keypad;
 /* Non-zero means the user wants to enable a meta key. */
 int _rl_enable_meta = 1;
 
+#if defined (__EMX__)
+static void
+_emx_get_screensize (swp, shp)
+     int *swp, *shp;
+{
+  int sz[2];
+
+  _scrsize (sz);
+
+  if (swp)
+    *swp = sz[0];
+  if (shp)
+    *shp = sz[1];
+}
+#endif
+
 /* Get readline's idea of the screen size.  TTY is a file descriptor open
    to the terminal.  If IGNORE_ENV is true, we do not pay attention to the
    values of $LINES and $COLUMNS.  The tests for TERM_STRING_BUFFER being
@@ -161,124 +192,148 @@ _rl_get_screen_size (tty, ignore_env)
 #if defined (TIOCGWINSZ)
   struct winsize window_size;
 #endif /* TIOCGWINSZ */
-#if defined (__EMX__)
-  int sz[2];
-#endif
 
 #if defined (TIOCGWINSZ)
   if (ioctl (tty, TIOCGWINSZ, &window_size) == 0)
     {
-      screenwidth = (int) window_size.ws_col;
-      screenheight = (int) window_size.ws_row;
+      _rl_screenwidth = (int) window_size.ws_col;
+      _rl_screenheight = (int) window_size.ws_row;
     }
 #endif /* TIOCGWINSZ */
 
 #if defined (__EMX__)
-  _scrsize (sz);
-  screenwidth = sz[0];
-  screenheight = sz[1];
+  _emx_get_screensize (&_rl_screenwidth, &_rl_screenheight);
 #endif
 
   /* Environment variable COLUMNS overrides setting of "co" if IGNORE_ENV
      is unset. */
-  if (screenwidth <= 0)
+  if (_rl_screenwidth <= 0)
     {
-      if (ignore_env == 0 && (ss = get_env_value ("COLUMNS")))
-	screenwidth = atoi (ss);
+      if (ignore_env == 0 && (ss = sh_get_env_value ("COLUMNS")))
+	_rl_screenwidth = atoi (ss);
 
-      if (screenwidth <= 0 && term_string_buffer)
-	screenwidth = tgetnum ("co");
+#if !defined (__DJGPP__)
+      if (_rl_screenwidth <= 0 && term_string_buffer)
+	_rl_screenwidth = tgetnum ("co");
+#endif
     }
 
   /* Environment variable LINES overrides setting of "li" if IGNORE_ENV
      is unset. */
-  if (screenheight <= 0)
+  if (_rl_screenheight <= 0)
     {
-      if (ignore_env == 0 && (ss = get_env_value ("LINES")))
-	screenheight = atoi (ss);
+      if (ignore_env == 0 && (ss = sh_get_env_value ("LINES")))
+	_rl_screenheight = atoi (ss);
 
-      if (screenheight <= 0 && term_string_buffer)
-	screenheight = tgetnum ("li");
+#if !defined (__DJGPP__)
+      if (_rl_screenheight <= 0 && term_string_buffer)
+	_rl_screenheight = tgetnum ("li");
+#endif
     }
 
   /* If all else fails, default to 80x24 terminal. */
-  if (screenwidth <= 1)
-    screenwidth = 80;
+  if (_rl_screenwidth <= 1)
+    _rl_screenwidth = 80;
 
-  if (screenheight <= 0)
-    screenheight = 24;
+  if (_rl_screenheight <= 0)
+    _rl_screenheight = 24;
 
   /* If we're being compiled as part of bash, set the environment
      variables $LINES and $COLUMNS to new values.  Otherwise, just
      do a pair of putenv () or setenv () calls. */
-  set_lines_and_columns (screenheight, screenwidth);
+  sh_set_lines_and_columns (_rl_screenheight, _rl_screenwidth);
 
-  if (!_rl_term_autowrap)
-    screenwidth--;
+  if (_rl_term_autowrap == 0)
+    _rl_screenwidth--;
 
-  screenchars = screenwidth * screenheight;
+  _rl_screenchars = _rl_screenwidth * _rl_screenheight;
 }
 
 void
 _rl_set_screen_size (rows, cols)
      int rows, cols;
 {
-  screenheight = rows;
-  screenwidth = cols;
+  if (rows == 0 || cols == 0)
+    return;
+
+  _rl_screenheight = rows;
+  _rl_screenwidth = cols;
 
   if (_rl_term_autowrap == 0)
-    screenwidth--;
+    _rl_screenwidth--;
 
-  screenchars = screenwidth * screenheight;
+  _rl_screenchars = _rl_screenwidth * _rl_screenheight;
 }
 
-extern void _rl_redisplay_after_sigwinch();
+void
+rl_set_screen_size (rows, cols)
+     int rows, cols;
+{
+  _rl_set_screen_size (rows, cols);
+}
 
+void
+rl_get_screen_size (rows, cols)
+     int *rows, *cols;
+{
+  if (rows)
+    *rows = _rl_screenheight;
+  if (cols)
+    *cols = _rl_screenwidth;
+}
+     
 void
 rl_resize_terminal ()
 {
   if (readline_echoing_p)
     {
       _rl_get_screen_size (fileno (rl_instream), 1);
-      _rl_redisplay_after_sigwinch ();
+      if (CUSTOM_REDISPLAY_FUNC ())
+	rl_forced_update_display ();
+      else
+	_rl_redisplay_after_sigwinch ();
     }
 }
 
 struct _tc_string {
-  const char *tc_var;
-  char **tc_value;
+     const char *tc_var;
+     const char **tc_value;
 };
 
 /* This should be kept sorted, just in case we decide to change the
    search algorithm to something smarter. */
 static struct _tc_string tc_strings[] =
 {
-  {"DC", &term_DC},
-  {"IC", &term_IC},
-  {"ce", &term_clreol},
-  {"cl", &term_clrpag},
-  {"cr", &term_cr},
-  {"dc", &term_dc},
-  {"ei", &term_ei},
-  {"ic", &term_ic},
-  {"im", &term_im},
-  {"kd", &term_kd},
-  {"kh", &term_kh},	/* home */
-  {"kH", &term_kH},	/* end */
-  {"kl", &term_kl},
-  {"kr", &term_kr},
-  {"ku", &term_ku},
-  {"ks", &term_ks},
-  {"ke", &term_ke},
-  {"le", &term_backspace},
-  {"mm", &term_mm},
-  {"mo", &term_mo},
+  { "@7", &_rl_term_at7 },
+  { "DC", &_rl_term_DC },
+  { "IC", &_rl_term_IC },
+  { "ce", &_rl_term_clreol },
+  { "cl", &_rl_term_clrpag },
+  { "cr", &_rl_term_cr },
+  { "dc", &_rl_term_dc },
+  { "ei", &_rl_term_ei },
+  { "ic", &_rl_term_ic },
+  { "im", &_rl_term_im },
+  { "kH", &_rl_term_kH },	/* home down ?? */
+  { "kI", &_rl_term_kI },	/* insert */
+  { "kd", &_rl_term_kd },
+  { "ke", &_rl_term_ke },	/* end keypad mode */
+  { "kh", &_rl_term_kh },	/* home */
+  { "kl", &_rl_term_kl },
+  { "kr", &_rl_term_kr },
+  { "ks", &_rl_term_ks },	/* start keypad mode */
+  { "ku", &_rl_term_ku },
+  { "le", &_rl_term_backspace },
+  { "mm", &_rl_term_mm },
+  { "mo", &_rl_term_mo },
 #if defined (HACK_TERMCAP_MOTION)
-  {"nd", &term_forward_char},
+  { "nd", &_rl_term_forward_char },
 #endif
-  {"pc", &term_pc},
-  {"up", &term_up},
-  {"vb", &visible_bell},
+  { "pc", &_rl_term_pc },
+  { "up", &_rl_term_up },
+  { "vb", &_rl_visible_bell },
+  { "vs", &_rl_term_vs },
+  { "ve", &_rl_term_ve },
 };
 
 #define NUM_TC_STRINGS (sizeof (tc_strings) / sizeof (struct _tc_string))
@@ -289,73 +344,99 @@ static void
 get_term_capabilities (bp)
      char **bp;
 {
-  register int i;
+#if !defined (__DJGPP__)	/* XXX - doesn't DJGPP have a termcap library? */
+  register unsigned int i;
 
-  for (i = 0; i < (int) NUM_TC_STRINGS; i++)
+  for (i = 0; i < NUM_TC_STRINGS; i++)
+#  ifdef __LCC__
+    *(tc_strings[i].tc_value) = tgetstr ((char *)tc_strings[i].tc_var, bp);
+#  else
     *(tc_strings[i].tc_value) = tgetstr (tc_strings[i].tc_var, bp);
+#  endif
+#endif
   tcap_initialized = 1;
 }
 
 int
 _rl_init_terminal_io (terminal_name)
-     char *terminal_name;
+     const char *terminal_name;
 {
-#if defined (__GO32__)
-  screenwidth = ScreenCols ();
-  screenheight = ScreenRows ();
-  screenchars = screenwidth * screenheight;
-  term_cr = (char*) "\r";
-  term_im = term_ei = term_ic = term_IC = (char *)NULL;
-  term_up = term_dc = term_DC = visible_bell = (char *)NULL;
-
-  /* Does the __GO32__ have a meta key?  I don't know. */
-  term_has_meta = 0;
-  term_mm = term_mo = (char *)NULL;
-
-  /* It probably has arrow keys, but I don't know what they are. */
-  term_ku = term_kd = term_kr = term_kl = (char *)NULL;
-
-#if defined (HACK_TERMCAP_MOTION)
-  term_forward_char = (char *)NULL;
-#endif /* HACK_TERMCAP_MOTION */
-  terminal_can_insert = _rl_term_autowrap = 0;
-  return;
-#else /* !__GO32__ */
-
   const char *term;
   char *buffer;
-  int tty;
-  Keymap xkeymap;
+  int tty, tgetent_ret;
 
-  term = terminal_name ? terminal_name : get_env_value ("TERM");
+  term = terminal_name ? terminal_name : sh_get_env_value ("TERM");
+  _rl_term_clrpag = _rl_term_cr = _rl_term_clreol = (char *)NULL;
+  tty = rl_instream ? fileno (rl_instream) : 0;
+  _rl_screenwidth = _rl_screenheight = 0;
 
-  if (term_string_buffer == 0)
-    term_string_buffer = xmalloc (2032);
+  if (term == 0)
+    term = "dumb";
 
-  if (term_buffer == 0)
-    term_buffer = xmalloc (4080);
+  /* I've separated this out for later work on not calling tgetent at all
+     if the calling application has supplied a custom redisplay function,
+     (and possibly if the application has supplied a custom input function). */
+  if (CUSTOM_REDISPLAY_FUNC())
+    {
+      tgetent_ret = -1;
+    }
+  else
+    {
+      if (term_string_buffer == 0)
+	term_string_buffer = (char *)xmalloc(2032);
 
-  buffer = term_string_buffer;
+      if (term_buffer == 0)
+	term_buffer = (char *)xmalloc(4080);
 
-  term_clrpag = term_cr = term_clreol = (char *)NULL;
+      buffer = term_string_buffer;
 
-  if (term == 0)
-    term = "dumb";
+      tgetent_ret = tgetent (term_buffer, term);
+    }
 
-  if (tgetent (term_buffer, term) <= 0)
+  if (tgetent_ret <= 0)
     {
-      dumb_term = 1;
-      screenwidth = 79;
-      screenheight = 24;
-      screenchars = 79 * 24;
-      term_cr = (char*) "\r";
-      term_im = term_ei = term_ic = term_IC = (char *)NULL;
-      term_up = term_dc = term_DC = visible_bell = (char *)NULL;
-      term_ku = term_kd = term_kl = term_kr = (char *)NULL;
+      FREE (term_string_buffer);
+      FREE (term_buffer);
+      buffer = term_buffer = term_string_buffer = (char *)NULL;
+
+      _rl_term_autowrap = 0;	/* used by _rl_get_screen_size */
+
+#if defined (__EMX__)
+      _emx_get_screensize (&_rl_screenwidth, &_rl_screenheight);
+      _rl_screenwidth--;
+#else /* !__EMX__ */
+      _rl_get_screen_size (tty, 0);
+#endif /* !__EMX__ */
+
+      /* Defaults. */
+      if (_rl_screenwidth <= 0 || _rl_screenheight <= 0)
+        {
+	  _rl_screenwidth = 79;
+	  _rl_screenheight = 24;
+        }
+
+      /* Everything below here is used by the redisplay code (tputs). */
+      _rl_screenchars = _rl_screenwidth * _rl_screenheight;
+      _rl_term_cr = "\r";
+      _rl_term_im = _rl_term_ei = _rl_term_ic = _rl_term_IC = (char *)NULL;
+      _rl_term_up = _rl_term_dc = _rl_term_DC = _rl_visible_bell = (char *)NULL;
+      _rl_term_ku = _rl_term_kd = _rl_term_kl = _rl_term_kr = (char *)NULL;
+      _rl_term_kh = _rl_term_kH = _rl_term_kI = (char *)NULL;
+      _rl_term_ks = _rl_term_ke = _rl_term_at7 = (char *)NULL;
+      _rl_term_mm = _rl_term_mo = (char *)NULL;
+      _rl_term_ve = _rl_term_vs = (char *)NULL;
 #if defined (HACK_TERMCAP_MOTION)
       term_forward_char = (char *)NULL;
 #endif
-      terminal_can_insert = 0;
+      _rl_terminal_can_insert = term_has_meta = 0;
+
+      /* Reasonable defaults for tgoto().  Readline currently only uses
+         tgoto if _rl_term_IC or _rl_term_DC is defined, but just in case we
+         change that later... */
+      PC = '\0';
+      BC = (char*)(_rl_term_backspace = "\b");
+      UP = (char*)_rl_term_up;
+
       return 0;
     }
 
@@ -363,16 +444,12 @@ _rl_init_terminal_io (terminal_name)
 
   /* Set up the variables that the termcap library expects the application
      to provide. */
-  PC = term_pc ? *term_pc : 0;
-  BC = term_backspace;
-  UP = term_up;
+  PC = _rl_term_pc ? *_rl_term_pc : 0;
+  BC = (char*)_rl_term_backspace;
+  UP = (char*)_rl_term_up;
 
-  if (!term_cr)
-    term_cr = (char*) "\r";
-
-  tty = rl_instream ? fileno (rl_instream) : 0;
-
-  screenwidth = screenheight = 0;
+  if (!_rl_term_cr)
+    _rl_term_cr = "\r";
 
   _rl_term_autowrap = tgetflag ("am") && tgetflag ("xn");
 
@@ -382,53 +459,57 @@ _rl_init_terminal_io (terminal_name)
       character insertion if *any one of* the capabilities `IC',
       `im', `ic' or `ip' is provided."  But we can't do anything if
       only `ip' is provided, so... */
-  terminal_can_insert = (term_IC || term_im || term_ic);
+  _rl_terminal_can_insert = (_rl_term_IC || _rl_term_im || _rl_term_ic);
 
   /* Check to see if this terminal has a meta key and clear the capability
      variables if there is none. */
   term_has_meta = (tgetflag ("km") || tgetflag ("MT"));
   if (!term_has_meta)
-    term_mm = term_mo = (char *)NULL;
+    _rl_term_mm = _rl_term_mo = (char *)NULL;
 
   /* Attempt to find and bind the arrow keys.  Do not override already
      bound keys in an overzealous attempt, however. */
-  xkeymap = _rl_keymap;
-
-  _rl_keymap = emacs_standard_keymap;
-  _rl_bind_if_unbound (term_ku, rl_get_previous_history);
-  _rl_bind_if_unbound (term_kd, rl_get_next_history);
-  _rl_bind_if_unbound (term_kr, rl_forward);
-  _rl_bind_if_unbound (term_kl, rl_backward);
 
-  _rl_bind_if_unbound (term_kh, rl_beg_of_line);	/* Home */
-  _rl_bind_if_unbound (term_kH, rl_end_of_line);	/* End */
+  bind_termcap_arrow_keys (emacs_standard_keymap);
 
 #if defined (VI_MODE)
-  _rl_keymap = vi_movement_keymap;
-  _rl_bind_if_unbound (term_ku, rl_get_previous_history);
-  _rl_bind_if_unbound (term_kd, rl_get_next_history);
-  _rl_bind_if_unbound (term_kr, rl_forward);
-  _rl_bind_if_unbound (term_kl, rl_backward);
-
-  _rl_bind_if_unbound (term_kh, rl_beg_of_line);	/* Home */
-  _rl_bind_if_unbound (term_kH, rl_end_of_line);	/* End */
+  bind_termcap_arrow_keys (vi_movement_keymap);
+  bind_termcap_arrow_keys (vi_insertion_keymap);
 #endif /* VI_MODE */
 
-  _rl_keymap = xkeymap;
-
-#endif /* !__GO32__ */
   return 0;
 }
 
-char *
+/* Bind the arrow key sequences from the termcap description in MAP. */
+static void
+bind_termcap_arrow_keys (map)
+     Keymap map;
+{
+  Keymap xkeymap;
+
+  xkeymap = _rl_keymap;
+  _rl_keymap = map;
+
+  _rl_bind_if_unbound (_rl_term_ku, rl_get_previous_history);
+  _rl_bind_if_unbound (_rl_term_kd, rl_get_next_history);
+  _rl_bind_if_unbound (_rl_term_kr, rl_forward);
+  _rl_bind_if_unbound (_rl_term_kl, rl_backward);
+
+  _rl_bind_if_unbound (_rl_term_kh, rl_beg_of_line);	/* Home */
+  _rl_bind_if_unbound (_rl_term_at7, rl_end_of_line);	/* End */
+
+  _rl_keymap = xkeymap;
+}
+
+const char *
 rl_get_termcap (cap)
-     char *cap;
+     const char *cap;
 {
-  register int i;
+  register unsigned int i;
 
   if (tcap_initialized == 0)
     return ((char *)NULL);
-  for (i = 0; i < (int) NUM_TC_STRINGS; i++)
+  for (i = 0; i < NUM_TC_STRINGS; i++)
     {
       if (tc_strings[i].tc_var[0] == cap[0] && strcmp (tc_strings[i].tc_var, cap) == 0)
         return *(tc_strings[i].tc_value);
@@ -440,7 +521,7 @@ rl_get_termcap (cap)
    has changed. */
 int
 rl_reset_terminal (terminal_name)
-     char *terminal_name;
+     const char *terminal_name;
 {
   _rl_init_terminal_io (terminal_name);
   return 0;
@@ -462,10 +543,11 @@ _rl_output_character_function (c)
   return putc (c, _rl_out_stream);
 }
 #endif /* !_MINIX */
+
 /* Write COUNT characters from STRING to the output stream. */
 void
 _rl_output_some_chars (string, count)
-     char *string;
+     const char *string;
      int count;
 {
   fwrite (string, 1, count, _rl_out_stream);
@@ -478,12 +560,10 @@ _rl_backspace (count)
 {
   register int i;
 
-#if !defined (__GO32__)
-  if (term_backspace)
+  if (_rl_term_backspace)
     for (i = 0; i < count; i++)
-      tputs (term_backspace, 1, _rl_output_character_function);
+      tputs (_rl_term_backspace, 1, _rl_output_character_function);
   else
-#endif /* !__GO32__ */
     for (i = 0; i < count; i++)
       putc ('\b', _rl_out_stream);
   return 0;
@@ -491,11 +571,11 @@ _rl_backspace (count)
 
 /* Move to the start of the next line. */
 int
-crlf ()
+rl_crlf ()
 {
 #if defined (NEW_TTY_DRIVER)
-  if (term_cr)
-    tputs (term_cr, 1, _rl_output_character_function);
+  if (_rl_term_cr)
+    tputs (_rl_term_cr, 1, _rl_output_character_function);
 #endif /* NEW_TTY_DRIVER */
   putc ('\n', _rl_out_stream);
   return 0;
@@ -503,20 +583,19 @@ crlf ()
 
 /* Ring the terminal bell. */
 int
-ding ()
+rl_ding ()
 {
   if (readline_echoing_p)
     {
-#if !defined (__GO32__)
       switch (_rl_bell_preference)
         {
 	case NO_BELL:
 	default:
 	  break;
 	case VISIBLE_BELL:
-	  if (visible_bell)
+	  if (_rl_visible_bell)
 	    {
-	      tputs (visible_bell, 1, _rl_output_character_function);
+	      tputs (_rl_visible_bell, 1, _rl_output_character_function);
 	      break;
 	    }
 	  /* FALLTHROUGH */
@@ -525,10 +604,6 @@ ding ()
 	  fflush (stderr);
 	  break;
         }
-#else /* __GO32__ */
-      fprintf (stderr, "\007");
-      fflush (stderr);
-#endif /* __GO32__ */
       return (0);
     }
   return (-1);
@@ -543,16 +618,46 @@ ding ()
 void
 _rl_enable_meta_key ()
 {
-  if (term_has_meta && term_mm)
-    tputs (term_mm, 1, _rl_output_character_function);
+#if !defined (__DJGPP__)
+  if (term_has_meta && _rl_term_mm)
+    tputs (_rl_term_mm, 1, _rl_output_character_function);
+#endif
 }
 
 void
 _rl_control_keypad (on)
      int on;
 {
-  if (on && term_ks)
-    tputs (term_ks, 1, _rl_output_character_function);
-  else if (!on && term_ke)
-    tputs (term_ke, 1, _rl_output_character_function);
+#if !defined (__DJGPP__)
+  if (on && _rl_term_ks)
+    tputs (_rl_term_ks, 1, _rl_output_character_function);
+  else if (!on && _rl_term_ke)
+    tputs (_rl_term_ke, 1, _rl_output_character_function);
+#endif
+}
+
+/* **************************************************************** */
+/*								    */
+/*	 		Controlling the Cursor			    */
+/*								    */
+/* **************************************************************** */
+
+/* Set the cursor appropriately depending on IM, which is one of the
+   insert modes (insert or overwrite).  Insert mode gets the normal
+   cursor.  Overwrite mode gets a very visible cursor.  Only does
+   anything if we have both capabilities. */
+void
+_rl_set_cursor (im, force)
+     int im, force;
+{
+  if (_rl_term_ve && _rl_term_vs)
+    {
+      if (force || im != rl_insert_mode)
+	{
+	  if (im == RL_IM_OVERWRITE)
+	    tputs (_rl_term_vs, 1, _rl_output_character_function);
+	  else
+	    tputs (_rl_term_ve, 1, _rl_output_character_function);
+	}
+    }
 }
diff --git a/readline/text.c b/readline/text.c
new file mode 100644
index 0000000000000000000000000000000000000000..81a468fdbda8739a935e12da9a240280a91f0465
--- /dev/null
+++ b/readline/text.c
@@ -0,0 +1,1540 @@
+/* text.c -- text handling commands for readline. */
+
+/* Copyright (C) 1987-2002 Free Software Foundation, Inc.
+
+   This file is part of the GNU Readline Library, a library for
+   reading lines of text with interactive input and history editing.
+
+   The GNU Readline Library is free software; you can redistribute it
+   and/or modify it under the terms of the GNU General Public License
+   as published by the Free Software Foundation; either version 2, or
+   (at your option) any later version.
+
+   The GNU Readline Library is distributed in the hope that it will be
+   useful, but WITHOUT ANY WARRANTY; without even the implied warranty
+   of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+   GNU General Public License for more details.
+
+   The GNU General Public License is often shipped with GNU software, and
+   is generally kept in a file called COPYING or LICENSE.  If you do not
+   have a copy of the license, write to the Free Software Foundation,
+   59 Temple Place, Suite 330, Boston, MA 02111 USA. */
+#define READLINE_LIBRARY
+
+#if defined (HAVE_CONFIG_H)
+#  include <config.h>
+#endif
+
+#if defined (HAVE_UNISTD_H)
+#  include <unistd.h>
+#endif /* HAVE_UNISTD_H */
+
+#if defined (HAVE_STDLIB_H)
+#  include <stdlib.h>
+#else
+#  include "ansi_stdlib.h"
+#endif /* HAVE_STDLIB_H */
+
+#if defined (HAVE_LOCALE_H)
+#  include <locale.h>
+#endif
+
+#include <stdio.h>
+
+/* System-specific feature definitions and include files. */
+#include "rldefs.h"
+#include "rlmbutil.h"
+
+#if defined (__EMX__)
+#  define INCL_DOSPROCESS
+#  include <os2.h>
+#endif /* __EMX__ */
+
+/* Some standard library routines. */
+#include "readline.h"
+#include "history.h"
+
+#include "rlprivate.h"
+#include "rlshell.h"
+#include "xmalloc.h"
+
+/* Forward declarations. */
+static int rl_change_case PARAMS((int, int));
+static int _rl_char_search PARAMS((int, int, int));
+
+/* **************************************************************** */
+/*								    */
+/*			Insert and Delete			    */
+/*								    */
+/* **************************************************************** */
+
+/* Insert a string of text into the line at point.  This is the only
+   way that you should do insertion.  _rl_insert_char () calls this
+   function.  Returns the number of characters inserted. */
+int
+rl_insert_text (string)
+     const char *string;
+{
+  register int i, l;
+
+  l = (string && *string) ? strlen (string) : 0;
+  if (l == 0)
+    return 0;
+
+  if (rl_end + l >= rl_line_buffer_len)
+    rl_extend_line_buffer (rl_end + l);
+
+  for (i = rl_end; i >= rl_point; i--)
+    rl_line_buffer[i + l] = rl_line_buffer[i];
+  strncpy (rl_line_buffer + rl_point, string, l);
+
+  /* Remember how to undo this if we aren't undoing something. */
+  if (_rl_doing_an_undo == 0)
+    {
+      /* If possible and desirable, concatenate the undos. */
+      if ((l == 1) &&
+	  rl_undo_list &&
+	  (rl_undo_list->what == UNDO_INSERT) &&
+	  (rl_undo_list->end == rl_point) &&
+	  (rl_undo_list->end - rl_undo_list->start < 20))
+	rl_undo_list->end++;
+      else
+	rl_add_undo (UNDO_INSERT, rl_point, rl_point + l, (char *)NULL);
+    }
+  rl_point += l;
+  rl_end += l;
+  rl_line_buffer[rl_end] = '\0';
+  return l;
+}
+
+/* Delete the string between FROM and TO.  FROM is inclusive, TO is not.
+   Returns the number of characters deleted. */
+int
+rl_delete_text (from, to)
+     int from, to;
+{
+  register char *text;
+  register int diff, i;
+
+  /* Fix it if the caller is confused. */
+  if (from > to)
+    SWAP (from, to);
+
+  /* fix boundaries */
+  if (to > rl_end)
+    {
+      to = rl_end;
+      if (from > to)
+	from = to;
+    }
+  if (from < 0)
+    from = 0;
+
+  text = rl_copy_text (from, to);
+
+  /* Some versions of strncpy() can't handle overlapping arguments. */
+  diff = to - from;
+  for (i = from; i < rl_end - diff; i++)
+    rl_line_buffer[i] = rl_line_buffer[i + diff];
+
+  /* Remember how to undo this delete. */
+  if (_rl_doing_an_undo == 0)
+    rl_add_undo (UNDO_DELETE, from, to, text);
+  else
+    free (text);
+
+  rl_end -= diff;
+  rl_line_buffer[rl_end] = '\0';
+  return (diff);
+}
+
+/* Fix up point so that it is within the line boundaries after killing
+   text.  If FIX_MARK_TOO is non-zero, the mark is forced within line
+   boundaries also. */
+
+#define _RL_FIX_POINT(x) \
+	do { \
+	if (x > rl_end) \
+	  x = rl_end; \
+	else if (x < 0) \
+	  x = 0; \
+	} while (0)
+
+void
+_rl_fix_point (fix_mark_too)
+     int fix_mark_too;
+{
+  _RL_FIX_POINT (rl_point);
+  if (fix_mark_too)
+    _RL_FIX_POINT (rl_mark);
+}
+#undef _RL_FIX_POINT
+
+int
+_rl_replace_text (text, start, end)
+     const char *text;
+     int start, end;
+{
+  int n;
+
+  rl_begin_undo_group ();
+  rl_delete_text (start, end + 1);
+  rl_point = start;
+  n = rl_insert_text (text);
+  rl_end_undo_group ();
+
+  return n;
+}
+
+/* Replace the current line buffer contents with TEXT.  If CLEAR_UNDO is
+   non-zero, we free the current undo list. */
+void
+rl_replace_line (text, clear_undo)
+     const char *text;
+     int clear_undo;
+{
+  int len;
+
+  len = strlen (text);
+  if (len >= rl_line_buffer_len)
+    rl_extend_line_buffer (len);
+  strcpy (rl_line_buffer, text);
+  rl_end = len;
+
+  if (clear_undo)
+    rl_free_undo_list ();
+
+  _rl_fix_point (1);
+}
+
+/* **************************************************************** */
+/*								    */
+/*			Readline character functions		    */
+/*								    */
+/* **************************************************************** */
+
+/* This is not a gap editor, just a stupid line input routine.  No hair
+   is involved in writing any of the functions, and none should be. */
+
+/* Note that:
+
+   rl_end is the place in the string that we would place '\0';
+   i.e., it is always safe to place '\0' there.
+
+   rl_point is the place in the string where the cursor is.  Sometimes
+   this is the same as rl_end.
+
+   Any command that is called interactively receives two arguments.
+   The first is a count: the numeric arg pased to this command.
+   The second is the key which invoked this command.
+*/
+
+/* **************************************************************** */
+/*								    */
+/*			Movement Commands			    */
+/*								    */
+/* **************************************************************** */
+
+/* Note that if you `optimize' the display for these functions, you cannot
+   use said functions in other functions which do not do optimizing display.
+   I.e., you will have to update the data base for rl_redisplay, and you
+   might as well let rl_redisplay do that job. */
+
+/* Move forward COUNT bytes. */
+int
+rl_forward_byte (count, key)
+     int count, key;
+{
+  if (count < 0)
+    return (rl_backward_byte (-count, key));
+
+  if (count > 0)
+    {
+      int end = rl_point + count;
+#if defined (VI_MODE)
+      int lend = rl_end > 0 ? rl_end - (rl_editing_mode == vi_mode) : rl_end;
+#else
+      int lend = rl_end;
+#endif
+
+      if (end > lend)
+	{
+	  rl_point = lend;
+	  rl_ding ();
+	}
+      else
+	rl_point = end;
+    }
+
+  if (rl_end < 0)
+    rl_end = 0;
+
+  return 0;
+}
+
+#if defined (HANDLE_MULTIBYTE)
+/* Move forward COUNT characters. */
+int
+rl_forward_char (count, key)
+     int count, key;
+{
+  int point;
+
+  if (MB_CUR_MAX == 1 || rl_byte_oriented)
+    return (rl_forward_byte (count, key));
+
+  if (count < 0)
+    return (rl_backward_char (-count, key));
+
+  if (count > 0)
+    {
+      point = _rl_find_next_mbchar (rl_line_buffer, rl_point, count, MB_FIND_NONZERO);
+
+#if defined (VI_MODE)
+      if (rl_end <= point && rl_editing_mode == vi_mode)
+	point = _rl_find_prev_mbchar (rl_line_buffer, rl_end, MB_FIND_NONZERO);
+#endif
+
+      if (rl_point == point)
+	rl_ding ();
+
+      rl_point = point;
+
+      if (rl_end < 0)
+	rl_end = 0;
+    }
+
+  return 0;
+}
+#else /* !HANDLE_MULTIBYTE */
+int
+rl_forward_char (count, key)
+     int count, key;
+{
+  return (rl_forward_byte (count, key));
+}
+#endif /* !HANDLE_MULTIBYTE */
+  
+/* Backwards compatibility. */
+int
+rl_forward (count, key)
+     int count, key;
+{
+  return (rl_forward_char (count, key));
+}
+
+/* Move backward COUNT bytes. */
+int
+rl_backward_byte (count, key)
+     int count, key;
+{
+  if (count < 0)
+    return (rl_forward_byte (-count, key));
+
+  if (count > 0)
+    {
+      if (rl_point < count)
+	{
+	  rl_point = 0;
+	  rl_ding ();
+	}
+      else
+	rl_point -= count;
+    }
+
+  if (rl_point < 0)
+    rl_point = 0;
+
+  return 0;
+}
+
+#if defined (HANDLE_MULTIBYTE)
+/* Move backward COUNT characters. */
+int
+rl_backward_char (count, key)
+     int count, key;
+{
+  int point;
+
+  if (MB_CUR_MAX == 1 || rl_byte_oriented)
+    return (rl_backward_byte (count, key));
+
+  if (count < 0)
+    return (rl_forward_char (-count, key));
+
+  if (count > 0)
+    {
+      point = rl_point;
+
+      while (count > 0 && point > 0)
+	{
+	  point = _rl_find_prev_mbchar (rl_line_buffer, point, MB_FIND_NONZERO);
+	  count--;
+	}
+      if (count > 0)
+	{
+	  rl_point = 0;
+	  rl_ding ();
+	}
+      else
+        rl_point = point;
+    }
+
+  return 0;
+}
+#else
+int
+rl_backward_char (count, key)
+     int count, key;
+{
+  return (rl_backward_byte (count, key));
+}
+#endif
+
+/* Backwards compatibility. */
+int
+rl_backward (count, key)
+     int count, key;
+{
+  return (rl_backward_char (count, key));
+}
+
+/* Move to the beginning of the line. */
+int
+rl_beg_of_line (count, key)
+     int count __attribute__((unused)), key __attribute__((unused));
+{
+  rl_point = 0;
+  return 0;
+}
+
+/* Move to the end of the line. */
+int
+rl_end_of_line (count, key)
+     int count __attribute__((unused)), key __attribute__((unused));
+{
+  rl_point = rl_end;
+  return 0;
+}
+
+/* XXX - these might need changes for multibyte characters */
+/* Move forward a word.  We do what Emacs does. */
+int
+rl_forward_word (count, key)
+     int count, key;
+{
+  int c;
+
+  if (count < 0)
+    return (rl_backward_word (-count, key));
+
+  while (count)
+    {
+      if (rl_point == rl_end)
+	return 0;
+
+      /* If we are not in a word, move forward until we are in one.
+	 Then, move forward until we hit a non-alphabetic character. */
+      c = rl_line_buffer[rl_point];
+      if (rl_alphabetic (c) == 0)
+	{
+	  while (++rl_point < rl_end)
+	    {
+	      c = rl_line_buffer[rl_point];
+	      if (rl_alphabetic (c))
+		break;
+	    }
+	}
+
+      if (rl_point == rl_end)
+	return 0;
+
+      while (++rl_point < rl_end)
+	{
+	  c = rl_line_buffer[rl_point];
+	  if (rl_alphabetic (c) == 0)
+	    break;
+	}
+      --count;
+    }
+
+  return 0;
+}
+
+/* Move backward a word.  We do what Emacs does. */
+int
+rl_backward_word (count, key)
+     int count, key;
+{
+  int c;
+
+  if (count < 0)
+    return (rl_forward_word (-count, key));
+
+  while (count)
+    {
+      if (!rl_point)
+	return 0;
+
+      /* Like rl_forward_word (), except that we look at the characters
+	 just before point. */
+
+      c = rl_line_buffer[rl_point - 1];
+      if (rl_alphabetic (c) == 0)
+	{
+	  while (--rl_point)
+	    {
+	      c = rl_line_buffer[rl_point - 1];
+	      if (rl_alphabetic (c))
+		break;
+	    }
+	}
+
+      while (rl_point)
+	{
+	  c = rl_line_buffer[rl_point - 1];
+	  if (rl_alphabetic (c) == 0)
+	    break;
+	  else
+	    --rl_point;
+	}
+
+      --count;
+    }
+
+  return 0;
+}
+
+/* Clear the current line.  Numeric argument to C-l does this. */
+int
+rl_refresh_line (ignore1, ignore2)
+     int ignore1 __attribute__((unused)), ignore2 __attribute__((unused));
+{
+  int curr_line;
+
+  curr_line = _rl_current_display_line ();
+
+  _rl_move_vert (curr_line);
+  _rl_move_cursor_relative (0, rl_line_buffer);   /* XXX is this right */
+
+  _rl_clear_to_eol (0);		/* arg of 0 means to not use spaces */
+
+  rl_forced_update_display ();
+  rl_display_fixed = 1;
+
+  return 0;
+}
+
+/* C-l typed to a line without quoting clears the screen, and then reprints
+   the prompt and the current input line.  Given a numeric arg, redraw only
+   the current line. */
+int
+rl_clear_screen (count, key)
+     int count, key;
+{
+  if (rl_explicit_arg)
+    {
+      rl_refresh_line (count, key);
+      return 0;
+    }
+
+  _rl_clear_screen ();		/* calls termcap function to clear screen */
+  rl_forced_update_display ();
+  rl_display_fixed = 1;
+
+  return 0;
+}
+
+int
+rl_arrow_keys (count, c)
+     int count, c __attribute__((unused));
+{
+  int ch;
+
+  RL_SETSTATE(RL_STATE_MOREINPUT);
+  ch = rl_read_key ();
+  RL_UNSETSTATE(RL_STATE_MOREINPUT);
+
+  switch (_rl_to_upper (ch))
+    {
+    case 'A':
+      rl_get_previous_history (count, ch);
+      break;
+
+    case 'B':
+      rl_get_next_history (count, ch);
+      break;
+
+    case 'C':
+      if (MB_CUR_MAX > 1 && rl_byte_oriented == 0)
+	rl_forward_char (count, ch);
+      else
+	rl_forward_byte (count, ch);
+      break;
+
+    case 'D':
+      if (MB_CUR_MAX > 1 && rl_byte_oriented == 0)
+	rl_backward_char (count, ch);
+      else
+	rl_backward_byte (count, ch);
+      break;
+
+    default:
+      rl_ding ();
+    }
+
+  return 0;
+}
+
+/* **************************************************************** */
+/*								    */
+/*			Text commands				    */
+/*								    */
+/* **************************************************************** */
+
+#ifdef HANDLE_MULTIBYTE
+static char pending_bytes[MB_LEN_MAX];
+static int pending_bytes_length = 0;
+static mbstate_t ps = {0};
+#endif
+
+/* Insert the character C at the current location, moving point forward.
+   If C introduces a multibyte sequence, we read the whole sequence and
+   then insert the multibyte char into the line buffer. */
+int
+_rl_insert_char (count, c)
+     int count, c;
+{
+  register int i;
+  char *string;
+#ifdef HANDLE_MULTIBYTE
+  int string_size;
+  char incoming[MB_LEN_MAX + 1];
+  int incoming_length = 0;
+  mbstate_t ps_back;
+  static int stored_count = 0;
+#endif
+
+  if (count <= 0)
+    return 0;
+
+#if defined (HANDLE_MULTIBYTE)
+  if (MB_CUR_MAX == 1 || rl_byte_oriented)
+    {
+      incoming[0] = c;
+      incoming[1] = '\0';
+      incoming_length = 1;
+    }
+  else
+    {
+      wchar_t wc;
+      size_t ret;
+
+      if (stored_count <= 0)
+	stored_count = count;
+      else
+	count = stored_count;
+
+      ps_back = ps;
+      pending_bytes[pending_bytes_length++] = c;
+      ret = mbrtowc (&wc, pending_bytes, pending_bytes_length, &ps);
+
+      if (ret == (size_t)-2)
+	{
+	  /* Bytes too short to compose character, try to wait for next byte.
+	     Restore the state of the byte sequence, because in this case the
+	     effect of mbstate is undefined. */
+	  ps = ps_back;
+	  return 1;
+	}
+      else if (ret == (size_t)-1)
+	{
+	  /* Invalid byte sequence for the current locale.  Treat first byte
+	     as a single character. */
+	  incoming[0] = pending_bytes[0];
+	  incoming[1] = '\0';
+	  incoming_length = 1;
+	  pending_bytes_length--;
+	  memmove (pending_bytes, pending_bytes + 1, pending_bytes_length);
+	  /* Clear the state of the byte sequence, because in this case the
+	     effect of mbstate is undefined. */
+	  memset (&ps, 0, sizeof (mbstate_t));
+	}
+      else if (ret == (size_t)0)
+	{
+	  incoming[0] = '\0';
+	  incoming_length = 0;
+	  pending_bytes_length--;
+	  /* Clear the state of the byte sequence, because in this case the
+	     effect of mbstate is undefined. */
+	  memset (&ps, 0, sizeof (mbstate_t));
+	}
+      else
+	{
+	  /* We successfully read a single multibyte character. */
+	  memcpy (incoming, pending_bytes, pending_bytes_length);
+	  incoming[pending_bytes_length] = '\0';
+	  incoming_length = pending_bytes_length;
+	  pending_bytes_length = 0;
+	}
+    }
+#endif /* HANDLE_MULTIBYTE */
+	  
+  /* If we can optimize, then do it.  But don't let people crash
+     readline because of extra large arguments. */
+  if (count > 1 && count <= 1024)
+    {
+#if defined (HANDLE_MULTIBYTE)
+      string_size = count * incoming_length;
+      string = (char *)xmalloc (1 + string_size);
+
+      i = 0;
+      while (i < string_size)
+	{
+	  strncpy (string + i, incoming, incoming_length);
+	  i += incoming_length;
+	}
+      incoming_length = 0;
+      stored_count = 0;
+#else /* !HANDLE_MULTIBYTE */
+      string = (char *)xmalloc (1 + count);
+
+      for (i = 0; i < count; i++)
+	string[i] = c;
+#endif /* !HANDLE_MULTIBYTE */
+
+      string[i] = '\0';
+      rl_insert_text (string);
+      free (string);
+
+      return 0;
+    }
+
+  if (count > 1024)
+    {
+      int decreaser;
+#if defined (HANDLE_MULTIBYTE)
+      string_size = incoming_length * 1024;
+      string = (char *)xmalloc (1 + string_size);
+
+      i = 0;
+      while (i < string_size)
+	{
+	  strncpy (string + i, incoming, incoming_length);
+	  i += incoming_length;
+	}
+
+      while (count)
+	{
+	  decreaser = (count > 1024) ? 1024 : count;
+	  string[decreaser*incoming_length] = '\0';
+	  rl_insert_text (string);
+	  count -= decreaser;
+	}
+
+      free (string);
+      incoming_length = 0;
+      stored_count = 0;
+#else /* !HANDLE_MULTIBYTE */
+      char str[1024+1];
+
+      for (i = 0; i < 1024; i++)
+	str[i] = c;
+
+      while (count)
+	{
+	  decreaser = (count > 1024 ? 1024 : count);
+	  str[decreaser] = '\0';
+	  rl_insert_text (str);
+	  count -= decreaser;
+	}
+#endif /* !HANDLE_MULTIBYTE */
+
+      return 0;
+    }
+
+#if defined (HANDLE_MULTIBYTE)
+  if (MB_CUR_MAX == 1 || rl_byte_oriented)
+    {
+#endif
+      /* We are inserting a single character.
+	 If there is pending input, then make a string of all of the
+	 pending characters that are bound to rl_insert, and insert
+	 them all. */
+      if (_rl_any_typein ())
+	_rl_insert_typein (c);
+      else
+	{
+	  /* Inserting a single character. */
+	  char str[2];
+
+	  str[1] = '\0';
+	  str[0] = c;
+	  rl_insert_text (str);
+	}
+#if defined (HANDLE_MULTIBYTE)
+    }
+  else
+    {
+      rl_insert_text (incoming);
+      stored_count = 0;
+    }
+#endif
+
+  return 0;
+}
+
+/* Overwrite the character at point (or next COUNT characters) with C.
+   If C introduces a multibyte character sequence, read the entire sequence
+   before starting the overwrite loop. */
+int
+_rl_overwrite_char (count, c)
+     int count, c;
+{
+  int i;
+#if defined (HANDLE_MULTIBYTE)
+  char mbkey[MB_LEN_MAX];
+  int k;
+
+  /* Read an entire multibyte character sequence to insert COUNT times. */
+  if (count > 0 && MB_CUR_MAX > 1 && rl_byte_oriented == 0)
+    k = _rl_read_mbstring (c, mbkey, MB_LEN_MAX);
+#endif
+
+  for (i = 0; i < count; i++)
+    {
+      rl_begin_undo_group ();
+
+      if (rl_point < rl_end)
+	rl_delete (1, c);
+
+#if defined (HANDLE_MULTIBYTE)
+      if (MB_CUR_MAX > 1 && rl_byte_oriented == 0)
+	rl_insert_text (mbkey);
+      else
+#endif
+	_rl_insert_char (1, c);
+
+      rl_end_undo_group ();
+    }
+
+  return 0;
+}
+
+int
+rl_insert (count, c)
+     int count, c;
+{
+  return (rl_insert_mode == RL_IM_INSERT ? _rl_insert_char (count, c)
+  					 : _rl_overwrite_char (count, c));
+}
+
+/* Insert the next typed character verbatim. */
+int
+rl_quoted_insert (count, key)
+     int count, key __attribute__((unused));
+{
+  int c;
+
+#if defined (HANDLE_SIGNALS)
+  _rl_disable_tty_signals ();
+#endif
+
+  RL_SETSTATE(RL_STATE_MOREINPUT);
+  c = rl_read_key ();
+  RL_UNSETSTATE(RL_STATE_MOREINPUT);
+
+#if defined (HANDLE_SIGNALS)
+  _rl_restore_tty_signals ();
+#endif
+
+  return (_rl_insert_char (count, c));  
+}
+
+/* Insert a tab character. */
+int
+rl_tab_insert (count, key)
+     int count, key __attribute__((unused));
+{
+  return (_rl_insert_char (count, '\t'));
+}
+
+/* What to do when a NEWLINE is pressed.  We accept the whole line.
+   KEY is the key that invoked this command.  I guess it could have
+   meaning in the future. */
+int
+rl_newline (count, key)
+     int count __attribute__((unused)), key __attribute__((unused));
+{
+  rl_done = 1;
+
+  if (_rl_history_preserve_point)
+    _rl_history_saved_point = (rl_point == rl_end) ? -1 : rl_point;
+
+  RL_SETSTATE(RL_STATE_DONE);
+
+#if defined (VI_MODE)
+  if (rl_editing_mode == vi_mode)
+    {
+      _rl_vi_done_inserting ();
+      _rl_vi_reset_last ();
+    }
+#endif /* VI_MODE */
+
+  /* If we've been asked to erase empty lines, suppress the final update,
+     since _rl_update_final calls rl_crlf(). */
+  if (rl_erase_empty_line && rl_point == 0 && rl_end == 0)
+    return 0;
+
+  if (readline_echoing_p)
+    _rl_update_final ();
+  return 0;
+}
+
+/* What to do for some uppercase characters, like meta characters,
+   and some characters appearing in emacs_ctlx_keymap.  This function
+   is just a stub, you bind keys to it and the code in _rl_dispatch ()
+   is special cased. */
+int
+rl_do_lowercase_version (ignore1, ignore2)
+     int ignore1 __attribute__((unused)), ignore2 __attribute__((unused));
+{
+  return 0;
+}
+
+/* This is different from what vi does, so the code's not shared.  Emacs
+   rubout in overwrite mode has one oddity:  it replaces a control
+   character that's displayed as two characters (^X) with two spaces. */
+int
+_rl_overwrite_rubout (count, key)
+     int count, key;
+{
+  int opoint;
+  int i, l;
+
+  if (rl_point == 0)
+    {
+      rl_ding ();
+      return 1;
+    }
+
+  opoint = rl_point;
+
+  /* L == number of spaces to insert */
+  for (i = l = 0; i < count; i++)
+    {
+      rl_backward_char (1, key);
+      l += rl_character_len (rl_line_buffer[rl_point], rl_point);	/* not exactly right */
+    }
+
+  rl_begin_undo_group ();
+
+  if (count > 1 || rl_explicit_arg)
+    rl_kill_text (opoint, rl_point);
+  else
+    rl_delete_text (opoint, rl_point);
+
+  /* Emacs puts point at the beginning of the sequence of spaces. */
+  opoint = rl_point;
+  _rl_insert_char (l, ' ');
+  rl_point = opoint;
+
+  rl_end_undo_group ();
+
+  return 0;
+}
+  
+/* Rubout the character behind point. */
+int
+rl_rubout (count, key)
+     int count, key;
+{
+  if (count < 0)
+    return (rl_delete (-count, key));
+
+  if (!rl_point)
+    {
+      rl_ding ();
+      return -1;
+    }
+
+  if (rl_insert_mode == RL_IM_OVERWRITE)
+    return (_rl_overwrite_rubout (count, key));
+
+  return (_rl_rubout_char (count, key));
+}
+
+int
+_rl_rubout_char (count, key)
+     int count, key;
+{
+  int orig_point;
+  unsigned char c;
+
+  /* Duplicated code because this is called from other parts of the library. */
+  if (count < 0)
+    return (rl_delete (-count, key));
+
+  if (rl_point == 0)
+    {
+      rl_ding ();
+      return -1;
+    }
+
+  if (count > 1 || rl_explicit_arg)
+    {
+      orig_point = rl_point;
+#if defined (HANDLE_MULTIBYTE)
+      if (MB_CUR_MAX > 1 && rl_byte_oriented == 0)
+	rl_backward_char (count, key);
+      else
+#endif
+        rl_backward_byte (count, key);
+      rl_kill_text (orig_point, rl_point);
+    }
+  else
+    {
+#if defined (HANDLE_MULTIBYTE)
+      if (MB_CUR_MAX == 1 || rl_byte_oriented)
+	{
+#endif
+	  c = rl_line_buffer[--rl_point];
+	  rl_delete_text (rl_point, rl_point + 1);
+#if defined (HANDLE_MULTIBYTE)
+	}
+      else
+	{
+	  int orig_point;
+
+	  orig_point = rl_point;
+	  rl_point = _rl_find_prev_mbchar (rl_line_buffer, rl_point, MB_FIND_NONZERO);
+	  c = rl_line_buffer[rl_point];
+	  rl_delete_text (rl_point, orig_point);
+	}
+#endif /* HANDLE_MULTIBYTE */
+
+      /* I don't think that the hack for end of line is needed for
+	 multibyte chars. */
+#if defined (HANDLE_MULTIBYTE)
+      if (MB_CUR_MAX == 1 || rl_byte_oriented)
+#endif
+      if (rl_point == rl_end && ISPRINT (c) && _rl_last_c_pos)
+	{
+	  int l;
+	  l = rl_character_len (c, rl_point);
+	  _rl_erase_at_end_of_line (l);
+	}
+    }
+
+  return 0;
+}
+
+/* Delete the character under the cursor.  Given a numeric argument,
+   kill that many characters instead. */
+int
+rl_delete (count, key)
+     int count, key;
+{
+  int r;
+
+  if (count < 0)
+    return (_rl_rubout_char (-count, key));
+
+  if (rl_point == rl_end)
+    {
+      rl_ding ();
+      return -1;
+    }
+
+  if (count > 1 || rl_explicit_arg)
+    {
+      int orig_point = rl_point;
+#if defined (HANDLE_MULTIBYTE)
+      if (MB_CUR_MAX > 1 && rl_byte_oriented == 0)
+	rl_forward_char (count, key);
+      else
+#endif
+	rl_forward_byte (count, key);
+
+      r = rl_kill_text (orig_point, rl_point);
+      rl_point = orig_point;
+      return r;
+    }
+  else
+    {
+      int new_point;
+      if (MB_CUR_MAX > 1 && rl_byte_oriented == 0)
+	new_point = _rl_find_next_mbchar (rl_line_buffer, rl_point, 1, MB_FIND_NONZERO);
+      else
+	new_point = rl_point + 1;
+	
+      return (rl_delete_text (rl_point, new_point));
+    }
+}
+
+/* Delete the character under the cursor, unless the insertion
+   point is at the end of the line, in which case the character
+   behind the cursor is deleted.  COUNT is obeyed and may be used
+   to delete forward or backward that many characters. */      
+int
+rl_rubout_or_delete (count, key)
+     int count, key;
+{
+  if (rl_end != 0 && rl_point == rl_end)
+    return (_rl_rubout_char (count, key));
+  else
+    return (rl_delete (count, key));
+}  
+
+/* Delete all spaces and tabs around point. */
+int
+rl_delete_horizontal_space (count, ignore)
+     int count __attribute__((unused)), ignore __attribute__((unused));
+{
+  int start = rl_point;
+
+  while (rl_point && whitespace (rl_line_buffer[rl_point - 1]))
+    rl_point--;
+
+  start = rl_point;
+
+  while (rl_point < rl_end && whitespace (rl_line_buffer[rl_point]))
+    rl_point++;
+
+  if (start != rl_point)
+    {
+      rl_delete_text (start, rl_point);
+      rl_point = start;
+    }
+  return 0;
+}
+
+/* Like the tcsh editing function delete-char-or-list.  The eof character
+   is caught before this is invoked, so this really does the same thing as
+   delete-char-or-list-or-eof, as long as it's bound to the eof character. */
+int
+rl_delete_or_show_completions (count, key)
+     int count, key;
+{
+  if (rl_end != 0 && rl_point == rl_end)
+    return (rl_possible_completions (count, key));
+  else
+    return (rl_delete (count, key));
+}
+
+#ifndef RL_COMMENT_BEGIN_DEFAULT
+#define RL_COMMENT_BEGIN_DEFAULT "#"
+#endif
+
+/* Turn the current line into a comment in shell history.
+   A K*rn shell style function. */
+int
+rl_insert_comment (count, key)
+     int count __attribute__((unused)), key;
+{
+  const char *rl_comment_text;
+  int rl_comment_len;
+
+  rl_beg_of_line (1, key);
+  rl_comment_text = _rl_comment_begin ? _rl_comment_begin : RL_COMMENT_BEGIN_DEFAULT;
+
+  if (rl_explicit_arg == 0)
+    rl_insert_text (rl_comment_text);
+  else
+    {
+      rl_comment_len = strlen (rl_comment_text);
+      if (STREQN (rl_comment_text, rl_line_buffer, rl_comment_len))
+	rl_delete_text (rl_point, rl_point + rl_comment_len);
+      else
+	rl_insert_text (rl_comment_text);
+    }
+
+  (*rl_redisplay_function) ();
+  rl_newline (1, '\n');
+
+  return (0);
+}
+
+/* **************************************************************** */
+/*								    */
+/*			Changing Case				    */
+/*								    */
+/* **************************************************************** */
+
+/* The three kinds of things that we know how to do. */
+#define UpCase 1
+#define DownCase 2
+#define CapCase 3
+
+/* Uppercase the word at point. */
+int
+rl_upcase_word (count, key)
+     int count, key __attribute__((unused));
+{
+  return (rl_change_case (count, UpCase));
+}
+
+/* Lowercase the word at point. */
+int
+rl_downcase_word (count, key)
+     int count, key __attribute__((unused));
+{
+  return (rl_change_case (count, DownCase));
+}
+
+/* Upcase the first letter, downcase the rest. */
+int
+rl_capitalize_word (count, key)
+     int count, key __attribute__((unused));
+{
+ return (rl_change_case (count, CapCase));
+}
+
+/* The meaty function.
+   Change the case of COUNT words, performing OP on them.
+   OP is one of UpCase, DownCase, or CapCase.
+   If a negative argument is given, leave point where it started,
+   otherwise, leave it where it moves to. */
+static int
+rl_change_case (count, op)
+     int count, op;
+{
+  register int start, end;
+  int inword, c;
+
+  start = rl_point;
+  rl_forward_word (count, 0);
+  end = rl_point;
+
+  if (count < 0)
+    SWAP (start, end);
+
+  /* We are going to modify some text, so let's prepare to undo it. */
+  rl_modifying (start, end);
+
+  for (inword = 0; start < end; start++)
+    {
+      c = rl_line_buffer[start];
+      switch (op)
+	{
+	case UpCase:
+	  rl_line_buffer[start] = _rl_to_upper (c);
+	  break;
+
+	case DownCase:
+	  rl_line_buffer[start] = _rl_to_lower (c);
+	  break;
+
+	case CapCase:
+	  rl_line_buffer[start] = (inword == 0) ? _rl_to_upper (c) : _rl_to_lower (c);
+	  inword = rl_alphabetic (rl_line_buffer[start]);
+	  break;
+
+	default:
+	  rl_ding ();
+	  return -1;
+	}
+    }
+  rl_point = end;
+  return 0;
+}
+
+/* **************************************************************** */
+/*								    */
+/*			Transposition				    */
+/*								    */
+/* **************************************************************** */
+
+/* Transpose the words at point.  If point is at the end of the line,
+   transpose the two words before point. */
+int
+rl_transpose_words (count, key)
+     int count, key;
+{
+  char *word1, *word2;
+  int w1_beg, w1_end, w2_beg, w2_end;
+  int orig_point = rl_point;
+
+  if (!count)
+    return 0;
+
+  /* Find the two words. */
+  rl_forward_word (count, key);
+  w2_end = rl_point;
+  rl_backward_word (1, key);
+  w2_beg = rl_point;
+  rl_backward_word (count, key);
+  w1_beg = rl_point;
+  rl_forward_word (1, key);
+  w1_end = rl_point;
+
+  /* Do some check to make sure that there really are two words. */
+  if ((w1_beg == w2_beg) || (w2_beg < w1_end))
+    {
+      rl_ding ();
+      rl_point = orig_point;
+      return -1;
+    }
+
+  /* Get the text of the words. */
+  word1 = rl_copy_text (w1_beg, w1_end);
+  word2 = rl_copy_text (w2_beg, w2_end);
+
+  /* We are about to do many insertions and deletions.  Remember them
+     as one operation. */
+  rl_begin_undo_group ();
+
+  /* Do the stuff at word2 first, so that we don't have to worry
+     about word1 moving. */
+  rl_point = w2_beg;
+  rl_delete_text (w2_beg, w2_end);
+  rl_insert_text (word1);
+
+  rl_point = w1_beg;
+  rl_delete_text (w1_beg, w1_end);
+  rl_insert_text (word2);
+
+  /* This is exactly correct since the text before this point has not
+     changed in length. */
+  rl_point = w2_end;
+
+  /* I think that does it. */
+  rl_end_undo_group ();
+  free (word1);
+  free (word2);
+
+  return 0;
+}
+
+/* Transpose the characters at point.  If point is at the end of the line,
+   then transpose the characters before point. */
+int
+rl_transpose_chars (count, key)
+     int count, key __attribute__((unused));
+{
+#if defined (HANDLE_MULTIBYTE)
+  char *dummy;
+  int i, prev_point;
+#else
+  char dummy[2];
+#endif
+  int char_length;
+
+  if (count == 0)
+    return 0;
+
+  if (!rl_point || rl_end < 2)
+    {
+      rl_ding ();
+      return -1;
+    }
+
+  rl_begin_undo_group ();
+
+  if (rl_point == rl_end)
+    {
+      if (MB_CUR_MAX > 1 && rl_byte_oriented == 0)
+	rl_point = _rl_find_prev_mbchar (rl_line_buffer, rl_point, MB_FIND_NONZERO);
+      else
+	--rl_point;
+      count = 1;
+    }
+
+#if defined (HANDLE_MULTIBYTE)
+  prev_point = rl_point;
+  if (MB_CUR_MAX > 1 && rl_byte_oriented == 0)
+    rl_point = _rl_find_prev_mbchar (rl_line_buffer, rl_point, MB_FIND_NONZERO);
+  else
+#endif
+    rl_point--;
+
+#if defined (HANDLE_MULTIBYTE)
+  char_length = prev_point - rl_point;
+  dummy = (char *)xmalloc (char_length + 1);
+  for (i = 0; i < char_length; i++)
+    dummy[i] = rl_line_buffer[rl_point + i];
+  dummy[i] = '\0';
+#else
+  dummy[0] = rl_line_buffer[rl_point];
+  dummy[char_length = 1] = '\0';
+#endif
+
+  rl_delete_text (rl_point, rl_point + char_length);
+
+  rl_point = _rl_find_next_mbchar (rl_line_buffer, rl_point, count, MB_FIND_NONZERO);
+
+  _rl_fix_point (0);
+  rl_insert_text (dummy);
+  rl_end_undo_group ();
+
+#if defined (HANDLE_MULTIBYTE)
+  free (dummy);
+#endif
+
+  return 0;
+}
+
+/* **************************************************************** */
+/*								    */
+/*			Character Searching			    */
+/*								    */
+/* **************************************************************** */
+
+int
+#if defined (HANDLE_MULTIBYTE)
+_rl_char_search_internal (count, dir, smbchar, len)
+     int count, dir;
+     char *smbchar;
+     int len;
+#else
+_rl_char_search_internal (count, dir, schar)
+     int count, dir, schar;
+#endif
+{
+  int pos, inc;
+#if defined (HANDLE_MULTIBYTE)
+  int prepos;
+#endif
+
+  pos = rl_point;
+  inc = (dir < 0) ? -1 : 1;
+  while (count)
+    {
+      if ((dir < 0 && pos <= 0) || (dir > 0 && pos >= rl_end))
+	{
+	  rl_ding ();
+	  return -1;
+	}
+
+#if defined (HANDLE_MULTIBYTE)
+      pos = (inc > 0) ? _rl_find_next_mbchar (rl_line_buffer, pos, 1, MB_FIND_ANY)
+		      : _rl_find_prev_mbchar (rl_line_buffer, pos, MB_FIND_ANY);
+#else
+      pos += inc;
+#endif
+      do
+	{
+#if defined (HANDLE_MULTIBYTE)
+	  if (_rl_is_mbchar_matched (rl_line_buffer, pos, rl_end, smbchar, len))
+#else
+	  if (rl_line_buffer[pos] == schar)
+#endif
+	    {
+	      count--;
+	      if (dir < 0)
+	        rl_point = (dir == BTO) ? _rl_find_next_mbchar (rl_line_buffer, pos, 1, MB_FIND_ANY)
+					: pos;
+	      else
+		rl_point = (dir == FTO) ? _rl_find_prev_mbchar (rl_line_buffer, pos, MB_FIND_ANY)
+					: pos;
+	      break;
+	    }
+#if defined (HANDLE_MULTIBYTE)
+	  prepos = pos;
+#endif
+	}
+#if defined (HANDLE_MULTIBYTE)
+      while ((dir < 0) ? (pos = _rl_find_prev_mbchar (rl_line_buffer, pos, MB_FIND_ANY)) != prepos
+		       : (pos = _rl_find_next_mbchar (rl_line_buffer, pos, 1, MB_FIND_ANY)) != prepos);
+#else
+      while ((dir < 0) ? pos-- : ++pos < rl_end);
+#endif
+    }
+  return (0);
+}
+
+/* Search COUNT times for a character read from the current input stream.
+   FDIR is the direction to search if COUNT is non-negative; otherwise
+   the search goes in BDIR.  So much is dependent on HANDLE_MULTIBYTE
+   that there are two separate versions of this function. */
+#if defined (HANDLE_MULTIBYTE)
+static int
+_rl_char_search (count, fdir, bdir)
+     int count, fdir, bdir;
+{
+  char mbchar[MB_LEN_MAX];
+  int mb_len;
+
+  mb_len = _rl_read_mbchar (mbchar, MB_LEN_MAX);
+
+  if (count < 0)
+    return (_rl_char_search_internal (-count, bdir, mbchar, mb_len));
+  else
+    return (_rl_char_search_internal (count, fdir, mbchar, mb_len));
+}
+#else /* !HANDLE_MULTIBYTE */
+static int
+_rl_char_search (count, fdir, bdir)
+     int count, fdir, bdir;
+{
+  int c;
+
+  RL_SETSTATE(RL_STATE_MOREINPUT);
+  c = rl_read_key ();
+  RL_UNSETSTATE(RL_STATE_MOREINPUT);
+
+  if (count < 0)
+    return (_rl_char_search_internal (-count, bdir, c));
+  else
+    return (_rl_char_search_internal (count, fdir, c));
+}
+#endif /* !HANDLE_MULTIBYTE */
+
+int
+rl_char_search (count, key)
+     int count, key __attribute__((unused));
+{
+  return (_rl_char_search (count, FFIND, BFIND));
+}
+
+int
+rl_backward_char_search (count, key)
+     int count, key __attribute__((unused));
+{
+  return (_rl_char_search (count, BFIND, FFIND));
+}
+
+/* **************************************************************** */
+/*								    */
+/*		   The Mark and the Region.			    */
+/*								    */
+/* **************************************************************** */
+
+/* Set the mark at POSITION. */
+int
+_rl_set_mark_at_pos (position)
+     int position;
+{
+  if (position > rl_end)
+    return -1;
+
+  rl_mark = position;
+  return 0;
+}
+
+/* A bindable command to set the mark. */
+int
+rl_set_mark (count, key)
+     int count, key __attribute__((unused));
+{
+  return (_rl_set_mark_at_pos (rl_explicit_arg ? count : rl_point));
+}
+
+/* Exchange the position of mark and point. */
+int
+rl_exchange_point_and_mark (count, key)
+     int count __attribute__((unused)), key __attribute__((unused));
+{
+  if (rl_mark > rl_end)
+    rl_mark = -1;
+
+  if (rl_mark == -1)
+    {
+      rl_ding ();
+      return -1;
+    }
+  else
+    SWAP (rl_point, rl_mark);
+
+  return 0;
+}
diff --git a/readline/tilde.c b/readline/tilde.c
index 05c9ed741ed6806d2f8789c8cf8a9361d8fc3e8b..fab4aab65adcb2feed57b6480b80c3323dd10c6f 100644
--- a/readline/tilde.c
+++ b/readline/tilde.c
@@ -7,7 +7,7 @@
 
    Readline is free software; you can redistribute it and/or modify it
    under the terms of the GNU General Public License as published by the
-   Free Software Foundation; either version 1, or (at your option) any
+   Free Software Foundation; either version 2, or (at your option) any
    later version.
 
    Readline is distributed in the hope that it will be useful, but
@@ -17,7 +17,7 @@
 
    You should have received a copy of the GNU General Public License
    along with Readline; see the file COPYING.  If not, write to the Free
-   Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. */
+   Software Foundation, 59 Temple Place, Suite 330, Boston, MA 02111 USA. */
 
 #if defined (HAVE_CONFIG_H)
 #  include <config.h>
@@ -47,16 +47,19 @@
 
 #include "tilde.h"
 
+#if defined (TEST) || defined (STATIC_MALLOC)
+static void *xmalloc (), *xrealloc ();
+#else
+#  include "xmalloc.h"
+#endif /* TEST || STATIC_MALLOC */
+
 #if !defined (HAVE_GETPW_DECLS)
-extern struct passwd *getpwuid (), *getpwnam ();
+extern struct passwd *getpwuid PARAMS((uid_t));
+extern struct passwd *getpwnam PARAMS((const char *));
 #endif /* !HAVE_GETPW_DECLS */
 
 #if !defined (savestring)
-extern char *xmalloc ();
-#  ifndef strcpy
-extern char *strcpy ();
-#  endif
-#define savestring(x) strcpy (xmalloc (1 + strlen (x)), (x))
+#define savestring(x) strcpy ((char *)xmalloc (1 + strlen (x)), (x))
 #endif /* !savestring */
 
 #if !defined (NULL)
@@ -67,62 +70,63 @@ extern char *strcpy ();
 #  endif /* !__STDC__ */
 #endif /* !NULL */
 
-#if defined (TEST) || defined (STATIC_MALLOC)
-static char *xmalloc (), *xrealloc ();
-#else
-extern char *xmalloc (), *xrealloc ();
-#endif /* TEST || STATIC_MALLOC */
-
 /* If being compiled as part of bash, these will be satisfied from
    variables.o.  If being compiled as part of readline, they will
    be satisfied from shell.o. */
-extern char *get_home_dir ();
-extern char *get_env_value ();
+extern char *sh_get_home_dir PARAMS((void));
+extern char *sh_get_env_value PARAMS((const char *));
 
 /* The default value of tilde_additional_prefixes.  This is set to
    whitespace preceding a tilde so that simple programs which do not
    perform any word separation get desired behaviour. */
 static const char *default_prefixes[] =
-  { " ~", "\t~", (char *)NULL };
+  { " ~", "\t~", (const char *)NULL };
 
 /* The default value of tilde_additional_suffixes.  This is set to
    whitespace or newline so that simple programs which do not
    perform any word separation get desired behaviour. */
 static const char *default_suffixes[] =
-  { " ", "\n", (char *)NULL };
+  { " ", "\n", (const char *)NULL };
 
 /* If non-null, this contains the address of a function that the application
    wants called before trying the standard tilde expansions.  The function
    is called with the text sans tilde, and returns a malloc()'ed string
    which is the expansion, or a NULL pointer if the expansion fails. */
-CPFunction *tilde_expansion_preexpansion_hook = (CPFunction *)NULL;
+tilde_hook_func_t *tilde_expansion_preexpansion_hook = (tilde_hook_func_t *)NULL;
 
 /* If non-null, this contains the address of a function to call if the
    standard meaning for expanding a tilde fails.  The function is called
    with the text (sans tilde, as in "foo"), and returns a malloc()'ed string
    which is the expansion, or a NULL pointer if there is no expansion. */
-CPFunction *tilde_expansion_failure_hook = (CPFunction *)NULL;
+tilde_hook_func_t *tilde_expansion_failure_hook = (tilde_hook_func_t *)NULL;
 
 /* When non-null, this is a NULL terminated array of strings which
    are duplicates for a tilde prefix.  Bash uses this to expand
    `=~' and `:~'. */
-const char ** tilde_additional_prefixes = default_prefixes;
+char **tilde_additional_prefixes = (char **)default_prefixes;
 
 /* When non-null, this is a NULL terminated array of strings which match
    the end of a username, instead of just "/".  Bash sets this to
    `:' and `=~'. */
-const char **tilde_additional_suffixes = default_suffixes;
+char **tilde_additional_suffixes = (char **)default_suffixes;
+
+static int tilde_find_prefix PARAMS((const char *, int *));
+static int tilde_find_suffix PARAMS((const char *));
+static char *isolate_tilde_prefix PARAMS((const char *, int *));
+static char *glue_prefix_and_suffix PARAMS((char *, const char *, int));
 
 /* Find the start of a tilde expansion in STRING, and return the index of
    the tilde which starts the expansion.  Place the length of the text
    which identified this tilde starter in LEN, excluding the tilde itself. */
 static int
 tilde_find_prefix (string, len)
-     char *string;
+     const char *string;
      int *len;
 {
   register int i, j, string_len;
-  register const char **prefixes = tilde_additional_prefixes;
+  register char **prefixes;
+
+  prefixes = tilde_additional_prefixes;
 
   string_len = strlen (string);
   *len = 0;
@@ -151,17 +155,21 @@ tilde_find_prefix (string, len)
    the character which ends the tilde definition.  */
 static int
 tilde_find_suffix (string)
-     char *string;
+     const char *string;
 {
   register int i, j, string_len;
-  register const char **suffixes;
+  register char **suffixes;
 
   suffixes = tilde_additional_suffixes;
   string_len = strlen (string);
 
   for (i = 0; i < string_len; i++)
     {
+#if defined (__MSDOS__)
+      if (string[i] == '/' || string[i] == '\\' /* || !string[i] */)
+#else
       if (string[i] == '/' /* || !string[i] */)
+#endif
 	break;
 
       for (j = 0; suffixes && suffixes[j]; j++)
@@ -176,16 +184,16 @@ tilde_find_suffix (string)
 /* Return a new string which is the result of tilde expanding STRING. */
 char *
 tilde_expand (string)
-     char *string;
+     const char *string;
 {
   char *result;
   int result_size, result_index;
 
   result_index = result_size = 0;
-  if ((result = strchr (string, '~')))
-    result = xmalloc (result_size = (strlen (string) + 16));
+  if ((result = strchr(string, '~')))
+    result = (char *)xmalloc (result_size = (strlen (string) + 16));
   else
-    result = xmalloc (result_size = (strlen (string) + 1));
+    result = (char *)xmalloc (result_size = (strlen (string) + 1));
 
   /* Scan through STRING expanding tildes as we come to them. */
   while (1)
@@ -199,7 +207,7 @@ tilde_expand (string)
 
       /* Copy the skipped text into the result. */
       if ((result_index + start + 1) > result_size)
-	result = xrealloc (result, 1 + (result_size += (start + 20)));
+	result = (char *)xrealloc (result, 1 + (result_size += (start + 20)));
 
       strncpy (result + result_index, string, start);
       result_index += start;
@@ -216,7 +224,7 @@ tilde_expand (string)
 	break;
 
       /* Expand the entire tilde word, and copy it into RESULT. */
-      tilde_word = xmalloc (1 + end);
+      tilde_word = (char *)xmalloc (1 + end);
       strncpy (tilde_word, string, end);
       tilde_word[end] = '\0';
       string += end;
@@ -225,11 +233,18 @@ tilde_expand (string)
       free (tilde_word);
 
       len = strlen (expansion);
-      if ((result_index + len + 1) > result_size)
-	result = xrealloc (result, 1 + (result_size += (len + 20)));
+#ifdef __CYGWIN__
+      /* Fix for Cygwin to prevent ~user/xxx from expanding to //xxx when
+	 $HOME for `user' is /.  On cygwin, // denotes a network drive. */
+      if (len > 1 || *expansion != '/' || *string != '/')
+#endif
+	{
+	  if ((result_index + len + 1) > result_size)
+	    result = (char *)xrealloc (result, 1 + (result_size += (len + 20)));
 
-      strcpy (result + result_index, expansion);
-      result_index += len;
+	  strcpy (result + result_index, expansion);
+	  result_index += len;
+	}
       free (expansion);
     }
 
@@ -243,14 +258,18 @@ tilde_expand (string)
    the location it points to. */
 static char *
 isolate_tilde_prefix (fname, lenp)
-     char *fname;
+     const char *fname;
      int *lenp;
 {
   char *ret;
   int i;
 
-  ret = xmalloc (strlen (fname));
+  ret = (char *)xmalloc (strlen (fname));
+#if defined (__MSDOS__)
+  for (i = 1; fname[i] && fname[i] != '/' && fname[i] != '\\'; i++)
+#else
   for (i = 1; fname[i] && fname[i] != '/'; i++)
+#endif
     ret[i - 1] = fname[i];
   ret[i - 1] = '\0';
   if (lenp)
@@ -262,7 +281,8 @@ isolate_tilde_prefix (fname, lenp)
    SUFFIND. */
 static char *
 glue_prefix_and_suffix (prefix, suffix, suffind)
-     char *prefix, *suffix;
+     char *prefix;
+     const char *suffix;
      int suffind;
 {
   char *ret;
@@ -270,8 +290,8 @@ glue_prefix_and_suffix (prefix, suffix, suffind)
 
   plen = (prefix && *prefix) ? strlen (prefix) : 0;
   slen = strlen (suffix + suffind);
-  ret = xmalloc (plen + slen + 1);
-  if (prefix && *prefix)
+  ret = (char *)xmalloc (plen + slen + 1);
+  if (plen)
     strcpy (ret, prefix);
   strcpy (ret + plen, suffix + suffind);
   return ret;
@@ -282,7 +302,7 @@ glue_prefix_and_suffix (prefix, suffix, suffind)
    This always returns a newly-allocated string, never static storage. */
 char *
 tilde_expand_word (filename)
-     char *filename;
+     const char *filename;
 {
   char *dirname, *expansion, *username;
   int user_len;
@@ -300,12 +320,12 @@ tilde_expand_word (filename)
   if (filename[1] == '\0' || filename[1] == '/')
     {
       /* Prefix $HOME to the rest of the string. */
-      expansion = get_env_value ("HOME");
+      expansion = sh_get_env_value ("HOME");
 
       /* If there is no HOME variable, look up the directory in
 	 the password database. */
       if (expansion == 0)
-	expansion = get_home_dir ();
+	expansion = sh_get_home_dir ();
 
       return (glue_prefix_and_suffix (expansion, filename, 1));
     }
@@ -394,28 +414,28 @@ main (argc, argv)
 
 static void memory_error_and_abort ();
 
-static char *
+static void *
 xmalloc (bytes)
-     int bytes;
+     size_t bytes;
 {
-  char *temp = (char *)malloc (bytes);
+  void *temp = (char *)malloc (bytes);
 
   if (!temp)
     memory_error_and_abort ();
   return (temp);
 }
 
-static char *
+static void *
 xrealloc (pointer, bytes)
-     char *pointer;
+     void *pointer;
      int bytes;
 {
-  char *temp;
+  void *temp;
 
   if (!pointer)
-    temp = (char *)malloc (bytes);
+    temp = malloc (bytes);
   else
-    temp = (char *)realloc (pointer, bytes);
+    temp = realloc (pointer, bytes);
 
   if (!temp)
     memory_error_and_abort ();
diff --git a/readline/tilde.h b/readline/tilde.h
index 45eea1b66e5091ef60d8a0ce0ff848723ce7c38d..f8182c999d9b43c2b88cceb0f4142eb607b95154 100644
--- a/readline/tilde.h
+++ b/readline/tilde.h
@@ -8,7 +8,7 @@
 
    The Library is free software; you can redistribute it and/or modify
    it under the terms of the GNU General Public License as published by
-   the Free Software Foundation; either version 1, or (at your option)
+   the Free Software Foundation; either version 2, or (at your option)
    any later version.
 
    The Library is distributed in the hope that it will be useful, but
@@ -19,47 +19,60 @@
    The GNU General Public License is often shipped with GNU software, and
    is generally kept in a file called COPYING or LICENSE.  If you do not
    have a copy of the license, write to the Free Software Foundation,
-   675 Mass Ave, Cambridge, MA 02139, USA. */
+   59 Temple Place, Suite 330, Boston, MA 02111 USA. */
 
 #if !defined (_TILDE_H_)
 #  define _TILDE_H_
 
-/* Function pointers can be declared as (Function *)foo. */
-#if !defined (_FUNCTION_DEF)
-#  define _FUNCTION_DEF
-typedef int Function ();
-typedef void VFunction ();
-typedef char *CPFunction ();
-typedef char **CPPFunction ();
-#endif /* _FUNCTION_DEF */
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+/* A function can be defined using prototypes and compile on both ANSI C
+   and traditional C compilers with something like this:
+	extern char *func PARAMS((char *, char *, int)); */
+
+#if !defined (PARAMS)
+#  if defined (__STDC__) || defined (__GNUC__) || defined (__cplusplus)
+#    define PARAMS(protos) protos
+#  else
+#    define PARAMS(protos) ()
+#  endif
+#endif
+
+typedef char *tilde_hook_func_t PARAMS((char *));
 
 /* If non-null, this contains the address of a function that the application
    wants called before trying the standard tilde expansions.  The function
    is called with the text sans tilde, and returns a malloc()'ed string
    which is the expansion, or a NULL pointer if the expansion fails. */
-extern CPFunction *tilde_expansion_preexpansion_hook;
+extern tilde_hook_func_t *tilde_expansion_preexpansion_hook;
 
 /* If non-null, this contains the address of a function to call if the
    standard meaning for expanding a tilde fails.  The function is called
    with the text (sans tilde, as in "foo"), and returns a malloc()'ed string
    which is the expansion, or a NULL pointer if there is no expansion. */
-extern CPFunction *tilde_expansion_failure_hook;
+extern tilde_hook_func_t *tilde_expansion_failure_hook;
 
 /* When non-null, this is a NULL terminated array of strings which
    are duplicates for a tilde prefix.  Bash uses this to expand
    `=~' and `:~'. */
-extern const char **tilde_additional_prefixes;
+extern char **tilde_additional_prefixes;
 
 /* When non-null, this is a NULL terminated array of strings which match
    the end of a username, instead of just "/".  Bash sets this to
    `:' and `=~'. */
-extern const char **tilde_additional_suffixes;
+extern char **tilde_additional_suffixes;
 
 /* Return a new string which is the result of tilde expanding STRING. */
-extern char *tilde_expand ();
+extern char *tilde_expand PARAMS((const char *));
 
 /* Do the work of tilde expansion on FILENAME.  FILENAME starts with a
    tilde.  If there is no expansion, call tilde_expansion_failure_hook. */
-extern char *tilde_expand_word ();
+extern char *tilde_expand_word PARAMS((const char *));
+
+#ifdef __cplusplus
+}
+#endif
 
 #endif /* _TILDE_H_ */
diff --git a/readline/undo.c b/readline/undo.c
index c8f4892b774d346c015b5cc3b3292b8c65c2f351..df913195fad6cabc158d88325a2dfe11b2c38ee7 100644
--- a/readline/undo.c
+++ b/readline/undo.c
@@ -8,7 +8,7 @@
 
    The GNU Readline Library is free software; you can redistribute it
    and/or modify it under the terms of the GNU General Public License
-   as published by the Free Software Foundation; either version 1, or
+   as published by the Free Software Foundation; either version 2, or
    (at your option) any later version.
 
    The GNU Readline Library is distributed in the hope that it will be
@@ -19,7 +19,7 @@
    The GNU General Public License is often shipped with GNU software, and
    is generally kept in a file called COPYING or LICENSE.  If you do not
    have a copy of the license, write to the Free Software Foundation,
-   675 Mass Ave, Cambridge, MA 02139, USA. */
+   59 Temple Place, Suite 330, Boston, MA 02111 USA. */
 #define READLINE_LIBRARY
 
 #if defined (HAVE_CONFIG_H)
@@ -47,7 +47,8 @@
 #include "readline.h"
 #include "history.h"
 
-#define SWAP(s, e)  do { int t; t = s; s = e; e = t; } while (0)
+#include "rlprivate.h"
+#include "xmalloc.h"
 
 /* Non-zero tells rl_delete_text and rl_insert_text to not add to
    the undo list. */
@@ -84,7 +85,7 @@ rl_add_undo (what, start, end, text)
 
 /* Free the existing undo list. */
 void
-free_undo_list ()
+rl_free_undo_list ()
 {
   while (rl_undo_list)
     {
@@ -105,17 +106,18 @@ int
 rl_do_undo ()
 {
   UNDO_LIST *release;
-  int waiting_for_begin = 0;
-  int start = 0, end = 0;
+  int waiting_for_begin, start, end;
 
 #define TRANS(i) ((i) == -1 ? rl_point : ((i) == -2 ? rl_end : (i)))
 
+  start = end = waiting_for_begin = 0;
   do
     {
       if (!rl_undo_list)
 	return (0);
 
       _rl_doing_an_undo = 1;
+      RL_SETSTATE(RL_STATE_UNDOING);
 
       /* To better support vi-mode, a start or end value of -1 means
 	 rl_point, and a value of -2 means rl_end. */
@@ -150,11 +152,12 @@ rl_do_undo ()
 	  if (waiting_for_begin)
 	    waiting_for_begin--;
 	  else
-	    ding ();
+	    rl_ding ();
 	  break;
 	}
 
       _rl_doing_an_undo = 0;
+      RL_UNSETSTATE(RL_STATE_UNDOING);
 
       release = rl_undo_list;
       rl_undo_list = rl_undo_list->next;
@@ -168,13 +171,14 @@ rl_do_undo ()
 
 int
 _rl_fix_last_undo_of_type (type, start, end)
-     int type, start, end;
+     unsigned int type;
+     int start, end;
 {
   UNDO_LIST *rl;
 
   for (rl = rl_undo_list; rl; rl = rl->next)
     {
-      if ((int) rl->what == type)
+      if (rl->what == type)
 	{
 	  rl->start = start;
 	  rl->end = end;
@@ -225,11 +229,11 @@ rl_modifying (start, end)
 
 /* Revert the current line to its previous state. */
 int
-rl_revert_line (int count __attribute__((unused)),
-		int key __attribute__((unused)))
+rl_revert_line (count, key)
+     int count __attribute__((unused)), key __attribute__((unused));
 {
   if (!rl_undo_list)
-    ding ();
+    rl_ding ();
   else
     {
       while (rl_undo_list)
@@ -240,7 +244,8 @@ rl_revert_line (int count __attribute__((unused)),
 
 /* Do some undoing of things that were done. */
 int
-rl_undo_command (int count, int key __attribute__((unused)))
+rl_undo_command (count, key)
+     int count, key __attribute__((unused));
 {
   if (count < 0)
     return 0;	/* Nothing to do. */
@@ -251,7 +256,7 @@ rl_undo_command (int count, int key __attribute__((unused)))
 	count--;
       else
 	{
-	  ding ();
+	  rl_ding ();
 	  break;
 	}
     }
diff --git a/readline/util.c b/readline/util.c
index bcd8f3bc5b2c9eb534a0cc2b780d07b8d389e0fa..2a6e4e3398adc65acb9ffe47ff3395ff1975602c 100644
--- a/readline/util.c
+++ b/readline/util.c
@@ -7,7 +7,7 @@
 
    The GNU Readline Library is free software; you can redistribute it
    and/or modify it under the terms of the GNU General Public License
-   as published by the Free Software Foundation; either version 1, or
+   as published by the Free Software Foundation; either version 2, or
    (at your option) any later version.
 
    The GNU Readline Library is distributed in the hope that it will be
@@ -18,7 +18,7 @@
    The GNU General Public License is often shipped with GNU software, and
    is generally kept in a file called COPYING or LICENSE.  If you do not
    have a copy of the license, write to the Free Software Foundation,
-   675 Mass Ave, Cambridge, MA 02139, USA. */
+   59 Temple Place, Suite 330, Boston, MA 02111 USA. */
 #define READLINE_LIBRARY
 
 #if defined (HAVE_CONFIG_H)
@@ -52,24 +52,8 @@
 /* Some standard library routines. */
 #include "readline.h"
 
-#define SWAP(s, e)  do { int t; t = s; s = e; e = t; } while (0)
-
-/* Pseudo-globals imported from readline.c */
-extern int readline_echoing_p;
-extern procenv_t readline_top_level;
-extern int rl_line_buffer_len;
-extern Function *rl_last_func;
-
-extern int _rl_defining_kbd_macro;
-extern char *_rl_executing_macro;
-
-/* Pseudo-global functions imported from other library files. */
-extern void _rl_replace_text ();
-extern void _rl_pop_executing_macro ();
-extern void _rl_set_the_line ();
-extern void _rl_init_argument ();
-
-extern char *xmalloc (), *xrealloc ();
+#include "rlprivate.h"
+#include "xmalloc.h"
 
 /* **************************************************************** */
 /*								    */
@@ -84,7 +68,7 @@ int _rl_allow_pathname_alphabetic_chars = 0;
 static const char *pathname_alphabetic_chars = "/-_=~.#$";
 
 int
-alphabetic (c)
+rl_alphabetic (c)
      int c;
 {
   if (ALPHABETIC (c))
@@ -98,36 +82,36 @@ alphabetic (c)
 int
 _rl_abort_internal ()
 {
-  ding ();
+  rl_ding ();
   rl_clear_message ();
   _rl_init_argument ();
-  rl_pending_input = 0;
+  rl_clear_pending_input ();
 
-  _rl_defining_kbd_macro = 0;
-  while (_rl_executing_macro)
+  RL_UNSETSTATE (RL_STATE_MACRODEF);
+  while (rl_executing_macro)
     _rl_pop_executing_macro ();
 
-  rl_last_func = (Function *)NULL;
+  rl_last_func = (rl_command_func_t *)NULL;
   longjmp (readline_top_level, 1);
   return (0);
 }
 
 int
-rl_abort (int count __attribute__((unused)),
-	  int key __attribute__((unused)))
+rl_abort (count, key)
+     int count __attribute__((unused)), key __attribute__((unused));
 {
   return (_rl_abort_internal ());
 }
 
 int
-rl_tty_status (int count __attribute__((unused)),
-	       int key __attribute__((unused)))
+rl_tty_status (count, key)
+     int count __attribute__((unused)), key __attribute__((unused));
 {
 #if defined (TIOCSTAT)
   ioctl (1, TIOCSTAT, (char *)0);
   rl_refresh_line (count, key);
 #else
-  ding ();
+  rl_ding ();
 #endif
   return 0;
 }
@@ -146,7 +130,7 @@ rl_copy_text (from, to)
     SWAP (from, to);
 
   length = to - from;
-  copy = xmalloc (1 + length);
+  copy = (char *)xmalloc (1 + length);
   strncpy (copy, rl_line_buffer + from, length);
   copy[length] = '\0';
   return (copy);
@@ -161,7 +145,7 @@ rl_extend_line_buffer (len)
   while (len >= rl_line_buffer_len)
     {
       rl_line_buffer_len += DEFAULT_BUFFER_SIZE;
-      rl_line_buffer = xrealloc (rl_line_buffer, rl_line_buffer_len);
+      rl_line_buffer = (char *)xrealloc (rl_line_buffer, rl_line_buffer_len);
     }
 
   _rl_set_the_line ();
@@ -170,8 +154,8 @@ rl_extend_line_buffer (len)
 
 /* A function for simple tilde expansion. */
 int
-rl_tilde_expand (int ignore __attribute__((unused)),
-		 int key __attribute__((unused)))
+rl_tilde_expand (ignore, key)
+     int ignore __attribute__((unused)), key __attribute__((unused));
 {
   register int start, end;
   char *homedir, *temp;
@@ -207,7 +191,7 @@ rl_tilde_expand (int ignore __attribute__((unused)),
   if (rl_line_buffer[start] == '~')
     {
       len = end - start + 1;
-      temp = xmalloc (len + 1);
+      temp = (char *)xmalloc (len + 1);
       strncpy (temp, rl_line_buffer + start, len);
       temp[len] = '\0';
       homedir = tilde_expand (temp);
@@ -229,16 +213,51 @@ rl_tilde_expand (int ignore __attribute__((unused)),
    match in s1.  The compare is case insensitive. */
 char *
 _rl_strindex (s1, s2)
-     register char *s1, *s2;
+     register const char *s1, *s2;
 {
   register int i, l, len;
 
   for (i = 0, l = strlen (s2), len = strlen (s1); (len - i) >= l; i++)
     if (_rl_strnicmp (s1 + i, s2, l) == 0)
-      return (s1 + i);
+      return ((char *) (s1 + i));
   return ((char *)NULL);
 }
 
+#ifndef HAVE_STRPBRK
+/* Find the first occurrence in STRING1 of any character from STRING2.
+   Return a pointer to the character in STRING1. */
+char *
+_rl_strpbrk (string1, string2)
+     const char *string1, *string2;
+{
+  register const char *scan;
+#if defined (HANDLE_MULTIBYTE)
+  mbstate_t ps;
+  register int i, v;
+
+  memset (&ps, 0, sizeof (mbstate_t));
+#endif
+
+  for (; *string1; string1++)
+    {
+      for (scan = string2; *scan; scan++)
+	{
+	  if (*string1 == *scan)
+	    return ((char *)string1);
+	}
+#if defined (HANDLE_MULTIBYTE)
+      if (MB_CUR_MAX > 1 && rl_byte_oriented == 0)
+	{
+	  v = _rl_get_char_len (string1, &ps);
+	  if (v > 1)
+	    string += v - 1;	/* -1 to account for auto-increment in loop */
+	}
+#endif
+    }
+  return ((char *)NULL);
+}
+#endif
+
 #if !defined (HAVE_STRCASECMP)
 /* Compare at most COUNT characters from string1 to string2.  Case
    doesn't matter. */
@@ -297,69 +316,23 @@ _rl_qsort_string_compare (s1, s2)
 #endif
 }
 
-/* Function equivalents for the macros defined in chartypes.h. */
-#undef _rl_uppercase_p
-int
-_rl_uppercase_p (c)
-     int c;
-{
-  return (isupper (c));
-}
-
-#undef _rl_lowercase_p
-int
-_rl_lowercase_p (c)
-     int c;
-{
-  return (islower (c));
-}
+/* Function equivalents for the macros defined in chardefs.h. */
+#define FUNCTION_FOR_MACRO(f)	int (f) (c) int c; { return f (c); }
 
-#undef _rl_pure_alphabetic
-int
-_rl_pure_alphabetic (c)
-     int c;
-{
-  return (isupper (c) || islower (c));
-}
-
-#undef _rl_digit_p
-int
-_rl_digit_p (c)
-     int c;
-{
-  return (isdigit (c));
-}
-
-#undef _rl_to_lower
-int
-_rl_to_lower (c)
-     int c;
-{
-  return (isupper (c) ? tolower (c) : c);
-}
-
-#undef _rl_to_upper
-int
-_rl_to_upper (c)
-     int c;
-{
-  return (islower (c) ? toupper (c) : c);
-}
-
-#undef _rl_digit_value
-int
-_rl_digit_value (c)
-     int c;
-{
-  return (isdigit (c) ? c - '0' : c);
-}
+FUNCTION_FOR_MACRO (_rl_digit_p)
+FUNCTION_FOR_MACRO (_rl_digit_value)
+FUNCTION_FOR_MACRO (_rl_lowercase_p)
+FUNCTION_FOR_MACRO (_rl_pure_alphabetic)
+FUNCTION_FOR_MACRO (_rl_to_lower)
+FUNCTION_FOR_MACRO (_rl_to_upper)
+FUNCTION_FOR_MACRO (_rl_uppercase_p)
 
 /* Backwards compatibility, now that savestring has been removed from
    all `public' readline header files. */
 #undef _rl_savestring
 char *
 _rl_savestring (s)
-     char *s;
+     const char *s;
 {
-  return ((char *)strcpy (xmalloc (1 + (int)strlen (s)), (s)));
+  return (strcpy ((char *)xmalloc (1 + (int)strlen (s)), (s)));
 }
diff --git a/readline/vi_keymap.c b/readline/vi_keymap.c
index 14929a319303c79c6acc59e6e95f76bbea51863b..53a67c674ce0c1fa90e3cc28d593d0b036a833cb 100644
--- a/readline/vi_keymap.c
+++ b/readline/vi_keymap.c
@@ -7,7 +7,7 @@
 
    The GNU Readline Library is free software; you can redistribute it
    and/or modify it under the terms of the GNU General Public License
-   as published by the Free Software Foundation; either version 1, or
+   as published by the Free Software Foundation; either version 2, or
    (at your option) any later version.
 
    The GNU Readline Library is distributed in the hope that it will be
@@ -18,7 +18,7 @@
    The GNU General Public License is often shipped with GNU software, and
    is generally kept in a file called COPYING or LICENSE.  If you do not
    have a copy of the license, write to the Free Software Foundation,
-   675 Mass Ave, Cambridge, MA 02139, USA. */
+   59 Temple Place, Suite 330, Boston, MA 02111 USA. */
 
 #if !defined (BUFSIZ)
 #include <stdio.h>
@@ -33,429 +33,429 @@ extern KEYMAP_ENTRY_ARRAY vi_escape_keymap;
 /* The keymap arrays for handling vi mode. */
 KEYMAP_ENTRY_ARRAY vi_movement_keymap = {
   /* The regular control keys come first. */
-  { ISFUNC, (Function *)0x0 },		/* Control-@ */
-  { ISFUNC, (Function *)0x0 },		/* Control-a */
-  { ISFUNC, (Function *)0x0 },		/* Control-b */
-  { ISFUNC, (Function *)0x0 },		/* Control-c */
-  { ISFUNC, rl_vi_eof_maybe },		/* Control-d */
-  { ISFUNC, rl_emacs_editing_mode },	/* Control-e */
-  { ISFUNC, (Function *)0x0 },		/* Control-f */
-  { ISFUNC, rl_abort },			/* Control-g */
-  { ISFUNC, rl_backward },		/* Control-h */
-  { ISFUNC, (Function *)0x0 },		/* Control-i */
-  { ISFUNC, rl_newline },		/* Control-j */
-  { ISFUNC, rl_kill_line },		/* Control-k */
-  { ISFUNC, rl_clear_screen },		/* Control-l */
-  { ISFUNC, rl_newline },		/* Control-m */
-  { ISFUNC, rl_get_next_history },	/* Control-n */
-  { ISFUNC, (Function *)0x0 },		/* Control-o */
-  { ISFUNC, rl_get_previous_history },	/* Control-p */
-  { ISFUNC, rl_quoted_insert },		/* Control-q */
-  { ISFUNC, rl_reverse_search_history }, /* Control-r */
-  { ISFUNC, rl_forward_search_history }, /* Control-s */
-  { ISFUNC, rl_transpose_chars },	/* Control-t */
-  { ISFUNC, rl_unix_line_discard },	/* Control-u */
-  { ISFUNC, rl_quoted_insert },		/* Control-v */
-  { ISFUNC, rl_unix_word_rubout },	/* Control-w */
-  { ISFUNC, (Function *)0x0 },		/* Control-x */
-  { ISFUNC, rl_yank },			/* Control-y */
-  { ISFUNC, (Function *)0x0 },		/* Control-z */
-
-  { ISFUNC, (Function *)0x0 },		/* Control-[ */	/* vi_escape_keymap */
-  { ISFUNC, (Function *)0x0 },		/* Control-\ */
-  { ISFUNC, (Function *)0x0 },		/* Control-] */
-  { ISFUNC, (Function *)0x0 },		/* Control-^ */
-  { ISFUNC, rl_vi_undo },		/* Control-_ */
+  { ISFUNC, (rl_command_func_t *)0x0 },		/* Control-@ */
+  { ISFUNC, (rl_command_func_t *)0x0 },		/* Control-a */
+  { ISFUNC, (rl_command_func_t *)0x0 },		/* Control-b */
+  { ISFUNC, (rl_command_func_t *)0x0 },		/* Control-c */
+  { ISFUNC, rl_vi_eof_maybe },			/* Control-d */
+  { ISFUNC, rl_emacs_editing_mode },		/* Control-e */
+  { ISFUNC, (rl_command_func_t *)0x0 },		/* Control-f */
+  { ISFUNC, rl_abort },				/* Control-g */
+  { ISFUNC, rl_backward_char },			/* Control-h */
+  { ISFUNC, (rl_command_func_t *)0x0 },		/* Control-i */
+  { ISFUNC, rl_newline },			/* Control-j */
+  { ISFUNC, rl_kill_line },			/* Control-k */
+  { ISFUNC, rl_clear_screen },			/* Control-l */
+  { ISFUNC, rl_newline },			/* Control-m */
+  { ISFUNC, rl_get_next_history },		/* Control-n */
+  { ISFUNC, (rl_command_func_t *)0x0 },		/* Control-o */
+  { ISFUNC, rl_get_previous_history },		/* Control-p */
+  { ISFUNC, rl_quoted_insert },			/* Control-q */
+  { ISFUNC, rl_reverse_search_history },	/* Control-r */
+  { ISFUNC, rl_forward_search_history },	/* Control-s */
+  { ISFUNC, rl_transpose_chars },		/* Control-t */
+  { ISFUNC, rl_unix_line_discard },		/* Control-u */
+  { ISFUNC, rl_quoted_insert },			/* Control-v */
+  { ISFUNC, rl_unix_word_rubout },		/* Control-w */
+  { ISFUNC, (rl_command_func_t *)0x0 },		/* Control-x */
+  { ISFUNC, rl_yank },				/* Control-y */
+  { ISFUNC, (rl_command_func_t *)0x0 },		/* Control-z */
+
+  { ISFUNC, (rl_command_func_t *)0x0 },		/* Control-[ */	/* vi_escape_keymap */
+  { ISFUNC, (rl_command_func_t *)0x0 },		/* Control-\ */
+  { ISFUNC, (rl_command_func_t *)0x0 },		/* Control-] */
+  { ISFUNC, (rl_command_func_t *)0x0 },		/* Control-^ */
+  { ISFUNC, rl_vi_undo },			/* Control-_ */
 
   /* The start of printing characters. */
-  { ISFUNC, rl_forward },		/* SPACE */
-  { ISFUNC, (Function *)0x0 },		/* ! */
-  { ISFUNC, (Function *)0x0 },		/* " */
-  { ISFUNC, rl_insert_comment },	/* # */
-  { ISFUNC, rl_end_of_line },		/* $ */
-  { ISFUNC, rl_vi_match },		/* % */
-  { ISFUNC, rl_vi_tilde_expand },	/* & */
-  { ISFUNC, (Function *)0x0 },		/* ' */
-  { ISFUNC, (Function *)0x0 },		/* ( */
-  { ISFUNC, (Function *)0x0 },		/* ) */
-  { ISFUNC, rl_vi_complete },		/* * */
-  { ISFUNC, rl_get_next_history},	/* + */
-  { ISFUNC, rl_vi_char_search },	/* , */
-  { ISFUNC, rl_get_previous_history },	/* - */
-  { ISFUNC, rl_vi_redo },		/* . */
-  { ISFUNC, rl_vi_search },		/* / */
+  { ISFUNC, rl_forward_char },			/* SPACE */
+  { ISFUNC, (rl_command_func_t *)0x0 },		/* ! */
+  { ISFUNC, (rl_command_func_t *)0x0 },		/* " */
+  { ISFUNC, rl_insert_comment },		/* # */
+  { ISFUNC, rl_end_of_line },			/* $ */
+  { ISFUNC, rl_vi_match },			/* % */
+  { ISFUNC, rl_vi_tilde_expand },		/* & */
+  { ISFUNC, (rl_command_func_t *)0x0 },		/* ' */
+  { ISFUNC, (rl_command_func_t *)0x0 },		/* ( */
+  { ISFUNC, (rl_command_func_t *)0x0 },		/* ) */
+  { ISFUNC, rl_vi_complete },			/* * */
+  { ISFUNC, rl_get_next_history},		/* + */
+  { ISFUNC, rl_vi_char_search },		/* , */
+  { ISFUNC, rl_get_previous_history },		/* - */
+  { ISFUNC, rl_vi_redo },			/* . */
+  { ISFUNC, rl_vi_search },			/* / */
 
   /* Regular digits. */
-  { ISFUNC, rl_beg_of_line },		/* 0 */
-  { ISFUNC, rl_vi_arg_digit },		/* 1 */
-  { ISFUNC, rl_vi_arg_digit },		/* 2 */
-  { ISFUNC, rl_vi_arg_digit },		/* 3 */
-  { ISFUNC, rl_vi_arg_digit },		/* 4 */
-  { ISFUNC, rl_vi_arg_digit },		/* 5 */
-  { ISFUNC, rl_vi_arg_digit },		/* 6 */
-  { ISFUNC, rl_vi_arg_digit },		/* 7 */
-  { ISFUNC, rl_vi_arg_digit },		/* 8 */
-  { ISFUNC, rl_vi_arg_digit },		/* 9 */
+  { ISFUNC, rl_beg_of_line },			/* 0 */
+  { ISFUNC, rl_vi_arg_digit },			/* 1 */
+  { ISFUNC, rl_vi_arg_digit },			/* 2 */
+  { ISFUNC, rl_vi_arg_digit },			/* 3 */
+  { ISFUNC, rl_vi_arg_digit },			/* 4 */
+  { ISFUNC, rl_vi_arg_digit },			/* 5 */
+  { ISFUNC, rl_vi_arg_digit },			/* 6 */
+  { ISFUNC, rl_vi_arg_digit },			/* 7 */
+  { ISFUNC, rl_vi_arg_digit },			/* 8 */
+  { ISFUNC, rl_vi_arg_digit },			/* 9 */
 
   /* A little more punctuation. */
-  { ISFUNC, (Function *)0x0 },		/* : */
-  { ISFUNC, rl_vi_char_search },	/* ; */
-  { ISFUNC, (Function *)0x0 },		/* < */
-  { ISFUNC, rl_vi_complete },		/* = */
-  { ISFUNC, (Function *)0x0 },		/* > */
-  { ISFUNC, rl_vi_search },		/* ? */
-  { ISFUNC, (Function *)0x0 },		/* @ */
+  { ISFUNC, (rl_command_func_t *)0x0 },		/* : */
+  { ISFUNC, rl_vi_char_search },		/* ; */
+  { ISFUNC, (rl_command_func_t *)0x0 },		/* < */
+  { ISFUNC, rl_vi_complete },			/* = */
+  { ISFUNC, (rl_command_func_t *)0x0 },		/* > */
+  { ISFUNC, rl_vi_search },			/* ? */
+  { ISFUNC, (rl_command_func_t *)0x0 },		/* @ */
 
   /* Uppercase alphabet. */
-  { ISFUNC, rl_vi_append_eol },		/* A */
-  { ISFUNC, rl_vi_prev_word},		/* B */
-  { ISFUNC, rl_vi_change_to },		/* C */
-  { ISFUNC, rl_vi_delete_to },		/* D */
-  { ISFUNC, rl_vi_end_word },		/* E */
-  { ISFUNC, rl_vi_char_search },	/* F */
-  { ISFUNC, rl_vi_fetch_history },	/* G */
-  { ISFUNC, (Function *)0x0 },		/* H */
-  { ISFUNC, rl_vi_insert_beg },		/* I */
-  { ISFUNC, (Function *)0x0 },		/* J */
-  { ISFUNC, (Function *)0x0 },		/* K */
-  { ISFUNC, (Function *)0x0 },		/* L */
-  { ISFUNC, (Function *)0x0 },		/* M */
-  { ISFUNC, rl_vi_search_again },	/* N */
-  { ISFUNC, (Function *)0x0 },		/* O */
-  { ISFUNC, rl_vi_put },		/* P */
-  { ISFUNC, (Function *)0x0 },		/* Q */
-  { ISFUNC, rl_vi_replace },		/* R */
-  { ISFUNC, rl_vi_subst },		/* S */
-  { ISFUNC, rl_vi_char_search },	/* T */
-  { ISFUNC, rl_revert_line },		/* U */
-  { ISFUNC, (Function *)0x0 },		/* V */
-  { ISFUNC, rl_vi_next_word },		/* W */
-  { ISFUNC, rl_rubout },		/* X */
-  { ISFUNC, rl_vi_yank_to },		/* Y */
-  { ISFUNC, (Function *)0x0 },		/* Z */
+  { ISFUNC, rl_vi_append_eol },			/* A */
+  { ISFUNC, rl_vi_prev_word},			/* B */
+  { ISFUNC, rl_vi_change_to },			/* C */
+  { ISFUNC, rl_vi_delete_to },			/* D */
+  { ISFUNC, rl_vi_end_word },			/* E */
+  { ISFUNC, rl_vi_char_search },		/* F */
+  { ISFUNC, rl_vi_fetch_history },		/* G */
+  { ISFUNC, (rl_command_func_t *)0x0 },		/* H */
+  { ISFUNC, rl_vi_insert_beg },			/* I */
+  { ISFUNC, (rl_command_func_t *)0x0 },		/* J */
+  { ISFUNC, (rl_command_func_t *)0x0 },		/* K */
+  { ISFUNC, (rl_command_func_t *)0x0 },		/* L */
+  { ISFUNC, (rl_command_func_t *)0x0 },		/* M */
+  { ISFUNC, rl_vi_search_again },		/* N */
+  { ISFUNC, (rl_command_func_t *)0x0 },		/* O */
+  { ISFUNC, rl_vi_put },			/* P */
+  { ISFUNC, (rl_command_func_t *)0x0 },		/* Q */
+  { ISFUNC, rl_vi_replace },			/* R */
+  { ISFUNC, rl_vi_subst },			/* S */
+  { ISFUNC, rl_vi_char_search },		/* T */
+  { ISFUNC, rl_revert_line },			/* U */
+  { ISFUNC, (rl_command_func_t *)0x0 },		/* V */
+  { ISFUNC, rl_vi_next_word },			/* W */
+  { ISFUNC, rl_rubout },			/* X */
+  { ISFUNC, rl_vi_yank_to },			/* Y */
+  { ISFUNC, (rl_command_func_t *)0x0 },		/* Z */
 
   /* Some more punctuation. */
-  { ISFUNC, (Function *)0x0 },		/* [ */
-  { ISFUNC, rl_vi_complete },		/* \ */
-  { ISFUNC, (Function *)0x0 },		/* ] */
-  { ISFUNC, rl_vi_first_print },	/* ^ */
-  { ISFUNC, rl_vi_yank_arg },		/* _ */
-  { ISFUNC, rl_vi_goto_mark },		/* ` */
+  { ISFUNC, (rl_command_func_t *)0x0 },		/* [ */
+  { ISFUNC, rl_vi_complete },			/* \ */
+  { ISFUNC, (rl_command_func_t *)0x0 },		/* ] */
+  { ISFUNC, rl_vi_first_print },		/* ^ */
+  { ISFUNC, rl_vi_yank_arg },			/* _ */
+  { ISFUNC, rl_vi_goto_mark },			/* ` */
 
   /* Lowercase alphabet. */
-  { ISFUNC, rl_vi_append_mode },	/* a */
-  { ISFUNC, rl_vi_prev_word },		/* b */
-  { ISFUNC, rl_vi_change_to },		/* c */
-  { ISFUNC, rl_vi_delete_to },		/* d */
-  { ISFUNC, rl_vi_end_word },		/* e */
-  { ISFUNC, rl_vi_char_search },	/* f */
-  { ISFUNC, (Function *)0x0 },		/* g */
-  { ISFUNC, rl_backward },		/* h */
-  { ISFUNC, rl_vi_insertion_mode },	/* i */
-  { ISFUNC, rl_get_next_history },	/* j */
-  { ISFUNC, rl_get_previous_history },	/* k */
-  { ISFUNC, rl_forward },		/* l */
-  { ISFUNC, rl_vi_set_mark },		/* m */
-  { ISFUNC, rl_vi_search_again },	/* n */
-  { ISFUNC, (Function *)0x0 },		/* o */
-  { ISFUNC, rl_vi_put },		/* p */
-  { ISFUNC, (Function *)0x0 },		/* q */
-  { ISFUNC, rl_vi_change_char },	/* r */
-  { ISFUNC, rl_vi_subst },		/* s */
-  { ISFUNC, rl_vi_char_search },	/* t */
-  { ISFUNC, rl_vi_undo },		/* u */
-  { ISFUNC, (Function *)0x0 },		/* v */
-  { ISFUNC, rl_vi_next_word },		/* w */
-  { ISFUNC, rl_vi_delete },		/* x */
-  { ISFUNC, rl_vi_yank_to },		/* y */
-  { ISFUNC, (Function *)0x0 },		/* z */
+  { ISFUNC, rl_vi_append_mode },		/* a */
+  { ISFUNC, rl_vi_prev_word },			/* b */
+  { ISFUNC, rl_vi_change_to },			/* c */
+  { ISFUNC, rl_vi_delete_to },			/* d */
+  { ISFUNC, rl_vi_end_word },			/* e */
+  { ISFUNC, rl_vi_char_search },		/* f */
+  { ISFUNC, (rl_command_func_t *)0x0 },		/* g */
+  { ISFUNC, rl_backward_char },			/* h */
+  { ISFUNC, rl_vi_insertion_mode },		/* i */
+  { ISFUNC, rl_get_next_history },		/* j */
+  { ISFUNC, rl_get_previous_history },		/* k */
+  { ISFUNC, rl_forward_char },			/* l */
+  { ISFUNC, rl_vi_set_mark },			/* m */
+  { ISFUNC, rl_vi_search_again },		/* n */
+  { ISFUNC, (rl_command_func_t *)0x0 },		/* o */
+  { ISFUNC, rl_vi_put },			/* p */
+  { ISFUNC, (rl_command_func_t *)0x0 },		/* q */
+  { ISFUNC, rl_vi_change_char },		/* r */
+  { ISFUNC, rl_vi_subst },			/* s */
+  { ISFUNC, rl_vi_char_search },		/* t */
+  { ISFUNC, rl_vi_undo },			/* u */
+  { ISFUNC, (rl_command_func_t *)0x0 },		/* v */
+  { ISFUNC, rl_vi_next_word },			/* w */
+  { ISFUNC, rl_vi_delete },			/* x */
+  { ISFUNC, rl_vi_yank_to },			/* y */
+  { ISFUNC, (rl_command_func_t *)0x0 },		/* z */
 
   /* Final punctuation. */
-  { ISFUNC, (Function *)0x0 },		/* { */
-  { ISFUNC, rl_vi_column },		/* | */
-  { ISFUNC, (Function *)0x0 },		/* } */
-  { ISFUNC, rl_vi_change_case },	/* ~ */
-  { ISFUNC, (Function *)0x0 },		/* RUBOUT */
+  { ISFUNC, (rl_command_func_t *)0x0 },		/* { */
+  { ISFUNC, rl_vi_column },			/* | */
+  { ISFUNC, (rl_command_func_t *)0x0 },		/* } */
+  { ISFUNC, rl_vi_change_case },		/* ~ */
+  { ISFUNC, (rl_command_func_t *)0x0 },		/* RUBOUT */
 
 #if KEYMAP_SIZE > 128
   /* Undefined keys. */
-  { ISFUNC, (Function *)0x0 },
-  { ISFUNC, (Function *)0x0 },
-  { ISFUNC, (Function *)0x0 },
-  { ISFUNC, (Function *)0x0 },
-  { ISFUNC, (Function *)0x0 },
-  { ISFUNC, (Function *)0x0 },
-  { ISFUNC, (Function *)0x0 },
-  { ISFUNC, (Function *)0x0 },
-  { ISFUNC, (Function *)0x0 },
-  { ISFUNC, (Function *)0x0 },
-  { ISFUNC, (Function *)0x0 },
-  { ISFUNC, (Function *)0x0 },
-  { ISFUNC, (Function *)0x0 },
-  { ISFUNC, (Function *)0x0 },
-  { ISFUNC, (Function *)0x0 },
-  { ISFUNC, (Function *)0x0 },
-  { ISFUNC, (Function *)0x0 },
-  { ISFUNC, (Function *)0x0 },
-  { ISFUNC, (Function *)0x0 },
-  { ISFUNC, (Function *)0x0 },
-  { ISFUNC, (Function *)0x0 },
-  { ISFUNC, (Function *)0x0 },
-  { ISFUNC, (Function *)0x0 },
-  { ISFUNC, (Function *)0x0 },
-  { ISFUNC, (Function *)0x0 },
-  { ISFUNC, (Function *)0x0 },
-  { ISFUNC, (Function *)0x0 },
-  { ISFUNC, (Function *)0x0 },
-  { ISFUNC, (Function *)0x0 },
-  { ISFUNC, (Function *)0x0 },
-  { ISFUNC, (Function *)0x0 },
-  { ISFUNC, (Function *)0x0 },
-  { ISFUNC, (Function *)0x0 },
-  { ISFUNC, (Function *)0x0 },
-  { ISFUNC, (Function *)0x0 },
-  { ISFUNC, (Function *)0x0 },
-  { ISFUNC, (Function *)0x0 },
-  { ISFUNC, (Function *)0x0 },
-  { ISFUNC, (Function *)0x0 },
-  { ISFUNC, (Function *)0x0 },
-  { ISFUNC, (Function *)0x0 },
-  { ISFUNC, (Function *)0x0 },
-  { ISFUNC, (Function *)0x0 },
-  { ISFUNC, (Function *)0x0 },
-  { ISFUNC, (Function *)0x0 },
-  { ISFUNC, (Function *)0x0 },
-  { ISFUNC, (Function *)0x0 },
-  { ISFUNC, (Function *)0x0 },
-  { ISFUNC, (Function *)0x0 },
-  { ISFUNC, (Function *)0x0 },
-  { ISFUNC, (Function *)0x0 },
-  { ISFUNC, (Function *)0x0 },
-  { ISFUNC, (Function *)0x0 },
-  { ISFUNC, (Function *)0x0 },
-  { ISFUNC, (Function *)0x0 },
-  { ISFUNC, (Function *)0x0 },
-  { ISFUNC, (Function *)0x0 },
-  { ISFUNC, (Function *)0x0 },
-  { ISFUNC, (Function *)0x0 },
-  { ISFUNC, (Function *)0x0 },
-  { ISFUNC, (Function *)0x0 },
-  { ISFUNC, (Function *)0x0 },
-  { ISFUNC, (Function *)0x0 },
-  { ISFUNC, (Function *)0x0 },
-  { ISFUNC, (Function *)0x0 },
-  { ISFUNC, (Function *)0x0 },
-  { ISFUNC, (Function *)0x0 },
-  { ISFUNC, (Function *)0x0 },
-  { ISFUNC, (Function *)0x0 },
-  { ISFUNC, (Function *)0x0 },
-  { ISFUNC, (Function *)0x0 },
-  { ISFUNC, (Function *)0x0 },
-  { ISFUNC, (Function *)0x0 },
-  { ISFUNC, (Function *)0x0 },
-  { ISFUNC, (Function *)0x0 },
-  { ISFUNC, (Function *)0x0 },
-  { ISFUNC, (Function *)0x0 },
-  { ISFUNC, (Function *)0x0 },
-  { ISFUNC, (Function *)0x0 },
-  { ISFUNC, (Function *)0x0 },
-  { ISFUNC, (Function *)0x0 },
-  { ISFUNC, (Function *)0x0 },
-  { ISFUNC, (Function *)0x0 },
-  { ISFUNC, (Function *)0x0 },
-  { ISFUNC, (Function *)0x0 },
-  { ISFUNC, (Function *)0x0 },
-  { ISFUNC, (Function *)0x0 },
-  { ISFUNC, (Function *)0x0 },
-  { ISFUNC, (Function *)0x0 },
-  { ISFUNC, (Function *)0x0 },
-  { ISFUNC, (Function *)0x0 },
-  { ISFUNC, (Function *)0x0 },
-  { ISFUNC, (Function *)0x0 },
-  { ISFUNC, (Function *)0x0 },
-  { ISFUNC, (Function *)0x0 },
-  { ISFUNC, (Function *)0x0 },
-  { ISFUNC, (Function *)0x0 },
-  { ISFUNC, (Function *)0x0 },
-  { ISFUNC, (Function *)0x0 },
-  { ISFUNC, (Function *)0x0 },
-  { ISFUNC, (Function *)0x0 },
-  { ISFUNC, (Function *)0x0 },
-  { ISFUNC, (Function *)0x0 },
-  { ISFUNC, (Function *)0x0 },
-  { ISFUNC, (Function *)0x0 },
-  { ISFUNC, (Function *)0x0 },
-  { ISFUNC, (Function *)0x0 },
-  { ISFUNC, (Function *)0x0 },
-  { ISFUNC, (Function *)0x0 },
-  { ISFUNC, (Function *)0x0 },
-  { ISFUNC, (Function *)0x0 },
-  { ISFUNC, (Function *)0x0 },
-  { ISFUNC, (Function *)0x0 },
-  { ISFUNC, (Function *)0x0 },
-  { ISFUNC, (Function *)0x0 },
-  { ISFUNC, (Function *)0x0 },
-  { ISFUNC, (Function *)0x0 },
-  { ISFUNC, (Function *)0x0 },
-  { ISFUNC, (Function *)0x0 },
-  { ISFUNC, (Function *)0x0 },
-  { ISFUNC, (Function *)0x0 },
-  { ISFUNC, (Function *)0x0 },
-  { ISFUNC, (Function *)0x0 },
-  { ISFUNC, (Function *)0x0 },
-  { ISFUNC, (Function *)0x0 },
-  { ISFUNC, (Function *)0x0 },
-  { ISFUNC, (Function *)0x0 },
-  { ISFUNC, (Function *)0x0 }
+  { ISFUNC, (rl_command_func_t *)0x0 },
+  { ISFUNC, (rl_command_func_t *)0x0 },
+  { ISFUNC, (rl_command_func_t *)0x0 },
+  { ISFUNC, (rl_command_func_t *)0x0 },
+  { ISFUNC, (rl_command_func_t *)0x0 },
+  { ISFUNC, (rl_command_func_t *)0x0 },
+  { ISFUNC, (rl_command_func_t *)0x0 },
+  { ISFUNC, (rl_command_func_t *)0x0 },
+  { ISFUNC, (rl_command_func_t *)0x0 },
+  { ISFUNC, (rl_command_func_t *)0x0 },
+  { ISFUNC, (rl_command_func_t *)0x0 },
+  { ISFUNC, (rl_command_func_t *)0x0 },
+  { ISFUNC, (rl_command_func_t *)0x0 },
+  { ISFUNC, (rl_command_func_t *)0x0 },
+  { ISFUNC, (rl_command_func_t *)0x0 },
+  { ISFUNC, (rl_command_func_t *)0x0 },
+  { ISFUNC, (rl_command_func_t *)0x0 },
+  { ISFUNC, (rl_command_func_t *)0x0 },
+  { ISFUNC, (rl_command_func_t *)0x0 },
+  { ISFUNC, (rl_command_func_t *)0x0 },
+  { ISFUNC, (rl_command_func_t *)0x0 },
+  { ISFUNC, (rl_command_func_t *)0x0 },
+  { ISFUNC, (rl_command_func_t *)0x0 },
+  { ISFUNC, (rl_command_func_t *)0x0 },
+  { ISFUNC, (rl_command_func_t *)0x0 },
+  { ISFUNC, (rl_command_func_t *)0x0 },
+  { ISFUNC, (rl_command_func_t *)0x0 },
+  { ISFUNC, (rl_command_func_t *)0x0 },
+  { ISFUNC, (rl_command_func_t *)0x0 },
+  { ISFUNC, (rl_command_func_t *)0x0 },
+  { ISFUNC, (rl_command_func_t *)0x0 },
+  { ISFUNC, (rl_command_func_t *)0x0 },
+  { ISFUNC, (rl_command_func_t *)0x0 },
+  { ISFUNC, (rl_command_func_t *)0x0 },
+  { ISFUNC, (rl_command_func_t *)0x0 },
+  { ISFUNC, (rl_command_func_t *)0x0 },
+  { ISFUNC, (rl_command_func_t *)0x0 },
+  { ISFUNC, (rl_command_func_t *)0x0 },
+  { ISFUNC, (rl_command_func_t *)0x0 },
+  { ISFUNC, (rl_command_func_t *)0x0 },
+  { ISFUNC, (rl_command_func_t *)0x0 },
+  { ISFUNC, (rl_command_func_t *)0x0 },
+  { ISFUNC, (rl_command_func_t *)0x0 },
+  { ISFUNC, (rl_command_func_t *)0x0 },
+  { ISFUNC, (rl_command_func_t *)0x0 },
+  { ISFUNC, (rl_command_func_t *)0x0 },
+  { ISFUNC, (rl_command_func_t *)0x0 },
+  { ISFUNC, (rl_command_func_t *)0x0 },
+  { ISFUNC, (rl_command_func_t *)0x0 },
+  { ISFUNC, (rl_command_func_t *)0x0 },
+  { ISFUNC, (rl_command_func_t *)0x0 },
+  { ISFUNC, (rl_command_func_t *)0x0 },
+  { ISFUNC, (rl_command_func_t *)0x0 },
+  { ISFUNC, (rl_command_func_t *)0x0 },
+  { ISFUNC, (rl_command_func_t *)0x0 },
+  { ISFUNC, (rl_command_func_t *)0x0 },
+  { ISFUNC, (rl_command_func_t *)0x0 },
+  { ISFUNC, (rl_command_func_t *)0x0 },
+  { ISFUNC, (rl_command_func_t *)0x0 },
+  { ISFUNC, (rl_command_func_t *)0x0 },
+  { ISFUNC, (rl_command_func_t *)0x0 },
+  { ISFUNC, (rl_command_func_t *)0x0 },
+  { ISFUNC, (rl_command_func_t *)0x0 },
+  { ISFUNC, (rl_command_func_t *)0x0 },
+  { ISFUNC, (rl_command_func_t *)0x0 },
+  { ISFUNC, (rl_command_func_t *)0x0 },
+  { ISFUNC, (rl_command_func_t *)0x0 },
+  { ISFUNC, (rl_command_func_t *)0x0 },
+  { ISFUNC, (rl_command_func_t *)0x0 },
+  { ISFUNC, (rl_command_func_t *)0x0 },
+  { ISFUNC, (rl_command_func_t *)0x0 },
+  { ISFUNC, (rl_command_func_t *)0x0 },
+  { ISFUNC, (rl_command_func_t *)0x0 },
+  { ISFUNC, (rl_command_func_t *)0x0 },
+  { ISFUNC, (rl_command_func_t *)0x0 },
+  { ISFUNC, (rl_command_func_t *)0x0 },
+  { ISFUNC, (rl_command_func_t *)0x0 },
+  { ISFUNC, (rl_command_func_t *)0x0 },
+  { ISFUNC, (rl_command_func_t *)0x0 },
+  { ISFUNC, (rl_command_func_t *)0x0 },
+  { ISFUNC, (rl_command_func_t *)0x0 },
+  { ISFUNC, (rl_command_func_t *)0x0 },
+  { ISFUNC, (rl_command_func_t *)0x0 },
+  { ISFUNC, (rl_command_func_t *)0x0 },
+  { ISFUNC, (rl_command_func_t *)0x0 },
+  { ISFUNC, (rl_command_func_t *)0x0 },
+  { ISFUNC, (rl_command_func_t *)0x0 },
+  { ISFUNC, (rl_command_func_t *)0x0 },
+  { ISFUNC, (rl_command_func_t *)0x0 },
+  { ISFUNC, (rl_command_func_t *)0x0 },
+  { ISFUNC, (rl_command_func_t *)0x0 },
+  { ISFUNC, (rl_command_func_t *)0x0 },
+  { ISFUNC, (rl_command_func_t *)0x0 },
+  { ISFUNC, (rl_command_func_t *)0x0 },
+  { ISFUNC, (rl_command_func_t *)0x0 },
+  { ISFUNC, (rl_command_func_t *)0x0 },
+  { ISFUNC, (rl_command_func_t *)0x0 },
+  { ISFUNC, (rl_command_func_t *)0x0 },
+  { ISFUNC, (rl_command_func_t *)0x0 },
+  { ISFUNC, (rl_command_func_t *)0x0 },
+  { ISFUNC, (rl_command_func_t *)0x0 },
+  { ISFUNC, (rl_command_func_t *)0x0 },
+  { ISFUNC, (rl_command_func_t *)0x0 },
+  { ISFUNC, (rl_command_func_t *)0x0 },
+  { ISFUNC, (rl_command_func_t *)0x0 },
+  { ISFUNC, (rl_command_func_t *)0x0 },
+  { ISFUNC, (rl_command_func_t *)0x0 },
+  { ISFUNC, (rl_command_func_t *)0x0 },
+  { ISFUNC, (rl_command_func_t *)0x0 },
+  { ISFUNC, (rl_command_func_t *)0x0 },
+  { ISFUNC, (rl_command_func_t *)0x0 },
+  { ISFUNC, (rl_command_func_t *)0x0 },
+  { ISFUNC, (rl_command_func_t *)0x0 },
+  { ISFUNC, (rl_command_func_t *)0x0 },
+  { ISFUNC, (rl_command_func_t *)0x0 },
+  { ISFUNC, (rl_command_func_t *)0x0 },
+  { ISFUNC, (rl_command_func_t *)0x0 },
+  { ISFUNC, (rl_command_func_t *)0x0 },
+  { ISFUNC, (rl_command_func_t *)0x0 },
+  { ISFUNC, (rl_command_func_t *)0x0 },
+  { ISFUNC, (rl_command_func_t *)0x0 },
+  { ISFUNC, (rl_command_func_t *)0x0 },
+  { ISFUNC, (rl_command_func_t *)0x0 },
+  { ISFUNC, (rl_command_func_t *)0x0 },
+  { ISFUNC, (rl_command_func_t *)0x0 },
+  { ISFUNC, (rl_command_func_t *)0x0 },
+  { ISFUNC, (rl_command_func_t *)0x0 },
+  { ISFUNC, (rl_command_func_t *)0x0 }
 #endif /* KEYMAP_SIZE > 128 */
 };
 
 
 KEYMAP_ENTRY_ARRAY vi_insertion_keymap = {
   /* The regular control keys come first. */
-  { ISFUNC, (Function *)0x0 },		/* Control-@ */
-  { ISFUNC, rl_insert },		/* Control-a */
-  { ISFUNC, rl_insert },		/* Control-b */
-  { ISFUNC, rl_insert },		/* Control-c */
-  { ISFUNC, rl_vi_eof_maybe },		/* Control-d */
-  { ISFUNC, rl_insert },		/* Control-e */
-  { ISFUNC, rl_insert },		/* Control-f */
-  { ISFUNC, rl_insert },		/* Control-g */
-  { ISFUNC, rl_rubout },		/* Control-h */
-  { ISFUNC, rl_complete },		/* Control-i */
-  { ISFUNC, rl_newline },		/* Control-j */
-  { ISFUNC, rl_insert },		/* Control-k */
-  { ISFUNC, rl_insert },		/* Control-l */
-  { ISFUNC, rl_newline },		/* Control-m */
-  { ISFUNC, rl_insert },		/* Control-n */
-  { ISFUNC, rl_insert },		/* Control-o */
-  { ISFUNC, rl_insert },		/* Control-p */
-  { ISFUNC, rl_insert },		/* Control-q */
-  { ISFUNC, rl_reverse_search_history }, /* Control-r */
-  { ISFUNC, rl_forward_search_history }, /* Control-s */
-  { ISFUNC, rl_transpose_chars },	/* Control-t */
-  { ISFUNC, rl_unix_line_discard },	/* Control-u */
-  { ISFUNC, rl_quoted_insert },		/* Control-v */
-  { ISFUNC, rl_unix_word_rubout },	/* Control-w */
-  { ISFUNC, rl_insert },		/* Control-x */
-  { ISFUNC, rl_yank },			/* Control-y */
-  { ISFUNC, rl_insert },		/* Control-z */
-
-  { ISFUNC, rl_vi_movement_mode },	/* Control-[ */
-  { ISFUNC, rl_insert },		/* Control-\ */
-  { ISFUNC, rl_insert },		/* Control-] */
-  { ISFUNC, rl_insert },		/* Control-^ */
-  { ISFUNC, rl_vi_undo },		/* Control-_ */
+  { ISFUNC, (rl_command_func_t *)0x0 },		/* Control-@ */
+  { ISFUNC, rl_insert },			/* Control-a */
+  { ISFUNC, rl_insert },			/* Control-b */
+  { ISFUNC, rl_insert },			/* Control-c */
+  { ISFUNC, rl_vi_eof_maybe },			/* Control-d */
+  { ISFUNC, rl_insert },			/* Control-e */
+  { ISFUNC, rl_insert },			/* Control-f */
+  { ISFUNC, rl_insert },			/* Control-g */
+  { ISFUNC, rl_rubout },			/* Control-h */
+  { ISFUNC, rl_complete },			/* Control-i */
+  { ISFUNC, rl_newline },			/* Control-j */
+  { ISFUNC, rl_insert },			/* Control-k */
+  { ISFUNC, rl_insert },			/* Control-l */
+  { ISFUNC, rl_newline },			/* Control-m */
+  { ISFUNC, rl_insert },			/* Control-n */
+  { ISFUNC, rl_insert },			/* Control-o */
+  { ISFUNC, rl_insert },			/* Control-p */
+  { ISFUNC, rl_insert },			/* Control-q */
+  { ISFUNC, rl_reverse_search_history },	/* Control-r */
+  { ISFUNC, rl_forward_search_history },	/* Control-s */
+  { ISFUNC, rl_transpose_chars },		/* Control-t */
+  { ISFUNC, rl_unix_line_discard },		/* Control-u */
+  { ISFUNC, rl_quoted_insert },			/* Control-v */
+  { ISFUNC, rl_unix_word_rubout },		/* Control-w */
+  { ISFUNC, rl_insert },			/* Control-x */
+  { ISFUNC, rl_yank },				/* Control-y */
+  { ISFUNC, rl_insert },			/* Control-z */
+
+  { ISFUNC, rl_vi_movement_mode },		/* Control-[ */
+  { ISFUNC, rl_insert },			/* Control-\ */
+  { ISFUNC, rl_insert },			/* Control-] */
+  { ISFUNC, rl_insert },			/* Control-^ */
+  { ISFUNC, rl_vi_undo },			/* Control-_ */
 
   /* The start of printing characters. */
-  { ISFUNC, rl_insert },		/* SPACE */
-  { ISFUNC, rl_insert },		/* ! */
-  { ISFUNC, rl_insert },		/* " */
-  { ISFUNC, rl_insert },		/* # */
-  { ISFUNC, rl_insert },		/* $ */
-  { ISFUNC, rl_insert },		/* % */
-  { ISFUNC, rl_insert },		/* & */
-  { ISFUNC, rl_insert },		/* ' */
-  { ISFUNC, rl_insert },		/* ( */
-  { ISFUNC, rl_insert },		/* ) */
-  { ISFUNC, rl_insert },		/* * */
-  { ISFUNC, rl_insert },		/* + */
-  { ISFUNC, rl_insert },		/* , */
-  { ISFUNC, rl_insert },		/* - */
-  { ISFUNC, rl_insert },		/* . */
-  { ISFUNC, rl_insert },		/* / */
+  { ISFUNC, rl_insert },			/* SPACE */
+  { ISFUNC, rl_insert },			/* ! */
+  { ISFUNC, rl_insert },			/* " */
+  { ISFUNC, rl_insert },			/* # */
+  { ISFUNC, rl_insert },			/* $ */
+  { ISFUNC, rl_insert },			/* % */
+  { ISFUNC, rl_insert },			/* & */
+  { ISFUNC, rl_insert },			/* ' */
+  { ISFUNC, rl_insert },			/* ( */
+  { ISFUNC, rl_insert },			/* ) */
+  { ISFUNC, rl_insert },			/* * */
+  { ISFUNC, rl_insert },			/* + */
+  { ISFUNC, rl_insert },			/* , */
+  { ISFUNC, rl_insert },			/* - */
+  { ISFUNC, rl_insert },			/* . */
+  { ISFUNC, rl_insert },			/* / */
 
   /* Regular digits. */
-  { ISFUNC, rl_insert },		/* 0 */
-  { ISFUNC, rl_insert },		/* 1 */
-  { ISFUNC, rl_insert },		/* 2 */
-  { ISFUNC, rl_insert },		/* 3 */
-  { ISFUNC, rl_insert },		/* 4 */
-  { ISFUNC, rl_insert },		/* 5 */
-  { ISFUNC, rl_insert },		/* 6 */
-  { ISFUNC, rl_insert },		/* 7 */
-  { ISFUNC, rl_insert },		/* 8 */
-  { ISFUNC, rl_insert },		/* 9 */
+  { ISFUNC, rl_insert },			/* 0 */
+  { ISFUNC, rl_insert },			/* 1 */
+  { ISFUNC, rl_insert },			/* 2 */
+  { ISFUNC, rl_insert },			/* 3 */
+  { ISFUNC, rl_insert },			/* 4 */
+  { ISFUNC, rl_insert },			/* 5 */
+  { ISFUNC, rl_insert },			/* 6 */
+  { ISFUNC, rl_insert },			/* 7 */
+  { ISFUNC, rl_insert },			/* 8 */
+  { ISFUNC, rl_insert },			/* 9 */
 
   /* A little more punctuation. */
-  { ISFUNC, rl_insert },		/* : */
-  { ISFUNC, rl_insert },		/* ; */
-  { ISFUNC, rl_insert },		/* < */
-  { ISFUNC, rl_insert },		/* = */
-  { ISFUNC, rl_insert },		/* > */
-  { ISFUNC, rl_insert },		/* ? */
-  { ISFUNC, rl_insert },		/* @ */
+  { ISFUNC, rl_insert },			/* : */
+  { ISFUNC, rl_insert },			/* ; */
+  { ISFUNC, rl_insert },			/* < */
+  { ISFUNC, rl_insert },			/* = */
+  { ISFUNC, rl_insert },			/* > */
+  { ISFUNC, rl_insert },			/* ? */
+  { ISFUNC, rl_insert },			/* @ */
 
   /* Uppercase alphabet. */
-  { ISFUNC, rl_insert },		/* A */
-  { ISFUNC, rl_insert },		/* B */
-  { ISFUNC, rl_insert },		/* C */
-  { ISFUNC, rl_insert },		/* D */
-  { ISFUNC, rl_insert },		/* E */
-  { ISFUNC, rl_insert },		/* F */
-  { ISFUNC, rl_insert },		/* G */
-  { ISFUNC, rl_insert },		/* H */
-  { ISFUNC, rl_insert },		/* I */
-  { ISFUNC, rl_insert },		/* J */
-  { ISFUNC, rl_insert },		/* K */
-  { ISFUNC, rl_insert },		/* L */
-  { ISFUNC, rl_insert },		/* M */
-  { ISFUNC, rl_insert },		/* N */
-  { ISFUNC, rl_insert },		/* O */
-  { ISFUNC, rl_insert },		/* P */
-  { ISFUNC, rl_insert },		/* Q */
-  { ISFUNC, rl_insert },		/* R */
-  { ISFUNC, rl_insert },		/* S */
-  { ISFUNC, rl_insert },		/* T */
-  { ISFUNC, rl_insert },		/* U */
-  { ISFUNC, rl_insert },		/* V */
-  { ISFUNC, rl_insert },		/* W */
-  { ISFUNC, rl_insert },		/* X */
-  { ISFUNC, rl_insert },		/* Y */
-  { ISFUNC, rl_insert },		/* Z */
+  { ISFUNC, rl_insert },			/* A */
+  { ISFUNC, rl_insert },			/* B */
+  { ISFUNC, rl_insert },			/* C */
+  { ISFUNC, rl_insert },			/* D */
+  { ISFUNC, rl_insert },			/* E */
+  { ISFUNC, rl_insert },			/* F */
+  { ISFUNC, rl_insert },			/* G */
+  { ISFUNC, rl_insert },			/* H */
+  { ISFUNC, rl_insert },			/* I */
+  { ISFUNC, rl_insert },			/* J */
+  { ISFUNC, rl_insert },			/* K */
+  { ISFUNC, rl_insert },			/* L */
+  { ISFUNC, rl_insert },			/* M */
+  { ISFUNC, rl_insert },			/* N */
+  { ISFUNC, rl_insert },			/* O */
+  { ISFUNC, rl_insert },			/* P */
+  { ISFUNC, rl_insert },			/* Q */
+  { ISFUNC, rl_insert },			/* R */
+  { ISFUNC, rl_insert },			/* S */
+  { ISFUNC, rl_insert },			/* T */
+  { ISFUNC, rl_insert },			/* U */
+  { ISFUNC, rl_insert },			/* V */
+  { ISFUNC, rl_insert },			/* W */
+  { ISFUNC, rl_insert },			/* X */
+  { ISFUNC, rl_insert },			/* Y */
+  { ISFUNC, rl_insert },			/* Z */
 
   /* Some more punctuation. */
-  { ISFUNC, rl_insert },		/* [ */
-  { ISFUNC, rl_insert },		/* \ */
-  { ISFUNC, rl_insert },		/* ] */
-  { ISFUNC, rl_insert },		/* ^ */
-  { ISFUNC, rl_insert },		/* _ */
-  { ISFUNC, rl_insert },		/* ` */
+  { ISFUNC, rl_insert },			/* [ */
+  { ISFUNC, rl_insert },			/* \ */
+  { ISFUNC, rl_insert },			/* ] */
+  { ISFUNC, rl_insert },			/* ^ */
+  { ISFUNC, rl_insert },			/* _ */
+  { ISFUNC, rl_insert },			/* ` */
 
   /* Lowercase alphabet. */
-  { ISFUNC, rl_insert },		/* a */
-  { ISFUNC, rl_insert },		/* b */
-  { ISFUNC, rl_insert },		/* c */
-  { ISFUNC, rl_insert },		/* d */
-  { ISFUNC, rl_insert },		/* e */
-  { ISFUNC, rl_insert },		/* f */
-  { ISFUNC, rl_insert },		/* g */
-  { ISFUNC, rl_insert },		/* h */
-  { ISFUNC, rl_insert },		/* i */
-  { ISFUNC, rl_insert },		/* j */
-  { ISFUNC, rl_insert },		/* k */
-  { ISFUNC, rl_insert },		/* l */
-  { ISFUNC, rl_insert },		/* m */
-  { ISFUNC, rl_insert },		/* n */
-  { ISFUNC, rl_insert },		/* o */
-  { ISFUNC, rl_insert },		/* p */
-  { ISFUNC, rl_insert },		/* q */
-  { ISFUNC, rl_insert },		/* r */
-  { ISFUNC, rl_insert },		/* s */
-  { ISFUNC, rl_insert },		/* t */
-  { ISFUNC, rl_insert },		/* u */
-  { ISFUNC, rl_insert },		/* v */
-  { ISFUNC, rl_insert },		/* w */
-  { ISFUNC, rl_insert },		/* x */
-  { ISFUNC, rl_insert },		/* y */
-  { ISFUNC, rl_insert },		/* z */
+  { ISFUNC, rl_insert },			/* a */
+  { ISFUNC, rl_insert },			/* b */
+  { ISFUNC, rl_insert },			/* c */
+  { ISFUNC, rl_insert },			/* d */
+  { ISFUNC, rl_insert },			/* e */
+  { ISFUNC, rl_insert },			/* f */
+  { ISFUNC, rl_insert },			/* g */
+  { ISFUNC, rl_insert },			/* h */
+  { ISFUNC, rl_insert },			/* i */
+  { ISFUNC, rl_insert },			/* j */
+  { ISFUNC, rl_insert },			/* k */
+  { ISFUNC, rl_insert },			/* l */
+  { ISFUNC, rl_insert },			/* m */
+  { ISFUNC, rl_insert },			/* n */
+  { ISFUNC, rl_insert },			/* o */
+  { ISFUNC, rl_insert },			/* p */
+  { ISFUNC, rl_insert },			/* q */
+  { ISFUNC, rl_insert },			/* r */
+  { ISFUNC, rl_insert },			/* s */
+  { ISFUNC, rl_insert },			/* t */
+  { ISFUNC, rl_insert },			/* u */
+  { ISFUNC, rl_insert },			/* v */
+  { ISFUNC, rl_insert },			/* w */
+  { ISFUNC, rl_insert },			/* x */
+  { ISFUNC, rl_insert },			/* y */
+  { ISFUNC, rl_insert },			/* z */
 
   /* Final punctuation. */
-  { ISFUNC, rl_insert },		/* { */
-  { ISFUNC, rl_insert },		/* | */
-  { ISFUNC, rl_insert },		/* } */
-  { ISFUNC, rl_insert },		/* ~ */
-  { ISFUNC, rl_rubout },		/* RUBOUT */
+  { ISFUNC, rl_insert },			/* { */
+  { ISFUNC, rl_insert },			/* | */
+  { ISFUNC, rl_insert },			/* } */
+  { ISFUNC, rl_insert },			/* ~ */
+  { ISFUNC, rl_rubout },			/* RUBOUT */
 
 #if KEYMAP_SIZE > 128
   /* Pure 8-bit characters (128 - 159).
@@ -598,280 +598,280 @@ KEYMAP_ENTRY_ARRAY vi_insertion_keymap = {
 #if 0
 KEYMAP_ENTRY_ARRAY vi_escape_keymap = {
   /* The regular control keys come first. */
-  { ISFUNC, (Function *)0x0 },		/* Control-@ */
-  { ISFUNC, (Function *)0x0 },		/* Control-a */
-  { ISFUNC, (Function *)0x0 },		/* Control-b */
-  { ISFUNC, (Function *)0x0 },		/* Control-c */
-  { ISFUNC, (Function *)0x0 },		/* Control-d */
-  { ISFUNC, (Function *)0x0 },		/* Control-e */
-  { ISFUNC, (Function *)0x0 },		/* Control-f */
-  { ISFUNC, (Function *)0x0 },		/* Control-g */
-  { ISFUNC, (Function *)0x0 },		/* Control-h */
-  { ISFUNC, rl_tab_insert},		/* Control-i */
-  { ISFUNC, rl_emacs_editing_mode},	/* Control-j */
-  { ISFUNC, rl_kill_line },		/* Control-k */
-  { ISFUNC, (Function *)0x0 },		/* Control-l */
-  { ISFUNC, rl_emacs_editing_mode},	/* Control-m */
-  { ISFUNC, (Function *)0x0 },		/* Control-n */
-  { ISFUNC, (Function *)0x0 },		/* Control-o */
-  { ISFUNC, (Function *)0x0 },		/* Control-p */
-  { ISFUNC, (Function *)0x0 },		/* Control-q */
-  { ISFUNC, (Function *)0x0 },		/* Control-r */
-  { ISFUNC, (Function *)0x0 },		/* Control-s */
-  { ISFUNC, (Function *)0x0 },		/* Control-t */
-  { ISFUNC, (Function *)0x0 },		/* Control-u */
-  { ISFUNC, (Function *)0x0 },		/* Control-v */
-  { ISFUNC, (Function *)0x0 },		/* Control-w */
-  { ISFUNC, (Function *)0x0 },		/* Control-x */
-  { ISFUNC, (Function *)0x0 },		/* Control-y */
-  { ISFUNC, (Function *)0x0 },		/* Control-z */
-
-  { ISFUNC, rl_vi_movement_mode },	/* Control-[ */
-  { ISFUNC, (Function *)0x0 },		/* Control-\ */
-  { ISFUNC, (Function *)0x0 },		/* Control-] */
-  { ISFUNC, (Function *)0x0 },		/* Control-^ */
-  { ISFUNC, rl_vi_undo },		/* Control-_ */
+  { ISFUNC, (rl_command_func_t *)0x0 },		/* Control-@ */
+  { ISFUNC, (rl_command_func_t *)0x0 },		/* Control-a */
+  { ISFUNC, (rl_command_func_t *)0x0 },		/* Control-b */
+  { ISFUNC, (rl_command_func_t *)0x0 },		/* Control-c */
+  { ISFUNC, (rl_command_func_t *)0x0 },		/* Control-d */
+  { ISFUNC, (rl_command_func_t *)0x0 },		/* Control-e */
+  { ISFUNC, (rl_command_func_t *)0x0 },		/* Control-f */
+  { ISFUNC, (rl_command_func_t *)0x0 },		/* Control-g */
+  { ISFUNC, (rl_command_func_t *)0x0 },		/* Control-h */
+  { ISFUNC, rl_tab_insert},			/* Control-i */
+  { ISFUNC, rl_emacs_editing_mode},		/* Control-j */
+  { ISFUNC, rl_kill_line },			/* Control-k */
+  { ISFUNC, (rl_command_func_t *)0x0 },		/* Control-l */
+  { ISFUNC, rl_emacs_editing_mode},		/* Control-m */
+  { ISFUNC, (rl_command_func_t *)0x0 },		/* Control-n */
+  { ISFUNC, (rl_command_func_t *)0x0 },		/* Control-o */
+  { ISFUNC, (rl_command_func_t *)0x0 },		/* Control-p */
+  { ISFUNC, (rl_command_func_t *)0x0 },		/* Control-q */
+  { ISFUNC, (rl_command_func_t *)0x0 },		/* Control-r */
+  { ISFUNC, (rl_command_func_t *)0x0 },		/* Control-s */
+  { ISFUNC, (rl_command_func_t *)0x0 },		/* Control-t */
+  { ISFUNC, (rl_command_func_t *)0x0 },		/* Control-u */
+  { ISFUNC, (rl_command_func_t *)0x0 },		/* Control-v */
+  { ISFUNC, (rl_command_func_t *)0x0 },		/* Control-w */
+  { ISFUNC, (rl_command_func_t *)0x0 },		/* Control-x */
+  { ISFUNC, (rl_command_func_t *)0x0 },		/* Control-y */
+  { ISFUNC, (rl_command_func_t *)0x0 },		/* Control-z */
+
+  { ISFUNC, rl_vi_movement_mode },		/* Control-[ */
+  { ISFUNC, (rl_command_func_t *)0x0 },		/* Control-\ */
+  { ISFUNC, (rl_command_func_t *)0x0 },		/* Control-] */
+  { ISFUNC, (rl_command_func_t *)0x0 },		/* Control-^ */
+  { ISFUNC, rl_vi_undo },			/* Control-_ */
 
   /* The start of printing characters. */
-  { ISFUNC, (Function *)0x0 },		/* SPACE */
-  { ISFUNC, (Function *)0x0 },		/* ! */
-  { ISFUNC, (Function *)0x0 },		/* " */
-  { ISFUNC, (Function *)0x0 },		/* # */
-  { ISFUNC, (Function *)0x0 },		/* $ */
-  { ISFUNC, (Function *)0x0 },		/* % */
-  { ISFUNC, (Function *)0x0 },		/* & */
-  { ISFUNC, (Function *)0x0 },		/* ' */
-  { ISFUNC, (Function *)0x0 },		/* ( */
-  { ISFUNC, (Function *)0x0 },		/* ) */
-  { ISFUNC, (Function *)0x0 },		/* * */
-  { ISFUNC, (Function *)0x0 },		/* + */
-  { ISFUNC, (Function *)0x0 },		/* , */
-  { ISFUNC, (Function *)0x0 },		/* - */
-  { ISFUNC, (Function *)0x0 },		/* . */
-  { ISFUNC, (Function *)0x0 },		/* / */
+  { ISFUNC, (rl_command_func_t *)0x0 },		/* SPACE */
+  { ISFUNC, (rl_command_func_t *)0x0 },		/* ! */
+  { ISFUNC, (rl_command_func_t *)0x0 },		/* " */
+  { ISFUNC, (rl_command_func_t *)0x0 },		/* # */
+  { ISFUNC, (rl_command_func_t *)0x0 },		/* $ */
+  { ISFUNC, (rl_command_func_t *)0x0 },		/* % */
+  { ISFUNC, (rl_command_func_t *)0x0 },		/* & */
+  { ISFUNC, (rl_command_func_t *)0x0 },		/* ' */
+  { ISFUNC, (rl_command_func_t *)0x0 },		/* ( */
+  { ISFUNC, (rl_command_func_t *)0x0 },		/* ) */
+  { ISFUNC, (rl_command_func_t *)0x0 },		/* * */
+  { ISFUNC, (rl_command_func_t *)0x0 },		/* + */
+  { ISFUNC, (rl_command_func_t *)0x0 },		/* , */
+  { ISFUNC, (rl_command_func_t *)0x0 },		/* - */
+  { ISFUNC, (rl_command_func_t *)0x0 },		/* . */
+  { ISFUNC, (rl_command_func_t *)0x0 },		/* / */
 
   /* Regular digits. */
-  { ISFUNC, rl_vi_arg_digit },		/* 0 */
-  { ISFUNC, rl_vi_arg_digit },		/* 1 */
-  { ISFUNC, rl_vi_arg_digit },		/* 2 */
-  { ISFUNC, rl_vi_arg_digit },		/* 3 */
-  { ISFUNC, rl_vi_arg_digit },		/* 4 */
-  { ISFUNC, rl_vi_arg_digit },		/* 5 */
-  { ISFUNC, rl_vi_arg_digit },		/* 6 */
-  { ISFUNC, rl_vi_arg_digit },		/* 7 */
-  { ISFUNC, rl_vi_arg_digit },		/* 8 */
-  { ISFUNC, rl_vi_arg_digit },		/* 9 */
+  { ISFUNC, rl_vi_arg_digit },			/* 0 */
+  { ISFUNC, rl_vi_arg_digit },			/* 1 */
+  { ISFUNC, rl_vi_arg_digit },			/* 2 */
+  { ISFUNC, rl_vi_arg_digit },			/* 3 */
+  { ISFUNC, rl_vi_arg_digit },			/* 4 */
+  { ISFUNC, rl_vi_arg_digit },			/* 5 */
+  { ISFUNC, rl_vi_arg_digit },			/* 6 */
+  { ISFUNC, rl_vi_arg_digit },			/* 7 */
+  { ISFUNC, rl_vi_arg_digit },			/* 8 */
+  { ISFUNC, rl_vi_arg_digit },			/* 9 */
 
   /* A little more punctuation. */
-  { ISFUNC, (Function *)0x0 },		/* : */
-  { ISFUNC, (Function *)0x0 },		/* ; */
-  { ISFUNC, (Function *)0x0 },		/* < */
-  { ISFUNC, (Function *)0x0 },		/* = */
-  { ISFUNC, (Function *)0x0 },		/* > */
-  { ISFUNC, (Function *)0x0 },		/* ? */
-  { ISFUNC, (Function *)0x0 },		/* @ */
+  { ISFUNC, (rl_command_func_t *)0x0 },		/* : */
+  { ISFUNC, (rl_command_func_t *)0x0 },		/* ; */
+  { ISFUNC, (rl_command_func_t *)0x0 },		/* < */
+  { ISFUNC, (rl_command_func_t *)0x0 },		/* = */
+  { ISFUNC, (rl_command_func_t *)0x0 },		/* > */
+  { ISFUNC, (rl_command_func_t *)0x0 },		/* ? */
+  { ISFUNC, (rl_command_func_t *)0x0 },		/* @ */
 
   /* Uppercase alphabet. */
-  { ISFUNC, rl_do_lowercase_version },	/* A */
-  { ISFUNC, rl_do_lowercase_version },	/* B */
-  { ISFUNC, rl_do_lowercase_version },	/* C */
-  { ISFUNC, rl_do_lowercase_version },	/* D */
-  { ISFUNC, rl_do_lowercase_version },	/* E */
-  { ISFUNC, rl_do_lowercase_version },	/* F */
-  { ISFUNC, rl_do_lowercase_version },	/* G */
-  { ISFUNC, rl_do_lowercase_version },	/* H */
-  { ISFUNC, rl_do_lowercase_version },	/* I */
-  { ISFUNC, rl_do_lowercase_version },	/* J */
-  { ISFUNC, rl_do_lowercase_version },	/* K */
-  { ISFUNC, rl_do_lowercase_version },	/* L */
-  { ISFUNC, rl_do_lowercase_version },	/* M */
-  { ISFUNC, rl_do_lowercase_version },	/* N */
-  { ISFUNC, rl_do_lowercase_version },	/* O */
-  { ISFUNC, rl_do_lowercase_version },	/* P */
-  { ISFUNC, rl_do_lowercase_version },	/* Q */
-  { ISFUNC, rl_do_lowercase_version },	/* R */
-  { ISFUNC, rl_do_lowercase_version },	/* S */
-  { ISFUNC, rl_do_lowercase_version },	/* T */
-  { ISFUNC, rl_do_lowercase_version },	/* U */
-  { ISFUNC, rl_do_lowercase_version },	/* V */
-  { ISFUNC, rl_do_lowercase_version },	/* W */
-  { ISFUNC, rl_do_lowercase_version },	/* X */
-  { ISFUNC, rl_do_lowercase_version },	/* Y */
-  { ISFUNC, rl_do_lowercase_version },	/* Z */
+  { ISFUNC, rl_do_lowercase_version },		/* A */
+  { ISFUNC, rl_do_lowercase_version },		/* B */
+  { ISFUNC, rl_do_lowercase_version },		/* C */
+  { ISFUNC, rl_do_lowercase_version },		/* D */
+  { ISFUNC, rl_do_lowercase_version },		/* E */
+  { ISFUNC, rl_do_lowercase_version },		/* F */
+  { ISFUNC, rl_do_lowercase_version },		/* G */
+  { ISFUNC, rl_do_lowercase_version },		/* H */
+  { ISFUNC, rl_do_lowercase_version },		/* I */
+  { ISFUNC, rl_do_lowercase_version },		/* J */
+  { ISFUNC, rl_do_lowercase_version },		/* K */
+  { ISFUNC, rl_do_lowercase_version },		/* L */
+  { ISFUNC, rl_do_lowercase_version },		/* M */
+  { ISFUNC, rl_do_lowercase_version },		/* N */
+  { ISFUNC, rl_do_lowercase_version },		/* O */
+  { ISFUNC, rl_do_lowercase_version },		/* P */
+  { ISFUNC, rl_do_lowercase_version },		/* Q */
+  { ISFUNC, rl_do_lowercase_version },		/* R */
+  { ISFUNC, rl_do_lowercase_version },		/* S */
+  { ISFUNC, rl_do_lowercase_version },		/* T */
+  { ISFUNC, rl_do_lowercase_version },		/* U */
+  { ISFUNC, rl_do_lowercase_version },		/* V */
+  { ISFUNC, rl_do_lowercase_version },		/* W */
+  { ISFUNC, rl_do_lowercase_version },		/* X */
+  { ISFUNC, rl_do_lowercase_version },		/* Y */
+  { ISFUNC, rl_do_lowercase_version },		/* Z */
 
   /* Some more punctuation. */
-  { ISFUNC, rl_arrow_keys },		/* [ */
-  { ISFUNC, (Function *)0x0 },		/* \ */
-  { ISFUNC, (Function *)0x0 },		/* ] */
-  { ISFUNC, (Function *)0x0 },		/* ^ */
-  { ISFUNC, (Function *)0x0 },		/* _ */
-  { ISFUNC, (Function *)0x0 },		/* ` */
+  { ISFUNC, rl_arrow_keys },			/* [ */
+  { ISFUNC, (rl_command_func_t *)0x0 },		/* \ */
+  { ISFUNC, (rl_command_func_t *)0x0 },		/* ] */
+  { ISFUNC, (rl_command_func_t *)0x0 },		/* ^ */
+  { ISFUNC, (rl_command_func_t *)0x0 },		/* _ */
+  { ISFUNC, (rl_command_func_t *)0x0 },		/* ` */
 
   /* Lowercase alphabet. */
-  { ISFUNC, (Function *)0x0 },		/* a */
-  { ISFUNC, (Function *)0x0 },		/* b */
-  { ISFUNC, (Function *)0x0 },		/* c */
-  { ISFUNC, (Function *)0x0 },		/* d */
-  { ISFUNC, (Function *)0x0 },		/* e */
-  { ISFUNC, (Function *)0x0 },		/* f */
-  { ISFUNC, (Function *)0x0 },		/* g */
-  { ISFUNC, (Function *)0x0 },		/* h */
-  { ISFUNC, (Function *)0x0 },		/* i */
-  { ISFUNC, (Function *)0x0 },		/* j */
-  { ISFUNC, (Function *)0x0 },		/* k */
-  { ISFUNC, (Function *)0x0 },		/* l */
-  { ISFUNC, (Function *)0x0 },		/* m */
-  { ISFUNC, (Function *)0x0 },		/* n */
-  { ISFUNC, rl_arrow_keys },		/* o */
-  { ISFUNC, (Function *)0x0 },		/* p */
-  { ISFUNC, (Function *)0x0 },		/* q */
-  { ISFUNC, (Function *)0x0 },		/* r */
-  { ISFUNC, (Function *)0x0 },		/* s */
-  { ISFUNC, (Function *)0x0 },		/* t */
-  { ISFUNC, (Function *)0x0 },		/* u */
-  { ISFUNC, (Function *)0x0 },		/* v */
-  { ISFUNC, (Function *)0x0 },		/* w */
-  { ISFUNC, (Function *)0x0 },		/* x */
-  { ISFUNC, (Function *)0x0 },		/* y */
-  { ISFUNC, (Function *)0x0 },		/* z */
+  { ISFUNC, (rl_command_func_t *)0x0 },		/* a */
+  { ISFUNC, (rl_command_func_t *)0x0 },		/* b */
+  { ISFUNC, (rl_command_func_t *)0x0 },		/* c */
+  { ISFUNC, (rl_command_func_t *)0x0 },		/* d */
+  { ISFUNC, (rl_command_func_t *)0x0 },		/* e */
+  { ISFUNC, (rl_command_func_t *)0x0 },		/* f */
+  { ISFUNC, (rl_command_func_t *)0x0 },		/* g */
+  { ISFUNC, (rl_command_func_t *)0x0 },		/* h */
+  { ISFUNC, (rl_command_func_t *)0x0 },		/* i */
+  { ISFUNC, (rl_command_func_t *)0x0 },		/* j */
+  { ISFUNC, (rl_command_func_t *)0x0 },		/* k */
+  { ISFUNC, (rl_command_func_t *)0x0 },		/* l */
+  { ISFUNC, (rl_command_func_t *)0x0 },		/* m */
+  { ISFUNC, (rl_command_func_t *)0x0 },		/* n */
+  { ISFUNC, rl_arrow_keys },			/* o */
+  { ISFUNC, (rl_command_func_t *)0x0 },		/* p */
+  { ISFUNC, (rl_command_func_t *)0x0 },		/* q */
+  { ISFUNC, (rl_command_func_t *)0x0 },		/* r */
+  { ISFUNC, (rl_command_func_t *)0x0 },		/* s */
+  { ISFUNC, (rl_command_func_t *)0x0 },		/* t */
+  { ISFUNC, (rl_command_func_t *)0x0 },		/* u */
+  { ISFUNC, (rl_command_func_t *)0x0 },		/* v */
+  { ISFUNC, (rl_command_func_t *)0x0 },		/* w */
+  { ISFUNC, (rl_command_func_t *)0x0 },		/* x */
+  { ISFUNC, (rl_command_func_t *)0x0 },		/* y */
+  { ISFUNC, (rl_command_func_t *)0x0 },		/* z */
 
   /* Final punctuation. */
-  { ISFUNC, (Function *)0x0 },		/* { */
-  { ISFUNC, (Function *)0x0 },		/* | */
-  { ISFUNC, (Function *)0x0 },		/* } */
-  { ISFUNC, (Function *)0x0 },		/* ~ */
-  { ISFUNC, rl_backward_kill_word },	/* RUBOUT */
+  { ISFUNC, (rl_command_func_t *)0x0 },		/* { */
+  { ISFUNC, (rl_command_func_t *)0x0 },		/* | */
+  { ISFUNC, (rl_command_func_t *)0x0 },		/* } */
+  { ISFUNC, (rl_command_func_t *)0x0 },		/* ~ */
+  { ISFUNC, rl_backward_kill_word },		/* RUBOUT */
 
 #if KEYMAP_SIZE > 128
   /* Undefined keys. */
-  { ISFUNC, (Function *)0x0 },
-  { ISFUNC, (Function *)0x0 },
-  { ISFUNC, (Function *)0x0 },
-  { ISFUNC, (Function *)0x0 },
-  { ISFUNC, (Function *)0x0 },
-  { ISFUNC, (Function *)0x0 },
-  { ISFUNC, (Function *)0x0 },
-  { ISFUNC, (Function *)0x0 },
-  { ISFUNC, (Function *)0x0 },
-  { ISFUNC, (Function *)0x0 },
-  { ISFUNC, (Function *)0x0 },
-  { ISFUNC, (Function *)0x0 },
-  { ISFUNC, (Function *)0x0 },
-  { ISFUNC, (Function *)0x0 },
-  { ISFUNC, (Function *)0x0 },
-  { ISFUNC, (Function *)0x0 },
-  { ISFUNC, (Function *)0x0 },
-  { ISFUNC, (Function *)0x0 },
-  { ISFUNC, (Function *)0x0 },
-  { ISFUNC, (Function *)0x0 },
-  { ISFUNC, (Function *)0x0 },
-  { ISFUNC, (Function *)0x0 },
-  { ISFUNC, (Function *)0x0 },
-  { ISFUNC, (Function *)0x0 },
-  { ISFUNC, (Function *)0x0 },
-  { ISFUNC, (Function *)0x0 },
-  { ISFUNC, (Function *)0x0 },
-  { ISFUNC, (Function *)0x0 },
-  { ISFUNC, (Function *)0x0 },
-  { ISFUNC, (Function *)0x0 },
-  { ISFUNC, (Function *)0x0 },
-  { ISFUNC, (Function *)0x0 },
-  { ISFUNC, (Function *)0x0 },
-  { ISFUNC, (Function *)0x0 },
-  { ISFUNC, (Function *)0x0 },
-  { ISFUNC, (Function *)0x0 },
-  { ISFUNC, (Function *)0x0 },
-  { ISFUNC, (Function *)0x0 },
-  { ISFUNC, (Function *)0x0 },
-  { ISFUNC, (Function *)0x0 },
-  { ISFUNC, (Function *)0x0 },
-  { ISFUNC, (Function *)0x0 },
-  { ISFUNC, (Function *)0x0 },
-  { ISFUNC, (Function *)0x0 },
-  { ISFUNC, (Function *)0x0 },
-  { ISFUNC, (Function *)0x0 },
-  { ISFUNC, (Function *)0x0 },
-  { ISFUNC, (Function *)0x0 },
-  { ISFUNC, (Function *)0x0 },
-  { ISFUNC, (Function *)0x0 },
-  { ISFUNC, (Function *)0x0 },
-  { ISFUNC, (Function *)0x0 },
-  { ISFUNC, (Function *)0x0 },
-  { ISFUNC, (Function *)0x0 },
-  { ISFUNC, (Function *)0x0 },
-  { ISFUNC, (Function *)0x0 },
-  { ISFUNC, (Function *)0x0 },
-  { ISFUNC, (Function *)0x0 },
-  { ISFUNC, (Function *)0x0 },
-  { ISFUNC, (Function *)0x0 },
-  { ISFUNC, (Function *)0x0 },
-  { ISFUNC, (Function *)0x0 },
-  { ISFUNC, (Function *)0x0 },
-  { ISFUNC, (Function *)0x0 },
-  { ISFUNC, (Function *)0x0 },
-  { ISFUNC, (Function *)0x0 },
-  { ISFUNC, (Function *)0x0 },
-  { ISFUNC, (Function *)0x0 },
-  { ISFUNC, (Function *)0x0 },
-  { ISFUNC, (Function *)0x0 },
-  { ISFUNC, (Function *)0x0 },
-  { ISFUNC, (Function *)0x0 },
-  { ISFUNC, (Function *)0x0 },
-  { ISFUNC, (Function *)0x0 },
-  { ISFUNC, (Function *)0x0 },
-  { ISFUNC, (Function *)0x0 },
-  { ISFUNC, (Function *)0x0 },
-  { ISFUNC, (Function *)0x0 },
-  { ISFUNC, (Function *)0x0 },
-  { ISFUNC, (Function *)0x0 },
-  { ISFUNC, (Function *)0x0 },
-  { ISFUNC, (Function *)0x0 },
-  { ISFUNC, (Function *)0x0 },
-  { ISFUNC, (Function *)0x0 },
-  { ISFUNC, (Function *)0x0 },
-  { ISFUNC, (Function *)0x0 },
-  { ISFUNC, (Function *)0x0 },
-  { ISFUNC, (Function *)0x0 },
-  { ISFUNC, (Function *)0x0 },
-  { ISFUNC, (Function *)0x0 },
-  { ISFUNC, (Function *)0x0 },
-  { ISFUNC, (Function *)0x0 },
-  { ISFUNC, (Function *)0x0 },
-  { ISFUNC, (Function *)0x0 },
-  { ISFUNC, (Function *)0x0 },
-  { ISFUNC, (Function *)0x0 },
-  { ISFUNC, (Function *)0x0 },
-  { ISFUNC, (Function *)0x0 },
-  { ISFUNC, (Function *)0x0 },
-  { ISFUNC, (Function *)0x0 },
-  { ISFUNC, (Function *)0x0 },
-  { ISFUNC, (Function *)0x0 },
-  { ISFUNC, (Function *)0x0 },
-  { ISFUNC, (Function *)0x0 },
-  { ISFUNC, (Function *)0x0 },
-  { ISFUNC, (Function *)0x0 },
-  { ISFUNC, (Function *)0x0 },
-  { ISFUNC, (Function *)0x0 },
-  { ISFUNC, (Function *)0x0 },
-  { ISFUNC, (Function *)0x0 },
-  { ISFUNC, (Function *)0x0 },
-  { ISFUNC, (Function *)0x0 },
-  { ISFUNC, (Function *)0x0 },
-  { ISFUNC, (Function *)0x0 },
-  { ISFUNC, (Function *)0x0 },
-  { ISFUNC, (Function *)0x0 },
-  { ISFUNC, (Function *)0x0 },
-  { ISFUNC, (Function *)0x0 },
-  { ISFUNC, (Function *)0x0 },
-  { ISFUNC, (Function *)0x0 },
-  { ISFUNC, (Function *)0x0 },
-  { ISFUNC, (Function *)0x0 },
-  { ISFUNC, (Function *)0x0 },
-  { ISFUNC, (Function *)0x0 },
-  { ISFUNC, (Function *)0x0 },
-  { ISFUNC, (Function *)0x0 },
-  { ISFUNC, (Function *)0x0 },
-  { ISFUNC, (Function *)0x0 }
+  { ISFUNC, (rl_command_func_t *)0x0 },
+  { ISFUNC, (rl_command_func_t *)0x0 },
+  { ISFUNC, (rl_command_func_t *)0x0 },
+  { ISFUNC, (rl_command_func_t *)0x0 },
+  { ISFUNC, (rl_command_func_t *)0x0 },
+  { ISFUNC, (rl_command_func_t *)0x0 },
+  { ISFUNC, (rl_command_func_t *)0x0 },
+  { ISFUNC, (rl_command_func_t *)0x0 },
+  { ISFUNC, (rl_command_func_t *)0x0 },
+  { ISFUNC, (rl_command_func_t *)0x0 },
+  { ISFUNC, (rl_command_func_t *)0x0 },
+  { ISFUNC, (rl_command_func_t *)0x0 },
+  { ISFUNC, (rl_command_func_t *)0x0 },
+  { ISFUNC, (rl_command_func_t *)0x0 },
+  { ISFUNC, (rl_command_func_t *)0x0 },
+  { ISFUNC, (rl_command_func_t *)0x0 },
+  { ISFUNC, (rl_command_func_t *)0x0 },
+  { ISFUNC, (rl_command_func_t *)0x0 },
+  { ISFUNC, (rl_command_func_t *)0x0 },
+  { ISFUNC, (rl_command_func_t *)0x0 },
+  { ISFUNC, (rl_command_func_t *)0x0 },
+  { ISFUNC, (rl_command_func_t *)0x0 },
+  { ISFUNC, (rl_command_func_t *)0x0 },
+  { ISFUNC, (rl_command_func_t *)0x0 },
+  { ISFUNC, (rl_command_func_t *)0x0 },
+  { ISFUNC, (rl_command_func_t *)0x0 },
+  { ISFUNC, (rl_command_func_t *)0x0 },
+  { ISFUNC, (rl_command_func_t *)0x0 },
+  { ISFUNC, (rl_command_func_t *)0x0 },
+  { ISFUNC, (rl_command_func_t *)0x0 },
+  { ISFUNC, (rl_command_func_t *)0x0 },
+  { ISFUNC, (rl_command_func_t *)0x0 },
+  { ISFUNC, (rl_command_func_t *)0x0 },
+  { ISFUNC, (rl_command_func_t *)0x0 },
+  { ISFUNC, (rl_command_func_t *)0x0 },
+  { ISFUNC, (rl_command_func_t *)0x0 },
+  { ISFUNC, (rl_command_func_t *)0x0 },
+  { ISFUNC, (rl_command_func_t *)0x0 },
+  { ISFUNC, (rl_command_func_t *)0x0 },
+  { ISFUNC, (rl_command_func_t *)0x0 },
+  { ISFUNC, (rl_command_func_t *)0x0 },
+  { ISFUNC, (rl_command_func_t *)0x0 },
+  { ISFUNC, (rl_command_func_t *)0x0 },
+  { ISFUNC, (rl_command_func_t *)0x0 },
+  { ISFUNC, (rl_command_func_t *)0x0 },
+  { ISFUNC, (rl_command_func_t *)0x0 },
+  { ISFUNC, (rl_command_func_t *)0x0 },
+  { ISFUNC, (rl_command_func_t *)0x0 },
+  { ISFUNC, (rl_command_func_t *)0x0 },
+  { ISFUNC, (rl_command_func_t *)0x0 },
+  { ISFUNC, (rl_command_func_t *)0x0 },
+  { ISFUNC, (rl_command_func_t *)0x0 },
+  { ISFUNC, (rl_command_func_t *)0x0 },
+  { ISFUNC, (rl_command_func_t *)0x0 },
+  { ISFUNC, (rl_command_func_t *)0x0 },
+  { ISFUNC, (rl_command_func_t *)0x0 },
+  { ISFUNC, (rl_command_func_t *)0x0 },
+  { ISFUNC, (rl_command_func_t *)0x0 },
+  { ISFUNC, (rl_command_func_t *)0x0 },
+  { ISFUNC, (rl_command_func_t *)0x0 },
+  { ISFUNC, (rl_command_func_t *)0x0 },
+  { ISFUNC, (rl_command_func_t *)0x0 },
+  { ISFUNC, (rl_command_func_t *)0x0 },
+  { ISFUNC, (rl_command_func_t *)0x0 },
+  { ISFUNC, (rl_command_func_t *)0x0 },
+  { ISFUNC, (rl_command_func_t *)0x0 },
+  { ISFUNC, (rl_command_func_t *)0x0 },
+  { ISFUNC, (rl_command_func_t *)0x0 },
+  { ISFUNC, (rl_command_func_t *)0x0 },
+  { ISFUNC, (rl_command_func_t *)0x0 },
+  { ISFUNC, (rl_command_func_t *)0x0 },
+  { ISFUNC, (rl_command_func_t *)0x0 },
+  { ISFUNC, (rl_command_func_t *)0x0 },
+  { ISFUNC, (rl_command_func_t *)0x0 },
+  { ISFUNC, (rl_command_func_t *)0x0 },
+  { ISFUNC, (rl_command_func_t *)0x0 },
+  { ISFUNC, (rl_command_func_t *)0x0 },
+  { ISFUNC, (rl_command_func_t *)0x0 },
+  { ISFUNC, (rl_command_func_t *)0x0 },
+  { ISFUNC, (rl_command_func_t *)0x0 },
+  { ISFUNC, (rl_command_func_t *)0x0 },
+  { ISFUNC, (rl_command_func_t *)0x0 },
+  { ISFUNC, (rl_command_func_t *)0x0 },
+  { ISFUNC, (rl_command_func_t *)0x0 },
+  { ISFUNC, (rl_command_func_t *)0x0 },
+  { ISFUNC, (rl_command_func_t *)0x0 },
+  { ISFUNC, (rl_command_func_t *)0x0 },
+  { ISFUNC, (rl_command_func_t *)0x0 },
+  { ISFUNC, (rl_command_func_t *)0x0 },
+  { ISFUNC, (rl_command_func_t *)0x0 },
+  { ISFUNC, (rl_command_func_t *)0x0 },
+  { ISFUNC, (rl_command_func_t *)0x0 },
+  { ISFUNC, (rl_command_func_t *)0x0 },
+  { ISFUNC, (rl_command_func_t *)0x0 },
+  { ISFUNC, (rl_command_func_t *)0x0 },
+  { ISFUNC, (rl_command_func_t *)0x0 },
+  { ISFUNC, (rl_command_func_t *)0x0 },
+  { ISFUNC, (rl_command_func_t *)0x0 },
+  { ISFUNC, (rl_command_func_t *)0x0 },
+  { ISFUNC, (rl_command_func_t *)0x0 },
+  { ISFUNC, (rl_command_func_t *)0x0 },
+  { ISFUNC, (rl_command_func_t *)0x0 },
+  { ISFUNC, (rl_command_func_t *)0x0 },
+  { ISFUNC, (rl_command_func_t *)0x0 },
+  { ISFUNC, (rl_command_func_t *)0x0 },
+  { ISFUNC, (rl_command_func_t *)0x0 },
+  { ISFUNC, (rl_command_func_t *)0x0 },
+  { ISFUNC, (rl_command_func_t *)0x0 },
+  { ISFUNC, (rl_command_func_t *)0x0 },
+  { ISFUNC, (rl_command_func_t *)0x0 },
+  { ISFUNC, (rl_command_func_t *)0x0 },
+  { ISFUNC, (rl_command_func_t *)0x0 },
+  { ISFUNC, (rl_command_func_t *)0x0 },
+  { ISFUNC, (rl_command_func_t *)0x0 },
+  { ISFUNC, (rl_command_func_t *)0x0 },
+  { ISFUNC, (rl_command_func_t *)0x0 },
+  { ISFUNC, (rl_command_func_t *)0x0 },
+  { ISFUNC, (rl_command_func_t *)0x0 },
+  { ISFUNC, (rl_command_func_t *)0x0 },
+  { ISFUNC, (rl_command_func_t *)0x0 },
+  { ISFUNC, (rl_command_func_t *)0x0 },
+  { ISFUNC, (rl_command_func_t *)0x0 },
+  { ISFUNC, (rl_command_func_t *)0x0 },
+  { ISFUNC, (rl_command_func_t *)0x0 },
+  { ISFUNC, (rl_command_func_t *)0x0 },
+  { ISFUNC, (rl_command_func_t *)0x0 },
+  { ISFUNC, (rl_command_func_t *)0x0 },
+  { ISFUNC, (rl_command_func_t *)0x0 }
 #endif /* KEYMAP_SIZE > 128 */
 };
 #endif
diff --git a/readline/vi_mode.c b/readline/vi_mode.c
index eb392b643bae285c093e5d0c44959ce93e29f246..01df589f625bb3c43ed71bbd49f4238ac821645a 100644
--- a/readline/vi_mode.c
+++ b/readline/vi_mode.c
@@ -8,7 +8,7 @@
 
    The GNU Readline Library is free software; you can redistribute it
    and/or modify it under the terms of the GNU General Public License
-   as published by the Free Software Foundation; either version 1, or
+   as published by the Free Software Foundation; either version 2, or
    (at your option) any later version.
 
    The GNU Readline Library is distributed in the hope that it will be
@@ -19,7 +19,7 @@
    The GNU General Public License is often shipped with GNU software, and
    is generally kept in a file called COPYING or LICENSE.  If you do not
    have a copy of the license, write to the Free Software Foundation,
-   675 Mass Ave, Cambridge, MA 02139, USA. */
+   59 Temple Place, Suite 330, Boston, MA 02111 USA. */
 #define READLINE_LIBRARY
 
 /* **************************************************************** */
@@ -51,54 +51,23 @@
 
 /* Some standard library routines. */
 #include "rldefs.h"
+#include "rlmbutil.h"
+
 #include "readline.h"
 #include "history.h"
 
-#ifndef _rl_digit_p
-#define _rl_digit_p(c)  ((c) >= '0' && (c) <= '9')
-#endif
-
-#ifndef _rl_digit_value
-#define _rl_digit_value(c) ((c) - '0')
-#endif
+#include "rlprivate.h"
+#include "xmalloc.h"
 
 #ifndef member
 #define member(c, s) ((c) ? (char *)strchr ((s), (c)) != (char *)NULL : 0)
 #endif
 
-#ifndef isident
-#define isident(c) ((_rl_pure_alphabetic (c) || _rl_digit_p (c) || c == '_'))
-#endif
-
-#ifndef exchange
-#define exchange(x, y) do {int temp = x; x = y; y = temp;} while (0)
-#endif
-
-extern char *xmalloc (), *xrealloc ();
-
-/* Variables imported from readline.c */
-extern int rl_point, rl_end, rl_mark;
-extern FILE *rl_instream;
-extern int rl_line_buffer_len, rl_explicit_arg, rl_numeric_arg;
-extern Keymap _rl_keymap;
-extern char *rl_prompt;
-extern char *rl_line_buffer;
-extern int rl_arg_sign;
-
-extern int _rl_doing_an_undo;
-extern int _rl_undo_group_level;
-
-extern void _rl_dispatch ();
-extern int _rl_char_search_internal ();
-
-extern void rl_extend_line_buffer ();
-extern int rl_vi_check ();
-
 /* Non-zero means enter insertion mode. */
 static int _rl_vi_doing_insert;
 
 /* Command keys which do movement for xxx_to commands. */
-static const char *vi_motion = " hl^$0ftFt;,%wbeWBE|";
+static const char *vi_motion = " hl^$0ftFT;,%wbeWBE|";
 
 /* Keymap used for vi replace characters.  Created dynamically since
    rarely used. */
@@ -118,7 +87,11 @@ static int _rl_vi_last_command = 'i';	/* default `.' puts you in insert mode */
 static int _rl_vi_last_repeat = 1;
 static int _rl_vi_last_arg_sign = 1;
 static int _rl_vi_last_motion;
+#if defined (HANDLE_MULTIBYTE)
+static char _rl_vi_last_search_mbchar[MB_LEN_MAX];
+#else
 static int _rl_vi_last_search_char;
+#endif
 static int _rl_vi_last_replacement;
 
 static int _rl_vi_last_key_before_insert;
@@ -129,20 +102,18 @@ static int vi_redoing;
 static const char *vi_textmod = "_*\\AaIiCcDdPpYyRrSsXx~";
 
 /* Arrays for the saved marks. */
-static int vi_mark_chars[27];
+static int vi_mark_chars['z' - 'a' + 1];
 
-static int rl_digit_loop1 ();
+static void _rl_vi_stuff_insert PARAMS((int));
+static void _rl_vi_save_insert PARAMS((UNDO_LIST *));
+static int rl_digit_loop1 PARAMS((void));
 
 void
 _rl_vi_initialize_line ()
 {
-#ifndef __QNXNTO__
-  register uint i;
-#else
   register unsigned int i;
-#endif
 
-  for (i = 0; i < (int) sizeof (vi_mark_chars) / sizeof (int); i++)
+  for (i = 0; i < sizeof (vi_mark_chars) / sizeof (int); i++)
     vi_mark_chars[i] = -1;
 }
 
@@ -189,12 +160,15 @@ int
 rl_vi_redo (count, c)
      int count, c __attribute__((unused));
 {
+  int r;
+
   if (!rl_explicit_arg)
     {
       rl_numeric_arg = _rl_vi_last_repeat;
       rl_arg_sign = _rl_vi_last_arg_sign;
     }
 
+  r = 0;
   vi_redoing = 1;
   /* If we're redoing an insert with `i', stuff in the inserted text
      and do not go into insertion mode. */
@@ -206,10 +180,10 @@ rl_vi_redo (count, c)
 	rl_point--;
     }
   else
-    _rl_dispatch (_rl_vi_last_command, _rl_keymap);
+    r = _rl_dispatch (_rl_vi_last_command, _rl_keymap);
   vi_redoing = 0;
 
-  return (0);
+  return (r);
 }
 
 /* A placeholder for further expansion. */
@@ -219,10 +193,10 @@ rl_vi_undo (count, key)
 {
   return (rl_undo_command (count, key));
 }
-
+    
 /* Yank the nth arg from the previous line into this line at point. */
 int
-rl_vi_yank_arg (count, key) 
+rl_vi_yank_arg (count, key)
      int count, key __attribute__((unused));
 {
   /* Readline thinks that the first word on a line is the 0th, while vi
@@ -295,7 +269,7 @@ rl_vi_search (count, key)
       break;
 
     default:
-      ding ();
+      rl_ding ();
       break;
     }
   return (0);
@@ -351,7 +325,7 @@ rl_vi_prev_word (count, key)
 
   if (rl_point == 0)
     {
-      ding ();
+      rl_ding ();
       return (0);
     }
 
@@ -373,7 +347,7 @@ rl_vi_next_word (count, key)
 
   if (rl_point >= (rl_end - 1))
     {
-      ding ();
+      rl_ding ();
       return (0);
     }
 
@@ -391,7 +365,7 @@ rl_vi_end_word (count, key)
 {
   if (count < 0)
     {
-      ding ();
+      rl_ding ();
       return -1;
     }
 
@@ -481,14 +455,14 @@ rl_vi_fword (count, ignore)
   while (count-- && rl_point < (rl_end - 1))
     {
       /* Move to white space (really non-identifer). */
-      if (isident (rl_line_buffer[rl_point]))
+      if (_rl_isident (rl_line_buffer[rl_point]))
 	{
-	  while (isident (rl_line_buffer[rl_point]) && rl_point < rl_end)
+	  while (_rl_isident (rl_line_buffer[rl_point]) && rl_point < rl_end)
 	    rl_point++;
 	}
       else /* if (!whitespace (rl_line_buffer[rl_point])) */
 	{
-	  while (!isident (rl_line_buffer[rl_point]) &&
+	  while (!_rl_isident (rl_line_buffer[rl_point]) &&
 		 !whitespace (rl_line_buffer[rl_point]) && rl_point < rl_end)
 	    rl_point++;
 	}
@@ -518,9 +492,9 @@ rl_vi_bword (count, ignore)
 	 back so we don't get messed up by the rl_point++ down there in
 	 the while loop.  Without this code, words like `l;' screw up the
 	 function. */
-      last_is_ident = isident (rl_line_buffer[rl_point - 1]);
-      if ((isident (rl_line_buffer[rl_point]) && !last_is_ident) ||
-	  (!isident (rl_line_buffer[rl_point]) && last_is_ident))
+      last_is_ident = _rl_isident (rl_line_buffer[rl_point - 1]);
+      if ((_rl_isident (rl_line_buffer[rl_point]) && !last_is_ident) ||
+	  (!_rl_isident (rl_line_buffer[rl_point]) && last_is_ident))
 	rl_point--;
 
       while (rl_point > 0 && whitespace (rl_line_buffer[rl_point]))
@@ -528,10 +502,10 @@ rl_vi_bword (count, ignore)
 
       if (rl_point > 0)
 	{
-	  if (isident (rl_line_buffer[rl_point]))
-	    while (--rl_point >= 0 && isident (rl_line_buffer[rl_point]));
+	  if (_rl_isident (rl_line_buffer[rl_point]))
+	    while (--rl_point >= 0 && _rl_isident (rl_line_buffer[rl_point]));
 	  else
-	    while (--rl_point >= 0 && !isident (rl_line_buffer[rl_point]) &&
+	    while (--rl_point >= 0 && !_rl_isident (rl_line_buffer[rl_point]) &&
 		   !whitespace (rl_line_buffer[rl_point]));
 	  rl_point++;
 	}
@@ -553,10 +527,10 @@ rl_vi_eword (count, ignore)
 
       if (rl_point < rl_end)
 	{
-	  if (isident (rl_line_buffer[rl_point]))
-	    while (++rl_point < rl_end && isident (rl_line_buffer[rl_point]));
+	  if (_rl_isident (rl_line_buffer[rl_point]))
+	    while (++rl_point < rl_end && _rl_isident (rl_line_buffer[rl_point]));
 	  else
-	    while (++rl_point < rl_end && !isident (rl_line_buffer[rl_point])
+	    while (++rl_point < rl_end && !_rl_isident (rl_line_buffer[rl_point])
 		   && !whitespace (rl_line_buffer[rl_point]));
 	}
       rl_point--;
@@ -578,7 +552,17 @@ rl_vi_append_mode (count, key)
      int count __attribute__((unused)), key;
 {
   if (rl_point < rl_end)
-    rl_point++;
+    {
+      if (MB_CUR_MAX == 1 || rl_byte_oriented)
+	rl_point++;
+      else
+        {
+          int point = rl_point;
+          rl_forward_char (1, key);
+          if (point == rl_point)
+            rl_point = rl_end;
+        }
+    }
   rl_vi_insertion_mode (1, key);
   return (0);
 }
@@ -632,17 +616,18 @@ _rl_vi_save_insert (up)
   if (len >= vi_insert_buffer_size)
     {
       vi_insert_buffer_size += (len + 32) - (len % 32);
-      vi_insert_buffer = xrealloc (vi_insert_buffer, vi_insert_buffer_size);
+      vi_insert_buffer = (char *)xrealloc (vi_insert_buffer, vi_insert_buffer_size);
     }
   strncpy (vi_insert_buffer, rl_line_buffer + start, len - 1);
   vi_insert_buffer[len-1] = '\0';
 }
-
+    
 void
 _rl_vi_done_inserting ()
 {
   if (_rl_vi_doing_insert)
     {
+      /* The `C', `s', and `S' commands set this. */
       rl_end_undo_group ();
       /* Now, the text between rl_undo_list->next->start and
 	 rl_undo_list->next->end is what was inserted while in insert
@@ -671,7 +656,7 @@ rl_vi_movement_mode (count, key)
      int count __attribute__((unused)), key;
 {
   if (rl_point > 0)
-    rl_backward (1, key);
+    rl_backward_char (1, key);
 
   _rl_keymap = vi_movement_keymap;
   _rl_vi_done_inserting ();
@@ -688,6 +673,51 @@ rl_vi_arg_digit (count, c)
     return (rl_digit_argument (count, c));
 }
 
+/* Change the case of the next COUNT characters. */
+#if defined (HANDLE_MULTIBYTE)
+static int
+_rl_vi_change_mbchar_case (count)
+     int count;
+{
+  wchar_t wc;
+  char mb[MB_LEN_MAX];
+  mbstate_t ps;
+
+  memset (&ps, 0, sizeof (mbstate_t));
+  if (_rl_adjust_point (rl_line_buffer, rl_point, &ps) > 0)
+    count--;
+  while (count-- && rl_point < rl_end)
+    {
+      mbrtowc (&wc, rl_line_buffer + rl_point, rl_end - rl_point, &ps);
+      if (iswupper (wc))
+	wc = towlower (wc);
+      else if (iswlower (wc))
+	wc = towupper (wc);
+      else
+	{
+	  /* Just skip over chars neither upper nor lower case */
+	  rl_forward_char (1, 0);
+	  continue;
+	}
+
+      /* Vi is kind of strange here. */
+      if (wc)
+	{
+	  wctomb (mb, wc);
+	  rl_begin_undo_group ();
+	  rl_delete (1, 0);
+	  rl_insert_text (mb);
+	  rl_end_undo_group ();
+	  rl_vi_check ();
+	}
+      else
+        rl_forward_char (1, 0);
+    }
+
+  return 0;
+}
+#endif
+
 int
 rl_vi_change_case (count, ignore)
      int count, ignore __attribute__((unused));
@@ -698,6 +728,11 @@ rl_vi_change_case (count, ignore)
   if (rl_point >= rl_end)
     return (0);
 
+#if defined (HANDLE_MULTIBYTE)
+  if (MB_CUR_MAX > 1 && rl_byte_oriented == 0)
+    return (_rl_vi_change_mbchar_case (count));
+#endif
+
   while (count-- && rl_point < rl_end)
     {
       if (_rl_uppercase_p (rl_line_buffer[rl_point]))
@@ -707,7 +742,7 @@ rl_vi_change_case (count, ignore)
       else
 	{
 	  /* Just skip over characters neither upper nor lower case. */
-	  rl_forward (1, c);
+	  rl_forward_char (1, c);
 	  continue;
 	}
 
@@ -716,12 +751,12 @@ rl_vi_change_case (count, ignore)
 	{
 	  rl_begin_undo_group ();
 	  rl_delete (1, c);
-	  rl_insert (1, c);
+	  _rl_insert_char (1, c);
 	  rl_end_undo_group ();
 	  rl_vi_check ();
         }
       else
-	rl_forward (1, c);
+	rl_forward_char (1, c);
     }
   return (0);
 }
@@ -731,10 +766,10 @@ rl_vi_put (count, key)
      int count __attribute__((unused)), key;
 {
   if (!_rl_uppercase_p (key) && (rl_point + 1 <= rl_end))
-    rl_point++;
+    rl_point = _rl_find_next_mbchar (rl_line_buffer, rl_point, 1, MB_FIND_NONZERO);
 
   rl_yank (1, key);
-  rl_backward (1, key);
+  rl_backward_char (1, key);
   return (0);
 }
 
@@ -742,7 +777,12 @@ int
 rl_vi_check ()
 {
   if (rl_point && rl_point == rl_end)
-    rl_point--;
+    {
+      if (MB_CUR_MAX > 1 && rl_byte_oriented == 0)
+	rl_point = _rl_find_prev_mbchar (rl_line_buffer, rl_point, MB_FIND_NONZERO);
+      else
+        rl_point--;
+    }
   return (0);
 }
 
@@ -765,7 +805,9 @@ rl_vi_domove (key, nextkey)
   int old_end;
 
   rl_mark = rl_point;
+  RL_SETSTATE(RL_STATE_MOREINPUT);
   c = rl_read_key ();
+  RL_UNSETSTATE(RL_STATE_MOREINPUT);
   *nextkey = c;
 
   if (!member (c, vi_motion))
@@ -776,7 +818,9 @@ rl_vi_domove (key, nextkey)
 	  rl_numeric_arg = _rl_digit_value (c);
 	  rl_digit_loop1 ();
 	  rl_numeric_arg *= save;
+	  RL_SETSTATE(RL_STATE_MOREINPUT);
 	  c = rl_read_key ();	/* real command */
+	  RL_UNSETSTATE(RL_STATE_MOREINPUT);
 	  *nextkey = c;
 	}
       else if (key == c && (key == 'd' || key == 'y' || key == 'c'))
@@ -840,24 +884,36 @@ rl_vi_domove (key, nextkey)
     }
 
   if (rl_mark < rl_point)
-    exchange (rl_point, rl_mark);
+    SWAP (rl_point, rl_mark);
 
   return (0);
 }
 
 /* A simplified loop for vi. Don't dispatch key at end.
-   Don't recognize minus sign? */
+   Don't recognize minus sign?
+   Should this do rl_save_prompt/rl_restore_prompt? */
 static int
 rl_digit_loop1 ()
 {
   int key, c;
 
+  RL_SETSTATE(RL_STATE_NUMERICARG);
   while (1)
     {
-      rl_message ("(arg: %d) ", rl_arg_sign * rl_numeric_arg, 0);
+      if (rl_numeric_arg > 1000000)
+	{
+	  rl_explicit_arg = rl_numeric_arg = 0;
+	  rl_ding ();
+	  rl_clear_message ();
+	  RL_UNSETSTATE(RL_STATE_NUMERICARG);
+	  return 1;
+	}
+      rl_message ("(arg: %d) ", rl_arg_sign * rl_numeric_arg);
+      RL_SETSTATE(RL_STATE_MOREINPUT);
       key = c = rl_read_key ();
+      RL_UNSETSTATE(RL_STATE_MOREINPUT);
 
-      if (_rl_keymap[c].type == ISFUNC &&
+      if (c >= 0 && _rl_keymap[c].type == ISFUNC &&
 	  _rl_keymap[c].function == rl_universal_argument)
 	{
 	  rl_numeric_arg *= 4;
@@ -880,6 +936,8 @@ rl_digit_loop1 ()
 	  break;
 	}
     }
+
+  RL_UNSETSTATE(RL_STATE_NUMERICARG);
   return (0);
 }
 
@@ -896,7 +954,7 @@ rl_vi_delete_to (count, key)
 
   if (rl_vi_domove (key, &c))
     {
-      ding ();
+      rl_ding ();
       return -1;
     }
 
@@ -924,7 +982,7 @@ rl_vi_change_to (count, key)
 
   if (rl_vi_domove (key, &c))
     {
-      ding ();
+      rl_ding ();
       return -1;
     }
 
@@ -974,7 +1032,7 @@ rl_vi_yank_to (count, key)
 
   if (rl_vi_domove (key, &c))
     {
-      ding ();
+      rl_ding ();
       return -1;
     }
 
@@ -1000,19 +1058,22 @@ rl_vi_delete (count, key)
 
   if (rl_end == 0)
     {
-      ding ();
+      rl_ding ();
       return -1;
     }
 
-  end = rl_point + count;
+  if (MB_CUR_MAX > 1 && rl_byte_oriented == 0)
+    end = _rl_find_next_mbchar (rl_line_buffer, rl_point, count, MB_FIND_NONZERO);
+  else
+    end = rl_point + count;
 
   if (end >= rl_end)
     end = rl_end;
 
   rl_kill_text (rl_point, end);
-
+  
   if (rl_point > 0 && rl_point == rl_end)
-    rl_backward (1, key);
+    rl_backward_char (1, key);
   return (0);
 }
 
@@ -1037,7 +1098,12 @@ int
 rl_vi_char_search (count, key)
      int count, key;
 {
+#if defined (HANDLE_MULTIBYTE)
+  static char *target;
+  static int mb_len;
+#else
   static char target;
+#endif
   static int orig_dir, dir;
 
   if (key == ';' || key == ',')
@@ -1045,9 +1111,22 @@ rl_vi_char_search (count, key)
   else
     {
       if (vi_redoing)
+#if defined (HANDLE_MULTIBYTE)
+	target = _rl_vi_last_search_mbchar;
+#else
 	target = _rl_vi_last_search_char;
+#endif
       else
-	_rl_vi_last_search_char = target = rl_getc (rl_instream);
+	{
+#if defined (HANDLE_MULTIBYTE)
+	  mb_len = _rl_read_mbchar (_rl_vi_last_search_mbchar, MB_LEN_MAX);
+	  target = _rl_vi_last_search_mbchar;
+#else
+	  RL_SETSTATE(RL_STATE_MOREINPUT);
+	  _rl_vi_last_search_char = target = rl_read_key ();
+	  RL_UNSETSTATE(RL_STATE_MOREINPUT);
+#endif
+	}
 
       switch (key)
         {
@@ -1069,7 +1148,11 @@ rl_vi_char_search (count, key)
         }
     }
 
+#if defined (HANDLE_MULTIBYTE)
+   return (_rl_char_search_internal (count, dir, target, mb_len));
+#else
   return (_rl_char_search_internal (count, dir, target));
+#endif
 }
 
 /* Match brackets */
@@ -1077,19 +1160,30 @@ int
 rl_vi_match (ignore, key)
      int ignore __attribute__((unused)), key;
 {
-  int count = 1, brack, pos;
+  int count = 1, brack, pos, tmp, pre;
 
   pos = rl_point;
   if ((brack = rl_vi_bracktype (rl_line_buffer[rl_point])) == 0)
     {
-      while ((brack = rl_vi_bracktype (rl_line_buffer[rl_point])) == 0 &&
-	     rl_point < rl_end - 1)
-	rl_forward (1, key);
+      if (MB_CUR_MAX > 1 && rl_byte_oriented == 0)
+	{
+	  while ((brack = rl_vi_bracktype (rl_line_buffer[rl_point])) == 0)
+	    {
+	      pre = rl_point;
+	      rl_forward_char (1, key);
+	      if (pre == rl_point)
+	        break;
+	    }
+	}
+      else
+	while ((brack = rl_vi_bracktype (rl_line_buffer[rl_point])) == 0 &&
+		rl_point < rl_end - 1)
+	  rl_forward_char (1, key);
 
       if (brack <= 0)
 	{
 	  rl_point = pos;
-	  ding ();
+	  rl_ding ();
 	  return -1;
 	}
     }
@@ -1100,7 +1194,16 @@ rl_vi_match (ignore, key)
     {
       while (count)
 	{
-	  if (--pos >= 0)
+	  tmp = pos;
+	  if (MB_CUR_MAX == 1 || rl_byte_oriented)
+	    pos--;
+	  else
+	    {
+	      pos = _rl_find_prev_mbchar (rl_line_buffer, pos, MB_FIND_ANY);
+	      if (tmp == pos)
+	        pos--;
+	    }
+	  if (pos >= 0)
 	    {
 	      int b = rl_vi_bracktype (rl_line_buffer[pos]);
 	      if (b == -brack)
@@ -1110,7 +1213,7 @@ rl_vi_match (ignore, key)
 	    }
 	  else
 	    {
-	      ding ();
+	      rl_ding ();
 	      return -1;
 	    }
 	}
@@ -1119,7 +1222,12 @@ rl_vi_match (ignore, key)
     {			/* brack > 0 */
       while (count)
 	{
-	  if (++pos < rl_end)
+	  if (MB_CUR_MAX == 1 || rl_byte_oriented)
+	    pos++;
+	  else
+	    pos = _rl_find_next_mbchar (rl_line_buffer, pos, 1, MB_FIND_ANY);
+
+	  if (pos < rl_end)
 	    {
 	      int b = rl_vi_bracktype (rl_line_buffer[pos]);
 	      if (b == -brack)
@@ -1129,7 +1237,7 @@ rl_vi_match (ignore, key)
 	    }
 	  else
 	    {
-	      ding ();
+	      rl_ding ();
 	      return -1;
 	    }
 	}
@@ -1154,6 +1262,11 @@ rl_vi_bracktype (c)
     }
 }
 
+/* XXX - think about reading an entire mbchar with _rl_read_mbchar and
+   inserting it in one bunch instead of the loop below (like in
+   rl_vi_char_search or _rl_vi_change_mbchar_case.  Set c to mbchar[0]
+   for test against 033 or ^C.  Make sure that _rl_read_mbchar does
+   this right. */
 int
 rl_vi_change_char (count, key)
      int count, key __attribute__((unused));
@@ -1163,7 +1276,11 @@ rl_vi_change_char (count, key)
   if (vi_redoing)
     c = _rl_vi_last_replacement;
   else
-    _rl_vi_last_replacement = c = rl_getc (rl_instream);
+    {
+      RL_SETSTATE(RL_STATE_MOREINPUT);
+      _rl_vi_last_replacement = c = rl_read_key ();
+      RL_UNSETSTATE(RL_STATE_MOREINPUT);
+    }
 
   if (c == '\033' || c == CTRL ('C'))
     return -1;
@@ -1173,9 +1290,19 @@ rl_vi_change_char (count, key)
       rl_begin_undo_group ();
 
       rl_delete (1, c);
-      rl_insert (1, c);
+#if defined (HANDLE_MULTIBYTE)
+      if (MB_CUR_MAX > 1 && rl_byte_oriented == 0)
+	while (_rl_insert_char (1, c))
+	  {
+	    RL_SETSTATE (RL_STATE_MOREINPUT);
+	    c = rl_read_key ();
+	    RL_UNSETSTATE (RL_STATE_MOREINPUT);
+	  }
+      else
+#endif
+	_rl_insert_char (1, c);
       if (count == 0)
-	rl_backward (1, c);
+	rl_backward_char (1, c);
 
       rl_end_undo_group ();
     }
@@ -1186,66 +1313,29 @@ int
 rl_vi_subst (count, key)
      int count, key;
 {
-  rl_begin_undo_group ();
-
-  if (_rl_uppercase_p (key))
-    {
-      rl_beg_of_line (1, key);
-      rl_kill_line (1, key);
-    }
-  else
-    rl_delete_text (rl_point, rl_point+count);
-
-  rl_end_undo_group ();
-
-  _rl_vi_set_last (key, count, rl_arg_sign);
-
-  if (vi_redoing)
-    {
-      int o = _rl_doing_an_undo;
-
-      _rl_doing_an_undo = 1;
-      if (vi_insert_buffer && *vi_insert_buffer)
-	rl_insert_text (vi_insert_buffer);
-      _rl_doing_an_undo = o;
-    }
-  else
-    {
-      rl_begin_undo_group ();
-      _rl_vi_doing_insert = 1;
-      rl_vi_insertion_mode (1, key);
-    }
+  /* If we are redoing, rl_vi_change_to will stuff the last motion char */
+  if (vi_redoing == 0)
+    rl_stuff_char ((key == 'S') ? 'c' : ' ');	/* `S' == `cc', `s' == `c ' */
 
-  return (0);
+  return (rl_vi_change_to (count, 'c'));
 }
 
 int
 rl_vi_overstrike (count, key)
      int count, key;
 {
-  int i;
-
   if (_rl_vi_doing_insert == 0)
     {
       _rl_vi_doing_insert = 1;
       rl_begin_undo_group ();
     }
 
-  for (i = 0; i < count; i++)
+  if (count > 0)
     {
-      vi_replace_count++;
-      rl_begin_undo_group ();
-
-      if (rl_point < rl_end)
-	{
-	  rl_delete (1, key);
-	  rl_insert (1, key);
-	}
-      else
-	rl_insert (1, key);
-
-      rl_end_undo_group ();
+      _rl_overwrite_char (count, key);
+      vi_replace_count += count;
     }
+
   return (0);
 }
 
@@ -1259,7 +1349,7 @@ rl_vi_overstrike_delete (count, key)
     {
       if (vi_replace_count == 0)
 	{
-	  ding ();
+	  rl_ding ();
 	  break;
 	}
       s = rl_point;
@@ -1268,7 +1358,7 @@ rl_vi_overstrike_delete (count, key)
 	vi_replace_count--;
 
       if (rl_point == s)
-	rl_backward (1, key);
+	rl_backward_char (1, key);
     }
 
   if (vi_replace_count == 0 && _rl_vi_doing_insert)
@@ -1329,7 +1419,7 @@ rl_vi_possible_completions()
     }
   else if (rl_line_buffer[rl_point - 1] == ';')
     {
-      ding ();
+      rl_ding ();
       return (0);
     }
 
@@ -1347,10 +1437,13 @@ rl_vi_set_mark (count, key)
 {
   int ch;
 
+  RL_SETSTATE(RL_STATE_MOREINPUT);
   ch = rl_read_key ();
-  if (_rl_lowercase_p (ch) == 0)
+  RL_UNSETSTATE(RL_STATE_MOREINPUT);
+
+  if (ch < 'a' || ch > 'z')
     {
-      ding ();
+      rl_ding ();
       return -1;
     }
   ch -= 'a';
@@ -1364,22 +1457,25 @@ rl_vi_goto_mark (count, key)
 {
   int ch;
 
+  RL_SETSTATE(RL_STATE_MOREINPUT);
   ch = rl_read_key ();
+  RL_UNSETSTATE(RL_STATE_MOREINPUT);
+
   if (ch == '`')
     {
       rl_point = rl_mark;
       return 0;
     }
-  else if (_rl_lowercase_p (ch) == 0)
+  else if (ch < 'a' || ch > 'z')
     {
-      ding ();
+      rl_ding ();
       return -1;
     }
 
   ch -= 'a';
   if (vi_mark_chars[ch] == -1)
     {
-      ding ();
+      rl_ding ();
       return -1;
     }
   rl_point = vi_mark_chars[ch];
diff --git a/readline/xmalloc.c b/readline/xmalloc.c
index 4160651191bba0f7f1a55e55ed5b837bfe0695aa..8985d340d398cd28f5278c8c275cad0faed4a592 100644
--- a/readline/xmalloc.c
+++ b/readline/xmalloc.c
@@ -7,7 +7,7 @@
 
    Readline is free software; you can redistribute it and/or modify it
    under the terms of the GNU General Public License as published by the
-   Free Software Foundation; either version 1, or (at your option) any
+   Free Software Foundation; either version 2, or (at your option) any
    later version.
 
    Readline is distributed in the hope that it will be useful, but
@@ -17,7 +17,8 @@
 
    You should have received a copy of the GNU General Public License
    along with Readline; see the file COPYING.  If not, write to the Free
-   Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. */
+   Software Foundation, 59 Temple Place, Suite 330, Boston, MA 02111 USA. */
+#define READLINE_LIBRARY
 
 #if defined (HAVE_CONFIG_H)
 #include <config.h>
@@ -31,7 +32,7 @@
 #  include "ansi_stdlib.h"
 #endif /* HAVE_STDLIB_H */
 
-static void memory_error_and_abort ();
+#include "xmalloc.h"
 
 /* **************************************************************** */
 /*								    */
@@ -39,48 +40,48 @@ static void memory_error_and_abort ();
 /*								    */
 /* **************************************************************** */
 
+static void
+memory_error_and_abort (fname)
+     char *fname;
+{
+  fprintf (stderr, "%s: out of virtual memory\n", fname);
+  exit (2);
+}
+
 /* Return a pointer to free()able block of memory large enough
    to hold BYTES number of bytes.  If the memory cannot be allocated,
    print an error message and abort. */
-char *
+PTR_T
 xmalloc (bytes)
-     int bytes;
+     size_t bytes;
 {
-  char *temp;
+  PTR_T temp;
 
-  temp = (char *)malloc (bytes);
+  temp = malloc (bytes);
   if (temp == 0)
     memory_error_and_abort ("xmalloc");
   return (temp);
 }
 
-char *
+PTR_T
 xrealloc (pointer, bytes)
-     char *pointer;
-     int bytes;
+     PTR_T pointer;
+     size_t bytes;
 {
-  char *temp;
+  PTR_T temp;
 
-  temp = pointer ? (char *)realloc (pointer, bytes) : (char *)malloc (bytes);
+  temp = pointer ? realloc (pointer, bytes) : malloc (bytes);
 
   if (temp == 0)
     memory_error_and_abort ("xrealloc");
   return (temp);
 }
 
-static void
-memory_error_and_abort (fname)
-     char *fname;
-{
-  fprintf (stderr, "%s: out of virtual memory\n", fname);
-  exit (2);
-}
-
 /* Use this as the function to call when adding unwind protects so we
    don't need to know what free() returns. */
 void
 xfree (string)
-     char *string;
+     PTR_T string;
 {
   if (string)
     free (string);
diff --git a/readline/xmalloc.h b/readline/xmalloc.h
new file mode 100644
index 0000000000000000000000000000000000000000..9cb08ba21f111caabc5849683438eb529ad14ef3
--- /dev/null
+++ b/readline/xmalloc.h
@@ -0,0 +1,46 @@
+/* xmalloc.h -- memory allocation that aborts on errors. */
+
+/* Copyright (C) 1999 Free Software Foundation, Inc.
+
+   This file is part of the GNU Readline Library, a library for
+   reading lines of text with interactive input and history editing.
+
+   The GNU Readline Library is free software; you can redistribute it
+   and/or modify it under the terms of the GNU General Public License
+   as published by the Free Software Foundation; either version 2, or
+   (at your option) any later version.
+
+   The GNU Readline Library is distributed in the hope that it will be
+   useful, but WITHOUT ANY WARRANTY; without even the implied warranty
+   of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+   GNU General Public License for more details.
+
+   The GNU General Public License is often shipped with GNU software, and
+   is generally kept in a file called COPYING or LICENSE.  If you do not
+   have a copy of the license, write to the Free Software Foundation,
+   59 Temple Place, Suite 330, Boston, MA 02111 USA. */
+
+#if !defined (_XMALLOC_H_)
+#define _XMALLOC_H_
+
+#if defined (READLINE_LIBRARY)
+#  include "rlstdc.h"
+#else
+#  include <readline/rlstdc.h>
+#endif
+
+#ifndef PTR_T
+
+#ifdef __STDC__
+#  define PTR_T	void *
+#else
+#  define PTR_T	char *
+#endif
+
+#endif /* !PTR_T */
+
+extern PTR_T xmalloc PARAMS((size_t));
+extern PTR_T xrealloc PARAMS((void *, size_t));
+extern void xfree PARAMS((void *));
+
+#endif /* _XMALLOC_H_ */
diff --git a/regex/Makefile.am b/regex/Makefile.am
index ee421b70bcf0e51492c0c1bd799aa1f95cff49cd..2e23efcbf2a90edfd5b9c3268f9d17de3f87d123 100644
--- a/regex/Makefile.am
+++ b/regex/Makefile.am
@@ -15,7 +15,7 @@
 # Software Foundation, Inc., 59 Temple Place - Suite 330, Boston,
 # MA 02111-1307, USA
 
-INCLUDES =		@MT_INCLUDES@ -I$(srcdir)/../include -I../include
+INCLUDES =		@MT_INCLUDES@ -I$(top_srcdir)/include
 noinst_LIBRARIES =	libregex.a
 LDADD =			libregex.a ../strings/libmystrings.a
 noinst_HEADERS =	cclass.h cname.h regex2.h utils.h engine.c regex.h
diff --git a/scripts/Makefile.am b/scripts/Makefile.am
index 72c869f3f64f9b6ce32d4ca7111be1bbc352a3f3..3ffa62d27c00dcbc52bea28a28ab18b5737446f3 100644
--- a/scripts/Makefile.am
+++ b/scripts/Makefile.am
@@ -104,6 +104,7 @@ SUFFIXES = .sh
 	  -e 's!@''CXX''@!@CXX@!'\
 	  -e 's!@''GXX''@!@GXX@!'\
 	  -e 's!@''PERL''@!@PERL@!' \
+	  -e 's!@''ASFLAGS''@!@SAVE_ASFLAGS@!'\
 	  -e 's!@''CFLAGS''@!@SAVE_CFLAGS@!'\
 	  -e 's!@''CXXFLAGS''@!@SAVE_CXXFLAGS@!'\
 	  -e 's!@''LDFLAGS''@!@SAVE_LDFLAGS@!'\
diff --git a/scripts/mysqlbug.sh b/scripts/mysqlbug.sh
index bd5cb497e59d76fad996145ca3d1a4033573cc16..8dbc931b7f61c3ac98165a27388c9beadf1eb116 100644
--- a/scripts/mysqlbug.sh
+++ b/scripts/mysqlbug.sh
@@ -8,7 +8,7 @@ VERSION="@VERSION@@MYSQL_SERVER_SUFFIX@"
 COMPILATION_COMMENT="@COMPILATION_COMMENT@"
 BUGmysql="mysql@lists.mysql.com"
 # This is set by configure
-COMP_ENV_INFO="CC='@CC@'  CFLAGS='@CFLAGS@'  CXX='@CXX@'  CXXFLAGS='@CXXFLAGS@'  LDFLAGS='@LDFLAGS@'"
+COMP_ENV_INFO="CC='@CC@'  CFLAGS='@CFLAGS@'  CXX='@CXX@'  CXXFLAGS='@CXXFLAGS@'  LDFLAGS='@LDFLAGS@'  ASFLAGS='@ASFLAGS@'"
 CONFIGURE_LINE="@CONF_COMMAND@"
 
 LIBC_INFO=""
diff --git a/scripts/mysqld_multi.sh b/scripts/mysqld_multi.sh
index b868006ee40aa4eb80842c77de077137347de890..3165a01362c2eab1e6a5b197e6a9a8043d592ffe 100644
--- a/scripts/mysqld_multi.sh
+++ b/scripts/mysqld_multi.sh
@@ -4,7 +4,7 @@ use Getopt::Long;
 use POSIX qw(strftime);
 
 $|=1;
-$VER="2.4";
+$VER="2.5";
 
 $opt_config_file   = undef();
 $opt_example       = 0;
@@ -212,6 +212,7 @@ sub start_mysqlds()
       }
       else
       {
+	$options[$j]=~ s/;/\\;/g;
 	$tmp.= " $options[$j]";
       }
     }
diff --git a/scripts/mysqld_safe.sh b/scripts/mysqld_safe.sh
index 9dea2eb393506f469aeb1f3b086576a17730fa96..96d3437f96d0ffc2bc7ea08b01a9a639e4e1d8c2 100644
--- a/scripts/mysqld_safe.sh
+++ b/scripts/mysqld_safe.sh
@@ -204,7 +204,7 @@ else
 fi
 
 USER_OPTION=""
-if test -w /
+if test -w / -o "$USER" = "root"
 then
   if test "$user" != "root" -o $SET_USER = 1
   then
@@ -215,6 +215,7 @@ then
   if test -n "$open_files"
   then
     ulimit -n $open_files
+    args="open-files-limit=$open_files $args"
   fi
   if test -n "$core_file_size"
   then
diff --git a/scripts/mysqlhotcopy.sh b/scripts/mysqlhotcopy.sh
index bc23c0e5d9588a25ae3974d30f303826bc0cc5ba..b8d4a0a9a38dc12235be67892bf0a0e625150ac7 100644
--- a/scripts/mysqlhotcopy.sh
+++ b/scripts/mysqlhotcopy.sh
@@ -90,6 +90,7 @@ my %opt = (
 Getopt::Long::Configure(qw(no_ignore_case)); # disambuguate -p and -P
 GetOptions( \%opt,
     "help",
+    "host|h=s",
     "user|u=s",
     "password|p=s",
     "port|P=s",
diff --git a/sql-bench/Results/ATIS-mysql-Linux_2.4.4_SMP_alpha b/sql-bench/Results/ATIS-mysql-Linux_2.4.4_SMP_alpha
new file mode 100644
index 0000000000000000000000000000000000000000..e0192d49a3daefa81f18afb8dde4c4d822951660
--- /dev/null
+++ b/sql-bench/Results/ATIS-mysql-Linux_2.4.4_SMP_alpha
@@ -0,0 +1,20 @@
+Testing server 'MySQL 4.0.5 beta' at 2002-10-23 12:35:44
+
+ATIS table test
+
+Creating tables
+Time for create_table (28):  0 wallclock secs ( 0.00 usr  0.00 sys +  0.00 cusr  0.00 csys =  0.00 CPU)
+
+Inserting data
+Time to insert (9768):  3 wallclock secs ( 0.52 usr  0.31 sys +  0.00 cusr  0.00 csys =  0.00 CPU)
+
+Retrieving data
+Time for select_simple_join (500):  1 wallclock secs ( 0.60 usr  0.29 sys +  0.00 cusr  0.00 csys =  0.00 CPU)
+Time for select_join (100):  2 wallclock secs ( 0.44 usr  0.27 sys +  0.00 cusr  0.00 csys =  0.00 CPU)
+Time for select_key_prefix_join (100): 10 wallclock secs ( 3.58 usr  2.30 sys +  0.00 cusr  0.00 csys =  0.00 CPU)
+Time for select_distinct (800): 10 wallclock secs ( 1.60 usr  0.81 sys +  0.00 cusr  0.00 csys =  0.00 CPU)
+Time for select_group (2800): 11 wallclock secs ( 1.44 usr  0.52 sys +  0.00 cusr  0.00 csys =  0.00 CPU)
+
+Removing tables
+Time to drop_table (28):  0 wallclock secs ( 0.00 usr  0.00 sys +  0.00 cusr  0.00 csys =  0.00 CPU)
+Total time: 37 wallclock secs ( 8.20 usr  4.50 sys +  0.00 cusr  0.00 csys =  0.00 CPU)
diff --git a/sql-bench/Results/RUN-mysql-Linux_2.4.4_SMP_alpha b/sql-bench/Results/RUN-mysql-Linux_2.4.4_SMP_alpha
new file mode 100644
index 0000000000000000000000000000000000000000..ba144b8d226c4eaddc21b7d021b94a35b0935750
--- /dev/null
+++ b/sql-bench/Results/RUN-mysql-Linux_2.4.4_SMP_alpha
@@ -0,0 +1,109 @@
+Benchmark DBD suite: 2.14
+Date of test:        2002-10-23 12:35:44
+Running tests on:    Linux 2.4.4-SMP alpha
+Arguments:           
+Comments:            Alpha DS20 2x500 MHz, 2G memory, key_buffer=16M, query_cache=16M; cxx 6.3 + ccc 6.2.9
+Limits from:         
+Server version:      MySQL 4.0.5 beta
+Optimization:        None
+Hardware:            
+
+ATIS: Total time: 37 wallclock secs ( 8.20 usr  4.50 sys +  0.00 cusr  0.00 csys =  0.00 CPU)
+alter-table: Total time: 277 wallclock secs ( 0.33 usr  0.14 sys +  0.00 cusr  0.00 csys =  0.00 CPU)
+big-tables: Total time: 39 wallclock secs ( 8.71 usr  8.56 sys +  0.00 cusr  0.00 csys =  0.00 CPU)
+connect: Total time: 209 wallclock secs (62.48 usr 49.95 sys +  0.00 cusr  0.00 csys =  0.00 CPU)
+create: Total time: 288 wallclock secs (10.88 usr  3.48 sys +  0.00 cusr  0.00 csys =  0.00 CPU)
+insert: Total time: 2381 wallclock secs (693.26 usr 241.11 sys +  0.00 cusr  0.00 csys =  0.00 CPU)
+select: Total time: 1298 wallclock secs (66.92 usr 20.96 sys +  0.00 cusr  0.00 csys =  0.00 CPU)
+transactions: Test skipped because the database doesn't support transactions
+wisconsin: Total time: 17 wallclock secs ( 3.66 usr  2.13 sys +  0.00 cusr  0.00 csys =  0.00 CPU)
+
+All 9 test executed successfully
+
+Totals per operation:
+Operation             seconds     usr     sys     cpu   tests
+alter_table_add                      154.00    0.18    0.06    0.00     992 
+alter_table_drop                     116.00    0.07    0.03    0.00     496 
+connect                               14.00    8.17    2.02    0.00   10000 
+connect+select_1_row                  17.00    8.80    2.79    0.00   10000 
+connect+select_simple                 16.00    8.86    2.57    0.00   10000 
+count                                 50.00    0.04    0.00    0.00     100 
+count_distinct                        32.00    0.44    0.07    0.00    1000 
+count_distinct_2                      32.00    0.44    0.08    0.00    1000 
+count_distinct_big                    54.00    7.37    4.25    0.00     120 
+count_distinct_group                  50.00    1.14    0.52    0.00    1000 
+count_distinct_group_on_key           38.00    0.48    0.12    0.00    1000 
+count_distinct_group_on_key_parts     50.00    1.15    0.47    0.00    1000 
+count_distinct_key_prefix             28.00    0.44    0.09    0.00    1000 
+count_group_on_key_parts              37.00    1.02    0.48    0.00    1000 
+count_on_key                         453.00   16.74    3.59    0.00   50100 
+create+drop                           15.00    2.92    0.95    0.00   10000 
+create_MANY_tables                   238.00    1.84    0.51    0.00   10000 
+create_index                           4.00    0.00    0.00    0.00       8 
+create_key+drop                       19.00    4.55    0.94    0.00   10000 
+create_table                           0.00    0.00    0.00    0.00      31 
+delete_all_many_keys                  47.00    0.02    0.01    0.00       1 
+delete_big                             0.00    0.00    0.00    0.00       1 
+delete_big_many_keys                  47.00    0.02    0.01    0.00     128 
+delete_key                             4.00    0.88    0.55    0.00   10000 
+delete_range                           9.00    0.00    0.00    0.00      12 
+drop_index                             3.00    0.00    0.00    0.00       8 
+drop_table                             0.00    0.00    0.00    0.00      28 
+drop_table_when_MANY_tables           10.00    0.67    0.44    0.00   10000 
+insert                               134.00   28.43   15.57    0.00  350768 
+insert_duplicates                     30.00    4.71    5.50    0.00  100000 
+insert_key                            98.00   13.49    3.80    0.00  100000 
+insert_many_fields                    14.00    0.32    0.11    0.00    2000 
+insert_select_1_key                    6.00    0.00    0.00    0.00       1 
+insert_select_2_keys                   8.00    0.00    0.00    0.00       1 
+min_max                               23.00    0.02    0.00    0.00      60 
+min_max_on_key                       188.00   27.44    5.93    0.00   85000 
+multiple_value_insert                  7.00    1.88    0.05    0.00  100000 
+order_by_big                          40.00   17.31   12.40    0.00      10 
+order_by_big_key                      31.00   18.84   12.61    0.00      10 
+order_by_big_key2                     30.00   17.35   12.38    0.00      10 
+order_by_big_key_desc                 32.00   19.23   12.70    0.00      10 
+order_by_big_key_diff                 36.00   17.33   12.44    0.00      10 
+order_by_big_key_prefix               30.00   17.36   12.49    0.00      10 
+order_by_key2_diff                     5.00    1.67    1.04    0.00     500 
+order_by_key_prefix                    2.00    0.92    0.56    0.00     500 
+order_by_range                         5.00    0.97    0.55    0.00     500 
+outer_join                            67.00    0.00    0.00    0.00      10 
+outer_join_found                      63.00    0.01    0.00    0.00      10 
+outer_join_not_found                  40.00    0.01    0.00    0.00     500 
+outer_join_on_key                     40.00    0.01    0.00    0.00      10 
+select_1_row                          27.00    5.70    6.78    0.00  100000 
+select_1_row_cache                    22.00    3.16    5.87    0.00  100000 
+select_2_rows                         30.00    5.96    7.15    0.00  100000 
+select_big                            31.00   18.08   12.50    0.00      80 
+select_big_str                        20.00    8.04    6.08    0.00   10000 
+select_cache                          89.00    3.03    0.74    0.00   10000 
+select_cache2                         91.00    3.53    0.76    0.00   10000 
+select_column+column                  30.00    5.07    5.64    0.00  100000 
+select_diff_key                      163.00    0.27    0.04    0.00     500 
+select_distinct                       10.00    1.60    0.81    0.00     800 
+select_group                         106.00    1.49    0.53    0.00    2911 
+select_group_when_MANY_tables          6.00    0.90    0.65    0.00   10000 
+select_join                            2.00    0.44    0.27    0.00     100 
+select_key                           142.00   77.87   17.06    0.00  200000 
+select_key2                          142.00   74.50   19.30    0.00  200000 
+select_key2_return_key               133.00   73.16   13.81    0.00  200000 
+select_key2_return_prim              132.00   70.56   13.25    0.00  200000 
+select_key_prefix                    141.00   73.88   18.25    0.00  200000 
+select_key_prefix_join                10.00    3.58    2.30    0.00     100 
+select_key_return_key                146.00   82.66   16.24    0.00  200000 
+select_many_fields                    25.00    8.38    8.45    0.00    2000 
+select_range                         242.00    8.57    4.60    0.00     410 
+select_range_key2                     19.00    6.12    1.72    0.00   25010 
+select_range_prefix                   18.00    6.28    1.70    0.00   25010 
+select_simple                         18.00    5.08    5.46    0.00  100000 
+select_simple_cache                   15.00    3.64    5.58    0.00  100000 
+select_simple_join                     1.00    0.60    0.29    0.00     500 
+update_big                            22.00    0.00    0.00    0.00      10 
+update_of_key                         25.00    4.24    1.90    0.00   50000 
+update_of_key_big                     18.00    0.04    0.03    0.00     501 
+update_of_primary_key_many_keys       20.00    0.03    0.01    0.00     256 
+update_with_key                      116.00   21.90   14.15    0.00  300000 
+update_with_key_prefix                36.00   11.11    4.60    0.00  100000 
+wisc_benchmark                         4.00    1.66    0.73    0.00     114 
+TOTALS                              4518.00  844.67  325.93    0.00 3227247 
diff --git a/sql-bench/Results/alter-table-mysql-Linux_2.4.4_SMP_alpha b/sql-bench/Results/alter-table-mysql-Linux_2.4.4_SMP_alpha
new file mode 100644
index 0000000000000000000000000000000000000000..1d58effc1a5cd51525fcec485fe21d27042e39fe
--- /dev/null
+++ b/sql-bench/Results/alter-table-mysql-Linux_2.4.4_SMP_alpha
@@ -0,0 +1,16 @@
+Testing server 'MySQL 4.0.5 beta' at 2002-10-23 12:36:21
+
+Testing of ALTER TABLE
+Testing with 1000 columns and 1000 rows in 20 steps
+Insert data into the table
+Time for insert (1000) 0 wallclock secs ( 0.06 usr  0.05 sys +  0.00 cusr  0.00 csys =  0.00 CPU)
+
+Time for alter_table_add (992): 154 wallclock secs ( 0.18 usr  0.06 sys +  0.00 cusr  0.00 csys =  0.00 CPU)
+
+Time for create_index (8):  4 wallclock secs ( 0.00 usr  0.00 sys +  0.00 cusr  0.00 csys =  0.00 CPU)
+
+Time for drop_index (8):  3 wallclock secs ( 0.00 usr  0.00 sys +  0.00 cusr  0.00 csys =  0.00 CPU)
+
+Time for alter_table_drop (496): 116 wallclock secs ( 0.07 usr  0.03 sys +  0.00 cusr  0.00 csys =  0.00 CPU)
+
+Total time: 277 wallclock secs ( 0.33 usr  0.14 sys +  0.00 cusr  0.00 csys =  0.00 CPU)
diff --git a/sql-bench/Results/big-tables-mysql-Linux_2.4.4_SMP_alpha b/sql-bench/Results/big-tables-mysql-Linux_2.4.4_SMP_alpha
new file mode 100644
index 0000000000000000000000000000000000000000..97f66029696915c6aa93d04a0c42eba943c23a5c
--- /dev/null
+++ b/sql-bench/Results/big-tables-mysql-Linux_2.4.4_SMP_alpha
@@ -0,0 +1,19 @@
+Testing server 'MySQL 4.0.5 beta' at 2002-10-23 12:40:58
+
+Testing of some unusual tables
+All tests are done 1000 times with 1000 fields
+
+Testing table with 1000 fields
+Testing select * from table with 1 record
+Time to select_many_fields(1000): 11 wallclock secs ( 4.59 usr  4.21 sys +  0.00 cusr  0.00 csys =  0.00 CPU)
+
+Testing select all_fields from table with 1 record
+Time to select_many_fields(1000): 14 wallclock secs ( 3.79 usr  4.24 sys +  0.00 cusr  0.00 csys =  0.00 CPU)
+
+Testing insert VALUES()
+Time to insert_many_fields(1000):  5 wallclock secs ( 0.29 usr  0.06 sys +  0.00 cusr  0.00 csys =  0.00 CPU)
+
+Testing insert (all_fields) VALUES()
+Time to insert_many_fields(1000):  9 wallclock secs ( 0.03 usr  0.05 sys +  0.00 cusr  0.00 csys =  0.00 CPU)
+
+Total time: 39 wallclock secs ( 8.71 usr  8.56 sys +  0.00 cusr  0.00 csys =  0.00 CPU)
diff --git a/sql-bench/Results/connect-mysql-Linux_2.4.4_SMP_alpha b/sql-bench/Results/connect-mysql-Linux_2.4.4_SMP_alpha
new file mode 100644
index 0000000000000000000000000000000000000000..a787d311a540fa7885a909c301204a7b98f56247
--- /dev/null
+++ b/sql-bench/Results/connect-mysql-Linux_2.4.4_SMP_alpha
@@ -0,0 +1,35 @@
+Testing server 'MySQL 4.0.5 beta' at 2002-10-23 12:41:37
+
+Testing the speed of connecting to the server and sending of data
+Connect tests are done 10000 times and other tests 100000 times
+
+Testing connection/disconnect
+Time to connect (10000): 14 wallclock secs ( 8.17 usr  2.02 sys +  0.00 cusr  0.00 csys =  0.00 CPU)
+
+Test connect/simple select/disconnect
+Time for connect+select_simple (10000): 16 wallclock secs ( 8.86 usr  2.57 sys +  0.00 cusr  0.00 csys =  0.00 CPU)
+
+Test simple select
+Time for select_simple (100000): 18 wallclock secs ( 5.08 usr  5.46 sys +  0.00 cusr  0.00 csys =  0.00 CPU)
+
+Test simple select
+Time for select_simple_cache (100000): 15 wallclock secs ( 3.64 usr  5.58 sys +  0.00 cusr  0.00 csys =  0.00 CPU)
+
+Testing connect/select 1 row from table/disconnect
+Time to connect+select_1_row (10000): 17 wallclock secs ( 8.80 usr  2.79 sys +  0.00 cusr  0.00 csys =  0.00 CPU)
+
+Testing select 1 row from table
+Time to select_1_row (100000): 27 wallclock secs ( 5.70 usr  6.78 sys +  0.00 cusr  0.00 csys =  0.00 CPU)
+
+Time to select_1_row_cache (100000): 22 wallclock secs ( 3.16 usr  5.87 sys +  0.00 cusr  0.00 csys =  0.00 CPU)
+
+Testing select 2 rows from table
+Time to select_2_rows (100000): 30 wallclock secs ( 5.96 usr  7.15 sys +  0.00 cusr  0.00 csys =  0.00 CPU)
+
+Test select with aritmetic (+)
+Time for select_column+column (100000): 30 wallclock secs ( 5.07 usr  5.64 sys +  0.00 cusr  0.00 csys =  0.00 CPU)
+
+Testing retrieval of big records (65000 bytes)
+Time to select_big_str (10000): 20 wallclock secs ( 8.04 usr  6.08 sys +  0.00 cusr  0.00 csys =  0.00 CPU)
+
+Total time: 209 wallclock secs (62.48 usr 49.95 sys +  0.00 cusr  0.00 csys =  0.00 CPU)
diff --git a/sql-bench/Results/create-mysql-Linux_2.4.4_SMP_alpha b/sql-bench/Results/create-mysql-Linux_2.4.4_SMP_alpha
new file mode 100644
index 0000000000000000000000000000000000000000..c6b2eaf9f23b300ab8e1a3f8a330c425aedd2cae
--- /dev/null
+++ b/sql-bench/Results/create-mysql-Linux_2.4.4_SMP_alpha
@@ -0,0 +1,18 @@
+Testing server 'MySQL 4.0.5 beta' at 2002-10-23 12:45:06
+
+Testing the speed of creating and droping tables
+Testing with 10000 tables and 10000 loop count
+
+Testing create of tables
+Time for create_MANY_tables (10000): 238 wallclock secs ( 1.84 usr  0.51 sys +  0.00 cusr  0.00 csys =  0.00 CPU)
+
+Accessing tables
+Time to select_group_when_MANY_tables (10000):  6 wallclock secs ( 0.90 usr  0.65 sys +  0.00 cusr  0.00 csys =  0.00 CPU)
+
+Testing drop
+Time for drop_table_when_MANY_tables (10000): 10 wallclock secs ( 0.67 usr  0.44 sys +  0.00 cusr  0.00 csys =  0.00 CPU)
+
+Testing create+drop
+Time for create+drop (10000): 15 wallclock secs ( 2.92 usr  0.95 sys +  0.00 cusr  0.00 csys =  0.00 CPU)
+Time for create_key+drop (10000): 19 wallclock secs ( 4.55 usr  0.94 sys +  0.00 cusr  0.00 csys =  0.00 CPU)
+Total time: 288 wallclock secs (10.88 usr  3.48 sys +  0.00 cusr  0.00 csys =  0.00 CPU)
diff --git a/sql-bench/Results/insert-mysql-Linux_2.4.4_SMP_alpha b/sql-bench/Results/insert-mysql-Linux_2.4.4_SMP_alpha
new file mode 100644
index 0000000000000000000000000000000000000000..0cdf5cbede85bb0cb594ddd21e035eee8bac9fb0
--- /dev/null
+++ b/sql-bench/Results/insert-mysql-Linux_2.4.4_SMP_alpha
@@ -0,0 +1,106 @@
+Testing server 'MySQL 4.0.5 beta' at 2002-10-23 12:49:54
+
+Testing the speed of inserting data into 1 table and do some selects on it.
+The tests are done with a table that has 100000 rows.
+
+Generating random keys
+Creating tables
+Inserting 100000 rows in order
+Inserting 100000 rows in reverse order
+Inserting 100000 rows in random order
+Time for insert (300000): 114 wallclock secs (25.11 usr 13.48 sys +  0.00 cusr  0.00 csys =  0.00 CPU)
+
+Testing insert of duplicates
+Time for insert_duplicates (100000): 30 wallclock secs ( 4.71 usr  5.50 sys +  0.00 cusr  0.00 csys =  0.00 CPU)
+
+Retrieving data from the table
+Time for select_big (10:3000000): 31 wallclock secs (17.94 usr 12.42 sys +  0.00 cusr  0.00 csys =  0.00 CPU)
+Time for order_by_big_key (10:3000000): 31 wallclock secs (18.84 usr 12.61 sys +  0.00 cusr  0.00 csys =  0.00 CPU)
+Time for order_by_big_key_desc (10:3000000): 32 wallclock secs (19.23 usr 12.70 sys +  0.00 cusr  0.00 csys =  0.00 CPU)
+Time for order_by_big_key_prefix (10:3000000): 30 wallclock secs (17.36 usr 12.49 sys +  0.00 cusr  0.00 csys =  0.00 CPU)
+Time for order_by_big_key2 (10:3000000): 30 wallclock secs (17.35 usr 12.38 sys +  0.00 cusr  0.00 csys =  0.00 CPU)
+Time for order_by_big_key_diff (10:3000000): 36 wallclock secs (17.33 usr 12.44 sys +  0.00 cusr  0.00 csys =  0.00 CPU)
+Time for order_by_big (10:3000000): 40 wallclock secs (17.31 usr 12.40 sys +  0.00 cusr  0.00 csys =  0.00 CPU)
+Time for order_by_range (500:125750):  5 wallclock secs ( 0.97 usr  0.55 sys +  0.00 cusr  0.00 csys =  0.00 CPU)
+Time for order_by_key_prefix (500:125750):  2 wallclock secs ( 0.92 usr  0.56 sys +  0.00 cusr  0.00 csys =  0.00 CPU)
+Time for order_by_key2_diff (500:250500):  5 wallclock secs ( 1.67 usr  1.04 sys +  0.00 cusr  0.00 csys =  0.00 CPU)
+Time for select_diff_key (500:1000): 163 wallclock secs ( 0.27 usr  0.04 sys +  0.00 cusr  0.00 csys =  0.00 CPU)
+Time for select_range_prefix (5010:42084): 10 wallclock secs ( 2.63 usr  0.75 sys +  0.00 cusr  0.00 csys =  0.00 CPU)
+Time for select_range_key2 (5010:42084): 10 wallclock secs ( 2.64 usr  0.76 sys +  0.00 cusr  0.00 csys =  0.00 CPU)
+Time for select_key_prefix (200000): 141 wallclock secs (73.88 usr 18.25 sys +  0.00 cusr  0.00 csys =  0.00 CPU)
+Time for select_key (200000): 142 wallclock secs (77.87 usr 17.06 sys +  0.00 cusr  0.00 csys =  0.00 CPU)
+Time for select_key_return_key (200000): 146 wallclock secs (82.66 usr 16.24 sys +  0.00 cusr  0.00 csys =  0.00 CPU)
+Time for select_key2 (200000): 142 wallclock secs (74.50 usr 19.30 sys +  0.00 cusr  0.00 csys =  0.00 CPU)
+Time for select_key2_return_key (200000): 133 wallclock secs (73.16 usr 13.81 sys +  0.00 cusr  0.00 csys =  0.00 CPU)
+Time for select_key2_return_prim (200000): 132 wallclock secs (70.56 usr 13.25 sys +  0.00 cusr  0.00 csys =  0.00 CPU)
+
+Test of compares with simple ranges
+Time for select_range_prefix (20000:43500):  8 wallclock secs ( 3.65 usr  0.95 sys +  0.00 cusr  0.00 csys =  0.00 CPU)
+Time for select_range_key2 (20000:43500):  9 wallclock secs ( 3.48 usr  0.96 sys +  0.00 cusr  0.00 csys =  0.00 CPU)
+Time for select_group (111): 95 wallclock secs ( 0.05 usr  0.01 sys +  0.00 cusr  0.00 csys =  0.00 CPU)
+Time for min_max_on_key (15000): 10 wallclock secs ( 5.77 usr  1.18 sys +  0.00 cusr  0.00 csys =  0.00 CPU)
+Time for min_max (60): 23 wallclock secs ( 0.02 usr  0.00 sys +  0.00 cusr  0.00 csys =  0.00 CPU)
+Time for count_on_key (100): 41 wallclock secs ( 0.04 usr  0.01 sys +  0.00 cusr  0.00 csys =  0.00 CPU)
+Time for count (100): 50 wallclock secs ( 0.04 usr  0.00 sys +  0.00 cusr  0.00 csys =  0.00 CPU)
+Time for count_distinct_big (20): 39 wallclock secs ( 0.01 usr  0.00 sys +  0.00 cusr  0.00 csys =  0.00 CPU)
+
+Testing update of keys with functions
+Time for update_of_key (50000):  25 wallclock secs ( 4.24 usr  1.90 sys +  0.00 cusr  0.00 csys =  0.00 CPU)
+Time for update_of_key_big (501): 18 wallclock secs ( 0.04 usr  0.03 sys +  0.00 cusr  0.00 csys =  0.00 CPU)
+
+Testing update with key
+Time for update_with_key (300000):  116 wallclock secs (21.90 usr 14.15 sys +  0.00 cusr  0.00 csys =  0.00 CPU)
+Time for update_with_key_prefix (100000):  36 wallclock secs (11.11 usr  4.60 sys +  0.00 cusr  0.00 csys =  0.00 CPU)
+
+Testing update of all rows
+Time for update_big (10):  22 wallclock secs ( 0.00 usr  0.00 sys +  0.00 cusr  0.00 csys =  0.00 CPU)
+
+Testing left outer join
+Time for outer_join_on_key (10:10):  40 wallclock secs ( 0.01 usr  0.00 sys +  0.00 cusr  0.00 csys =  0.00 CPU)
+Time for outer_join (10:10):  67 wallclock secs ( 0.00 usr  0.00 sys +  0.00 cusr  0.00 csys =  0.00 CPU)
+Time for outer_join_found (10:10):  63 wallclock secs ( 0.01 usr  0.00 sys +  0.00 cusr  0.00 csys =  0.00 CPU)
+Time for outer_join_not_found (500:10):  40 wallclock secs ( 0.01 usr  0.00 sys +  0.00 cusr  0.00 csys =  0.00 CPU)
+
+Testing SELECT ... WHERE id in (10 values)
+Time for select_in (500:5000)  0 wallclock secs ( 0.22 usr  0.06 sys +  0.00 cusr  0.00 csys =  0.00 CPU)
+
+Time for select_join_in (500:5000)  1 wallclock secs ( 0.23 usr  0.06 sys +  0.00 cusr  0.00 csys =  0.00 CPU)
+
+Testing SELECT ... WHERE id in (100 values)
+Time for select_in (500:50000)  4 wallclock secs ( 0.56 usr  0.26 sys +  0.00 cusr  0.00 csys =  0.00 CPU)
+
+Time for select_join_in (500:50000)  2 wallclock secs ( 0.57 usr  0.24 sys +  0.00 cusr  0.00 csys =  0.00 CPU)
+
+Testing SELECT ... WHERE id in (1000 values)
+Time for select_in (500:500000) 32 wallclock secs ( 3.96 usr  2.13 sys +  0.00 cusr  0.00 csys =  0.00 CPU)
+
+Time for select_join_in (500:500000) 17 wallclock secs ( 4.02 usr  2.07 sys +  0.00 cusr  0.00 csys =  0.00 CPU)
+
+
+Testing INSERT INTO ... SELECT
+Time for insert_select_1_key (1):   6 wallclock secs ( 0.00 usr  0.00 sys +  0.00 cusr  0.00 csys =  0.00 CPU)
+Time for insert_select_2_keys (1):   8 wallclock secs ( 0.00 usr  0.00 sys +  0.00 cusr  0.00 csys =  0.00 CPU)
+Time for drop table(2):  0 wallclock secs ( 0.00 usr  0.00 sys +  0.00 cusr  0.00 csys =  0.00 CPU)
+
+Testing delete
+Time for delete_key (10000):  4 wallclock secs ( 0.88 usr  0.55 sys +  0.00 cusr  0.00 csys =  0.00 CPU)
+Time for delete_range (12):  9 wallclock secs ( 0.00 usr  0.00 sys +  0.00 cusr  0.00 csys =  0.00 CPU)
+
+Insert into table with 16 keys and with a primary key with 16 parts
+Time for insert_key (100000): 98 wallclock secs (13.49 usr  3.80 sys +  0.00 cusr  0.00 csys =  0.00 CPU)
+
+Testing update of keys
+Time for update_of_primary_key_many_keys (256): 20 wallclock secs ( 0.03 usr  0.01 sys +  0.00 cusr  0.00 csys =  0.00 CPU)
+
+Deleting rows from the table
+Time for delete_big_many_keys (128): 47 wallclock secs ( 0.02 usr  0.01 sys +  0.00 cusr  0.00 csys =  0.00 CPU)
+
+Deleting everything from table
+Time for delete_all_many_keys (1): 47 wallclock secs ( 0.02 usr  0.01 sys +  0.00 cusr  0.00 csys =  0.00 CPU)
+
+Inserting 100000 rows with multiple values
+Time for multiple_value_insert (100000):  7 wallclock secs ( 1.88 usr  0.05 sys +  0.00 cusr  0.00 csys =  0.00 CPU)
+
+Time for drop table(1):  0 wallclock secs ( 0.00 usr  0.00 sys +  0.00 cusr  0.00 csys =  0.00 CPU)
+
+Total time: 2381 wallclock secs (693.26 usr 241.11 sys +  0.00 cusr  0.00 csys =  0.00 CPU)
diff --git a/sql-bench/Results/select-mysql-Linux_2.4.4_SMP_alpha b/sql-bench/Results/select-mysql-Linux_2.4.4_SMP_alpha
new file mode 100644
index 0000000000000000000000000000000000000000..939f130f92e52107cacf55c010e61885a34aa077
--- /dev/null
+++ b/sql-bench/Results/select-mysql-Linux_2.4.4_SMP_alpha
@@ -0,0 +1,30 @@
+Testing server 'MySQL 4.0.5 beta' at 2002-10-23 13:29:36
+
+Testing the speed of selecting on keys that consist of many parts
+The test-table has 10000 rows and the test is done with 500 ranges.
+
+Creating table
+Inserting 10000 rows
+Time to insert (10000):  4 wallclock secs ( 0.81 usr  0.38 sys +  0.00 cusr  0.00 csys =  0.00 CPU)
+
+Test if the database has a query cache
+Time for select_cache (10000): 89 wallclock secs ( 3.03 usr  0.74 sys +  0.00 cusr  0.00 csys =  0.00 CPU)
+
+Time for select_cache2 (10000): 91 wallclock secs ( 3.53 usr  0.76 sys +  0.00 cusr  0.00 csys =  0.00 CPU)
+
+Testing big selects on the table
+Time for select_big (70:17207):  0 wallclock secs ( 0.14 usr  0.08 sys +  0.00 cusr  0.00 csys =  0.00 CPU)
+Time for select_range (410:1057904): 242 wallclock secs ( 8.57 usr  4.60 sys +  0.00 cusr  0.00 csys =  0.00 CPU)
+Time for min_max_on_key (70000): 178 wallclock secs (21.67 usr  4.75 sys +  0.00 cusr  0.00 csys =  0.00 CPU)
+Time for count_on_key (50000): 412 wallclock secs (16.70 usr  3.58 sys +  0.00 cusr  0.00 csys =  0.00 CPU)
+
+Time for count_group_on_key_parts (1000:100000): 37 wallclock secs ( 1.02 usr  0.48 sys +  0.00 cusr  0.00 csys =  0.00 CPU)
+Testing count(distinct) on the table
+Time for count_distinct_key_prefix (1000:1000): 28 wallclock secs ( 0.44 usr  0.09 sys +  0.00 cusr  0.00 csys =  0.00 CPU)
+Time for count_distinct (1000:1000): 32 wallclock secs ( 0.44 usr  0.07 sys +  0.00 cusr  0.00 csys =  0.00 CPU)
+Time for count_distinct_2 (1000:1000): 32 wallclock secs ( 0.44 usr  0.08 sys +  0.00 cusr  0.00 csys =  0.00 CPU)
+Time for count_distinct_group_on_key (1000:6000): 38 wallclock secs ( 0.48 usr  0.12 sys +  0.00 cusr  0.00 csys =  0.00 CPU)
+Time for count_distinct_group_on_key_parts (1000:100000): 50 wallclock secs ( 1.15 usr  0.47 sys +  0.00 cusr  0.00 csys =  0.00 CPU)
+Time for count_distinct_group (1000:100000): 50 wallclock secs ( 1.14 usr  0.52 sys +  0.00 cusr  0.00 csys =  0.00 CPU)
+Time for count_distinct_big (100:1000000): 15 wallclock secs ( 7.36 usr  4.25 sys +  0.00 cusr  0.00 csys =  0.00 CPU)
+Total time: 1298 wallclock secs (66.92 usr 20.96 sys +  0.00 cusr  0.00 csys =  0.00 CPU)
diff --git a/sql-bench/Results/transactions-mysql-Linux_2.4.4_SMP_alpha b/sql-bench/Results/transactions-mysql-Linux_2.4.4_SMP_alpha
new file mode 100644
index 0000000000000000000000000000000000000000..47f81534c1e7f06673de448de93fdae01d35751a
--- /dev/null
+++ b/sql-bench/Results/transactions-mysql-Linux_2.4.4_SMP_alpha
@@ -0,0 +1,3 @@
+Testing server 'MySQL 4.0.5 beta' at 2002-10-23 13:51:14
+
+Test skipped because the database doesn't support transactions
diff --git a/sql-bench/Results/wisconsin-mysql-Linux_2.4.4_SMP_alpha b/sql-bench/Results/wisconsin-mysql-Linux_2.4.4_SMP_alpha
new file mode 100644
index 0000000000000000000000000000000000000000..445246a27c753400f9781a5f4cd39d460f670d09
--- /dev/null
+++ b/sql-bench/Results/wisconsin-mysql-Linux_2.4.4_SMP_alpha
@@ -0,0 +1,14 @@
+Testing server 'MySQL 4.0.5 beta' at 2002-10-23 13:51:14
+
+Wisconsin benchmark test
+
+Time for create_table (3):  0 wallclock secs ( 0.00 usr  0.00 sys +  0.00 cusr  0.00 csys =  0.00 CPU)
+
+Inserting data
+Time to insert (31000): 13 wallclock secs ( 1.99 usr  1.40 sys +  0.00 cusr  0.00 csys =  0.00 CPU)
+Time to delete_big (1):  0 wallclock secs ( 0.00 usr  0.00 sys +  0.00 cusr  0.00 csys =  0.00 CPU)
+
+Running the actual benchmark
+Time for wisc_benchmark (114):  4 wallclock secs ( 1.66 usr  0.73 sys +  0.00 cusr  0.00 csys =  0.00 CPU)
+
+Total time: 17 wallclock secs ( 3.66 usr  2.13 sys +  0.00 cusr  0.00 csys =  0.00 CPU)
diff --git a/sql-bench/bench-init.pl.sh b/sql-bench/bench-init.pl.sh
index 4e7e1c295048e01c283b3a6e86e2977ae015ae5d..9b999ee7f9515660dc2c72208fcb674d8a747985 100644
--- a/sql-bench/bench-init.pl.sh
+++ b/sql-bench/bench-init.pl.sh
@@ -39,7 +39,7 @@ require "$pwd/server-cfg" || die "Can't read Configuration file: $!\n";
 $|=1;				# Output data immediately
 
 $opt_skip_test=$opt_skip_create=$opt_skip_delete=$opt_verbose=$opt_fast_insert=$opt_lock_tables=$opt_debug=$opt_skip_delete=$opt_fast=$opt_force=$opt_log=$opt_use_old_results=$opt_help=$opt_odbc=$opt_small_test=$opt_small_tables=$opt_samll_key_tables=$opt_stage=$opt_old_headers=$opt_die_on_errors=$opt_tcpip=$opt_random=0;
-$opt_cmp=$opt_user=$opt_password="";
+$opt_cmp=$opt_user=$opt_password=$opt_connect_options="";
 $opt_server="mysql"; $opt_dir="output";
 $opt_host="localhost";$opt_database="test";
 $opt_machine=""; $opt_suffix="";
@@ -55,11 +55,11 @@ $log_prog_args=join(" ", skip_arguments(\@ARGV,"comments","cmp","server",
 					"use-old-results","skip-test",
 					"optimization","hw",
 					"machine", "dir", "suffix", "log"));
-GetOptions("skip-test=s","comments=s","cmp=s","server=s","user=s","host=s","database=s","password=s","loop-count=i","row-count=i","skip-create","skip-delete","verbose","fast-insert","lock-tables","debug","fast","force","field-count=i","regions=i","groups=i","time-limit=i","log","use-old-results","machine=s","dir=s","suffix=s","help","odbc","small-test","small-tables","small-key-tables","stage=i","threads=i","random","old-headers","die-on-errors","create-options=s","hires","tcpip","silent","optimization=s","hw=s","socket=s") || usage();
+GetOptions("skip-test=s","comments=s","cmp=s","server=s","user=s","host=s","database=s","password=s","loop-count=i","row-count=i","skip-create","skip-delete","verbose","fast-insert","lock-tables","debug","fast","force","field-count=i","regions=i","groups=i","time-limit=i","log","use-old-results","machine=s","dir=s","suffix=s","help","odbc","small-test","small-tables","small-key-tables","stage=i","threads=i","random","old-headers","die-on-errors","create-options=s","hires","tcpip","silent","optimization=s","hw=s","socket=s","connect-options=s") || usage();
 
 usage() if ($opt_help);
 $server=get_server($opt_server,$opt_host,$opt_database,$opt_odbc,
-                   machine_part(), $opt_socket);
+                   machine_part(), $opt_socket, $opt_connect_options);
 $limits=merge_limits($server,$opt_cmp);
 $date=date();
 @estimated=(0.0,0.0,0.0);		# For estimated time support
@@ -593,7 +593,11 @@ All benchmarks takes the following options:
  
 --hw='some comments'
  Add coments about hardware used for this test.
- 
+
+--connect-options='some connect options'
+  Add options, which uses at DBI connect.
+  For example --connect-options=mysql_read_default_file=/etc/my.cnf.
+
 EOF
   exit(0);
 }
diff --git a/sql-bench/crash-me.sh b/sql-bench/crash-me.sh
index 02e3072a3f9fd337bb9fd8108b76d3e5382288ce..5fa67773566143829434443edb765cfaca2d2221 100644
--- a/sql-bench/crash-me.sh
+++ b/sql-bench/crash-me.sh
@@ -38,7 +38,7 @@
 # as such, and clarify ones such as "mediumint" with comments such as
 # "3-byte int" or "same as xxx".
 
-$version="1.58";
+$version="1.59";
 
 use DBI;
 use Getopt::Long;
@@ -253,6 +253,9 @@ check_and_report("\` as identifier quote",'quote_ident_with_`',[],
 		 'select `A` from crash_me',[],"1",0);
 check_and_report("[] as identifier quote",'quote_ident_with_[',[],
 		 'select [A] from crash_me',[],"1",0);
+report('Double "" in identifiers as "','quote_ident_with_dbl_"',
+        'create table crash_me1 ("abc""d" integer)',
+	'drop table crash_me1');		 
 
 report("Column alias","column_alias","select a as ab from crash_me");
 report("Table alias","table_alias","select b.a from crash_me as b");
@@ -301,6 +304,7 @@ try_and_report("LIMIT number of rows","select_limit",
 	       ["with TOP",
 		"select TOP 1 * from crash_me"]);
 report("SELECT with LIMIT #,#","select_limit2", "select * from crash_me limit 1,1");
+report("SELECT with LIMIT # OFFSET #","select_limit3", "select * from crash_me limit 1 offset 1");
 
 # The following alter table commands MUST be kept together!
 if ($dbh->do("create table crash_q (a integer, b integer,c1 CHAR(10))"))
@@ -434,6 +438,9 @@ report("hex strings (x'1ace')","hex_strings","select x'1ace' $end_query");
 report_result("Value of logical operation (1=1)","logical_value",
 	      "select (1=1) $end_query");
 
+report_result("Value of TRUE","value_of_true","select TRUE $end_query");
+report_result("Value of FALSE","value_of_false","select FALSE $end_query");
+
 $logical_value= $limits{'logical_value'};
 
 $false=0;
@@ -584,7 +591,7 @@ print "$limits{'query_size'}\n";
 	      "int not null identity,unique(q)",
 	      # postgres types
 	      "box","bool","circle","polygon","point","line","lseg","path",
-	      "interval", "serial", "inet", "cidr", "macaddr",
+	      "interval", "inet", "cidr", "macaddr",
 
 	      # oracle types
 	      "varchar2(16)","nvarchar2(16)","number(9,2)","number(9)",
@@ -769,7 +776,6 @@ try_and_report("Automatic row id", "automatic_rowid",
    ["CURRENT_DATE","current_date","current_date",0,2],
    ["CURRENT_TIME","current_time","current_time",0,2],
    ["CURRENT_TIMESTAMP","current_timestamp","current_timestamp",0,2],
-   ["CURRENT_USER","current_user","current_user",0,2],
    ["EXTRACT","extract_sql","extract(minute from timestamp '2000-02-23 18:43:12.987')",43,0],
    ["LOCALTIME","localtime","localtime",0,2],
    ["LOCALTIMESTAMP","localtimestamp","localtimestamp",0,2],
@@ -778,11 +784,8 @@ try_and_report("Automatic row id", "automatic_rowid",
    ["NULLIF with numbers","nullif_num","NULLIF(NULLIF(1,2),1)",undef(),4],
    ["OCTET_LENGTH","octet_length","octet_length('abc')",3,0],
    ["POSITION","position","position('ll' in 'hello')",3,0],
-   ["SESSION_USER","session_user","session_user",0,2],
-   ["SYSTEM_USER","system_user","system_user",0,2],
    ["TRIM","trim","trim(trailing from trim(LEADING FROM ' abc '))","abc",3],
    ["UPPER","upper","UPPER('abc')","ABC",1],
-   ["USER","user","user"],
    ["concatenation with ||","concat_as_||","'abc' || 'def'","abcdef",1],
    );
 
@@ -960,8 +963,61 @@ try_and_report("Automatic row id", "automatic_rowid",
    ["automatic num->string convert","auto_num2string","concat('a',2)","a2",1],
    ["automatic string->num convert","auto_string2num","'1'+2",3,0],
    ["concatenation with +","concat_as_+","'abc' + 'def'","abcdef",1],
+   ["SUBSTR (2 arg)",'substr2arg',"substr('abcd',2)",'bcd',1],  #sapdb func
+   ["SUBSTR (3 arg)",'substr3arg',"substr('abcd',2,2)",'bc',1],
+   ["LFILL (3 arg)",'lfill3arg',"lfill('abcd','.',6)",'..abcd',1],
+   ["RFILL (3 arg)",'rfill3arg',"rfill('abcd','.',6)",'abcd..',1],
+   ["RPAD (4 arg)",'rpad4arg',"rpad('abcd',2,'+-',8)",'abcd+-+-',1],
+   ["LPAD (4 arg)",'rpad4arg',"lpad('abcd',2,'+-',8)",'+-+-abcd',1],
+   ["SAPDB compatible TRIM (1 arg)",'trim1arg',"trim(' abcd ')",'abcd',1],
+   ["SAPDB compatible TRIM (2 arg)",'trim2arg',"trim('..abcd..','.')",'abcd',1],
+   ["LTRIM (2 arg)",'ltrim2arg',"ltrim('..abcd..','.')",'abcd..',1],
+   ["RTRIM (2 arg)",'rtrim2arg',"rtrim('..abcd..','.')",'..abcd',1],
+   ["EXPAND",'expand2arg',"expand('abcd',6)",'abcd  ',0],
+   ["REPLACE (2 arg) ",'replace2arg',"replace('AbCd','bC')",'Ad',1],
+   ["MAPCHAR",'mapchar',"mapchar('Aâ')",'Aa',1],
+   ["ALPHA",'alpha',"alpha('Aâ',2)",'AA',1],
+   ["ASCII in string cast",'ascii_string',"ascii('a')",'a',1],
+   ["EBCDIC in string cast",'ebcdic_string',"ebcdic('a')",'a',1],
+   ["TRUNC (1 arg)",'trunc1arg',"trunc(222.6)",222,0],
+   ["NOROUND",'noround',"noround(222.6)",222.6,0],
+   ["FIXED",'fixed',"fixed(222.6666,10,2)",'222.67',0],
+   ["FLOAT",'float',"float(6666.66,4)",6667,0],
+   ["LENGTH",'length',"length(1)",2,0],
+   ["INDEX",'index',"index('abcdefg','cd',1,1)",3,0],
+   ["ADDDATE",'adddate',"ADDDATE('20021201',3)",'20021204',0],
+   ["SUBDATE",'subdate',"SUBDATE('20021204',3)",'20021201',0],
+   ["DATEDIFF (2 arg)",'datediff2arg',"DATEDIFF('20021204','20021201')",'3',0], # sapdb
+   ["DAYOFWEEK with sapdb internal date as arg",'dayofweek_sapdb',"DAYOFWEEK('19630816')",'5',0],
+   ["WEEKOFYEAR",'weekofyear',"WEEKOFYEAR('19630816')",'33',0],
+   ["DAYOFMONTH with sapdb internal date as arg",'dayofmonth_sapdb',"dayofmonth('19630816')",'16',0],
+   ["DAYOFYEAR  with sapdb internal date as arg",'dayofyear_sapdb',"DAYOFYEAR('19630816')",'228',0],
+   ["MAKEDATE",'makedate',"MAKEDATE(1963,228)",'19630816',0],
+   ["DAYNAME  with sapdb internal date as arg",'dayname_sapdb',"DAYNAME('19630816')",'Friday',0],
+   ["MONTHNAME with sapdb internal date as arg",'monthname_sapdb',"MONTHNAME('19630816')",'August',0],
+   ["ADDTIME",'addtime',"ADDTIME('00200212','00000300')",'00200215',0],
+   ["SUBTIME",'subdate',"SUBDATE('00200215','00000300')",'00200212',0],
+   ["TIMEDIFF",'timediff',"TIMEDIFF('00200215','00200212')",'00000003',0],
+   ["MAKETIME",'maketime',"MAKETIME(20,02,12)",'00200212',0],
+   ["YEAR with sapdb internal date as arg",'year_sapdb',"YEAR('20021201')",'2002',0],
+   ["MONTH with sapdb internal date as arg",'month_sapdb',"MONTH('20021201')",'12',0],
+   ["DAY",'day',"DAY('20021201')",1,0],
+   ["HOUR with sapdb internal time as arg",'hour_sapdb',"HOUR('00200212')",20,0],
+   ["MINUTE with sapdb internal time as arg",'minute_sapdb',"MINUTE('00200212')",2,0],
+   ["SECOND with sapdb internal time as arg",'second_sapdb',"SECOND('00200212')",12,0],
+   ["MICROSECOND",'microsecond',"MICROSECOND('19630816200212111111')",'111111',0],
+   ["TIMESTAMP",'timestamp',"timestamp('19630816','00200212')",'19630816200212000000',0],
+   ["TIME",'time',"time('00200212')",'00200212',0],
+   ["DATE",'date',"date('19630816')",'19630816',0],
+   ["VALUE",'value',"value(NULL,'WALRUS')",'WALRUS',0],
+   ["DECODE",'decode',"DECODE('S-103','T72',1,'S-103',2,'Leopard',3)",2,0],
+   ["NUM",'num',"NUM('2123')",2123,0],
+   ["CHAR (conversation date)",'char_date',"CHAR(DATE('19630816'),EUR)",'16.08.1963',0],
+   ["CHR (any type to string)",'chr_str',"CHR(67)",'67',0],
+   ["HEX",'hex',"HEX('A')",41,0],
    );
 
+
 @sql_group_functions=
   (
    ["AVG","avg","avg(a)",1,0],
@@ -1131,6 +1187,20 @@ else
 }
 
 
+if ($limits{'func_extra_noround'} eq 'yes')
+{
+  report("Ignoring NOROUND","ignoring_noround",
+  "create table crash_q (a int)",
+  "insert into crash_q values(noround(10.22))",
+  "drop table crash_q $drop_attr"); 
+}
+
+check_parenthesis("func_sql_","CURRENT_USER");
+check_parenthesis("func_sql_","SESSION_USER");
+check_parenthesis("func_sql_","SYSTEM_USER");
+check_parenthesis("func_sql_","USER");
+
+
 report("LIKE on numbers","like_with_number",
        "create table crash_q (a int,b int)",
        "insert into crash_q values(10,10)",
@@ -1561,19 +1631,29 @@ if (!defined($limits{"transactions"}))
 {
   my ($limit,$type);
   $limit="transactions";
+  $limit_r="rollback_metadata";
   print "$limit: ";
   foreach $type (('', 'type=bdb', 'type=innodb', 'type=gemini'))
   {
     undef($limits{$limit});
-    last if (!report_trans($limit,
+    if (!report_trans($limit,
 			   [create_table("crash_q",["a integer not null"],[],
 					 $type),
 			    "insert into crash_q values (1)"],
 			   "select * from crash_q",
 			   "drop table crash_q $drop_attr"
-			  ));
+			  ))
+     {
+       report_rollback($limit_r,
+              [create_table("crash_q",["a integer not null"],[],
+				 $type)],
+			    "insert into crash_q values (1)",
+			   "drop table crash_q $drop_attr" );
+     last;
+     };
   }
   print "$limits{$limit}\n";
+  print "$limit_r: $limits{$limit_r}\n";
 }
 
 report("atomic updates","atomic_updates",
@@ -1644,14 +1724,29 @@ report("Column constraints","constraint_check",
        "create table crash_q (a int check (a>0))",
        "drop table crash_q $drop_attr");
 
+report("Ignoring column constraints","ignoring_constraint_check",
+       "create table crash_q (a int check (a>0))",
+       "insert into crash_q values(0)",
+       "drop table crash_q $drop_attr") if ($limits{'constraint_check'} eq 'yes');
+
 report("Table constraints","constraint_check_table",
        "create table crash_q (a int ,b int, check (a>b))",
        "drop table crash_q $drop_attr");
 
-report("Named constraints","constraint_check",
+report("Ignoring table constraints","ignoring_constraint_check_table",
+       "create table crash_q (a int ,b int, check (a>b))",
+       "insert into crash_q values(0,0)",
+       "drop table crash_q $drop_attr") if ($limits{'constraint_check_table'} eq 'yes');
+
+report("Named constraints","constraint_check_named",
        "create table crash_q (a int ,b int, constraint abc check (a>b))",
        "drop table crash_q $drop_attr");
 
+report("Ignoring named constraints","ignoring_constraint_check_named",
+       "create table crash_q (a int ,b int, constraint abc check (a>b))",
+       "insert into crash_q values(0,0)",
+       "drop table crash_q $drop_attr") if ($limits{'constraint_check_named'} eq 'yes');
+
 report("NULL constraint (SyBase style)","constraint_null",
        "create table crash_q (a int null)",
        "drop table crash_q $drop_attr");
@@ -2018,7 +2113,7 @@ $key="safe_decimal_arithmetic";
 if (!defined($limits{$key}))
 {
    print "$prompt=";
-   save_incomplete($limit,$prompt);	
+   save_incomplete($key,$prompt);	
    if (!safe_query($server->create("crash_me_a",["a decimal(10,2)","b decimal(10,2)"]))) 
      {
        print DBI->errstr();
@@ -2045,6 +2140,53 @@ if (!defined($limits{$key}))
   print "$prompt=$limits{$key} (cached)\n";
 }
 
+# Check where is null values in sorted recordset
+if (!safe_query($server->create("crash_me_n",["i integer","r integer"]))) 
+ {
+   print DBI->errstr();
+   die "Can't create table 'crash_me_n' $DBI::errstr\n";
+ };
+assert("insert into crash_me_n (i) values(1)");
+assert("insert into crash_me_n values(2,2)");
+assert("insert into crash_me_n values(3,3)");
+assert("insert into crash_me_n values(4,4)");
+assert("insert into crash_me_n (i) values(5)");
+
+$key = "position_of_null";
+$prompt ="Where is null values in sorted recordset";
+if (!defined($limits{$key}))
+{
+ save_incomplete($key,$prompt);	
+ print "$prompt=";
+ $sth=$dbh->prepare("select r from crash_me_n order by r ");
+ $sth->execute;
+ $limit= detect_null_position($sth);
+ $sth->finish;
+ print "$limit\n";
+ save_config_data($key,$limit,$prompt);
+} else {
+  print "$prompt=$limits{$key} (cache)\n";
+}
+
+$key = "position_of_null_desc";
+$prompt ="Where is null values in sorted recordset (DESC)";
+if (!defined($limits{$key}))
+{
+ save_incomplete($key,$prompt);	
+ print "$prompt=";
+ $sth=$dbh->prepare("select r from crash_me_n order by r desc");
+ $sth->execute;
+ $limit= detect_null_position($sth);
+ $sth->finish;
+ print "$limit\n";
+ save_config_data($key,$limit,$prompt);
+} else {
+  print "$prompt=$limits{$key} (cache)\n";
+}
+
+
+assert("drop table  crash_me_n $drop_attr");
+
 
 #
 # End of test
@@ -2059,6 +2201,41 @@ $dbh->disconnect || warn $dbh->errstr;
 save_all_config_data();
 exit 0;
 
+# Check where is nulls in the sorted result (for)
+# it expects exactly 5 rows in the result
+
+sub detect_null_position
+{
+  my $sth = shift;
+  my ($z,$r1,$r2,$r3,$r4,$r5);
+ $r1 = $sth->fetchrow_array;
+ $r2 = $sth->fetchrow_array;
+ $r3 = $sth->fetchrow_array;
+ $r4 = $sth->fetchrow_array;
+ $r5 = $sth->fetchrow_array;
+ return "first" if ( !defined($r1) && !defined($r2) && defined($r3));
+ return "last" if ( !defined($r5) && !defined($r4) && defined($r3));
+ return "random";
+}
+
+sub check_parenthesis {
+ my $prefix=shift;
+ my $fn=shift;
+ my $resultat='no';
+ my $param_name=$prefix.lc($fn);
+ 
+ save_incomplete($param_name,$fn);
+ if (safe_query("select $fn $end_query") == 1)
+  {
+    $resultat="yes";
+  } 
+  elsif ( safe_query("select $fn() $end_query") == 1)   
+  {    
+    $resultat="with_parenthesis";
+  }
+  save_config_data($param_name,$resultat,$fn);
+}
+
 sub usage
 {
     print <<EOF;
@@ -2561,10 +2738,10 @@ sub report_result
   {
     save_incomplete($limit,$prompt);
     $error=safe_query_result($query,"1",2);
-    save_config_data($limit,$error ? "not supported" : $last_result,$prompt);
+    save_config_data($limit,$error ? "not supported" :$last_result,$prompt);
   }
   print "$limits{$limit}\n";
-  return $limits{$limit} ne "no";
+  return $limits{$limit} ne "not supported";
 }
 
 sub report_trans
@@ -2578,17 +2755,12 @@ sub report_trans
     {
       if (safe_query(\@$queries))
       {
-	  $rc = $dbh->rollback;
-	  if ($rc) {
-	    $dbh->{AutoCommit} = 1;
+	  $dbh->rollback;
+          $dbh->{AutoCommit} = 1;
 	    if (safe_query_result($check,"","")) {
 	      save_config_data($limit,"yes",$limit);
 	    }
 	    safe_query($clear);
-	  } else {
-	    $dbh->{AutoCommit} = 1;
-	    save_config_data($limit,"error",$limit);
-	  }
       } else {
         save_config_data($limit,"error",$limit);
       }
@@ -2603,6 +2775,39 @@ sub report_trans
   return $limits{$limit} ne "yes";
 }
 
+sub report_rollback
+{
+  my ($limit,$queries,$check,$clear)=@_;
+  if (!defined($limits{$limit}))
+  {
+    save_incomplete($limit,$prompt);
+    eval {undef($dbh->{AutoCommit})};
+    if (!$@)
+    {
+      if (safe_query(\@$queries))
+      {
+	  $dbh->rollback;
+           $dbh->{AutoCommit} = 1;
+           if (safe_query($check)) {
+	      save_config_data($limit,"no",$limit);
+	    }  else  {
+	      save_config_data($limit,"yes",$limit);
+	    };
+	    safe_query($clear);
+      } else {
+        save_config_data($limit,"error",$limit);
+      }
+    }
+    else
+    {
+      save_config_data($limit,"error",$limit);
+    }
+    safe_query($clear);
+  }
+  $dbh->{AutoCommit} = 1;
+  return $limits{$limit} ne "yes";
+}
+
 
 sub check_and_report
 {
@@ -2929,7 +3134,7 @@ sub read_config_data
       {
 	if ($key !~ /restart/i)
 	{
-	  $limits{$key}=$limit;
+	  $limits{$key}=$limit eq "null"? undef : $limit;
 	  $prompts{$key}=length($prompt) ? substr($prompt,2) : "";
 	  delete $limits{'restart'};
 	}
@@ -2959,7 +3164,8 @@ sub save_config_data
   return if (defined($limits{$key}) && $limits{$key} eq $limit);
   if (!defined($limit) || $limit eq "")
   {
-    die "Undefined limit for $key\n";
+#    die "Undefined limit for $key\n";
+     $limit = 'null'; 
   }
   print CONFIG_FILE "$key=$limit\t# $prompt\n";
   $limits{$key}=$limit;
@@ -3613,5 +3819,6 @@ sub check_query
 }
 
 
+
 ### TODO:
 # OID test instead of / in addition to _rowid
diff --git a/sql-bench/server-cfg.sh b/sql-bench/server-cfg.sh
index ea1697fb4c387254bc9467782798c9249dd43f97..213ecacea6f40aee752e6d822b815f17bd833680 100644
--- a/sql-bench/server-cfg.sh
+++ b/sql-bench/server-cfg.sh
@@ -33,10 +33,10 @@
 
 sub get_server
 {
-  my ($name,$host,$database,$odbc,$machine,$socket)=@_;
+  my ($name,$host,$database,$odbc,$machine,$socket,$connect_options)=@_;
   my ($server);
   if ($name =~ /mysql/i)
-  { $server=new db_MySQL($host, $database, $machine, $socket); }
+  { $server=new db_MySQL($host, $database, $machine, $socket,$connect_options); }
   elsif ($name =~ /pg/i)
   { $server= new db_Pg($host,$database); }
   elsif ($name =~ /msql/i)
@@ -69,11 +69,13 @@ sub get_server
   { $server= new db_db2($host,$database); }
   elsif ($name =~ /Mimer/i)
   { $server= new db_Mimer($host,$database); }
+  elsif ($name =~ /Sapdb/i)
+  { $server= new db_sapdb($host,$database); }
   elsif ($name =~ /interBase/i)
   { $server= new db_interbase($host,$database); }
   else
   {
-      die "Unknown sql server name used: $name\nUse one of: Access, Adabas, AdabasD, Empress, FrontBase, Oracle, Informix, InterBase, DB2, mSQL, Mimer, MS-SQL, MySQL, Pg, Solid or Sybase.\nIf the connection is done trough ODBC the name must end with _ODBC\n";
+      die "Unknown sql server name used: $name\nUse one of: Access, Adabas, AdabasD, Empress, FrontBase, Oracle, Informix, InterBase, DB2, mSQL, Mimer, MS-SQL, MySQL, Pg, Solid, SAPDB or Sybase.\nIf the connection is done trough ODBC the name must end with _ODBC\n";
   }
   if ($name =~ /_ODBC$/i || defined($odbc) && $odbc)
   {
@@ -94,7 +96,7 @@ sub get_server
 sub all_servers
 {
   return ["Access", "Adabas", "DB2", "Empress", "FrontBase", "Oracle",
-	  "Informix", "InterBase", "Mimer", "mSQL", "MS-SQL", "MySQL", "Pg",
+	  "Informix", "InterBase", "Mimer", "mSQL", "MS-SQL", "MySQL", "Pg","SAPDB",
 	  "Solid", "Sybase"];
 }
 
@@ -106,7 +108,7 @@ package db_MySQL;
 
 sub new
 {
-  my ($type,$host,$database,$machine,$socket)= @_;
+  my ($type,$host,$database,$machine,$socket,$connect_options)= @_;
   my $self= {};
   my %limits;
   bless $self;
@@ -114,6 +116,7 @@ sub new
   $self->{'cmp_name'}		= "mysql";
   $self->{'data_source'}	= "DBI:mysql:database=$database;host=$host";
   $self->{'data_source'} .= ";mysql_socket=$socket" if($socket);
+  $self->{'data_source'} .= ";$connect_options" if($connect_options);
   $self->{'limits'}		= \%limits;
   $self->{'blob'}		= "blob";
   $self->{'text'}		= "text";
@@ -3358,4 +3361,211 @@ sub fix_for_insert
   return $cmd;
 }
 
+#############################################################################
+#	     Configuration for SAPDB 
+#############################################################################
+
+package db_Sapdb;
+
+sub new
+{
+  my ($type,$host,$database)= @_;
+  my $self= {};
+  my %limits;
+  bless $self;
+
+  $self->{'cmp_name'}		= "sapdb";
+  $self->{'data_source'}	= "DBI:SAP_DB:$database";
+  $self->{'limits'}		= \%limits;
+  $self->{'blob'}		= "LONG"; # *
+  $self->{'text'}		= "LONG"; # *
+  $self->{'double_quotes'}	= 1; # Can handle:  'Walker''s'
+  $self->{'drop_attr'}		= "";
+  $self->{'transactions'}	= 1; # Transactions enabled *
+  $self->{'char_null'}          = "";
+  $self->{'numeric_null'}       = "";
+
+  $limits{'max_conditions'}	= 9999; # (Actually not a limit) *
+  $limits{'max_columns'}	= 1023;	# Max number of columns in table *
+  $limits{'max_tables'}		= 65000;	# Should be big enough * unlimited actually
+  $limits{'max_text_size'}	= 15000; # Max size with default buffers. 
+  $limits{'query_size'}		= 64*1024; # Max size with default buffers. *64 kb by default. May be set by system variable 
+  $limits{'max_index'}		= 510; # Max number of keys *
+  $limits{'max_index_parts'}	= 16; # Max segments/key *
+  $limits{'max_column_name'}	= 32; # max table and column name * 
+
+  $limits{'join_optimizer'}	= 1; # Can optimize FROM tables *
+  $limits{'load_data_infile'}	= 0; # Has load data infile *
+  $limits{'lock_tables'}	= 1; # Has lock tables 
+  $limits{'functions'}		= 1; # Has simple functions (+/-) *
+  $limits{'group_functions'}	= 1; # Have group functions *
+  $limits{'group_func_sql_min_str'} = 1; # Can execute MIN() and MAX() on strings *
+  $limits{'group_distinct_functions'}= 1; # Have count(distinct)  *
+  $limits{'select_without_from'}= 0; # Cannot do 'select 1';  *
+  $limits{'multi_drop'}		= 0; # Drop table cannot take many tables *
+  $limits{'subqueries'}		= 1; # Supports sub-queries. *
+  $limits{'left_outer_join'}	= 1; # Supports left outer joins *
+  $limits{'table_wildcard'}	= 1; # Has SELECT table_name.*
+  $limits{'having_with_alias'}  = 0; # Can use aliases in HAVING *
+  $limits{'having_with_group'}	= 1; # Can use group functions in HAVING *
+  $limits{'like_with_column'}	= 1; # Can use column1 LIKE column2 *
+  $limits{'order_by_position'}  = 1; # Can use 'ORDER BY 1' *
+  $limits{'group_by_position'}  = 0; # Cannot use 'GROUP BY 1' *
+  $limits{'alter_table'}	= 1; # Have ALTER TABLE *
+  $limits{'alter_add_multi_col'}= 1; # Have ALTER TABLE t add a int,add b int; *
+  $limits{'alter_table_dropcol'}= 1; # Have ALTER TABLE DROP column  *
+  $limits{'insert_multi_value'} = 0; # INSERT ... values (1,2),(3,4) *
+
+  $limits{'group_func_extra_std'} = 0; # Does not have group function std().
+
+  $limits{'func_odbc_mod'}	= 0; # Have function mod. *
+  $limits{'func_extra_%'}	= 0; # Does not have % as alias for mod() *
+  $limits{'func_odbc_floor'}	= 1; # Has func_odbc_floor function *
+  $limits{'func_extra_if'}	= 0; # Does not have function if. *
+  $limits{'column_alias'}	= 1; # Alias for fields in select statement. *
+  $limits{'NEG'}		= 1; # Supports -id *
+  $limits{'func_extra_in_num'}	= 0; # Has function in *
+  $limits{'limit'}		= 0; # Does not support the limit attribute *
+  $limits{'working_blobs'}	= 1; # If big varchar/blobs works *
+  $limits{'order_by_unused'}	= 1; # 
+  $limits{'working_all_fields'} = 1; #
+
+
+  return $self;
+}
+
+#
+# Get the version number of the database
+#
+
+sub version
+{
+  my ($self)=@_;
+  my ($dbh,$sth,$version,@row);
+
+  $dbh=$self->connect();
+  $sth = $dbh->prepare("SELECT KERNEL FROM VERSIONS") or die $DBI::errstr;
+  $version="SAP DB (unknown)";
+  if ($sth->execute && (@row = $sth->fetchrow_array)
+      && $row[0] =~ /([\d\.]+)/)
+  {
+    $version="sap-db $1";
+  }
+  $sth->finish;
+  $dbh->disconnect;
+  return $version;
+}
+
+#
+# Connection with optional disabling of logging
+#
+
+sub connect
+{
+  my ($self)=@_;
+  my ($dbh);
+  $dbh=DBI->connect($self->{'data_source'}, $main::opt_user,
+		    $main::opt_password,{ PrintError => 0, AutoCommit => 1}) ||
+		      die "Got error: '$DBI::errstr' when connecting to " . $self->{'data_source'} ." with user: '$main::opt_user' password: '$main::opt_password'\n";
+
+  return $dbh;
+}
+
+#
+# Returns a list of statements to create a table
+# The field types are in ANSI SQL format.
+#
+
+sub create
+{
+  my($self,$table_name,$fields,$index,$options) = @_;
+  my($query,@queries,$nr);
+  my @index;
+  my @keys;
+
+  $query="create table $table_name (";
+  foreach $field (@$fields)
+  {
+    $field =~ s/\bmediumint\b/int/i;
+    $field =~ s/\btinyint\b/int/i;
+    $field =~ s/ int\(\d\)/ int/i;
+    $field =~ s/BLOB/LONG/i;
+    $field =~ s/INTEGER\s*\(\d+\)/INTEGER/i;
+    $field =~ s/SMALLINT\s*\(\d+\)/SMALLINT/i;
+    $field =~ s/FLOAT\s*\((\d+),\d+\)/FLOAT\($1\)/i;
+    $field =~ s/DOUBLE/FLOAT\(38\)/i;
+    $field =~ s/DOUBLE\s+PRECISION/FLOAT\(38\)/i;
+    $query.= $field . ',';
+  }
+  $nr=0;
+  foreach $ind (@$index)
+  {
+    if ( $ind =~ /\bKEY\b/i ){
+      push(@keys,"ALTER TABLE $table_name ADD $ind");
+    } elsif ($ind =~ /^unique.*\(([^\(]*)\)$/i)  {
+      $nr++;
+      my $query="create unique index ${table_name}_$nr on $table_name ($1)";
+      push(@index,$query);
+    }else{
+      my @fields = split(' ',$ind);
+      my $query="CREATE INDEX $fields[1] ON $table_name $fields[2]";
+      print "$query \n";
+      push(@index,$query);
+    }
+  }
+  substr($query,-1)=")";		# Remove last ',';
+  $query.=" $options" if (defined($options));
+  push(@queries,$query);
+  push(@queries,@keys);
+  push(@queries,@index);
+  return @queries;
+}
+
+sub insert_file {
+  my($self,$dbname, $file) = @_;
+  print "insert of an ascii file isn't supported by SAPDB\n";
+  return 0;
+}
+
+#
+# Do any conversions to the ANSI SQL query so that the database can handle it
+#
+
+sub query {
+  my($self,$sql) = @_;
+  return $sql;
+}
+
+sub drop_index {
+  my ($self,$table,$index) = @_;
+  return "DROP INDEX $index";
+}
+
+#
+# Abort if the server has crashed
+# return: 0 if ok
+#	  1 question should be retried
+#
+
+sub abort_if_fatal_error
+{
+  return 0;
+}
+
+sub small_rollback_segment
+{
+  return 0;
+}
+
+sub reconnect_on_errors
+{
+  return 0;
+}
+
+sub fix_for_insert
+{
+  my ($self,$cmd) = @_;
+  return $cmd;
+}
+
 1;
diff --git a/sql-bench/test-create.sh b/sql-bench/test-create.sh
index 2853984e3938761163a0174cf369355746e0191a..1e7d3841bb5b0fe4d593c6284cd3a445286ce0dc 100644
--- a/sql-bench/test-create.sh
+++ b/sql-bench/test-create.sh
@@ -54,7 +54,7 @@ if ($opt_small_test)
 }
 
 
-print "Testing the speed of creating and droping tables\n";
+print "Testing the speed of creating and dropping tables\n";
 print "Testing with $max_tables tables and $opt_loop_count loop count\n\n";
 
 ####
diff --git a/sql/Makefile.am b/sql/Makefile.am
index 09fedd393c2361b04dcc9438efc3a42037656e9f..828e74c67fc070bbf4a8fb72ffc80227fb054626 100644
--- a/sql/Makefile.am
+++ b/sql/Makefile.am
@@ -22,9 +22,8 @@ MYSQLSHAREdir =		$(pkgdatadir)
 MYSQLBASEdir=		$(prefix)
 INCLUDES =		@MT_INCLUDES@ \
 			@bdb_includes@ @innodb_includes@ \
-			-I$(srcdir)/../include \
-			-I$(srcdir)/../regex \
-			-I$(srcdir) -I../include -I. $(openssl_includes)
+			-I$(top_srcdir)/include -I$(top_srcdir)/regex \
+			-I$(srcdir) $(openssl_includes)
 WRAPLIBS=		@WRAPLIBS@
 SUBDIRS =		share
 libexec_PROGRAMS =	mysqld
diff --git a/sql/field.cc b/sql/field.cc
index 73ef4439bc9e74913163f05562cda38d9c01a09c..f2324a0a33183d960ba3d87480fa8e50c59927c7 100644
--- a/sql/field.cc
+++ b/sql/field.cc
@@ -41,6 +41,11 @@
 #include <floatingpoint.h>
 #endif
 
+// Maximum allowed exponent value for converting string to decimal
+#define MAX_EXPONENT 1024
+
+
+
 /*****************************************************************************
   Instansiate templates and static variables
 *****************************************************************************/
@@ -392,7 +397,7 @@ int Field_decimal::store(const char *from, uint len, CHARSET_INFO *cs)
   const char *frac_digits_from, *frac_digits_end;
   /* The sign of the exponent : will be 0 (means no exponent), '+' or '-' */
   char expo_sign_char=0;
-  uint exponent=0;				// value of the exponent
+  uint exponent=0;                                // value of the exponent
   /*
     Pointers used when digits move from the left of the '.' to the
     right of the '.' (explained below)
@@ -488,13 +493,17 @@ int Field_decimal::store(const char *from, uint len, CHARSET_INFO *cs)
     else
       expo_sign_char= '+';
     /*
-      Read digits of the exponent and compute its value
-      'exponent' overflow (e.g. if 1E10000000000000000) is not a problem
-      (the value of the field will be overflow anyway, or 0 anyway, 
-      it does not change anything if the exponent is 2^32 or more
+      Read digits of the exponent and compute its value.  We must care about
+      'exponent' overflow, because as unsigned arithmetic is "modulo", big 
+      exponents will become small (e.g. 1e4294967296 will become 1e0, and the 
+      field will finally contain 1 instead of its max possible value).
     */
-    for (;from!=end && my_isdigit(system_charset_info, (*from)); from++)
+    for (;from!=end && my_isdigit(system_charset_info, *from); from++)
+    {
       exponent=10*exponent+(*from-'0');
+      if (exponent>MAX_EXPONENT)
+        break;
+    }
   }
   
   /*
@@ -536,6 +545,13 @@ int Field_decimal::store(const char *from, uint len, CHARSET_INFO *cs)
     int_digits_added_zeros=2 (to make 1234500).
   */
   
+  /* 
+     Below tmp_uint cannot overflow with small enough MAX_EXPONENT setting,
+     as int_digits_added_zeros<=exponent<4G and 
+     (int_digits_end-int_digits_from)<=max_allowed_packet<=2G and
+     (frac_digits_from-int_digits_tail_from)<=max_allowed_packet<=2G
+  */
+
   if (!expo_sign_char)
     tmp_uint=tmp_dec+(uint)(int_digits_end-int_digits_from);
   else if (expo_sign_char == '-') 
@@ -544,7 +560,7 @@ int Field_decimal::store(const char *from, uint len, CHARSET_INFO *cs)
     frac_digits_added_zeros=exponent-tmp_uint;
     int_digits_end -= tmp_uint;
     frac_digits_head_end=int_digits_end+tmp_uint;
-    tmp_uint=tmp_dec+(uint)(int_digits_end-int_digits_from);	
+    tmp_uint=tmp_dec+(uint)(int_digits_end-int_digits_from);     
   }
   else // (expo_sign_char=='+') 
   {
@@ -571,9 +587,9 @@ int Field_decimal::store(const char *from, uint len, CHARSET_INFO *cs)
 	int_digits_added_zeros=0;
       }
     }
-    tmp_uint=(tmp_dec+(uint)(int_digits_end-int_digits_from)
-	      +(uint)(frac_digits_from-int_digits_tail_from)+
-	      int_digits_added_zeros);
+    tmp_uint= (tmp_dec+(int_digits_end-int_digits_from)+
+               (uint)(frac_digits_from-int_digits_tail_from)+
+               int_digits_added_zeros);
   }
   
   /*
@@ -584,7 +600,7 @@ int Field_decimal::store(const char *from, uint len, CHARSET_INFO *cs)
     If the sign is defined and '-', we need one position for it
   */
 
-  if (field_length < tmp_uint + (int) (sign_char == '-'))
+  if (field_length < tmp_uint + (int) (sign_char == '-')) 
   {
     // too big number, change to max or min number
     Field_decimal::overflow(sign_char == '-');
@@ -647,69 +663,67 @@ int Field_decimal::store(const char *from, uint len, CHARSET_INFO *cs)
       *pos--=' ';  //fill with blanks
   }
   
-  if (tmp_dec)					// This field has decimals
-  { 
-    /*
-      Write digits of the frac_% parts ;
-      Depending on current_thd->count_cutted_fields, we may also want
-      to know if some non-zero tail of these parts will
-      be truncated (for example, 0.002->0.00 will generate a warning,
-      while 0.000->0.00 will not)
-      (and 0E1000000000 will not, while 1E-1000000000 will)
-    */
+  /*
+    Write digits of the frac_% parts ;
+    Depending on current_thd->count_cutted_fields, we may also want
+    to know if some non-zero tail of these parts will
+    be truncated (for example, 0.002->0.00 will generate a warning,
+    while 0.000->0.00 will not)
+    (and 0E1000000000 will not, while 1E-1000000000 will)
+  */
       
-    pos=to+(uint)(field_length-tmp_dec);	// Calculate post to '.'
+  pos=to+(uint)(field_length-tmp_dec);	// Calculate post to '.'
+  right_wall=to+field_length;
+  if (pos != right_wall) 
     *pos++='.';
-    right_wall=to+field_length;
 
-    if (expo_sign_char == '-')
+  if (expo_sign_char == '-')
+  {
+    while (frac_digits_added_zeros-- > 0)
     {
-      while (frac_digits_added_zeros-- > 0)
+      if (pos == right_wall) 
       {
-	if (pos == right_wall) 
-	{
-	  if (current_thd->count_cuted_fields && !is_cuted_fields_incr) 
-	    break; // Go on below to see if we lose non zero digits
-	  return 0;
-	}
-	*pos++='0';
+        if (current_thd->count_cuted_fields && !is_cuted_fields_incr) 
+          break; // Go on below to see if we lose non zero digits
+        return 0;
       }
-      while (int_digits_end != frac_digits_head_end)
+      *pos++='0';
+    }
+    while (int_digits_end != frac_digits_head_end)
+    {
+      tmp_char= *int_digits_end++;
+      if (pos == right_wall)
       {
-	tmp_char= *int_digits_end++;
-	if (pos == right_wall)
-	{
-	  if (tmp_char != '0')			// Losing a non zero digit ?
-	  {
-	    if (!is_cuted_fields_incr)
-	      current_thd->cuted_fields++;
-	    return 0;
-	  }
-	  continue;
-	}
-	*pos++= tmp_char;
+        if (tmp_char != '0')			// Losing a non zero digit ?
+        {
+          if (!is_cuted_fields_incr)
+            current_thd->cuted_fields++;
+          return 0;
+        }
+        continue;
       }
+      *pos++= tmp_char;
     }
+  }
 
-    for (;frac_digits_from!=frac_digits_end;) 
+  for (;frac_digits_from!=frac_digits_end;) 
+  {
+    tmp_char= *frac_digits_from++;
+    if (pos == right_wall)
     {
-      tmp_char= *frac_digits_from++;
-      if (pos == right_wall)
+      if (tmp_char != '0')			// Losing a non zero digit ?
       {
-	if (tmp_char != '0')			// Losing a non zero digit ?
-	{
-	  if (!is_cuted_fields_incr)
-	    current_thd->cuted_fields++;
-	  return 0;
-	}
-	continue;
+        if (!is_cuted_fields_incr)
+	  current_thd->cuted_fields++;
+        return 0;
       }
-      *pos++= tmp_char;
+      continue;
     }
-      
-    while (pos != right_wall)
-      *pos++='0';			// Fill with zeros at right of '.'
+    *pos++= tmp_char;
   }
+      
+  while (pos != right_wall)
+   *pos++='0';			// Fill with zeros at right of '.'
   return 0;
 }
 
@@ -3930,12 +3944,12 @@ int Field_string::pack_cmp(const char *b, uint length)
 }
 
 
-uint Field_string::packed_col_length(const char *ptr, uint length)
+uint Field_string::packed_col_length(const char *data_ptr, uint length)
 {
   if (length > 255)
-    return uint2korr(ptr)+2;
+    return uint2korr(data_ptr)+2;
   else
-    return (uint) ((uchar) *ptr)+1;
+    return (uint) ((uchar) *data_ptr)+1;
 }
 
 uint Field_string::max_packed_col_length(uint max_length)
@@ -4162,12 +4176,12 @@ int Field_varstring::pack_cmp(const char *b, uint key_length)
 		     (const uchar *)b,b_length);
 }
 
-uint Field_varstring::packed_col_length(const char *ptr, uint length)
+uint Field_varstring::packed_col_length(const char *data_ptr, uint length)
 {
   if (length > 255)
-    return uint2korr(ptr)+2;
+    return uint2korr(data_ptr)+2;
   else
-    return (uint) ((uchar) *ptr)+1;
+    return (uint) ((uchar) *data_ptr)+1;
 }
 
 uint Field_varstring::max_packed_col_length(uint max_length)
@@ -4698,12 +4712,12 @@ char *Field_blob::pack_key_from_key_image(char *to, const char *from,
   return to+length;
 }
 
-uint Field_blob::packed_col_length(const char *ptr, uint length)
+uint Field_blob::packed_col_length(const char *data_ptr, uint length)
 {
   if (length > 255)
-    return uint2korr(ptr)+2;
+    return uint2korr(data_ptr)+2;
   else
-    return (uint) ((uchar) *ptr)+1;
+    return (uint) ((uchar) *data_ptr)+1;
 }
 
 uint Field_blob::max_packed_col_length(uint max_length)
@@ -5294,10 +5308,11 @@ Field *make_field(char *ptr, uint32 field_length,
     return new Field_datetime(ptr,null_pos,null_bit,
 			      unireg_check, field_name, table, field_charset);
   case FIELD_TYPE_NULL:
-    default:					// Impossible (Wrong version)
     return new Field_null(ptr,field_length,unireg_check,field_name,table, field_charset);
+  default:					// Impossible (Wrong version)
+    break;
   }
-  return 0;					// Impossible (Wrong version)
+  return 0;
 }
 
 
diff --git a/sql/field.h b/sql/field.h
index 8c4c48968c4ec64331205426178304057f0364af..9fc72cf56ec794f7b32522984ac8de14d984c24e 100644
--- a/sql/field.h
+++ b/sql/field.h
@@ -126,10 +126,12 @@ class Field {
     Field *tmp= (Field*) memdup_root(root,(char*) this,size_of());
     if (tmp)
     {
-      tmp->table=new_table;
-      tmp->key_start=tmp->part_of_key=tmp->part_of_sortkey=0;
+      tmp->table= new_table;
+      tmp->key_start= tmp->part_of_key= tmp->part_of_sortkey= 0;
       tmp->unireg_check=Field::NONE;
-      tmp->flags&= (NOT_NULL_FLAG | BLOB_FLAG | UNSIGNED_FLAG | ZEROFILL_FLAG | ENUM_FLAG | SET_FLAG);
+      tmp->flags&= (NOT_NULL_FLAG | BLOB_FLAG | UNSIGNED_FLAG |
+		    ZEROFILL_FLAG | ENUM_FLAG | SET_FLAG);
+      tmp->table_name= new_table->table_name;
       tmp->reset_fields();
     }
     return tmp;
diff --git a/sql/filesort.cc b/sql/filesort.cc
index 53af60b037025b91b699fc6d4ca2f64fdb7947b8..fab666a12030c1e71dd81faae06f2ec8f0a81d4b 100644
--- a/sql/filesort.cc
+++ b/sql/filesort.cc
@@ -223,7 +223,7 @@ ha_rows filesort(THD *thd, TABLE *table, SORT_FIELD *sortorder, uint s_length,
   if (error)
     my_error(ER_FILSORT_ABORT,MYF(ME_ERROR+ME_WAITTANG));
   else
-    statistic_add(filesort_rows, records, &LOCK_status);
+    statistic_add(filesort_rows, (ulong) records, &LOCK_status);
   *examined_rows= param.examined_rows;
 #ifdef SKIP_DBUG_IN_FILESORT
   DBUG_POP();			/* Ok to DBUG */
@@ -724,7 +724,7 @@ int merge_buffers(SORTPARAM *param, IO_CACHE *from_file,
   org_max_rows=max_rows=param->max_rows;
 
   if (init_queue(&queue,(uint) (Tb-Fb)+1,offsetof(BUFFPEK,key),0,
-		 (int (*) (void *, byte *,byte*))
+		 (queue_compare)
 		 (cmp=get_ptr_compare(sort_length)),(void*) &sort_length))
     DBUG_RETURN(1);				/* purecov: inspected */
   for (buffpek= Fb ; buffpek <= Tb ; buffpek++)
diff --git a/sql/gen_lex_hash.cc b/sql/gen_lex_hash.cc
index 0d92397b616b16625c02f6c8edeaa4a31d892405..7daab22809310b103074baef83b95231b9cafb04 100644
--- a/sql/gen_lex_hash.cc
+++ b/sql/gen_lex_hash.cc
@@ -320,7 +320,7 @@ and you are welcome to modify and redistribute it under the GPL license\n");
   my_print_help(my_long_options);
 }
 
-static my_bool
+extern "C" my_bool
 get_one_option(int optid, const struct my_option *opt __attribute__((unused)),
 	       char *argument __attribute__((unused)))
 {
diff --git a/sql/gstream.cc b/sql/gstream.cc
index 5a58fef67447fb5f6f4c61ed1a90da69dfb5c36e..bd2345212c324a4a2f519a4b3c64ccc517d2a3b1 100644
--- a/sql/gstream.cc
+++ b/sql/gstream.cc
@@ -99,7 +99,7 @@ int GTextReadStream::get_next_number(double *d)
 
   char *endptr;
 
-  *d = strtod(cur, &endptr);
+  *d = my_strtod(my_charset_latin1, cur, &endptr);
 
   if(endptr)
   {
diff --git a/sql/ha_berkeley.cc b/sql/ha_berkeley.cc
index 6d5b469a913ec91465db9f07435078af35e3062f..679642ca949afadd429b142b0331cdbc12d7707e 100644
--- a/sql/ha_berkeley.cc
+++ b/sql/ha_berkeley.cc
@@ -1931,7 +1931,7 @@ int ha_berkeley::delete_table(const char *name)
 
 double ha_berkeley::scan_time()
 {
-  return records/3;
+  return rows2double(records/3);
 }
 
 ha_rows ha_berkeley::records_in_range(int keynr,
@@ -2206,7 +2206,7 @@ static BDB_SHARE *get_share(const char *table_name, TABLE *table)
   if (!(share=(BDB_SHARE*) hash_search(&bdb_open_tables, (byte*) table_name,
 				       length)))
   {
-    ha_rows *rec_per_key;
+    ulong *rec_per_key;
     char *tmp_name;
     DB **key_file;
     u_int32_t *key_type;
diff --git a/sql/ha_berkeley.h b/sql/ha_berkeley.h
index 198664d0c066b6b3f45e6b5e2769e033d9b9f87a..f2a81d123f1eb06744703c608154b4446799ada3 100644
--- a/sql/ha_berkeley.h
+++ b/sql/ha_berkeley.h
@@ -27,7 +27,8 @@
 
 typedef struct st_berkeley_share {
   ulonglong auto_ident;
-  ha_rows rows, org_rows, *rec_per_key;
+  ha_rows rows, org_rows;
+  ulong *rec_per_key;
   THR_LOCK lock;
   pthread_mutex_t mutex;
   char *table_name;
diff --git a/sql/ha_heap.cc b/sql/ha_heap.cc
index c06421617dd25148823f3f964af1ab5418205fe7..4a3b9495f6f0f8c4c3d8bccde66740c2c45b6471 100644
--- a/sql/ha_heap.cc
+++ b/sql/ha_heap.cc
@@ -245,7 +245,7 @@ int ha_heap::create(const char *name, TABLE *table,
 {
   uint key, parts, mem_per_row= 0;
   uint auto_key= 0, auto_key_type= 0;
-  ulong max_rows;
+  ha_rows max_rows;
   HP_KEYDEF *keydef;
   HA_KEYSEG *seg;
   char buff[FN_REFLEN];
@@ -310,8 +310,8 @@ int ha_heap::create(const char *name, TABLE *table,
     }
   }
   mem_per_row+= MY_ALIGN(table->reclength + 1, sizeof(char*));
-  max_rows = (ulong) (current_thd->variables.max_heap_table_size /
-		      mem_per_row);
+  max_rows = (ha_rows) (current_thd->variables.max_heap_table_size /
+			mem_per_row);
   HP_CREATE_INFO hp_create_info;
   hp_create_info.auto_key= auto_key;
   hp_create_info.auto_key_type= auto_key_type;
@@ -319,9 +319,9 @@ int ha_heap::create(const char *name, TABLE *table,
 				  create_info->auto_increment_value - 1 : 0);
   error= heap_create(fn_format(buff,name,"","",4+2),
 		     table->keys,keydef, table->reclength,
-		     ((table->max_rows < max_rows && table->max_rows) ? 
-		     table->max_rows : max_rows),
-		     table->min_rows, &hp_create_info);
+		     (ulong) ((table->max_rows < max_rows && table->max_rows) ? 
+			      table->max_rows : max_rows),
+		     (ulong) table->min_rows, &hp_create_info);
   my_free((gptr) keydef, MYF(0));
   if (file)
     info(HA_STATUS_NO_LOCK | HA_STATUS_CONST | HA_STATUS_VARIABLE);
diff --git a/sql/ha_innodb.cc b/sql/ha_innodb.cc
index 9aa63cc143511fff876af215a2eb0f39c0ee7f05..7787b543f34f214d3e4720187c158dafd01d1ec3 100644
--- a/sql/ha_innodb.cc
+++ b/sql/ha_innodb.cc
@@ -40,17 +40,12 @@ InnoDB */
 
 #include "ha_innodb.h"
 
-/* We must declare this here because we undef SAFE_MUTEX below */
 pthread_mutex_t innobase_mutex;
 
 /* Store MySQL definition of 'byte': in Linux it is char while InnoDB
 uses unsigned char */
 typedef byte	mysql_byte;
 
-#ifdef SAFE_MUTEX
-#undef pthread_mutex_t
-#endif
-
 #define INSIDE_HA_INNOBASE_CC
 
 /* Include necessary InnoDB headers */
@@ -97,6 +92,8 @@ are determined in innobase_init below: */
 char*	innobase_data_home_dir			= NULL;
 char*	innobase_log_group_home_dir		= NULL;
 char*	innobase_log_arch_dir			= NULL;
+/* The following has a midleading name: starting from 4.0.5 this also
+affects Windows */
 char*	innobase_unix_file_flush_method		= NULL;
 
 /* Below we have boolean-valued start-up parameters, and their default
@@ -253,6 +250,10 @@ convert_error_code_to_mysql(
   	} else if (error == (int) DB_TOO_BIG_RECORD) {
 
     		return(HA_ERR_TO_BIG_ROW);
+
+  	} else if (error == (int) DB_CORRUPTION) {
+
+    		return(HA_ERR_CRASHED);
     	} else {
     		return(-1);			// Unknown error
     	}
@@ -346,7 +347,8 @@ check_trx_exists(
 		trx = trx_allocate_for_mysql();
 
 		trx->mysql_thd = thd;
-
+		trx->mysql_query_str = &((*thd).query);
+		
 		thd->transaction.all.innobase_tid = trx;
 
 		/* The execution of a single SQL statement is denoted by
@@ -713,9 +715,10 @@ innobase_init(void)
 
 		DBUG_RETURN(TRUE);
 	}
-	srv_unix_file_flush_method_str = (innobase_unix_file_flush_method ?
+
+	srv_file_flush_method_str = (innobase_unix_file_flush_method ?
 				      innobase_unix_file_flush_method :
-				      (char*)"fdatasync");
+				      NULL);
 
 	srv_n_log_groups = (ulint) innobase_mirrored_log_groups;
 	srv_n_log_files = (ulint) innobase_log_files_in_group;
@@ -725,8 +728,6 @@ innobase_init(void)
 	srv_log_buffer_size = (ulint) innobase_log_buffer_size;
 	srv_flush_log_at_trx_commit = (ulint) innobase_flush_log_at_trx_commit;
 
-	srv_use_native_aio = 0;
-
 	srv_pool_size = (ulint) innobase_buffer_pool_size;
 
 	srv_mem_pool_size = (ulint) innobase_additional_mem_pool_size;
@@ -750,6 +751,14 @@ innobase_init(void)
 				default_charset_info->sort_order, 256);
 	}
 
+	/* Since we in this module access directly the fields of a trx
+        struct, and due to different headers and flags it might happen that
+	mutex_t has a different size in this module and in InnoDB
+	modules, we check at run time that the size is the same in
+	these compilation modules. */
+
+	srv_sizeof_trx_t_in_ha_innodb_cc = sizeof(trx_t);
+
 	err = innobase_start_or_create_for_mysql();
 
 	if (err != DB_SUCCESS) {
@@ -1147,15 +1156,15 @@ ha_innobase::open(
 	ib_table = dict_table_get_and_increment_handle_count(
 				      		     norm_name, NULL);
  	if (NULL == ib_table) {
-
-	  sql_print_error("InnoDB error:\n\
-Cannot find table %s from the internal data dictionary\n\
-of InnoDB though the .frm file for the table exists. Maybe you\n\
-have deleted and recreated InnoDB data files but have forgotten\n\
-to delete the corresponding .frm files of InnoDB tables, or you\n\
-have moved .frm files to another database?\n\
-Look from section 15.1 of http://www.innodb.com/ibman.html\n\
-how you can resolve the problem.\n",
+	        ut_print_timestamp(stderr);
+	        fprintf(stderr, "  InnoDB error:\n"
+"Cannot find table %s from the internal data dictionary\n"
+"of InnoDB though the .frm file for the table exists. Maybe you\n"
+"have deleted and recreated InnoDB data files but have forgotten\n"
+"to delete the corresponding .frm files of InnoDB tables, or you\n"
+"have moved .frm files to another database?\n"
+"Look from section 15.1 of http://www.innodb.com/ibman.html\n"
+"how you can resolve the problem.\n",
 			  norm_name);
 
 	        free_share(share);
@@ -1168,7 +1177,10 @@ how you can resolve the problem.\n",
 
 	((row_prebuilt_t*)innobase_prebuilt)->mysql_row_len = table->reclength;
 
-  	primary_key = MAX_KEY;
+	/* Looks like MySQL-3.23 sometimes has primary key number != 0 */
+
+ 	primary_key = table->primary_key;
+	key_used_on_scan = primary_key;
 
 	/* Allocate a buffer for a 'row reference'. A row reference is
 	a string of bytes of length ref_length which uniquely specifies
@@ -1177,13 +1189,14 @@ how you can resolve the problem.\n",
         of length ref_length! */
 
   	if (!row_table_got_default_clust_index(ib_table)) {
+	        if (primary_key >= MAX_KEY) {
+	                fprintf(stderr,
+		    "InnoDB: Error: table %s has a primary key in InnoDB\n"
+		    "InnoDB: data dictionary, but not in MySQL!\n", name);
+		}
 
 		((row_prebuilt_t*)innobase_prebuilt)
 				->clust_index_was_generated = FALSE;
-
-		primary_key = 0;
-		key_used_on_scan = 0;
-
  		/*
 		  MySQL allocates the buffer for ref. key_info->key_length
 		  includes space for all key columns + one byte for each column
@@ -1192,8 +1205,14 @@ how you can resolve the problem.\n",
 		  based on ref_length.
 		*/
  
-  		ref_length = table->key_info->key_length;
+  		ref_length = table->key_info[primary_key].key_length;
 	} else {
+	        if (primary_key != MAX_KEY) {
+	                fprintf(stderr,
+		    "InnoDB: Error: table %s has no primary key in InnoDB\n"
+		    "InnoDB: data dictionary, but has one in MySQL!\n", name);
+		}
+
 		((row_prebuilt_t*)innobase_prebuilt)
 				->clust_index_was_generated = TRUE;
 
@@ -1501,7 +1520,8 @@ ha_innobase::store_key_val_for_row(
 	  are equal
 	*/
 	bzero(buff, (ref_length- (uint) (buff - buff_start)));
-	DBUG_RETURN(ref_length);
+
+	DBUG_RETURN((uint)(buff - buff_start));
 }
 
 /******************************************************************
@@ -1679,6 +1699,7 @@ ha_innobase::write_row(
 	longlong	dummy;
 	ibool           incremented_auto_inc_for_stat = FALSE;
 	ibool           incremented_auto_inc_counter = FALSE;
+	ibool           skip_auto_inc_decr;
 
   	DBUG_ENTER("ha_innobase::write_row");
 
@@ -1843,13 +1864,31 @@ ha_innobase::write_row(
 	if (error != DB_SUCCESS) {
 	        /* If the insert did not succeed we restore the value of
 		the auto-inc counter we used; note that this behavior was
-		introduced only in version 4.0.4 */
+		introduced only in version 4.0.4.
+		NOTE that a REPLACE command handles a duplicate key error
+		itself, and we must not decrement the autoinc counter
+		if we are performing a REPLACE statement.
+		NOTE 2: if there was an error, for example a deadlock,
+		which caused InnoDB to roll back the whole transaction
+		already in the call of row_insert_for_mysql(), we may no
+		longer have the AUTO-INC lock, and cannot decrement
+		the counter here. */
+
+	        skip_auto_inc_decr = FALSE;
+
+	        if (error == DB_DUPLICATE_KEY) {
+	                ut_a(user_thd->query);
+	                dict_accept(user_thd->query, "REPLACE",
+				                       &skip_auto_inc_decr);
+		}
 
-	        if (incremented_auto_inc_counter) {
+	        if (!skip_auto_inc_decr && incremented_auto_inc_counter
+		    && prebuilt->trx->auto_inc_lock) {
 	                dict_table_autoinc_decrement(prebuilt->table);
 	        }
 
-		if (incremented_auto_inc_for_stat) {
+		if (!skip_auto_inc_decr && incremented_auto_inc_for_stat
+		    && prebuilt->trx->auto_inc_lock) {
 		        auto_inc_counter_for_this_stat--;
 		}
 	}
@@ -2181,8 +2220,16 @@ convert_search_mode_to_innobase(
 		case HA_READ_AFTER_KEY:		return(PAGE_CUR_G);
 		case HA_READ_BEFORE_KEY:	return(PAGE_CUR_L);
 		case HA_READ_PREFIX:		return(PAGE_CUR_GE);
-		case HA_READ_PREFIX_LAST:       return(PAGE_CUR_LE);
-		        /* HA_READ_PREFIX_LAST does not yet work in InnoDB! */
+		case HA_READ_PREFIX_LAST:
+		  /*		        ut_print_timestamp(stderr);
+                        fprintf(stderr,
+			" InnoDB: Warning: Using HA_READ_PREFIX_LAST\n"); */
+		        return(PAGE_CUR_LE);
+
+		        /* InnoDB does not yet support ..PREFIX_LAST!
+		        We have to add a new search flag
+		        PAGE_CUR_LE_OR_PREFIX to InnoDB. */
+
 			/* the above PREFIX flags mean that the last
 			field in the key value may just be a prefix
 			of the complete fixed length field */
@@ -2751,7 +2798,11 @@ ha_innobase::position(
 	that len is always fixed for this table. The following assertion
 	checks this. */
   
-	ut_a(len == ref_length);
+	if (len != ref_length) {
+	        fprintf(stderr,
+	 "InnoDB: Error: stored ref len is %lu, but table ref len is %lu\n",
+		  (ulint)len, (ulint)ref_length);
+	}
 }
 
 
@@ -2935,16 +2986,21 @@ ha_innobase::create(
 		trx->check_unique_secondary = FALSE;
 	}
 
+	if (lower_case_table_names) {
+		srv_lower_case_table_names = TRUE;
+	} else {
+		srv_lower_case_table_names = FALSE;
+	}
 
 	fn_format(name2, name, "", "",2);	// Remove the .frm extension
 
 	normalize_table_name(norm_name, name2);
 
-	/* Latch the InnoDB data dictionary exclusive so that no deadlocks
+	/* Latch the InnoDB data dictionary exclusively so that no deadlocks
 	or lock waits can happen in it during a table create operation.
-	(Drop table etc. do this latching in row0mysql.c.) */
+	Drop table etc. do this latching in row0mysql.c. */
 
-	row_mysql_lock_data_dictionary();
+	row_mysql_lock_data_dictionary(trx);
 
 	/* Create the table definition in InnoDB */
 
@@ -2953,7 +3009,7 @@ ha_innobase::create(
   	if (error) {
 		innobase_commit_low(trx);
 
-		row_mysql_unlock_data_dictionary();
+		row_mysql_unlock_data_dictionary(trx);
 
   		trx_free_for_mysql(trx);
 
@@ -2983,7 +3039,7 @@ ha_innobase::create(
   		if (error) {
 			innobase_commit_low(trx);
 
-			row_mysql_unlock_data_dictionary();
+			row_mysql_unlock_data_dictionary(trx);
 
 			trx_free_for_mysql(trx);
 
@@ -2998,7 +3054,7 @@ ha_innobase::create(
 					  (uint) primary_key_no))) {
 			innobase_commit_low(trx);
 
-			row_mysql_unlock_data_dictionary();
+			row_mysql_unlock_data_dictionary(trx);
 
   			trx_free_for_mysql(trx);
 
@@ -3014,7 +3070,7 @@ ha_innobase::create(
 
 			  	innobase_commit_low(trx);
 
-				row_mysql_unlock_data_dictionary();
+				row_mysql_unlock_data_dictionary(trx);
 
   				trx_free_for_mysql(trx);
 
@@ -3023,24 +3079,27 @@ ha_innobase::create(
       		}
   	}
 
-	error = row_table_add_foreign_constraints(trx,
-				create_info->create_statement, norm_name);
+	if (current_thd->query != NULL) {
+  	
+		error = row_table_add_foreign_constraints(trx,
+					current_thd->query, norm_name);
 
-	error = convert_error_code_to_mysql(error, NULL);
+		error = convert_error_code_to_mysql(error, NULL);
 
-	if (error) {
-		innobase_commit_low(trx);
+		if (error) {
+			innobase_commit_low(trx);
 
-		row_mysql_unlock_data_dictionary();
+			row_mysql_unlock_data_dictionary(trx);
 
-  		trx_free_for_mysql(trx);
+  			trx_free_for_mysql(trx);
 
-		DBUG_RETURN(error);
+			DBUG_RETURN(error);
+		}
 	}
 
   	innobase_commit_low(trx);
 
-	row_mysql_unlock_data_dictionary();
+	row_mysql_unlock_data_dictionary(trx);
 
 	/* Flush the log to reduce probability that the .frm files and
 	the InnoDB data dictionary get out-of-sync if the user runs
@@ -3082,6 +3141,12 @@ ha_innobase::delete_table(
 
   	DBUG_ENTER("ha_innobase::delete_table");
 
+	if (lower_case_table_names) {
+		srv_lower_case_table_names = TRUE;
+	} else {
+		srv_lower_case_table_names = FALSE;
+	}
+
 	trx = trx_allocate_for_mysql();
 
 	name_len = strlen(name);
@@ -3095,7 +3160,7 @@ ha_innobase::delete_table(
 
   	/* Drop the table in InnoDB */
 
-  	error = row_drop_table_for_mysql(norm_name, trx, FALSE);
+  	error = row_drop_table_for_mysql(norm_name, trx);
 
 	/* Flush the log to reduce probability that the .frm files and
 	the InnoDB data dictionary get out-of-sync if the user runs
@@ -3192,6 +3257,12 @@ ha_innobase::rename_table(
 
   	DBUG_ENTER("ha_innobase::rename_table");
 
+	if (lower_case_table_names) {
+		srv_lower_case_table_names = TRUE;
+	} else {
+		srv_lower_case_table_names = FALSE;
+	}
+
 	trx = trx_allocate_for_mysql();
 
 	name_len1 = strlen(from);
@@ -3318,7 +3389,7 @@ ha_innobase::estimate_number_of_rows(void)
 	row_prebuilt_t* prebuilt	= (row_prebuilt_t*) innobase_prebuilt;
 	dict_index_t*	index;
 	ulonglong	estimate;
-	ulonglong	data_file_length;
+	ulonglong	local_data_file_length;
 
 	/* Warning: since it is not sure that MySQL calls external_lock
 	before calling this function, the trx field in prebuilt can be
@@ -3328,7 +3399,7 @@ ha_innobase::estimate_number_of_rows(void)
 
 	index = dict_table_get_first_index_noninline(prebuilt->table);
 
-	data_file_length = ((ulonglong) index->stat_n_leaf_pages)
+	local_data_file_length = ((ulonglong) index->stat_n_leaf_pages)
     							* UNIV_PAGE_SIZE;
 
 	/* Calculate a minimum length for a clustered index record and from
@@ -3337,7 +3408,7 @@ ha_innobase::estimate_number_of_rows(void)
         by a threshold factor, we must add a safety factor 2 in front
 	of the formula below. */
 
-	estimate = 2 * data_file_length / dict_index_calc_min_rec_len(index);
+	estimate = 2 * local_data_file_length / dict_index_calc_min_rec_len(index);
 
 	DBUG_RETURN((ha_rows) estimate);
 }
@@ -3374,12 +3445,21 @@ ha_innobase::info(
 	row_prebuilt_t* prebuilt	= (row_prebuilt_t*) innobase_prebuilt;
 	dict_table_t*	ib_table;
 	dict_index_t*	index;
-	ulong		rec_per_key;
+	ha_rows		rec_per_key;
 	ulong		j;
 	ulong		i;
 
  	DBUG_ENTER("info");
 
+        /* If we are forcing recovery at a high level, we will suppress
+	statistics calculation on tables, because that may crash the
+	server if an index is badly corrupted. */
+
+        if (srv_force_recovery >= SRV_FORCE_NO_IBUF_MERGE) {
+
+                return;
+        }
+
 	/* Warning: since it is not sure that MySQL calls external_lock
 	before calling this function, the trx field in prebuilt can be
 	obsolete! */
@@ -3426,7 +3506,7 @@ ha_innobase::info(
 
 					rec_per_key = records;
 				} else {
-					rec_per_key = (ulong)(records /
+					rec_per_key = (ha_rows)(records /
    				         index->stat_n_diff_key_vals[j + 1]);
 				}
 
@@ -3441,8 +3521,9 @@ ha_innobase::info(
 					rec_per_key = 1;
 				}
 
- 				table->key_info[i].rec_per_key[j]
-								= rec_per_key;
+ 				table->key_info[i].rec_per_key[j]=
+				  rec_per_key >= ~(ulong) 0 ? ~(ulong) 0 :
+				  rec_per_key;
 			}
 
 			index = dict_table_get_next_index_noninline(index);
@@ -3641,7 +3722,6 @@ ha_innobase::reset(void)
   	return(0);
 }
 
-
 /**********************************************************************
 When we create a temporary table inside MySQL LOCK TABLES, MySQL will
 not call external_lock for the temporary table when it uses it. Instead,
@@ -3663,12 +3743,20 @@ ha_innobase::start_stmt(
 	innobase_release_stat_resources(trx);
 	trx_mark_sql_stat_end(trx);
 
+	if (trx->isolation_level <= TRX_ISO_READ_COMMITTED
+	    						&& trx->read_view) {
+	    	/* At low transaction isolation levels we let
+		each consistent read set its own snapshot */
+
+	    	read_view_close_for_mysql(trx);
+	}
+
 	auto_inc_counter_for_this_stat = 0;
 	prebuilt->sql_stat_start = TRUE;
 	prebuilt->hint_no_need_to_fetch_extra_cols = TRUE;
 	prebuilt->read_just_key = 0;
 
-	if (prebuilt->select_lock_type == LOCK_NONE) {
+	if (!prebuilt->mysql_has_locked) {
 	        /* This handle is for a temporary table created inside
 	        this same LOCK TABLES; since MySQL does NOT call external_lock
 	        in this case, we must use x-row locks inside InnoDB to be
@@ -3682,6 +3770,24 @@ ha_innobase::start_stmt(
 	return(0);
 }
 
+/**********************************************************************
+Maps a MySQL trx isolation level code to the InnoDB isolation level code */
+inline
+ulint
+innobase_map_isolation_level(
+/*=========================*/
+					/* out: InnoDB isolation level */
+	enum_tx_isolation	iso)	/* in: MySQL isolation level code */
+{
+	switch(iso) {
+		case ISO_READ_COMMITTED: return(TRX_ISO_READ_COMMITTED);
+		case ISO_REPEATABLE_READ: return(TRX_ISO_REPEATABLE_READ);
+		case ISO_SERIALIZABLE: return(TRX_ISO_SERIALIZABLE);
+		case ISO_READ_UNCOMMITTED: return(TRX_ISO_READ_UNCOMMITTED);
+		default: ut_a(0); return(0);
+	}	
+}
+	
 /**********************************************************************
 As MySQL will execute an external lock for every new table it uses when it
 starts to process an SQL statement (an exception is when MySQL calls
@@ -3703,6 +3809,7 @@ ha_innobase::external_lock(
 	trx_t*		trx;
 
   	DBUG_ENTER("ha_innobase::external_lock");
+	DBUG_PRINT("enter",("lock_type: %d", lock_type));
 
 	update_thd(thd);
 
@@ -3727,8 +3834,15 @@ ha_innobase::external_lock(
 
 		thd->transaction.all.innodb_active_trans = 1;
 		trx->n_mysql_tables_in_use++;
+		prebuilt->mysql_has_locked = TRUE;
 
-		if (thd->variables.tx_isolation == ISO_SERIALIZABLE
+		if (thd->variables.tx_isolation != ISO_REPEATABLE_READ) {
+			trx->isolation_level = innobase_map_isolation_level(
+						(enum_tx_isolation)
+						thd->variables.tx_isolation);
+		}
+
+		if (trx->isolation_level == TRX_ISO_SERIALIZABLE
 		    && prebuilt->select_lock_type == LOCK_NONE) {
 
 		    	/* To get serializable execution we let InnoDB
@@ -3744,6 +3858,7 @@ ha_innobase::external_lock(
 		}
 	} else {
 		trx->n_mysql_tables_in_use--;
+		prebuilt->mysql_has_locked = FALSE;
 		auto_inc_counter_for_this_stat = 0;
 
 		if (trx->n_mysql_tables_in_use == 0) {
@@ -3755,6 +3870,15 @@ ha_innobase::external_lock(
 
 			innobase_release_stat_resources(trx);
 
+			if (trx->isolation_level <= TRX_ISO_READ_COMMITTED
+	    						&& trx->read_view) {
+
+	    			/* At low transaction isolation levels we let
+				each consistent read set its own snapshot */
+
+	    			read_view_close_for_mysql(trx);
+			}
+			
 		  	if (!(thd->options
 				 & (OPTION_NOT_AUTOCOMMIT | OPTION_BEGIN))) {
 
@@ -3779,14 +3903,13 @@ innodb_show_status(
 	char*		buf;
 
   	DBUG_ENTER("innodb_show_status");
-
+	
 	if (innodb_skip) {
-
-	        fprintf(stderr,
-      "Cannot call SHOW INNODB STATUS because skip-innodb is defined\n");
-
-		DBUG_RETURN(-1);
-	}
+	        my_message(ER_NOT_SUPPORTED_YET,
+	  "Cannot call SHOW INNODB STATUS because skip-innodb is defined",
+			   MYF(0));
+                DBUG_RETURN(-1);
+        }
 
 	/* We let the InnoDB Monitor to output at most 100 kB of text, add
 	a safety margin of 10 kB for buffer overruns */
diff --git a/sql/ha_innodb.h b/sql/ha_innodb.h
index 357fb31b5e39f5261751975d1dbec94e48be513a..d2639f39c5bd5b8973da45945137c3d78e42e3fd 100644
--- a/sql/ha_innodb.h
+++ b/sql/ha_innodb.h
@@ -96,7 +96,7 @@ class ha_innobase: public handler
 	ulong index_flags(uint idx) const
 	{
 	  return (HA_READ_NEXT | HA_READ_PREV | HA_READ_ORDER |
-		  HA_KEY_READ_ONLY | HA_NOT_READ_PREFIX_LAST);
+		  HA_KEY_READ_ONLY);
 	}
   	uint max_record_length() const { return HA_MAX_REC_LENGTH; }
   	uint max_keys()          const { return MAX_KEY; }
diff --git a/sql/ha_isam.cc b/sql/ha_isam.cc
index 052e6a4b9ecd7f686003bc89c9ce3b1cee5ba121..6fa54d18aac9988a66c892bc10f7de0cc28b35e3 100644
--- a/sql/ha_isam.cc
+++ b/sql/ha_isam.cc
@@ -380,7 +380,8 @@ int ha_isam::create(const char *name, register TABLE *form,
   }
   recinfo_pos->base.type= (int) FIELD_LAST;	/* End of fieldinfo */
   error=nisam_create(fn_format(buff,name,"","",2+4+16),form->keys,keydef,
-		  recinfo,form->max_rows,form->min_rows,0,0,0L);
+		     recinfo,(ulong) form->max_rows, (ulong) form->min_rows,
+		     0, 0, 0L);
   my_free((gptr) recinfo,MYF(0));
   DBUG_RETURN(error);
 
diff --git a/sql/ha_isammrg.cc b/sql/ha_isammrg.cc
index b110ffba2f98381ae269c41784bee888bea8f572..94e394e76653231673ef5ce7981be4dd87543423 100644
--- a/sql/ha_isammrg.cc
+++ b/sql/ha_isammrg.cc
@@ -190,13 +190,15 @@ THR_LOCK_DATA **ha_isammrg::store_lock(THD *thd,
 				       THR_LOCK_DATA **to,
 				       enum thr_lock_type lock_type)
 {
-  MRG_TABLE *table;
+  MRG_TABLE *open_table;
 
-  for (table=file->open_tables ; table != file->end_table ; table++)
+  for (open_table=file->open_tables ;
+       open_table != file->end_table ;
+       open_table++)
   {
-    *(to++)= &table->table->lock;
-    if (lock_type != TL_IGNORE && table->table->lock.type == TL_UNLOCK)
-      table->table->lock.type=lock_type;
+    *(to++)= &open_table->table->lock;
+    if (lock_type != TL_IGNORE && open_table->table->lock.type == TL_UNLOCK)
+      open_table->table->lock.type=lock_type;
   }
   return to;
 }
diff --git a/sql/ha_myisam.cc b/sql/ha_myisam.cc
index c7f0ccf69eea3c77fcda7f1cbf0480103eae4a52..ae71e36287567a3095e5e9c2a364ab92ffd9a2b6 100644
--- a/sql/ha_myisam.cc
+++ b/sql/ha_myisam.cc
@@ -576,7 +576,6 @@ int ha_myisam::repair(THD *thd, MI_CHECK &param, bool optimize)
   }
 
   if (!optimize ||
-      //memcmp(file->state, & share->state.state, sizeof(MI_STATUS_INFO)) ||
       ((file->state->del || share->state.split != file->state->records) &&
        (!(param.testflag & T_QUICK) ||
 	!(share->state.changed & STATE_NOT_OPTIMIZED_KEYS))))
@@ -635,7 +634,12 @@ int ha_myisam::repair(THD *thd, MI_CHECK &param, bool optimize)
 			       STATE_CRASHED_ON_REPAIR);
       file->update|=HA_STATE_CHANGED | HA_STATE_ROW_CHANGED;
     }
-    //file->save_state=file->s->state.state;
+    /*
+      the following 'if', thought conceptually wrong,
+      is a useful optimization nevertheless.
+    */
+    if (file->state != &file->s->state.state);
+      file->s->state.state = *file->state;
     if (file->s->base.auto_key)
       update_auto_increment_key(&param, file, 1);
     if (optimize_done)
@@ -914,7 +918,7 @@ void ha_myisam::info(uint flag)
     if (table->key_parts)
       memcpy((char*) table->key_info[0].rec_per_key,
 	     (char*) info.rec_per_key,
-	     sizeof(ulong)*table->key_parts);
+	     sizeof(table->key_info[0].rec_per_key)*table->key_parts);
     raid_type=info.raid_type;
     raid_chunks=info.raid_chunks;
     raid_chunksize=info.raid_chunksize;
@@ -1014,7 +1018,7 @@ void ha_myisam::update_create_info(HA_CREATE_INFO *create_info)
 }
 
 
-int ha_myisam::create(const char *name, register TABLE *table,
+int ha_myisam::create(const char *name, register TABLE *table_arg,
 		      HA_CREATE_INFO *info)
 {
   int error;
@@ -1026,20 +1030,20 @@ int ha_myisam::create(const char *name, register TABLE *table,
   MI_KEYDEF *keydef;
   MI_COLUMNDEF *recinfo,*recinfo_pos;
   HA_KEYSEG *keyseg;
-  uint options=table->db_options_in_use;
+  uint options=table_arg->db_options_in_use;
   DBUG_ENTER("ha_myisam::create");
 
   type=HA_KEYTYPE_BINARY;				// Keep compiler happy
   if (!(my_multi_malloc(MYF(MY_WME),
-			&recinfo,(table->fields*2+2)*sizeof(MI_COLUMNDEF),
-			&keydef, table->keys*sizeof(MI_KEYDEF),
+			&recinfo,(table_arg->fields*2+2)*sizeof(MI_COLUMNDEF),
+			&keydef, table_arg->keys*sizeof(MI_KEYDEF),
 			&keyseg,
-			((table->key_parts + table->keys) * sizeof(HA_KEYSEG)),
+			((table_arg->key_parts + table_arg->keys) * sizeof(HA_KEYSEG)),
 			0)))
     DBUG_RETURN(1);
 
-  pos=table->key_info;
-  for (i=0; i < table->keys ; i++, pos++)
+  pos=table_arg->key_info;
+  for (i=0; i < table_arg->keys ; i++, pos++)
   {
     keydef[i].flag= (pos->flags & (HA_NOSAME | HA_FULLTEXT | HA_SPATIAL));
     keydef[i].key_alg=pos->algorithm == HA_KEY_ALG_UNDEF ?
@@ -1084,7 +1088,7 @@ int ha_myisam::create(const char *name, register TABLE *table,
       {
 	keydef[i].seg[j].null_bit=field->null_bit;
 	keydef[i].seg[j].null_pos= (uint) (field->null_ptr-
-					   (uchar*) table->record[0]);
+					   (uchar*) table_arg->record[0]);
       }
       else
       {
@@ -1102,19 +1106,19 @@ int ha_myisam::create(const char *name, register TABLE *table,
 	keydef[i].seg[j].flag|=HA_BLOB_PART;
 	/* save number of bytes used to pack length */
 	keydef[i].seg[j].bit_start= (uint) (field->pack_length() -
-					    table->blob_ptr_size);
+					    table_arg->blob_ptr_size);
       }
     }
     keyseg+=pos->key_parts;
   }
 
   recpos=0; recinfo_pos=recinfo;
-  while (recpos < (uint) table->reclength)
+  while (recpos < (uint) table_arg->reclength)
   {
     Field **field,*found=0;
-    minpos=table->reclength; length=0;
+    minpos=table_arg->reclength; length=0;
 
-    for (field=table->field ; *field ; field++)
+    for (field=table_arg->field ; *field ; field++)
     {
       if ((fieldpos=(*field)->offset()) >= recpos &&
 	  fieldpos <= minpos)
@@ -1160,7 +1164,7 @@ int ha_myisam::create(const char *name, register TABLE *table,
     {
       recinfo_pos->null_bit=found->null_bit;
       recinfo_pos->null_pos= (uint) (found->null_ptr-
-				  (uchar*) table->record[0]);
+				  (uchar*) table_arg->record[0]);
     }
     else
     {
@@ -1175,13 +1179,13 @@ int ha_myisam::create(const char *name, register TABLE *table,
   }
   MI_CREATE_INFO create_info;
   bzero((char*) &create_info,sizeof(create_info));
-  create_info.max_rows=table->max_rows;
-  create_info.reloc_rows=table->min_rows;
+  create_info.max_rows=table_arg->max_rows;
+  create_info.reloc_rows=table_arg->min_rows;
   create_info.auto_increment=(info->auto_increment_value ?
 			      info->auto_increment_value -1 :
 			      (ulonglong) 0);
-  create_info.data_file_length= ((ulonglong) table->max_rows *
-				 table->avg_row_length);
+  create_info.data_file_length= ((ulonglong) table_arg->max_rows *
+				 table_arg->avg_row_length);
   create_info.raid_type=info->raid_type;
   create_info.raid_chunks= (info->raid_chunks ? info->raid_chunks :
 			    RAID_DEFAULT_CHUNKS);
@@ -1191,7 +1195,7 @@ int ha_myisam::create(const char *name, register TABLE *table,
   create_info.index_file_name=info->index_file_name;
 
   error=mi_create(fn_format(buff,name,"","",2+4),
-		  table->keys,keydef,
+		  table_arg->keys,keydef,
 		  (uint) (recinfo_pos-recinfo), recinfo,
 		  0, (MI_UNIQUEDEF*) 0,
 		  &create_info,
diff --git a/sql/ha_myisammrg.cc b/sql/ha_myisammrg.cc
index c35bf6574454fa4cdc767283f9b3a661449ac00c..4398aaecf4db5c63ccf50ac8a059d71d6ef34943 100644
--- a/sql/ha_myisammrg.cc
+++ b/sql/ha_myisammrg.cc
@@ -160,6 +160,16 @@ int ha_myisammrg::index_last(byte * buf)
   return error;
 }
 
+int ha_myisammrg::index_next_same(byte * buf,
+                                  const byte *key __attribute__((unused)),
+                                  uint length __attribute__((unused)))
+{
+  statistic_increment(ha_read_next_count,&LOCK_status);
+  int error=myrg_rnext_same(file,buf);
+  table->status=error ? STATUS_NOT_FOUND: 0;
+  return error;
+}
+
 int ha_myisammrg::rnd_init(bool scan)
 {
   return myrg_extra(file,HA_EXTRA_RESET,0);
@@ -187,6 +197,19 @@ void ha_myisammrg::position(const byte *record)
   ha_store_ptr(ref, ref_length, (my_off_t) position);
 }
 
+ha_rows ha_myisammrg::records_in_range(int inx,
+				    const byte *start_key,uint start_key_len,
+				    enum ha_rkey_function start_search_flag,
+				    const byte *end_key,uint end_key_len,
+				    enum ha_rkey_function end_search_flag)
+{
+  return (ha_rows) myrg_records_in_range(file,
+				       inx,
+				       start_key,start_key_len,
+				       start_search_flag,
+				       end_key,end_key_len,
+				       end_search_flag);
+}
 
 void ha_myisammrg::info(uint flag)
 {
@@ -262,13 +285,15 @@ THR_LOCK_DATA **ha_myisammrg::store_lock(THD *thd,
 					 THR_LOCK_DATA **to,
 					 enum thr_lock_type lock_type)
 {
-  MYRG_TABLE *table;
+  MYRG_TABLE *open_table;
 
-  for (table=file->open_tables ; table != file->end_table ; table++)
+  for (open_table=file->open_tables ;
+       open_table != file->end_table ;
+       open_table++)
   {
-    *(to++)= &table->table->lock;
-    if (lock_type != TL_IGNORE && table->table->lock.type == TL_UNLOCK)
-      table->table->lock.type=lock_type;
+    *(to++)= &open_table->table->lock;
+    if (lock_type != TL_IGNORE && open_table->table->lock.type == TL_UNLOCK)
+      open_table->table->lock.type=lock_type;
   }
   return to;
 }
@@ -279,14 +304,16 @@ void ha_myisammrg::update_create_info(HA_CREATE_INFO *create_info)
   DBUG_ENTER("ha_myisammrg::update_create_info");
   if (!(create_info->used_fields & HA_CREATE_USED_UNION))
   {
-    MYRG_TABLE *table;
+    MYRG_TABLE *open_table;
     THD *thd=current_thd;
     create_info->merge_list.next= &create_info->merge_list.first;
     create_info->merge_list.elements=0;
 
-    for (table=file->open_tables ; table != file->end_table ; table++)
+    for (open_table=file->open_tables ;
+	 open_table != file->end_table ;
+	 open_table++)
     {
-      char *name=table->table->filename;
+      char *name=open_table->table->filename;
       char buff[FN_REFLEN];
       TABLE_LIST *ptr;
       if (!(ptr = (TABLE_LIST *) thd->calloc(sizeof(TABLE_LIST))))
@@ -323,7 +350,28 @@ int ha_myisammrg::create(const char *name, register TABLE *form,
 					sizeof(char*))))
     DBUG_RETURN(1);
   for (pos=table_names ; tables ; tables=tables->next)
-    *pos++= tables->real_name;
+  {
+    char *table_name;
+    if (create_info->options & HA_LEX_CREATE_TMP_TABLE)
+    {
+      TABLE **tbl=find_temporary_table(current_thd,
+          tables->db, tables->real_name);
+      if (!tbl)
+      {
+        table_name=sql_alloc(1+
+            my_snprintf(buff,FN_REFLEN,"%s/%s/%s",mysql_real_data_home,
+                        tables->db, tables->real_name));
+        if (!table_name)
+          DBUG_RETURN(1);
+        strcpy(table_name, buff);
+      }
+      else
+        table_name=(*tbl)->path;
+    }
+    else
+      table_name=tables->real_name;
+    *pos++= table_name;
+  }
   *pos=0;
   DBUG_RETURN(myrg_create(fn_format(buff,name,"","",2+4+16),
 			  (const char **) table_names,
@@ -340,13 +388,15 @@ void ha_myisammrg::append_create_info(String *packet)
     packet->append(get_type(&merge_insert_method,file->merge_insert_method-1));
   }
   packet->append(" UNION=(",8);
-  MYRG_TABLE *table,*first;
+  MYRG_TABLE *open_table,*first;
 
-  for (first=table=file->open_tables ; table != file->end_table ; table++)
+  for (first=open_table=file->open_tables ;
+       open_table != file->end_table ;
+       open_table++)
   {
-    char *name=table->table->filename;
+    char *name= open_table->table->filename;
     fn_format(buff,name,"","",3);
-    if (table != first)
+    if (open_table != first)
       packet->append(',');
     packet->append(buff,(uint) strlen(buff));
   }
diff --git a/sql/ha_myisammrg.h b/sql/ha_myisammrg.h
index b75d53600975f69402eca2e2eadcd47c6758aa88..008f5339caf13592153c171c1d767ade524f3e89 100644
--- a/sql/ha_myisammrg.h
+++ b/sql/ha_myisammrg.h
@@ -65,10 +65,16 @@ class ha_myisammrg: public handler
   int index_prev(byte * buf);
   int index_first(byte * buf);
   int index_last(byte * buf);
+  int index_next_same(byte *buf, const byte *key, uint keylen);
   int rnd_init(bool scan=1);
   int rnd_next(byte *buf);
   int rnd_pos(byte * buf, byte *pos);
   void position(const byte *record);
+  ha_rows records_in_range(int inx,
+                           const byte *start_key,uint start_key_len,
+                           enum ha_rkey_function start_search_flag,
+                           const byte *end_key,uint end_key_len,
+                           enum ha_rkey_function end_search_flag);
   my_off_t row_position() { return myrg_position(file); }
   void info(uint);
   int extra(enum ha_extra_function operation);
diff --git a/sql/handler.cc b/sql/handler.cc
index f60c344907561263423d255d741d5c6b9a09e863..cdd007f2cc2b4719fdfb22179b9d3a520f56374c 100644
--- a/sql/handler.cc
+++ b/sql/handler.cc
@@ -294,7 +294,8 @@ int ha_commit_trans(THD *thd, THD_TRANS* trans)
 	error=1;
       }
       else
-	transaction_commited= 1;
+	if (!(thd->options & OPTION_BEGIN))
+	  transaction_commited= 1; 
       trans->bdb_tid=0;
     }
 #endif
@@ -313,7 +314,7 @@ int ha_commit_trans(THD *thd, THD_TRANS* trans)
     }
 #endif
 #ifdef HAVE_QUERY_CACHE
-    if (transaction_commited)
+    if (transaction_commited && thd->transaction.changed_tables)
       query_cache.invalidate(thd->transaction.changed_tables);
 #endif /*HAVE_QUERY_CACHE*/
     if (error && trans == &thd->transaction.all && mysql_bin_log.is_open())
diff --git a/sql/handler.h b/sql/handler.h
index fbc27f4729b8d6fc4fa9991af8374f057ecb72d5..6cbd83af282498da75d317b1a3f925bf1f7f14c6 100644
--- a/sql/handler.h
+++ b/sql/handler.h
@@ -153,7 +153,6 @@ typedef struct st_ha_create_information
   CHARSET_INFO *table_charset;
   char *comment,*password;
   char *data_file_name, *index_file_name;
-  char *create_statement;
   ulonglong max_rows,min_rows;
   ulonglong auto_increment_value;
   ulong table_options;
@@ -230,7 +229,7 @@ class handler :public Sql_alloc
   void change_table_ptr(TABLE *table_arg) { table=table_arg; }
   virtual double scan_time()
     { return ulonglong2double(data_file_length) / IO_SIZE + 1; }
-  virtual double read_time(ha_rows rows) { return rows; }
+  virtual double read_time(ha_rows rows) { return rows2double(rows); }
   virtual bool fast_key_read() { return 0;}
   virtual key_map keys_to_use_for_scanning() { return 0; }
   virtual bool has_transactions(){ return 0;}
diff --git a/sql/hash_filo.h b/sql/hash_filo.h
index 4d746d9b9bd7db6e12882d33e83e0c9ff194cb57..f7384cc6e32ee03e0aa5f248a4ab3af08b78c7f9 100644
--- a/sql/hash_filo.h
+++ b/sql/hash_filo.h
@@ -40,7 +40,7 @@ class hash_filo
 {
   const uint size, key_offset, key_length;
   const hash_get_key get_key;
-  void (*free_element)(void*);
+  hash_free_key free_element;
   bool init;
 
   hash_filo_element *first_link,*last_link;
@@ -49,7 +49,7 @@ class hash_filo
   HASH cache;
 
   hash_filo(uint size_arg, uint key_offset_arg , uint key_length_arg,
-	    hash_get_key get_key_arg,void (*free_element_arg)(void*))
+	    hash_get_key get_key_arg, hash_free_key free_element_arg)
     :size(size_arg), key_offset(key_offset_arg), key_length(key_length_arg),
     get_key(get_key_arg), free_element(free_element_arg),init(0)
   {
diff --git a/sql/hostname.cc b/sql/hostname.cc
index 3da752f3b64a9c9e1b8e20a82fe5324ae39cef86..609532a67d6691ff839bbf735c42d74277f4d797 100644
--- a/sql/hostname.cc
+++ b/sql/hostname.cc
@@ -63,7 +63,7 @@ bool hostname_cache_init()
 
   if (!(hostname_cache=new hash_filo(HOST_CACHE_SIZE, offset,
 				     sizeof(struct in_addr),NULL,
-				     (void (*)(void*)) free)))
+				     (hash_free_key) free)))
     return 1;
   hostname_cache->clear();
   return 0;
diff --git a/sql/item.cc b/sql/item.cc
index 3ef7b657e9a22f770ea5d716a4d9acd402233b8b..f9e92dfedb2661d147466336a0348f9021e153c7 100644
--- a/sql/item.cc
+++ b/sql/item.cc
@@ -34,7 +34,8 @@ void item_init(void)
   item_user_lock_init();
 }
 
-Item::Item()
+Item::Item():
+  fixed(0)
 {
   marker=0;
   maybe_null=null_value=with_sum_func=unsigned_flag=0;
@@ -42,6 +43,20 @@ Item::Item()
   decimals=0; max_length=0;
   next=current_thd->free_list;			// Put in free list
   current_thd->free_list=this;
+  loop_id= 0;
+}
+
+bool Item::check_loop(uint id)
+{
+  DBUG_ENTER("Item::check_loop");
+  DBUG_PRINT("info", ("id %u, name %s", id, name));
+  if (loop_id == id)
+  {
+    DBUG_PRINT("info", ("id match"));
+    DBUG_RETURN(1);
+  }
+  loop_id= id;
+  DBUG_RETURN(0);
 }
 
 void Item::set_name(const char *str,uint length)
@@ -125,6 +140,7 @@ CHARSET_INFO * Item::thd_charset() const
 Item_field::Item_field(Field *f) :Item_ident(NullS,f->table_name,f->field_name)
 {
   set_field(f);
+  fixed= 1; // This item is not needed in fix_fields
 }
 
 
@@ -301,32 +317,27 @@ void Item_param::set_null()
 void Item_param::set_int(longlong i)
 {  
   int_value=(longlong)i; 
-  item_result_type = INT_RESULT;
   item_type = INT_ITEM;
 }
 
 void Item_param::set_double(double value)
 {  
   real_value=value;
-  item_result_type = REAL_RESULT;
   item_type = REAL_ITEM;
 }
 
 
-void Item_param::set_value(const char *str, uint length, CHARSET_INFO *cs)
+void Item_param::set_value(const char *str, uint length)
 {  
-  str_value.set(str,length,cs);
-  item_result_type = STRING_RESULT;
+  str_value.set(str,length,thd_charset());
   item_type = STRING_ITEM;
 }
 
 
-void Item_param::set_longdata(const char *str, ulong length, CHARSET_INFO *cs)
-{
-  /* TODO: Fix this for binary handling by making use of 
-     buffer_type.. 
-  */  
-  str_value.append(str,length);    
+void Item_param::set_longdata(const char *str, ulong length)
+{  
+  str_value.append(str,length);
+  long_data_supplied= 1;
 }
 
 
@@ -424,6 +435,7 @@ bool Item::fix_fields(THD *thd,
 		      struct st_table_list *list,
 		      Item ** ref)
 {
+  fixed= 1;
   return 0;
 }
 
@@ -491,21 +503,50 @@ bool Item_field::fix_fields(THD *thd, TABLE_LIST *tables, Item **ref)
 	cause error ER_NON_UNIQ_ERROR in find_field_in_tables.
       */
       SELECT_LEX *last= 0;
-      for (SELECT_LEX *sl= thd->lex.current_select->outer_select();
-	   sl;
-	   sl= sl->outer_select())
-	if ((tmp= find_field_in_tables(thd, this,
-				       (last= sl)->get_table_list(),
-				       0)) != not_found_field)
-	  break;
+      
+      Item **refer= (Item **)not_found_item;
+      // Prevent using outer fields in subselects, that is not supported now
+      if (thd->lex.current_select->linkage != DERIVED_TABLE_TYPE)
+	for (SELECT_LEX *sl= thd->lex.current_select->outer_select();
+	     sl;
+	     sl= sl->outer_select())
+	{
+	  if ((tmp= find_field_in_tables(thd, this,
+					 (last= sl)->get_table_list(),
+					 0)) != not_found_field)
+	    break;
+	  if ((refer= find_item_in_list(this, sl->item_list,
+				       REPORT_EXCEPT_NOT_FOUND)) !=
+	     (Item **)not_found_item)
+	    break;
+	  if (sl->linkage == DERIVED_TABLE_TYPE)
+	    break; // do not look over derived table
+	}
       if (!tmp)
 	return -1;
-      else if (tmp == not_found_field)
+      else if (!refer)
+	return 1;
+      else if (tmp == not_found_field && refer == (Item **)not_found_item)
       {
 	// call to return error code
 	find_field_in_tables(thd, this, tables, 1);
 	return -1;
       }
+      else if (refer != (Item **)not_found_item)
+      {
+	Item_ref *r;
+	*ref= r= new Item_ref(refer, (char *)table_name,
+			   (char *)field_name);
+	if (!r)
+	  return 1;
+	int res;
+	if ((res= r->fix_fields(thd, tables, ref)))
+	  return res;
+	r->depended_from= last;
+	thd->lex.current_select->mark_as_dependent(last);
+	thd->add_possible_loop(r);
+	return 0;
+      }
       else
       {
 	depended_from= last;
@@ -537,6 +578,7 @@ bool Item_field::fix_fields(THD *thd, TABLE_LIST *tables, Item **ref)
       return 1;
     return (*ref)->fix_fields(thd, tables, ref);
   }
+  fixed= 1;
   return 0;
 }
 
@@ -859,12 +901,21 @@ bool Item_ref::fix_fields(THD *thd,TABLE_LIST *tables, Item **reference)
   if (!ref)
   {
     SELECT_LEX *sl= thd->lex.current_select->outer_select();
+    /*
+      Finding only in current select will be performed for selects that have 
+      not outer one and for derived tables (which not support using outer 
+      fields for now)
+    */
     if ((ref= find_item_in_list(this, 
 				*(thd->lex.current_select->get_item_list()),
-				(sl ? REPORT_EXCEPT_NOT_FOUND :
-				 REPORT_ALL_ERRORS))) ==
+				((sl && 
+				  thd->lex.current_select->linkage !=
+				  DERIVED_TABLE_TYPE) ? 
+				  REPORT_EXCEPT_NOT_FOUND :
+				  REPORT_ALL_ERRORS))) ==
 	(Item **)not_found_item)
     {
+      Field *tmp= (Field*) not_found_field;
       /*
 	We can't find table field in table list of current select,
 	consequently we have to find it in outer subselect(s).
@@ -876,16 +927,23 @@ bool Item_ref::fix_fields(THD *thd,TABLE_LIST *tables, Item **reference)
       */
       SELECT_LEX *last=0;
       for ( ; sl ; sl= sl->outer_select())
-	if((ref= find_item_in_list(this, (last= sl)->item_list,
+      {
+	if ((ref= find_item_in_list(this, (last= sl)->item_list,
 				   REPORT_EXCEPT_NOT_FOUND)) !=
 	   (Item **)not_found_item)
 	  break;
+	if ((tmp= find_field_in_tables(thd, this,
+				       sl->get_table_list(),
+				       0)) != not_found_field);
+	if (sl->linkage == DERIVED_TABLE_TYPE)
+	  break; // do not look over derived table
+      }
 
       if (!ref)
-      {
 	return 1;
-      }
-      else if (ref == (Item **)not_found_item)
+      else if (!tmp)
+	return -1;
+      else if (ref == (Item **)not_found_item && tmp == not_found_field)
       {
 	// Call to report error
 	find_item_in_list(this,
@@ -894,10 +952,21 @@ bool Item_ref::fix_fields(THD *thd,TABLE_LIST *tables, Item **reference)
         ref= 0;
 	return 1;
       }
+      else if (tmp != not_found_field)
+      {
+	ref= 0; // To prevent "delete *ref;" on ~Item_erf() of this item
+	Item_field* f;
+	if (!((*reference)= f= new Item_field(tmp)))
+	  return 1;
+	f->depended_from= last;
+	thd->lex.current_select->mark_as_dependent(last);
+	return 0;
+      }
       else
       {
 	depended_from= last;
 	thd->lex.current_select->mark_as_dependent(last);
+	thd->add_possible_loop(this);
       }
     }
     else if (!ref)
@@ -906,9 +975,30 @@ bool Item_ref::fix_fields(THD *thd,TABLE_LIST *tables, Item **reference)
     maybe_null= (*ref)->maybe_null;
     decimals=	(*ref)->decimals;
   }
+  if (((*ref)->with_sum_func && 
+       (depended_from || 
+	!(thd->lex.current_select->linkage != GLOBAL_OPTIONS_TYPE &&
+	  thd->lex.current_select->select_lex()->having_fix_field))) ||
+      !(*ref)->fixed)
+  {
+    my_error(ER_ILLEGAL_REFERENCE, MYF(0), name, 
+	     ((*ref)->with_sum_func?
+	      "reference on group function":
+	      "forward reference in item list"));
+    return 1;
+  }
+  fixed= 1;
   return 0;
 }
 
+bool Item_ref::check_loop(uint id)
+{
+  DBUG_ENTER("Item_ref::check_loop");
+  if (Item_ident::check_loop(id))
+    DBUG_RETURN(1);
+  DBUG_RETURN((*ref)->check_loop(id));
+}
+
 /*
 ** If item is a const function, calculate it and return a const item
 ** The original item is freed if not returned
diff --git a/sql/item.h b/sql/item.h
index f3339c5a5a9cecb46d257e1561fe3c9bd9aa5292..4dde90d0beb54f6df9800697758d03b9feababf9 100644
--- a/sql/item.h
+++ b/sql/item.h
@@ -20,10 +20,11 @@
 #endif
 
 struct st_table_list;
-void item_init(void);				/* Init item functions */
+void item_init(void);			/* Init item functions */
 
 class Item {
-  Item(const Item &);				/* Prevent use of these */
+  uint loop_id;                         /* Used to find selfrefering loops */
+  Item(const Item &);			/* Prevent use of these */
   void operator=(Item &);
 public:
   static void *operator new(size_t size) {return (void*) sql_alloc((uint) size); }
@@ -45,6 +46,7 @@ class Item {
   my_bool null_value;			/* if item is null */
   my_bool unsigned_flag;
   my_bool with_sum_func;
+  my_bool fixed;                        /* If item fixed with fix_fields */
 
   // alloc & destruct is done as start of select using sql_alloc
   Item();
@@ -84,10 +86,14 @@ class Item {
   virtual bool get_date(TIME *ltime,bool fuzzydate);
   virtual bool get_time(TIME *ltime);
   virtual bool is_null() { return 0; };
-  virtual CHARSET_INFO *thd_charset() const;
-  virtual CHARSET_INFO *charset() const { return str_value.charset(); };
-  virtual bool binary() const { return str_value.charset()->state & MY_CS_BINSORT ? 1 : 0 ; }
-  virtual void set_charset(CHARSET_INFO *cs) { str_value.set_charset(cs); }
+  virtual bool check_loop(uint id);
+  virtual void top_level_item() {}
+
+  virtual bool binary() const
+  { return str_value.charset()->state & MY_CS_BINSORT ? 1 : 0 ; }
+  CHARSET_INFO *thd_charset() const;
+  CHARSET_INFO *charset() const { return str_value.charset(); };
+  void set_charset(CHARSET_INFO *cs) { str_value.set_charset(cs); }
 };
 
 
@@ -230,8 +236,8 @@ class Item_param :public Item
   Item_param(char *name_par=0)
   { 
     name= name_par ? name_par : (char*) "?";
-    long_data_supplied = false;
-    item_type = STRING_ITEM;
+    long_data_supplied= false;
+    item_type= STRING_ITEM;
     item_result_type = STRING_RESULT;
   }
   enum Type type() const { return item_type; }
@@ -243,12 +249,13 @@ class Item_param :public Item
   void set_null();
   void set_int(longlong i);
   void set_double(double i);
-  void set_value(const char *str, uint length, CHARSET_INFO *cs);
-  void set_long_str(const char *str, ulong length, CHARSET_INFO *cs);
-  void set_long_binary(const char *str, ulong length, CHARSET_INFO *cs);
-  void set_longdata(const char *str, ulong length, CHARSET_INFO *cs);
+  void set_value(const char *str, uint length);
+  void set_long_str(const char *str, ulong length);
+  void set_long_binary(const char *str, ulong length);
+  void set_longdata(const char *str, ulong length);
   void set_long_end();
   void reset() {}
+  void (*setup_param_func)(Item_param *param, uchar **pos);
   enum Item_result result_type () const
   { return item_result_type; }
   Item *new_item() { return new Item_param(name); }
@@ -445,8 +452,8 @@ class Item_ref :public Item_ident
     :Item_ident(NullS,table_name_par,field_name_par),ref(item) {}
   enum Type type() const		{ return REF_ITEM; }
   bool eq(const Item *item, bool binary_cmp) const
-  { return (*ref)->eq(item, binary_cmp); }
-  ~Item_ref() { if (ref) delete *ref; }
+  { return ref && (*ref)->eq(item, binary_cmp); }
+  ~Item_ref() { if (ref && (*ref) != this) delete *ref; }
   double val()
   {
     double tmp=(*ref)->val_result();
@@ -481,6 +488,7 @@ class Item_ref :public Item_ident
   void save_org_in_field(Field *field)	{ (*ref)->save_org_in_field(field); }
   enum Item_result result_type () const { return (*ref)->result_type(); }
   table_map used_tables() const		{ return (*ref)->used_tables(); }
+  bool check_loop(uint id);
 };
 
 
diff --git a/sql/item_cmpfunc.cc b/sql/item_cmpfunc.cc
index 1dfc5d86f5e7580da5f2d7d5237f56d72498716f..178eeab1e5a515a16ac6fdb0c97922b938fb1dc9 100644
--- a/sql/item_cmpfunc.cc
+++ b/sql/item_cmpfunc.cc
@@ -51,8 +51,8 @@ Item_bool_func2* Item_bool_func2::le_creator(Item *a, Item *b)
 
 /*
   Test functions
-  These returns 0LL if false and 1LL if true and null if some arg is null
-  'AND' and 'OR' never return null
+  Most of these  returns 0LL if false and 1LL if true and
+  NULL if some arg is NULL.
 */
 
 longlong Item_func_not::val_int()
@@ -368,6 +368,14 @@ void Item_func_interval::update_used_tables()
   const_item_cache&=item->const_item();
 }
 
+bool Item_func_interval::check_loop(uint id)
+{
+  DBUG_ENTER("Item_func_interval::check_loop");
+  if (Item_func::check_loop(id))
+    DBUG_RETURN(1);
+  DBUG_RETURN(item->check_loop(id));
+}
+
 void Item_func_between::fix_length_and_dec()
 {
    max_length=1;
@@ -378,13 +386,19 @@ void Item_func_between::fix_length_and_dec()
   */
   if (!args[0] || !args[1] || !args[2])
     return;
-  cmp_type=args[0]->result_type();
-  if (args[0]->binary())
+  cmp_type=item_cmp_type(args[0]->result_type(),
+           item_cmp_type(args[1]->result_type(),
+                         args[2]->result_type()));
+  if (args[0]->binary() | args[1]->binary() | args[2]->binary())
     string_compare=stringcmp;
   else
     string_compare=sortcmp;
 
-  // Make a special case of compare with fields to get nicer DATE comparisons
+  /*
+    Make a special case of compare with date/time and longlong fields.
+    They are compared as integers, so for const item this time-consuming
+    conversion can be done only once, not for every single comparison
+  */
   if (args[0]->type() == FIELD_ITEM)
   {
     Field *field=((Item_field*) args[0])->field;
@@ -800,6 +814,16 @@ Item_func_case::fix_fields(THD *thd, TABLE_LIST *tables, Item **ref)
   return 0;
 }
 
+bool Item_func_case::check_loop(uint id)
+{
+  DBUG_ENTER("Item_func_case::check_loop");
+  if (Item_func::check_loop(id))
+    DBUG_RETURN(1);
+
+  DBUG_RETURN((first_expr && first_expr->check_loop(id)) ||
+	      (else_expr && else_expr->check_loop(id)));
+}
+
 void Item_func_case::update_used_tables()
 {
   Item_func::update_used_tables();
@@ -1147,6 +1171,8 @@ Item_cond::fix_fields(THD *thd, TABLE_LIST *tables, Item **ref)
 #endif
       item= *li.ref();				// new current item
     }
+    if (abort_on_null)
+      item->top_level_item();
     if (item->fix_fields(thd, tables, li.ref()))
       return 1; /* purecov: inspected */
     used_tables_cache|=item->used_tables();
@@ -1158,9 +1184,24 @@ Item_cond::fix_fields(THD *thd, TABLE_LIST *tables, Item **ref)
   if (thd)
     thd->cond_count+=list.elements;
   fix_length_and_dec();
+  fixed= 1;
   return 0;
 }
 
+bool Item_cond::check_loop(uint id)
+{
+  DBUG_ENTER("Item_cond::check_loop");
+  if (Item_func::check_loop(id))
+    DBUG_RETURN(1);
+  List_iterator<Item> li(list);
+  Item *item;
+  while ((item= li++))
+  {
+    if (item->check_loop(id))
+      DBUG_RETURN(1);
+  }
+  DBUG_RETURN(0);
+}
 
 void Item_cond::split_sum_func(List<Item> &fields)
 {
@@ -1222,28 +1263,41 @@ void Item_cond::print(String *str)
   str->append(')');
 }
 
+/*
+  Evalution of AND(expr, expr, expr ...)
+
+  NOTES:
+    abort_if_null is set for AND expressions for which we don't care if the
+    result is NULL or 0. This is set for:
+    - WHERE clause
+    - HAVING clause
+    - IF(expression)
+
+  RETURN VALUES
+    1  If all expressions are true
+    0  If all expressions are false or if we find a NULL expression and
+       'abort_on_null' is set.
+    NULL if all expression are either 1 or NULL
+*/
+
 
 longlong Item_cond_and::val_int()
 {
   List_iterator_fast<Item> li(list);
   Item *item;
+  null_value= 0;
   while ((item=li++))
   {
     if (item->val_int() == 0)
     {
-      /*
-	TODO: In case of NULL, ANSI would require us to continue evaluation
-	until we get a FALSE value or run out of values; This would
-	require a lot of unnecessary evaluation, which we skip for now
-      */
-      null_value=item->null_value;
-      return 0;
+      if (abort_on_null || !(null_value= item->null_value))
+	return 0;				// return FALSE
     }
   }
-  null_value=0;
-  return 1;
+  return null_value ? 0 : 1;
 }
 
+
 longlong Item_cond_or::val_int()
 {
   List_iterator_fast<Item> li(list);
@@ -1262,6 +1316,45 @@ longlong Item_cond_or::val_int()
   return 0;
 }
 
+/*
+  Create an AND expression from two expressions
+
+  SYNOPSIS
+   and_expressions()
+   a		expression or NULL
+   b    	expression.
+   org_item	Don't modify a if a == *org_item
+		If a == NULL, org_item is set to point at b,
+		to ensure that future calls will not modify b.
+
+  NOTES
+    This will not modify item pointed to by org_item or b
+    The idea is that one can call this in a loop and create and
+    'and' over all items without modifying any of the original items.
+
+  RETURN
+    NULL	Error
+    Item
+*/
+
+Item *and_expressions(Item *a, Item *b, Item **org_item)
+{
+  if (!a)
+    return (*org_item= b);
+  if (a == *org_item)
+  {
+    Item_cond *res;
+    if ((res= new Item_cond_and(a, b)))
+      res->used_tables_cache= a->used_tables() | b->used_tables();
+    return res;
+  }
+  if (((Item_cond_and*) a)->add(b))
+    return 0;
+  ((Item_cond_and*) a)->used_tables_cache|= b->used_tables();
+  return a;
+}
+
+
 longlong Item_func_isnull::val_int()
 {
   /*
@@ -1305,10 +1398,10 @@ longlong Item_func_like::val_int()
     set_charset(my_charset_bin);
   if (canDoTurboBM)
     return turboBM_matches(res->ptr(), res->length()) ? 1 : 0;
-  if (binary())
-    return wild_compare(*res,*res2,escape) ? 0 : 1;
-  else
-    return wild_case_compare(*res,*res2,escape) ? 0 : 1;
+  return my_wildcmp(charset(),
+		    res->ptr(),res->ptr()+res->length(),
+		    res2->ptr(),res2->ptr()+res2->length(),
+		    escape,wild_one,wild_many) ? 0 : 1;
 }
 
 
@@ -1417,6 +1510,7 @@ Item_func_regex::fix_fields(THD *thd, TABLE_LIST *tables, Item **ref)
   }
   else
     maybe_null=1;
+  fixed= 1;
   return 0;
 }
 
diff --git a/sql/item_cmpfunc.h b/sql/item_cmpfunc.h
index 9976319740d4fd42bac3dd9c207f5fa6bf6a72a1..f1e51e674e9aa50b7f52510bc350c74ce74d8222 100644
--- a/sql/item_cmpfunc.h
+++ b/sql/item_cmpfunc.h
@@ -193,6 +193,7 @@ class Item_func_interval :public Item_int_func
   ~Item_func_interval() { delete item; }
   const char *func_name() const { return "interval"; }
   void update_used_tables();
+  bool check_loop(uint id);
 };
 
 
@@ -219,6 +220,11 @@ class Item_func_if :public Item_func
   longlong val_int();
   String *val_str(String *str);
   enum Item_result result_type () const { return cached_result_type; }
+  bool fix_fields(THD *thd,struct st_table_list *tlist, Item **ref)
+  {
+    args[0]->top_level_item();
+    return Item_func::fix_fields(thd, tlist, ref);
+  }
   void fix_length_and_dec();
   const char *func_name() const { return "if"; }
 };
@@ -269,6 +275,7 @@ class Item_func_case :public Item_func
   void print(String *str);
   bool fix_fields(THD *thd, struct st_table_list *tlist, Item **ref);
   Item *find_item(String *str);
+  bool check_loop(uint id);
 };
 
 
@@ -291,9 +298,9 @@ class in_vector :public Sql_alloc
   virtual void set(uint pos,Item *item)=0;
   virtual byte *get_value(Item *item)=0;
   void sort()
-    {
-      qsort(base,used_count,size,compare);
-    }
+  {
+    qsort(base,used_count,size,compare);
+  }
   int find(Item *item);
 };
 
@@ -431,6 +438,13 @@ class Item_func_in :public Item_int_func
   enum Functype functype() const { return IN_FUNC; }
   const char *func_name() const { return " IN "; }
   void update_used_tables();
+  bool check_loop(uint id)
+  {
+    DBUG_ENTER("Item_func_in::check_loop");
+    if (Item_func::check_loop(id))
+      DBUG_RETURN(1);
+    DBUG_RETURN(item->check_loop(id));
+  }
 };
 
 
@@ -555,10 +569,12 @@ class Item_cond :public Item_bool_func
 {
 protected:
   List<Item> list;
+  bool abort_on_null;
 public:
-  Item_cond() : Item_bool_func() { const_item_cache=0; }
-  Item_cond(Item *i1,Item *i2) :Item_bool_func()
-    { list.push_back(i1); list.push_back(i2); }
+  /* Item_cond() is only used to create top level items */
+  Item_cond() : Item_bool_func(), abort_on_null(1) { const_item_cache=0; }
+  Item_cond(Item *i1,Item *i2) :Item_bool_func(), abort_on_null(0)
+  { list.push_back(i1); list.push_back(i2); }
   ~Item_cond() { list.delete_elements(); }
   bool add(Item *item) { return list.push_back(item); }
   bool fix_fields(THD *, struct st_table_list *, Item **ref);
@@ -570,6 +586,8 @@ class Item_cond :public Item_bool_func
   void print(String *str);
   void split_sum_func(List<Item> &fields);
   friend int setup_conds(THD *thd,TABLE_LIST *tables,COND **conds);
+  bool check_loop(uint id);
+  void top_level_item() { abort_on_null=1; }
 };
 
 
@@ -617,6 +635,7 @@ inline Item *and_conds(Item *a,Item *b)
   return cond;
 }
 
+Item *and_expressions(Item *a, Item *b, Item **org_item);
 
 /**************************************************************
   Spatial relations
diff --git a/sql/item_create.cc b/sql/item_create.cc
index e4c9a160686e0b1096c1d1dff700fc886f85f522..aa3e7779d73269a74e6636307cdf575bd014efbe 100644
--- a/sql/item_create.cc
+++ b/sql/item_create.cc
@@ -76,7 +76,7 @@ Item *create_func_ceiling(Item* a)
 Item *create_func_connection_id(void)
 {
   THD *thd=current_thd;
-  thd->safe_to_cache_query=0;
+  thd->lex.safe_to_cache_query=0;
   return new Item_int("CONNECTION_ID()",(longlong) thd->thread_id,10);
 }
 
@@ -149,7 +149,7 @@ Item *create_func_floor(Item* a)
 Item *create_func_found_rows(void)
 {
   THD *thd=current_thd;
-  thd->safe_to_cache_query=0;
+  thd->lex.safe_to_cache_query=0;
   return new Item_int("FOUND_ROWS()",(longlong) thd->found_rows(),21);
 }
 
@@ -160,7 +160,7 @@ Item *create_func_from_days(Item* a)
 
 Item *create_func_get_lock(Item* a, Item *b)
 {
-  current_thd->safe_to_cache_query=0;
+  current_thd->lex.safe_to_cache_query=0;
   return new Item_func_get_lock(a, b);
 }
 
@@ -308,7 +308,7 @@ Item *create_func_radians(Item *a)
 
 Item *create_func_release_lock(Item* a)
 {
-  current_thd->safe_to_cache_query=0;
+  current_thd->lex.safe_to_cache_query=0;
   return new Item_func_release_lock(a);
 }
 
@@ -416,13 +416,13 @@ Item *create_func_year(Item* a)
 
 Item *create_load_file(Item* a)
 {
-  current_thd->safe_to_cache_query=0;
+  current_thd->lex.safe_to_cache_query=0;
   return new Item_load_file(a);
 }
 
 Item *create_wait_for_master_pos(Item* a, Item* b)
 {
-  current_thd->safe_to_cache_query=0;
+  current_thd->lex.safe_to_cache_query=0;
   return new Item_master_pos_wait(a, b);
 }
 
@@ -432,6 +432,7 @@ Item *create_func_cast(Item *a, Item_cast cast_type)
   LINT_INIT(res);
   switch (cast_type) {
   case ITEM_CAST_BINARY: 	res= new Item_func_binary(a); break;
+  case ITEM_CAST_CHAR:	 	res= new Item_char_typecast(a); break;
   case ITEM_CAST_SIGNED_INT:	res= new Item_func_signed(a); break;
   case ITEM_CAST_UNSIGNED_INT:  res= new Item_func_unsigned(a); break;
   case ITEM_CAST_DATE:		res= new Item_date_typecast(a); break;
@@ -443,7 +444,7 @@ Item *create_func_cast(Item *a, Item_cast cast_type)
 
 Item *create_func_is_free_lock(Item* a)
 {
-  current_thd->safe_to_cache_query=0;
+  current_thd->lex.safe_to_cache_query=0;
   return new Item_func_is_free_lock(a);
 }
 
diff --git a/sql/item_func.cc b/sql/item_func.cc
index 543a96107dcca67514a0d93fcbc81ce0bb63fa13..2af26e2fd9a648fa81a4e0411034447cc6ab6c7b 100644
--- a/sql/item_func.cc
+++ b/sql/item_func.cc
@@ -123,9 +123,26 @@ Item_func::fix_fields(THD *thd, TABLE_LIST *tables, Item **ref)
     }
   }
   fix_length_and_dec();
+  fixed= 1;
   return 0;
 }
 
+bool Item_func::check_loop(uint id)
+{
+  DBUG_ENTER("Item_func::check_loop");
+  if (Item_result_field::check_loop(id))
+    DBUG_RETURN(1);
+  if (arg_count)
+  {
+    Item **arg,**arg_end;
+    for (arg= args, arg_end= args+arg_count; arg != arg_end; arg++)
+    {
+      if ((*arg)->check_loop(id))
+	DBUG_RETURN(1);
+    }
+  }
+  DBUG_RETURN(0);
+}
 
 void Item_func::split_sum_func(List<Item> &fields)
 {
@@ -439,6 +456,25 @@ void Item_func_div::fix_length_and_dec()
   maybe_null=1;
 }
 
+
+/* Integer division */
+longlong Item_func_int_div::val_int()
+{
+  longlong value=args[0]->val_int();
+  longlong val2=args[1]->val_int();
+  if ((null_value= val2 == 0 || args[0]->null_value || args[1]->null_value))
+    return 0;
+  return value/val2;
+}
+
+
+void Item_func_int_div::fix_length_and_dec()
+{
+  max_length=args[0]->max_length - args[0]->decimals;
+  maybe_null=1;
+}
+
+
 double Item_func_mod::val()
 {
   double value= floor(args[0]->val()+0.5);
@@ -752,13 +788,14 @@ double Item_func_rand::val()
   }
   else if (!thd->rand_used)
   {
-    // no need to send a Rand log event if seed was given eg: RAND(seed),
-    // as it will be replicated in the query as such.
-
-    // save the seed only the first time RAND() is used in the query
+    /*
+      No need to send a Rand log event if seed was given eg: RAND(seed),
+      as it will be replicated in the query as such.
 
-    // once events are forwarded rather than recreated,
-    // the following can be skipped if inside the slave thread
+      Save the seed only the first time RAND() is used in the query
+      Once events are forwarded rather than recreated,
+      the following can be skipped if inside the slave thread
+    */
     thd->rand_used=1;
     thd->rand_saved_seed1=thd->rand.seed1;
     thd->rand_saved_seed2=thd->rand.seed2;
@@ -1571,7 +1608,7 @@ void item_user_lock_release(ULL *ull)
     tmp.copy(command, strlen(command), tmp.charset());
     tmp.append(ull->key,ull->key_length);
     tmp.append("\")");
-    Query_log_event qev(current_thd,tmp.ptr(), tmp.length());
+    Query_log_event qev(current_thd, tmp.ptr(), tmp.length(),1);
     qev.error_code=0; // this query is always safe to run on slave
     mysql_bin_log.write(&qev);
   }
@@ -2016,13 +2053,13 @@ void Item_func_set_user_var::print(String *str)
 
 user_var_entry *Item_func_get_user_var::get_entry()
 {
-  if (!entry  || ! entry->value)
+  if (!var_entry  || ! var_entry->value)
   {
     null_value=1;
     return 0;
   }
   null_value=0;
-  return entry;
+  return var_entry;
 }
 
 
@@ -2091,8 +2128,8 @@ void Item_func_get_user_var::fix_length_and_dec()
   maybe_null=1;
   decimals=NOT_FIXED_DEC;
   max_length=MAX_BLOB_WIDTH;
-  if ((entry= get_variable(&thd->user_vars, name, 0)))
-    const_var_flag= thd->query_id != entry->update_query_id;
+  if ((var_entry= get_variable(&thd->user_vars, name, 0)))
+    const_var_flag= thd->query_id != var_entry->update_query_id;
 }
 
 
@@ -2264,23 +2301,36 @@ bool Item_func_match::fix_fields(THD *thd, TABLE_LIST *tlist, Item **ref)
   return 0;
 }
 
+bool Item_func_match::check_loop(uint id)
+{
+  DBUG_ENTER("Item_func_match::check_loop");
+  if (Item_real_func::check_loop(id))
+    DBUG_RETURN(1);
+
+  List_iterator<Item> li(fields);
+  Item *item;
+  while ((item= li++))
+    if (item->check_loop(id))
+      DBUG_RETURN(1);
+  DBUG_RETURN(0);
+}
 
 bool Item_func_match::fix_index()
 {
   List_iterator_fast<Item> li(fields);
   Item_field *item;
-  uint ft_to_key[MAX_KEY], ft_cnt[MAX_KEY], fts=0, key;
+  uint ft_to_key[MAX_KEY], ft_cnt[MAX_KEY], fts=0, keynr;
   uint max_cnt=0, mkeys=0;
 
-  if (this->key == NO_SUCH_KEY)
+  if (key == NO_SUCH_KEY)
     return 0;
 
-  for (key=0 ; key<table->keys ; key++)
+  for (keynr=0 ; keynr < table->keys ; keynr++)
   {
-    if ((table->key_info[key].flags & HA_FULLTEXT) &&
-        (table->keys_in_use_for_query & (((key_map)1) << key)))
+    if ((table->key_info[keynr].flags & HA_FULLTEXT) &&
+        (table->keys_in_use_for_query & (((key_map)1) << keynr)))
     {
-      ft_to_key[fts]=key;
+      ft_to_key[fts]=keynr;
       ft_cnt[fts]=0;
       fts++;
     }
@@ -2291,45 +2341,45 @@ bool Item_func_match::fix_index()
 
   while ((item=(Item_field*)(li++)))
   {
-    for (key=0 ; key<fts ; key++)
+    for (keynr=0 ; keynr < fts ; keynr++)
     {
-      KEY *ft_key=&table->key_info[ft_to_key[key]];
+      KEY *ft_key=&table->key_info[ft_to_key[keynr]];
       uint key_parts=ft_key->key_parts;
 
       for (uint part=0 ; part < key_parts ; part++)
       {
 	if (item->field->eq(ft_key->key_part[part].field))
-	  ft_cnt[key]++;
+	  ft_cnt[keynr]++;
       }
     }
   }
 
-  for (key=0 ; key<fts ; key++)
+  for (keynr=0 ; keynr < fts ; keynr++)
   {
-    if (ft_cnt[key] > max_cnt)
+    if (ft_cnt[keynr] > max_cnt)
     {
       mkeys=0;
-      max_cnt=ft_cnt[mkeys]=ft_cnt[key];
-      ft_to_key[mkeys]=ft_to_key[key];
+      max_cnt=ft_cnt[mkeys]=ft_cnt[keynr];
+      ft_to_key[mkeys]=ft_to_key[keynr];
       continue;
     }
-    if (max_cnt && ft_cnt[key] == max_cnt)
+    if (max_cnt && ft_cnt[keynr] == max_cnt)
     {
       mkeys++;
-      ft_cnt[mkeys]=ft_cnt[key];
-      ft_to_key[mkeys]=ft_to_key[key];
+      ft_cnt[mkeys]=ft_cnt[keynr];
+      ft_to_key[mkeys]=ft_to_key[keynr];
       continue;
     }
   }
 
-  for (key=0 ; key<=mkeys ; key++)
+  for (keynr=0 ; keynr <= mkeys ; keynr++)
   {
     // for now, partial keys won't work. SerG
     if (max_cnt < fields.elements ||
-        max_cnt < table->key_info[ft_to_key[key]].key_parts)
+        max_cnt < table->key_info[ft_to_key[keynr]].key_parts)
       continue;
 
-    this->key=ft_to_key[key];
+    key=ft_to_key[keynr];
 
     return 0;
   }
@@ -2337,7 +2387,7 @@ bool Item_func_match::fix_index()
 err:
   if (mode == FT_BOOL)
   {
-    this->key=NO_SUCH_KEY;
+    key=NO_SUCH_KEY;
     return 0;
   }
   my_printf_error(ER_FT_MATCHING_KEY_NOT_FOUND,
@@ -2421,7 +2471,7 @@ Item *get_system_var(enum_var_type var_type, LEX_STRING name)
   }
   if (!(item=var->item(thd, var_type)))
     return 0;					// Impossible
-  thd->safe_to_cache_query=0;
+  thd->lex.safe_to_cache_query=0;
   buff[0]='@';
   buff[1]='@';
   pos=buff+2;
@@ -2447,7 +2497,7 @@ Item *get_system_var(enum_var_type var_type, const char *var_name, uint length,
   DBUG_ASSERT(var != 0);
   if (!(item=var->item(thd, var_type)))
     return 0;					// Impossible
-  thd->safe_to_cache_query=0;
+  thd->lex.safe_to_cache_query=0;
   item->set_name(item_name);		// Will use original name
   return item;
 }
diff --git a/sql/item_func.h b/sql/item_func.h
index 1e1f2ba39fc17499b729716353fcf6955b4aa624..38f461acc13925624ccd3204246339863ca6f76a 100644
--- a/sql/item_func.h
+++ b/sql/item_func.h
@@ -128,6 +128,7 @@ class Item_func :public Item_result_field
   bool is_null() { (void) val_int(); return null_value; }
   friend class udf_handler;
   Field *tmp_table_field(TABLE *t_arg);
+  bool check_loop(uint id);
 };
 
 
@@ -253,6 +254,18 @@ class Item_func_div :public Item_num_op
 };
 
 
+class Item_func_int_div :public Item_num_op
+{
+public:
+  Item_func_int_div(Item *a,Item *b) :Item_num_op(a,b)
+  { hybrid_type=INT_RESULT; }
+  double val() { return (double) val_int(); }
+  longlong val_int();
+  const char *func_name() const { return "DIV"; }
+  void fix_length_and_dec();
+};
+
+
 class Item_func_mod :public Item_num_op
 {
 public:
@@ -606,6 +619,13 @@ class Item_func_field :public Item_int_func
     const_item_cache&=  item->const_item();
     with_sum_func= with_sum_func || item->with_sum_func;
   }
+  bool check_loop(uint id)
+  {
+    DBUG_ENTER("Item_func_field::check_loop");
+    if (Item_int_func::check_loop(id))
+      DBUG_RETURN(1);
+    DBUG_RETURN(item->check_loop(id));
+  }
 };
 
 
@@ -734,6 +754,7 @@ class Item_udf_func :public Item_func
     bool res= udf.fix_fields(thd, tables, this, arg_count, args);
     used_tables_cache= udf.used_tables_cache;
     const_item_cache= udf.const_item_cache;
+    fixed= 1;
     return res;
   }
   Item_result result_type () const { return udf.result_type(); }
@@ -898,7 +919,7 @@ class Item_func_set_user_var :public Item_func
 class Item_func_get_user_var :public Item_func
 {
   LEX_STRING name;
-  user_var_entry *entry;
+  user_var_entry *var_entry;
   bool const_var_flag;
 
 public:
@@ -971,6 +992,7 @@ class Item_func_match :public Item_real_func
 
   bool fix_index();
   void init_search(bool no_order);
+  bool check_loop(uint id);
 };
 
 
@@ -1102,5 +1124,5 @@ class Item_func_is_free_lock :public Item_int_func
 enum Item_cast
 {
   ITEM_CAST_BINARY, ITEM_CAST_SIGNED_INT, ITEM_CAST_UNSIGNED_INT,
-  ITEM_CAST_DATE, ITEM_CAST_TIME, ITEM_CAST_DATETIME
+  ITEM_CAST_DATE, ITEM_CAST_TIME, ITEM_CAST_DATETIME, ITEM_CAST_CHAR
 };
diff --git a/sql/item_strfunc.cc b/sql/item_strfunc.cc
index 6f121ecdc062d052948da2a50276d39b44be3c6e..fc3b4da85614016826ef73191d9918615a82168d 100644
--- a/sql/item_strfunc.cc
+++ b/sql/item_strfunc.cc
@@ -1363,20 +1363,30 @@ String *Item_func_decode::val_str(String *str)
 
 String *Item_func_database::val_str(String *str)
 {
-  if (!current_thd->db)
+  THD *thd= current_thd;
+  if (!thd->db)
     str->length(0);
   else
-    str->set((const char*) current_thd->db,(uint) strlen(current_thd->db), default_charset_info);
+    str->copy((const char*) thd->db,(uint) strlen(thd->db),
+	      system_charset_info, thd->thd_charset);
   return str;
 }
 
 String *Item_func_user::val_str(String *str)
 {
-  THD *thd=current_thd;
-  if (str->copy((const char*) thd->user,(uint) strlen(thd->user), system_charset_info) ||
-      str->append('@') ||
-      str->append(thd->host ? thd->host : thd->ip ? thd->ip : ""))
-    return &empty_string;
+  THD          *thd=current_thd;
+  CHARSET_INFO *cs=thd->thd_charset;
+  const char   *host=thd->host ? thd->host : thd->ip ? thd->ip : "";
+  uint32       res_length=(strlen(thd->user)+strlen(host)+10) * cs->mbmaxlen;
+  
+  if (str->alloc(res_length))
+  {
+      null_value=1;
+      return 0;
+  }
+  res_length=cs->snprintf(cs, (char*)str->ptr(), res_length, "%s@%s",thd->user,host);
+  str->length(res_length);
+  str->set_charset(cs);
   return str;
 }
 
@@ -1928,7 +1938,7 @@ String *Item_func_conv_charset::val_str(String *str)
   s=(const uchar*)arg->ptr();
   se=s+arg->length();
   
-  dmaxlen=arg->length()*(to->mbmaxlen?to->mbmaxlen:1)+1;
+  dmaxlen=arg->length()*to->mbmaxlen+1;
   str->alloc(dmaxlen);
   d0=d=(unsigned char*)str->ptr();
   de=d+dmaxlen;
@@ -1970,7 +1980,7 @@ String *Item_func_conv_charset::val_str(String *str)
 
 void Item_func_conv_charset::fix_length_and_dec()
 {
-  max_length = args[0]->max_length*(conv_charset->mbmaxlen?conv_charset->mbmaxlen:1);
+  max_length = args[0]->max_length*conv_charset->mbmaxlen;
   set_charset(conv_charset);
 }
 
@@ -2002,7 +2012,7 @@ String *Item_func_conv_charset3::val_str(String *str)
   s=(const uchar*)arg->ptr();
   se=s+arg->length();
   
-  dmaxlen=arg->length()*(to_charset->mbmaxlen?to_charset->mbmaxlen:1)+1;
+  dmaxlen=arg->length()*to_charset->mbmaxlen+1;
   str->alloc(dmaxlen);
   d0=d=(unsigned char*)str->ptr();
   de=d+dmaxlen;
@@ -2057,6 +2067,7 @@ bool Item_func_conv_charset::fix_fields(THD *thd,struct st_table_list *tables, I
   const_item_cache=args[0]->const_item();
   set_charset(conv_charset);
   fix_length_and_dec();
+  fixed= 1;
   return 0;
 }
 
@@ -2091,6 +2102,7 @@ bool Item_func_set_collation::fix_fields(THD *thd,struct st_table_list *tables,
   used_tables_cache=args[0]->used_tables();
   const_item_cache=args[0]->const_item();
   fix_length_and_dec();
+  fixed= 1;
   return 0;
 }
 
@@ -2120,7 +2132,8 @@ String *Item_func_charset::val_str(String *str)
 
   if ((null_value=(args[0]->null_value || !res->charset())))
     return 0;
-  str->copy(res->charset()->name,strlen(res->charset()->name),default_charset_info);
+  str->copy(res->charset()->name,strlen(res->charset()->name),
+	    my_charset_latin1, thd_charset());
   return str;
 }
 
diff --git a/sql/item_strfunc.h b/sql/item_strfunc.h
index 14dadc9689186a46c1fdd71c4b1d9665e850003e..9fd9143586e1060be77cf04d1b3b49a62c568a0c 100644
--- a/sql/item_strfunc.h
+++ b/sql/item_strfunc.h
@@ -105,6 +105,13 @@ class Item_func_concat_ws :public Item_str_func
 	    || Item_func::fix_fields(thd, tlist, ref));
   }
  const char *func_name() const { return "concat_ws"; }
+ bool check_loop(uint id)
+ {
+   DBUG_ENTER("Item_func_concat_ws::check_loop");
+   if (Item_str_func::check_loop(id))
+     DBUG_RETURN(1);
+   DBUG_RETURN(separator->check_loop(id));
+ }
 };
 
 class Item_func_reverse :public Item_str_func
@@ -310,7 +317,11 @@ class Item_func_database :public Item_str_func
 public:
   Item_func_database() {}
   String *val_str(String *);
-  void fix_length_and_dec() { max_length= MAX_FIELD_NAME; }
+  void fix_length_and_dec() 
+  { 
+    max_length= MAX_FIELD_NAME * thd_charset()->mbmaxlen; 
+    set_charset(thd_charset());
+  }
   const char *func_name() const { return "database"; }
 };
 
@@ -319,7 +330,11 @@ class Item_func_user :public Item_str_func
 public:
   Item_func_user() {}
   String *val_str(String *);
-  void fix_length_and_dec() { max_length= USERNAME_LENGTH+HOSTNAME_LENGTH+1; }
+  void fix_length_and_dec() 
+  { 
+    max_length= (USERNAME_LENGTH+HOSTNAME_LENGTH+1)*thd_charset()->mbmaxlen; 
+    set_charset(thd_charset());
+  }
   const char *func_name() const { return "user"; }
 };
 
@@ -353,6 +368,13 @@ class Item_func_elt :public Item_str_func
   void fix_length_and_dec();
   void update_used_tables();
   const char *func_name() const { return "elt"; }
+  bool check_loop(uint id)
+  {
+    DBUG_ENTER("Item_func_elt::check_loop");
+    if (Item_str_func::check_loop(id))
+      DBUG_RETURN(1);
+    DBUG_RETURN(item->check_loop(id));
+  }
 };
 
 
@@ -373,6 +395,13 @@ class Item_func_make_set :public Item_str_func
   void fix_length_and_dec();
   void update_used_tables();
   const char *func_name() const { return "make_set"; }
+  bool check_loop(uint id)
+  {
+    DBUG_ENTER("Item_func_make_set::check_loop");
+    if (Item_str_func::check_loop(id))
+      DBUG_RETURN(1);
+    DBUG_RETURN(item->check_loop(id));
+  }
 };
 
 
@@ -465,8 +494,9 @@ class Item_func_binary :public Item_str_func
   {
     String *tmp=args[0]->val_str(a);
     null_value=args[0]->null_value;
+    tmp->set_charset(my_charset_bin);
     return tmp;
-   }
+  }
   void fix_length_and_dec() 
   { 
     set_charset(my_charset_bin); 
@@ -567,7 +597,8 @@ class Item_func_charset :public Item_str_func
   const char *func_name() const { return "charset"; }
   void fix_length_and_dec() 
   {
-     max_length=20; // should be enough
+     max_length=40; // should be enough
+     set_charset(thd_charset());
   };
 };
 
diff --git a/sql/item_subselect.cc b/sql/item_subselect.cc
index d8e1fee2277ce4d6cc8ddf71aa2ee89c3ddb3e2a..750fca5a4f87b9392d36d735c18dd382787048d5 100644
--- a/sql/item_subselect.cc
+++ b/sql/item_subselect.cc
@@ -33,7 +33,7 @@ SUBSELECT TODO:
 #include "sql_select.h"
 
 Item_subselect::Item_subselect():
-  Item(), engine_owner(1), value_assigned(0)
+  Item_result_field(), engine_owner(1), value_assigned(0)
 {
   assign_null();
   /*
@@ -89,6 +89,7 @@ void Item_subselect::make_field (Send_field *tmp_field)
 
 bool Item_subselect::fix_fields(THD *thd, TABLE_LIST *tables, Item **ref)
 {
+  char const *save_where= thd->where;
   int res= engine->prepare();
   if (!res)
   {
@@ -100,9 +101,20 @@ bool Item_subselect::fix_fields(THD *thd, TABLE_LIST *tables, Item **ref)
     }
     fix_length_and_dec();
   }
+  fixed= 1;
+  thd->where= save_where;
   return res;
 }
 
+bool Item_subselect::check_loop(uint id)
+{
+  DBUG_ENTER("Item_subselect::check_loop");
+  if (Item_result_field::check_loop(id))
+    DBUG_RETURN(1);
+  
+  DBUG_RETURN(engine->check_loop(id));
+}
+
 void Item_subselect::fix_length_and_dec()
 {
   engine->fix_length_and_dec();
@@ -339,6 +351,7 @@ subselect_single_select_engine::subselect_single_select_engine(THD *thd,
     thd->fatal_error= 1;
     my_message(ER_OUT_OF_RESOURCES, ER(ER_OUT_OF_RESOURCES), MYF(0));
   } 
+  unit->item= item;
   this->select_lex= select_lex;
 }
 
@@ -412,11 +425,13 @@ void subselect_union_engine::fix_length_and_dec()
 int subselect_single_select_engine::exec()
 {
   DBUG_ENTER("subselect_single_select_engine::exec");
+  char const *save_where= join->thd->where;
   if (!optimized)
   {
     optimized=1;
     if (join->optimize())
     {
+      join->thd->where= save_where;
       executed= 1;
       DBUG_RETURN(join->error?join->error:1);
     }
@@ -424,7 +439,10 @@ int subselect_single_select_engine::exec()
   if (select_lex->dependent && executed)
   {
     if (join->reinit())
+    {
+      join->thd->where= save_where;
       DBUG_RETURN(1);
+    }
     item->assign_null();
     item->assigned((executed= 0));
   }
@@ -435,14 +453,19 @@ int subselect_single_select_engine::exec()
     join->exec();
     join->thd->lex.current_select= save_select;
     executed= 1;
+    join->thd->where= save_where;
     DBUG_RETURN(join->error||thd->fatal_error);
   }
+  join->thd->where= save_where;
   DBUG_RETURN(0);
 }
 
 int subselect_union_engine::exec()
 {
-  return unit->exec();
+  char const *save_where= unit->thd->where;
+  int res= unit->exec();
+  unit->thd->where= save_where;
+  return res;
 }
 
 uint subselect_single_select_engine::cols()
@@ -464,3 +487,18 @@ bool subselect_union_engine::depended()
 {
   return unit->dependent;
 }
+
+bool subselect_single_select_engine::check_loop(uint id)
+{
+  DBUG_ENTER("subselect_single_select_engine::check_loop");
+  DBUG_RETURN(join->check_loop(id));
+}
+
+bool subselect_union_engine::check_loop(uint id)
+{
+  DBUG_ENTER("subselect_union_engine::check_loop");
+  for (SELECT_LEX *sl= unit->first_select(); sl; sl= sl->next_select())
+    if (sl->join && sl->join->check_loop(id))
+      DBUG_RETURN(1);
+  DBUG_RETURN(0);
+}
diff --git a/sql/item_subselect.h b/sql/item_subselect.h
index 3d455b6decfa9eb2b3095e33b9cbcf41972dfc11..3a635ace8bad614f12ffaaae8075aeaf1de31f5e 100644
--- a/sql/item_subselect.h
+++ b/sql/item_subselect.h
@@ -31,7 +31,7 @@ typedef Item_bool_func2* (*compare_func_creator)(Item*, Item*);
 
 /* base class for subselects */
 
-class Item_subselect :public Item
+class Item_subselect :public Item_result_field
 {
   my_bool engine_owner; /* Is this item owner of engine */
   my_bool value_assigned; /* value already assigned to subselect */
@@ -75,6 +75,7 @@ class Item_subselect :public Item
   bool fix_fields(THD *thd, TABLE_LIST *tables, Item **ref);
   virtual void fix_length_and_dec();
   table_map used_tables() const;
+  bool check_loop(uint id);
 
   friend class select_subselect;
 };
@@ -120,6 +121,7 @@ class Item_singleval_subselect :public Item_subselect
   Item *new_item() { return new Item_singleval_subselect(this); }
   enum Item_result result_type() const { return res_type; }
   void fix_length_and_dec();
+
   friend class select_singleval_subselect;
 };
 
@@ -210,6 +212,7 @@ class subselect_engine
   virtual uint cols()= 0; /* return number of columnss in select */
   virtual bool depended()= 0; /* depended from outer select */
   enum Item_result type() { return res_type; }
+  virtual bool check_loop(uint id)= 0;
 };
 
 class subselect_single_select_engine: public subselect_engine
@@ -223,11 +226,12 @@ class subselect_single_select_engine: public subselect_engine
   subselect_single_select_engine(THD *thd, st_select_lex *select,
 				 select_subselect *result,
 				 Item_subselect *item);
-  virtual int prepare();
-  virtual void fix_length_and_dec();
-  virtual int exec();
-  virtual uint cols();
-  virtual bool depended();
+  int prepare();
+  void fix_length_and_dec();
+  int exec();
+  uint cols();
+  bool depended();
+  bool check_loop(uint id);
 };
 
 class subselect_union_engine: public subselect_engine
@@ -238,9 +242,10 @@ class subselect_union_engine: public subselect_engine
 			 st_select_lex_unit *u,
 			 select_subselect *result,
 			 Item_subselect *item);
-  virtual int prepare();
-  virtual void fix_length_and_dec();
-  virtual int exec();
-  virtual uint cols();
-  virtual bool depended();
+  int prepare();
+  void fix_length_and_dec();
+  int exec();
+  uint cols();
+  bool depended();
+  bool check_loop(uint id);
 };
diff --git a/sql/item_sum.cc b/sql/item_sum.cc
index 0d8bca96ce786e330683a66f5ce5f850398503a9..567b5ee6ffaae768e7ea398b5f8cf85ce3f6d202 100644
--- a/sql/item_sum.cc
+++ b/sql/item_sum.cc
@@ -138,6 +138,7 @@ Item_sum_num::fix_fields(THD *thd, TABLE_LIST *tables, Item **ref)
   null_value=1;
   fix_length_and_dec();
   thd->allow_sum_func=1;			// Allow group functions
+  fixed= 1;
   return 0;
 }
 
@@ -168,6 +169,7 @@ Item_sum_hybrid::fix_fields(THD *thd, TABLE_LIST *tables, Item **ref)
   null_value=1;
   fix_length_and_dec();
   thd->allow_sum_func=1;			// Allow group functions
+  fixed= 1;
   return 0;
 }
 
diff --git a/sql/item_sum.h b/sql/item_sum.h
index a169a0ee562c40d1df0a9356c434144da9e15d71..70bb3a7c0a15903d0816e89340b316d377bfa27c 100644
--- a/sql/item_sum.h
+++ b/sql/item_sum.h
@@ -389,6 +389,7 @@ class Item_udf_sum : public Item_sum
   const char *func_name() const { return udf.name(); }
   bool fix_fields(THD *thd, TABLE_LIST *tables, Item **ref)
   {
+    fixed= 1;
     return udf.fix_fields(thd,tables,this,this->arg_count,this->args);
   }
   enum Sumfunctype sum_func () const { return UDF_SUM_FUNC; }
diff --git a/sql/item_timefunc.cc b/sql/item_timefunc.cc
index 8a1bd0be2913a0cef738e874d1efdc5ee35de425..7c085a1b25a52e84d3fefc3c71d4f3a47a3e2662 100644
--- a/sql/item_timefunc.cc
+++ b/sql/item_timefunc.cc
@@ -153,14 +153,17 @@ longlong Item_func_month::val_int()
 
 String* Item_func_monthname::val_str(String* str)
 {
-  uint month=(uint) Item_func_month::val_int();
+  uint   month=(uint) Item_func_month::val_int();
   if (!month)					// This is also true for NULL
   {
     null_value=1;
     return (String*) 0;
   }
   null_value=0;
-  return &month_names[month-1];
+  
+  String *m=&month_names[month-1];
+  str->copy(m->ptr(), m->length(), m->charset(), thd_charset());
+  return str;
 }
 
 // Returns the quarter of the year
@@ -195,15 +198,28 @@ longlong Item_func_second::val_int()
 }
 
 
-// Returns the week of year in the range of 0 - 53
+/*
+  Returns the week of year.
+
+  The bits in week_format has the following meaning:
+    0	If not set:	USA format: Sunday is first day of week
+        If set:		ISO format: Monday is first day of week
+    1   If not set:	Week is in range 0-53
+    	If set		Week is in range 1-53.
+*/
 
 longlong Item_func_week::val_int()
 {
   uint year;
+  uint week_format;
   TIME ltime;
   if (get_arg0_date(&ltime,0))
     return 0;
-  return (longlong) calc_week(&ltime, 0, args[1]->val_int() == 0, &year);
+  week_format= (uint) args[1]->val_int();
+  return (longlong) calc_week(&ltime, 
+			      (week_format & 2) != 0,
+			      (week_format & 1) == 0,
+			      &year);
 }
 
 
@@ -213,7 +229,7 @@ longlong Item_func_yearweek::val_int()
   TIME ltime;
   if (get_arg0_date(&ltime,0))
     return 0;
-  week=calc_week(&ltime, 1, args[1]->val_int() == 0, &year);
+  week=calc_week(&ltime, 1, (args[1]->val_int() & 1) == 0, &year);
   return week+year*100;
 }
 
@@ -234,7 +250,10 @@ String* Item_func_dayname::val_str(String* str)
   uint weekday=(uint) val_int();		// Always Item_func_daynr()
   if (null_value)
     return (String*) 0;
-  return &day_names[weekday];
+  
+  String *d=&day_names[weekday];
+  str->copy(d->ptr(), d->length(), d->charset(), thd_charset());
+  return str;
 }
 
 
@@ -396,16 +415,16 @@ String *Item_date::val_str(String *str)
     return (String*) 0;
   if (!value)					// zero daynr
   {
-    str->copy("0000-00-00",10,my_charset_latin1);
+    str->copy("0000-00-00",10,my_charset_latin1,thd_charset());
     return str;
   }
-  if (str->alloc(11))
-    return &empty_string;			/* purecov: inspected */
-  sprintf((char*) str->ptr(),"%04d-%02d-%02d",
+  
+  char tmpbuff[11];
+  sprintf(tmpbuff,"%04d-%02d-%02d",
 	  (int) (value/10000L) % 10000,
 	  (int) (value/100)%100,
 	  (int) (value%100));
-  str->length(10);
+  str->copy(tmpbuff,10,my_charset_latin1,thd_charset());
   return str;
 }
 
@@ -442,7 +461,10 @@ void Item_func_curdate::fix_length_and_dec()
 {
   struct tm tm_tmp,*start;
   time_t query_start=current_thd->query_start();
-  decimals=0; max_length=10;
+  
+  set_charset(thd_charset());
+  decimals=0; 
+  max_length=10*thd_charset()->mbmaxlen;
   localtime_r(&query_start,&tm_tmp);
   start=&tm_tmp;
   value=(longlong) ((ulong) ((uint) start->tm_year+1900)*10000L+
@@ -467,27 +489,48 @@ bool Item_func_curdate::get_date(TIME *res,
   return 0;
 }
 
+String *Item_func_curtime::val_str(String *str)
+{ 
+  str_value.set(buff,buff_length,thd_charset());
+  return &str_value;
+}
+
 void Item_func_curtime::fix_length_and_dec()
 {
   struct tm tm_tmp,*start;
   time_t query_start=current_thd->query_start();
-  decimals=0; max_length=8;
+  CHARSET_INFO *cs=thd_charset();
+
+  decimals=0; 
+  max_length=8*cs->mbmaxlen;
   localtime_r(&query_start,&tm_tmp);
   start=&tm_tmp;
+  set_charset(cs);
   value=(longlong) ((ulong) ((uint) start->tm_hour)*10000L+
 		    (ulong) (((uint) start->tm_min)*100L+
 			     (uint) start->tm_sec));
-  buff_length= my_sprintf(buff, (buff,"%02d:%02d:%02d",
+
+  buff_length=cs->snprintf(cs,buff,sizeof(buff),"%02d:%02d:%02d",
 				 (int) start->tm_hour,
 				 (int) start->tm_min,
-				 (int) start->tm_sec));
+				 (int) start->tm_sec);
+}
+
+String *Item_func_now::val_str(String *str)
+{
+  str_value.set(buff,buff_length,thd_charset());
+  return &str_value;
 }
 
 void Item_func_now::fix_length_and_dec()
 {
   struct tm tm_tmp,*start;
   time_t query_start=current_thd->query_start();
-  decimals=0; max_length=19;
+  CHARSET_INFO *cs=thd_charset();
+  
+  decimals=0;
+  max_length=19*cs->mbmaxlen;
+  set_charset(cs);
   localtime_r(&query_start,&tm_tmp);
   start=&tm_tmp;
   value=((longlong) ((ulong) ((uint) start->tm_year+1900)*10000L+
@@ -496,13 +539,14 @@ void Item_func_now::fix_length_and_dec()
 	 (longlong) ((ulong) ((uint) start->tm_hour)*10000L+
 		     (ulong) (((uint) start->tm_min)*100L+
 			    (uint) start->tm_sec)));
-  buff_length= (uint) my_sprintf(buff, (buff,"%04d-%02d-%02d %02d:%02d:%02d",
+  
+  buff_length= (uint) cs->snprintf(cs,buff, sizeof(buff),"%04d-%02d-%02d %02d:%02d:%02d",
 					((int) (start->tm_year+1900)) % 10000,
 					(int) start->tm_mon+1,
 					(int) start->tm_mday,
 					(int) start->tm_hour,
 					(int) start->tm_min,
-					(int) start->tm_sec));
+					(int) start->tm_sec);
   /* For getdate */
   ltime.year=	start->tm_year+1900;
   ltime.month=	start->tm_mon+1;
@@ -533,7 +577,7 @@ int  Item_func_now::save_in_field(Field *to)
 
 String *Item_func_sec_to_time::val_str(String *str)
 {
-  char buff[23];
+  char buff[23*2];
   const char *sign="";
   longlong seconds=(longlong) args[0]->val_int();
   ulong length;
@@ -547,7 +591,7 @@ String *Item_func_sec_to_time::val_str(String *str)
   uint sec= (uint) ((ulonglong) seconds % 3600);
   length= my_sprintf(buff,(buff,"%s%02lu:%02u:%02u",sign,(long) (seconds/3600),
 			   sec/60, sec % 60));
-  str->copy(buff, length, my_charset_latin1);
+  str->copy(buff, length, my_charset_latin1, thd_charset());
   return str;
 }
 
@@ -891,20 +935,26 @@ String *Item_func_from_unixtime::val_str(String *str)
 {
   struct tm tm_tmp,*start;
   time_t tmp=(time_t) args[0]->val_int();
+  uint32 l;
+  CHARSET_INFO *cs=thd_charset();
+  
   if ((null_value=args[0]->null_value))
     return 0;
   localtime_r(&tmp,&tm_tmp);
   start=&tm_tmp;
-  if (str->alloc(20))
+  
+  l=20*cs->mbmaxlen+32;
+  if (str->alloc(l))
     return str;					/* purecov: inspected */
-  sprintf((char*) str->ptr(),"%04d-%02d-%02d %02d:%02d:%02d",
+  l=cs->snprintf(cs,(char*) str->ptr(),l,"%04d-%02d-%02d %02d:%02d:%02d",
 	  (int) start->tm_year+1900,
 	  (int) start->tm_mon+1,
 	  (int) start->tm_mday,
 	  (int) start->tm_hour,
 	  (int) start->tm_min,
 	  (int) start->tm_sec);
-  str->length(19);
+  str->length(l);
+  str->set_charset(cs);
   return str;
 }
 
@@ -1035,26 +1085,31 @@ bool Item_date_add_interval::get_date(TIME *ltime, bool fuzzy_date)
 String *Item_date_add_interval::val_str(String *str)
 {
   TIME ltime;
+  CHARSET_INFO *cs=thd_charset();
+  uint32 l;
 
   if (Item_date_add_interval::get_date(&ltime,0))
     return 0;
   if (ltime.time_type == TIMESTAMP_DATE)
   {
-    if (str->alloc(11))
+    l=11*cs->mbmaxlen+32;
+    if (str->alloc(l))
       goto null_date;
-    sprintf((char*) str->ptr(),"%04d-%02d-%02d",
+    l=cs->snprintf(cs,(char*) str->ptr(),l,"%04d-%02d-%02d",
 	    ltime.year,ltime.month,ltime.day);
-    str->length(10);
+    str->length(l);
   }
   else
   {
-    if (str->alloc(20))
+    l=20*cs->mbmaxlen+32;
+    if (str->alloc(l))
       goto null_date;
-    sprintf((char*) str->ptr(),"%04d-%02d-%02d %02d:%02d:%02d",
+    l=cs->snprintf(cs,(char*) str->ptr(),l,"%04d-%02d-%02d %02d:%02d:%02d",
 	    ltime.year,ltime.month,ltime.day,
 	    ltime.hour,ltime.minute,ltime.second);
-    str->length(19);
+    str->length(l);
   }
+  str->set_charset(cs);
   return str;
 
  null_date:
diff --git a/sql/item_timefunc.h b/sql/item_timefunc.h
index de2860d24efbb94ef416f000749df7395aad351c..f9b987324f09ebf6dbabce7f4569ff3dd86b088f 100644
--- a/sql/item_timefunc.h
+++ b/sql/item_timefunc.h
@@ -27,7 +27,10 @@ class Item_func_period_add :public Item_int_func
   Item_func_period_add(Item *a,Item *b) :Item_int_func(a,b) {}
   longlong val_int();
   const char *func_name() const { return "period_add"; }
-  void fix_length_and_dec() { max_length=6; }
+  void fix_length_and_dec() 
+  { 
+    max_length=6*thd_charset()->mbmaxlen;
+  }
 };
 
 
@@ -37,7 +40,11 @@ class Item_func_period_diff :public Item_int_func
   Item_func_period_diff(Item *a,Item *b) :Item_int_func(a,b) {}
   longlong val_int();
   const char *func_name() const { return "period_diff"; }
-  void fix_length_and_dec() { decimals=0; max_length=6; }
+  void fix_length_and_dec()
+  { 
+    decimals=0;
+    max_length=6*thd_charset()->mbmaxlen;
+  }
 };
 
 
@@ -47,7 +54,12 @@ class Item_func_to_days :public Item_int_func
   Item_func_to_days(Item *a) :Item_int_func(a) {}
   longlong val_int();
   const char *func_name() const { return "to_days"; }
-  void fix_length_and_dec() { decimals=0; max_length=6; maybe_null=1; }
+  void fix_length_and_dec() 
+  { 
+    decimals=0; 
+    max_length=6*thd_charset()->mbmaxlen;
+    maybe_null=1; 
+  }
 };
 
 
@@ -57,7 +69,12 @@ class Item_func_dayofmonth :public Item_int_func
   Item_func_dayofmonth(Item *a) :Item_int_func(a) {}
   longlong val_int();
   const char *func_name() const { return "dayofmonth"; }
-  void fix_length_and_dec() { decimals=0; max_length=2; maybe_null=1; }
+  void fix_length_and_dec() 
+  { 
+    decimals=0; 
+    max_length=2*thd_charset()->mbmaxlen;
+    maybe_null=1; 
+  }
 };
 
 
@@ -74,7 +91,13 @@ class Item_func_month :public Item_func
   }
   const char *func_name() const { return "month"; }
   enum Item_result result_type () const { return INT_RESULT; }
-  void fix_length_and_dec() { decimals=0; max_length=2; maybe_null=1; }
+  void fix_length_and_dec() 
+  { 
+    set_charset(thd_charset());
+    decimals=0;
+    max_length=2*thd_charset()->mbmaxlen;
+    maybe_null=1; 
+  }
 };
 
 
@@ -85,7 +108,13 @@ class Item_func_monthname :public Item_func_month
   const char *func_name() const { return "monthname"; }
   String *val_str(String *str);
   enum Item_result result_type () const { return STRING_RESULT; }
-  void fix_length_and_dec() { decimals=0; max_length=10; maybe_null=1; }
+  void fix_length_and_dec() 
+  {
+    set_charset(thd_charset());
+    decimals=0;
+    max_length=10*thd_charset()->mbmaxlen;
+    maybe_null=1; 
+  }
 };
 
 
@@ -95,7 +124,12 @@ class Item_func_dayofyear :public Item_int_func
   Item_func_dayofyear(Item *a) :Item_int_func(a) {}
   longlong val_int();
   const char *func_name() const { return "dayofyear"; }
-  void fix_length_and_dec() { decimals=0; max_length=3; maybe_null=1; }
+  void fix_length_and_dec() 
+  { 
+    decimals=0;
+    max_length=3*thd_charset()->mbmaxlen;
+    maybe_null=1; 
+  }
 };
 
 
@@ -105,7 +139,12 @@ class Item_func_hour :public Item_int_func
   Item_func_hour(Item *a) :Item_int_func(a) {}
   longlong val_int();
   const char *func_name() const { return "hour"; }
-  void fix_length_and_dec() { decimals=0; max_length=2; maybe_null=1; }
+  void fix_length_and_dec()
+  {
+    decimals=0;
+    max_length=2*thd_charset()->mbmaxlen;
+    maybe_null=1;
+  }
 };
 
 
@@ -115,7 +154,12 @@ class Item_func_minute :public Item_int_func
   Item_func_minute(Item *a) :Item_int_func(a) {}
   longlong val_int();
   const char *func_name() const { return "minute"; }
-  void fix_length_and_dec() { decimals=0; max_length=2; maybe_null=1; }
+  void fix_length_and_dec()
+  {
+    decimals=0;
+    max_length=2*thd_charset()->mbmaxlen;
+    maybe_null=1;
+  }
 };
 
 
@@ -125,7 +169,12 @@ class Item_func_quarter :public Item_int_func
   Item_func_quarter(Item *a) :Item_int_func(a) {}
   longlong val_int();
   const char *func_name() const { return "quarter"; }
-  void fix_length_and_dec() { decimals=0; max_length=1; maybe_null=1; }
+  void fix_length_and_dec()
+  { 
+     decimals=0;
+     max_length=1*thd_charset()->mbmaxlen;
+     maybe_null=1;
+  }
 };
 
 
@@ -135,7 +184,12 @@ class Item_func_second :public Item_int_func
   Item_func_second(Item *a) :Item_int_func(a) {}
   longlong val_int();
   const char *func_name() const { return "second"; }
-  void fix_length_and_dec() { decimals=0; max_length=2; maybe_null=1; }
+  void fix_length_and_dec() 
+  { 
+    decimals=0;
+    max_length=2*thd_charset()->mbmaxlen;
+    maybe_null=1;
+  }
 };
 
 
@@ -145,7 +199,12 @@ class Item_func_week :public Item_int_func
   Item_func_week(Item *a,Item *b) :Item_int_func(a,b) {}
   longlong val_int();
   const char *func_name() const { return "week"; }
-  void fix_length_and_dec() { decimals=0; max_length=2; maybe_null=1; }
+  void fix_length_and_dec()
+  { 
+    decimals=0;
+    max_length=2*thd_charset()->mbmaxlen;
+    maybe_null=1;
+  }
 };
 
 class Item_func_yearweek :public Item_int_func
@@ -154,7 +213,12 @@ class Item_func_yearweek :public Item_int_func
   Item_func_yearweek(Item *a,Item *b) :Item_int_func(a,b) {}
   longlong val_int();
   const char *func_name() const { return "yearweek"; }
-  void fix_length_and_dec() { decimals=0; max_length=6; maybe_null=1; }
+  void fix_length_and_dec()
+  { 
+    decimals=0;
+    max_length=6*thd_charset()->mbmaxlen;
+    maybe_null=1;
+  }
 };
 
 
@@ -164,7 +228,12 @@ class Item_func_year :public Item_int_func
   Item_func_year(Item *a) :Item_int_func(a) {}
   longlong val_int();
   const char *func_name() const { return "year"; }
-  void fix_length_and_dec() { decimals=0; max_length=4; maybe_null=1; }
+  void fix_length_and_dec()
+  { 
+    decimals=0;
+    max_length=4*thd_charset()->mbmaxlen;
+    maybe_null=1;
+  }
 };
 
 
@@ -176,13 +245,20 @@ class Item_func_weekday :public Item_func
     :Item_func(a), odbc_type(type_arg) {}
   longlong val_int();
   double val() { return (double) val_int(); }
-  String *val_str(String *str) { 
+  String *val_str(String *str)
+  { 
     str->set(val_int(), thd_charset());
     return null_value ? 0 : str;
   }
   const char *func_name() const { return "weekday"; }
   enum Item_result result_type () const { return INT_RESULT; }
-  void fix_length_and_dec() { decimals=0; max_length=1; maybe_null=1; }
+  void fix_length_and_dec()
+  {
+    set_charset(thd_charset());
+    decimals=0;
+    max_length=1*thd_charset()->mbmaxlen;
+    maybe_null=1;
+  }
 };
 
 class Item_func_dayname :public Item_func_weekday
@@ -192,7 +268,13 @@ class Item_func_dayname :public Item_func_weekday
   const char *func_name() const { return "dayname"; }
   String *val_str(String *str);
   enum Item_result result_type () const { return STRING_RESULT; }
-  void fix_length_and_dec() { decimals=0; max_length=9; maybe_null=1; }
+  void fix_length_and_dec() 
+  { 
+    set_charset(thd_charset());
+    decimals=0; 
+    max_length=9*thd_charset()->mbmaxlen;
+    maybe_null=1; 
+  }
 };
 
 
@@ -206,7 +288,8 @@ class Item_func_unix_timestamp :public Item_int_func
   const char *func_name() const { return "timestamp"; }
   void fix_length_and_dec()
   {
-    decimals=0; max_length=10;
+    decimals=0;
+    max_length=10*thd_charset()->mbmaxlen;
   }
 };
 
@@ -219,7 +302,8 @@ class Item_func_time_to_sec :public Item_int_func
   const char *func_name() const { return "time_to_sec"; }
   void fix_length_and_dec()
   {
-    decimals=0; max_length=10;
+    decimals=0;
+    max_length=10*thd_charset()->mbmaxlen;
   }
 };
 
@@ -235,7 +319,12 @@ class Item_date :public Item_func
   String *val_str(String *str);
   double val() { return (double) val_int(); }
   const char *func_name() const { return "date"; }
-  void fix_length_and_dec() { decimals=0; max_length=10; }
+  void fix_length_and_dec()
+  { 
+    set_charset(thd_charset());
+    decimals=0;
+    max_length=10*thd_charset()->mbmaxlen;
+  }
   int  save_in_field(Field *to);
   void make_field(Send_field *tmp_field)
   {
@@ -269,7 +358,7 @@ class Item_date_func :public Item_str_func
 class Item_func_curtime :public Item_func
 {
   longlong value;
-  char buff[9];
+  char buff[9*2+32];
   uint buff_length;
 public:
   Item_func_curtime() :Item_func() {}
@@ -277,8 +366,7 @@ class Item_func_curtime :public Item_func
   enum Item_result result_type () const { return STRING_RESULT; }
   double val() { return (double) value; }
   longlong val_int() { return value; }
-  String *val_str(String *str)
-  { str_value.set(buff,buff_length,default_charset_info); return &str_value; }
+  String *val_str(String *str);
   const char *func_name() const { return "curtime"; }
   void fix_length_and_dec();
   void make_field(Send_field *tmp_field)
@@ -309,7 +397,7 @@ class Item_func_curdate :public Item_date
 class Item_func_now :public Item_date_func
 {
   longlong value;
-  char buff[20];
+  char buff[20*2+32];	// +32 to make my_snprintf_{8bit|ucs2} happy
   uint buff_length;
   TIME ltime;
 public:
@@ -319,8 +407,7 @@ class Item_func_now :public Item_date_func
   double val()	     { return (double) value; }
   longlong val_int() { return value; }
   int  save_in_field(Field *to);
-  String *val_str(String *str)
-  { str_value.set(buff,buff_length,default_charset_info); return &str_value; }
+  String *val_str(String *str);
   const char *func_name() const { return "now"; }
   void fix_length_and_dec();
   bool get_date(TIME *res,bool fuzzy_date);
@@ -359,7 +446,12 @@ class Item_func_from_unixtime :public Item_date_func
   longlong val_int();
   String *val_str(String *str);
   const char *func_name() const { return "from_unixtime"; }
-  void fix_length_and_dec() { decimals=0; max_length=19; }
+  void fix_length_and_dec()
+  { 
+    set_charset(thd_charset());
+    decimals=0;
+    max_length=19*thd_charset()->mbmaxlen;
+  }
 //  enum Item_result result_type () const { return STRING_RESULT; }
   bool get_date(TIME *res,bool fuzzy_date);
 };
@@ -372,7 +464,12 @@ class Item_func_sec_to_time :public Item_str_func
   double val() { return (double) Item_func_sec_to_time::val_int(); }
   longlong val_int();
   String *val_str(String *);
-  void fix_length_and_dec() { maybe_null=1; max_length=13; }
+  void fix_length_and_dec()
+  { 
+    set_charset(thd_charset());
+    maybe_null=1;
+    max_length=13*thd_charset()->mbmaxlen;
+  }
   const char *func_name() const { return "sec_to_time"; }
   void make_field(Send_field *tmp_field)
   {
@@ -404,12 +501,19 @@ class Item_date_add_interval :public Item_date_func
     :Item_date_func(a,b),int_type(type_arg), date_sub_interval(neg_arg) {}
   String *val_str(String *);
   const char *func_name() const { return "date_add_interval"; }
-  void fix_length_and_dec() { maybe_null=1; max_length=19; value.alloc(32);}
+  void fix_length_and_dec()
+  {
+    set_charset(thd_charset());
+    maybe_null=1;
+    max_length=19*thd_charset()->mbmaxlen;
+    value.alloc(32);
+  }
   double val() { return (double) val_int(); }
   longlong val_int();
   bool get_date(TIME *res,bool fuzzy_date);
 };
 
+
 class Item_extract :public Item_int_func
 {
   const interval_type int_type;
@@ -423,17 +527,40 @@ class Item_extract :public Item_int_func
   void fix_length_and_dec();
 };
 
+
 class Item_typecast :public Item_str_func
 {
 public:
   Item_typecast(Item *a) :Item_str_func(a) {}
+  const char *func_name() const { return "char"; }
   String *val_str(String *a)
-  { a=args[0]->val_str(a); null_value=args[0]->null_value; return a; }
-  void fix_length_and_dec() { max_length=args[0]->max_length; }
+  {
+    String *tmp=args[0]->val_str(a);
+    null_value=args[0]->null_value;
+    tmp->set_charset(charset());
+    return tmp;
+  }
+  void fix_length_and_dec()
+  {
+    set_charset(thd_charset());
+    max_length=args[0]->max_length;
+  }
   void print(String *str);
 };
 
 
+class Item_char_typecast :public Item_typecast
+{
+public:
+  Item_char_typecast(Item *a) :Item_typecast(a) {}
+  void fix_length_and_dec()
+  {
+    set_charset(thd_charset());
+    max_length=args[0]->max_length;
+  }
+};
+
+
 class Item_date_typecast :public Item_typecast
 {
 public:
@@ -450,6 +577,7 @@ class Item_date_typecast :public Item_typecast
   }  
 };
 
+
 class Item_time_typecast :public Item_typecast
 {
 public:
@@ -466,6 +594,7 @@ class Item_time_typecast :public Item_typecast
   }
 };
 
+
 class Item_datetime_typecast :public Item_typecast
 {
 public:
diff --git a/sql/item_uniq.h b/sql/item_uniq.h
index f0d1d353cfbbb434ef941edbf2e47f80969eea04..2004be63de2b9fc89d2ddd7470205e206e18382b 100644
--- a/sql/item_uniq.h
+++ b/sql/item_uniq.h
@@ -43,5 +43,9 @@ class Item_sum_unique_users :public Item_sum_num
   bool add() { return 0; }
   void reset_field() {}
   void update_field(int offset) {}
-  bool fix_fields(THD *thd, TABLE_LIST *tlist, Item **ref) { return 0;}
+  bool fix_fields(THD *thd, TABLE_LIST *tlist, Item **ref)
+  {
+    fixed= 1;
+    return 0;
+  }
 };
diff --git a/sql/lex.h b/sql/lex.h
index 744b4c9bf2742046b17ea9d0a4543e317e20bcb2..768d995b68b4134dcbc1c1882b47f7926f169c50 100644
--- a/sql/lex.h
+++ b/sql/lex.h
@@ -77,6 +77,7 @@ static SYMBOL symbols[] = {
   { "BOTH",		SYM(BOTH),0,0},
   { "BTREE",		SYM(BTREE_SYM),0,0},
   { "BY",		SYM(BY),0,0},
+  { "BYTE",		SYM(BYTE_SYM), 0, 0},
   { "CACHE",		SYM(CACHE_SYM),0,0},
   { "CASCADE",		SYM(CASCADE),0,0},
   { "CASE",		SYM(CASE_SYM),0,0},
@@ -127,8 +128,10 @@ static SYMBOL symbols[] = {
   { "DISABLE",		SYM(DISABLE_SYM),0,0},
   { "DISTINCT",		SYM(DISTINCT),0,0},
   { "DISTINCTROW",	SYM(DISTINCT),0,0},	/* Access likes this */
+  { "DIV",		SYM(DIV_SYM),0,0},
   { "DO",		SYM(DO_SYM),0,0},
   { "DOUBLE",		SYM(DOUBLE_SYM),0,0},
+  { "DUAL",		SYM(DUAL_SYM),0,0},
   { "DROP",		SYM(DROP),0,0},
   { "DUMPFILE",		SYM(DUMPFILE),0,0},
   { "DYNAMIC",		SYM(DYNAMIC_SYM),0,0},
@@ -154,6 +157,7 @@ static SYMBOL symbols[] = {
   { "FLOAT4",		SYM(FLOAT_SYM),0,0},
   { "FLOAT8",		SYM(DOUBLE_SYM),0,0},
   { "FLUSH",		SYM(FLUSH_SYM),0,0},
+  { "FALSE",		SYM(FALSE_SYM),0,0},
   { "FOREIGN",		SYM(FOREIGN),0,0},
   { "RAID_TYPE",	SYM(RAID_TYPE),0,0},
   { "RAID_CHUNKS",	SYM(RAID_CHUNKS),0,0},
@@ -218,6 +222,8 @@ static SYMBOL symbols[] = {
   { "LIMIT",		SYM(LIMIT),0,0},
   { "LOAD",		SYM(LOAD),0,0},
   { "LOCAL",		SYM(LOCAL_SYM),0,0},
+  { "LOCALTIME",	SYM(NOW_SYM),0,0},
+  { "LOCALTIMESTAMP",	SYM(NOW_SYM),0,0},
   { "LOCK",		SYM(LOCK_SYM),0,0},
   { "LOCKS",		SYM(LOCKS_SYM),0,0},
   { "LOGS",		SYM(LOGS_SYM),0,0},
@@ -248,6 +254,7 @@ static SYMBOL symbols[] = {
   { "MIN_ROWS",		SYM(MIN_ROWS),0,0},
   { "MINUTE",		SYM(MINUTE_SYM),0,0},
   { "MINUTE_SECOND",	SYM(MINUTE_SECOND_SYM),0,0},
+  { "MOD",		SYM(MOD_SYM),0,0},
   { "MODE",		SYM(MODE_SYM),0,0},
   { "MODIFY",		SYM(MODIFY_SYM),0,0},
   { "MONTH",		SYM(MONTH_SYM),0,0},
@@ -263,6 +270,7 @@ static SYMBOL symbols[] = {
   { "NOT",		SYM(NOT),0,0},
   { "NULL",		SYM(NULL_SYM),0,0},
   { "NUMERIC",		SYM(NUMERIC_SYM),0,0},
+  { "OFFSET",		SYM(OFFSET_SYM),0,0},
   { "ON",		SYM(ON),0,0},
   { "OPEN",		SYM(OPEN_SYM),0,0},
   { "OPTIMIZE",		SYM(OPTIMIZE),0,0},
@@ -314,6 +322,7 @@ static SYMBOL symbols[] = {
   { "RTREE",		SYM(RTREE_SYM),0,0},
   { "SECOND",		SYM(SECOND_SYM),0,0},
   { "SELECT",		SYM(SELECT_SYM),0,0},
+  { "SERIAL",		SYM(SERIAL_SYM),0,0},
   { "SERIALIZABLE",	SYM(SERIALIZABLE_SYM),0,0},
   { "SESSION",		SYM(SESSION_SYM),0,0},
   { "SET",		SYM(SET),0,0},
@@ -358,6 +367,7 @@ static SYMBOL symbols[] = {
   { "TRAILING",		SYM(TRAILING),0,0},
   { "TRANSACTION",	SYM(TRANSACTION_SYM),0,0},
   { "TRUNCATE",		SYM(TRUNCATE_SYM),0,0},
+  { "TRUE",		SYM(TRUE_SYM),0,0},
   { "TO",		SYM(TO_SYM),0,0},
   { "TYPE",		SYM(TYPE_SYM),0,0},
   { "TYPES",		SYM(TYPES_SYM),0,0},
@@ -371,8 +381,10 @@ static SYMBOL symbols[] = {
   { "USING",		SYM(USING),0,0},
   { "UPDATE",		SYM(UPDATE_SYM),0,0},
   { "USAGE",		SYM(USAGE),0,0},
+  { "VALUE",		SYM(VALUE_SYM),0,0},
   { "VALUES",		SYM(VALUES),0,0},
   { "VARCHAR",		SYM(VARCHAR),0,0},
+  { "VARCHARACTER",	SYM(VARCHAR),0,0},
   { "VARIABLES",	SYM(VARIABLES),0,0},
   { "VARYING",		SYM(VARYING),0,0},
   { "VARBINARY",	SYM(VARBINARY),0,0},
@@ -409,7 +421,9 @@ static SYMBOL sql_functions[] = {
   { "BIT_OR",		SYM(BIT_OR),0,0},
   { "BIT_AND",		SYM(BIT_AND),0,0},
   { "CAST",		SYM(CAST_SYM),0,0},
+  { "CEIL",		SYM(FUNC_ARG1),0,CREATE_FUNC(create_func_ceiling)},
   { "CEILING",		SYM(FUNC_ARG1),0,CREATE_FUNC(create_func_ceiling)},
+  { "CURRENT_USER",	SYM(USER),0,0},
   { "BIT_LENGTH",	SYM(FUNC_ARG1),0,CREATE_FUNC(create_func_bit_length)},
   { "CENTROID",		SYM(FUNC_ARG1),0,CREATE_FUNC(create_func_centroid)},
   { "CHAR_LENGTH",	SYM(FUNC_ARG1),0,CREATE_FUNC(create_func_char_length)},
@@ -501,7 +515,6 @@ static SYMBOL sql_functions[] = {
   { "MD5",              SYM(FUNC_ARG1),0,CREATE_FUNC(create_func_md5)},
   { "MID",		SYM(SUBSTRING),0,0},	/* unireg function */
   { "MIN",		SYM(MIN_SYM),0,0},
-  { "MOD",		SYM(FUNC_ARG2),0,CREATE_FUNC(create_func_mod)},
   { "MLINEFROMTEXT",	SYM(MLINEFROMTEXT),0,0},
   { "MPOINTFROMTEXT",	SYM(MPOINTFROMTEXT),0,0},
   { "MPOLYFROMTEXT",	SYM(MPOLYFROMTEXT),0,0},
diff --git a/sql/lock.cc b/sql/lock.cc
index 3b2444c8e9d864180ee4faceca108aae18ca9a3f..74d1109b2033db39e61c7aa184e164b25e6ed079 100644
--- a/sql/lock.cc
+++ b/sql/lock.cc
@@ -80,7 +80,7 @@ extern HASH open_cache;
 
 static MYSQL_LOCK *get_lock_data(THD *thd, TABLE **table,uint count,
 				 bool unlock, TABLE **write_locked);
-static int lock_external(TABLE **table,uint count);
+static int lock_external(THD *thd, TABLE **table,uint count);
 static int unlock_external(THD *thd, TABLE **table,uint count);
 static void print_lock_error(int error);
 
@@ -116,14 +116,14 @@ MYSQL_LOCK *mysql_lock_tables(THD *thd,TABLE **tables,uint count)
     }
 
     thd->proc_info="System lock";
-    if (lock_external(tables,count))
+    if (lock_external(thd, tables, count))
     {
       my_free((gptr) sql_lock,MYF(0));
       sql_lock=0;
       thd->proc_info=0;
       break;
     }
-    thd->proc_info=0;
+    thd->proc_info="Table lock";
     thd->locked=1;
     if (thr_multi_lock(sql_lock->locks,sql_lock->lock_count))
     {
@@ -142,6 +142,7 @@ MYSQL_LOCK *mysql_lock_tables(THD *thd,TABLE **tables,uint count)
       thd->locked=0;
       break;
     }
+    thd->proc_info=0;
 
     /* some table was altered or deleted. reopen tables marked deleted */
     mysql_unlock_tables(thd,sql_lock);
@@ -151,6 +152,7 @@ MYSQL_LOCK *mysql_lock_tables(THD *thd,TABLE **tables,uint count)
     if (wait_for_tables(thd))
       break;					// Couldn't open tables
   }
+  thd->proc_info=0;
   if (thd->killed)
   {
     my_error(ER_SERVER_SHUTDOWN,MYF(0));
@@ -166,15 +168,15 @@ MYSQL_LOCK *mysql_lock_tables(THD *thd,TABLE **tables,uint count)
 }
 
 
-static int lock_external(TABLE **tables,uint count)
+static int lock_external(THD *thd, TABLE **tables, uint count)
 {
   reg1 uint i;
   int lock_type,error;
-  THD *thd=current_thd;
   DBUG_ENTER("lock_external");
 
   for (i=1 ; i <= count ; i++, tables++)
   {
+    DBUG_ASSERT((*tables)->reginfo.lock_type >= TL_READ);
     lock_type=F_WRLCK;				/* Lock exclusive */
     if ((*tables)->db_stat & HA_READ_ONLY ||
 	((*tables)->reginfo.lock_type >= TL_READ &&
diff --git a/sql/log.cc b/sql/log.cc
index 286dba3f79b8071af9e015c5e21bdc3bb035338d..0e1af8e5dae05242f2e7b312704c3c132e77f9ef 100644
--- a/sql/log.cc
+++ b/sql/log.cc
@@ -1026,9 +1026,13 @@ bool MYSQL_LOG::write(THD *thd,enum enum_server_command command,
 bool MYSQL_LOG::write(Log_event* event_info)
 {
   bool error=0;
+  DBUG_ENTER("MYSQL_LOG::write(event)");
   
   if (!inited)					// Can't use mutex if not init
-    return 0;
+  {
+    DBUG_PRINT("error",("not initied"));
+    DBUG_RETURN(0);
+  }
   pthread_mutex_lock(&LOCK_log);
 
   /* In most cases this is only called if 'is_open()' is true */
@@ -1036,7 +1040,7 @@ bool MYSQL_LOG::write(Log_event* event_info)
   {
     bool should_rotate = 0;
     THD *thd=event_info->thd;
-    const char* db = event_info->get_db();
+    const char *local_db = event_info->get_db();
 #ifdef USING_TRANSACTIONS    
     IO_CACHE *file = ((event_info->get_cache_stmt()) ?
 		      &thd->transaction.trans_log :
@@ -1046,10 +1050,11 @@ bool MYSQL_LOG::write(Log_event* event_info)
 #endif    
     if ((thd && !(thd->options & OPTION_BIN_LOG) &&
 	 (thd->master_access & SUPER_ACL)) ||
-	(db && !db_ok(db, binlog_do_db, binlog_ignore_db)))
+	(local_db && !db_ok(local_db, binlog_do_db, binlog_ignore_db)))
     {
       VOID(pthread_mutex_unlock(&LOCK_log));
-      return 0;
+      DBUG_PRINT("error",("!db_ok"));
+      DBUG_RETURN(0);
     }
 
     error=1;
@@ -1087,7 +1092,7 @@ bool MYSQL_LOG::write(Log_event* event_info)
       char buf[1024] = "SET CHARACTER SET ";
       char* p = strend(buf);
       p = strmov(p, thd->variables.convert_set->name);
-      Query_log_event e(thd, buf, (ulong)(p - buf));
+      Query_log_event e(thd, buf, (ulong)(p - buf), 0);
       e.set_log_pos(this);
       if (e.write(file))
 	goto err;
@@ -1135,7 +1140,7 @@ bool MYSQL_LOG::write(Log_event* event_info)
   }
 
   pthread_mutex_unlock(&LOCK_log);
-  return error;
+  DBUG_RETURN(error);
 }
 
 
@@ -1165,6 +1170,7 @@ uint MYSQL_LOG::next_file_id()
 bool MYSQL_LOG::write(THD *thd, IO_CACHE *cache)
 {
   VOID(pthread_mutex_lock(&LOCK_log));
+  DBUG_ENTER("MYSQL_LOG::write(cache");
   
   if (is_open())				// Should always be true
   {
@@ -1223,7 +1229,7 @@ bool MYSQL_LOG::write(THD *thd, IO_CACHE *cache)
     signal_update();
   }
   VOID(pthread_mutex_unlock(&LOCK_log));
-  return 0;
+  DBUG_RETURN(0);
 
 err:
   if (!write_error)
@@ -1232,7 +1238,7 @@ bool MYSQL_LOG::write(THD *thd, IO_CACHE *cache)
     sql_print_error(ER(ER_ERROR_ON_WRITE), name, errno);
   }
   VOID(pthread_mutex_unlock(&LOCK_log));
-  return 1;
+  DBUG_RETURN(1);
 }
 
 
@@ -1242,7 +1248,7 @@ bool MYSQL_LOG::write(THD *thd, IO_CACHE *cache)
 */
 
 bool MYSQL_LOG::write(THD *thd,const char *query, uint query_length,
-		      time_t query_start)
+		      time_t query_start_arg)
 {
   bool error=0;
   if (is_open())
@@ -1260,7 +1266,7 @@ bool MYSQL_LOG::write(THD *thd,const char *query, uint query_length,
 	VOID(pthread_mutex_unlock(&LOCK_log));
 	return 0;
       }
-      if ((specialflag & SPECIAL_LONG_LOG_FORMAT) || query_start)
+      if ((specialflag & SPECIAL_LONG_LOG_FORMAT) || query_start_arg)
       {
 	current_time=time(NULL);
 	if (current_time != last_time)
@@ -1288,13 +1294,13 @@ bool MYSQL_LOG::write(THD *thd,const char *query, uint query_length,
 			thd->ip ? thd->ip : "") == (uint) -1)
 	  tmp_errno=errno;
       }
-      if (query_start)
+      if (query_start_arg)
       {
 	/* For slow query log */
 	if (my_b_printf(&log_file,
 			"# Query_time: %lu  Lock_time: %lu  Rows_sent: %lu  Rows_examined: %lu\n",
-			(ulong) (current_time - query_start),
-			(ulong) (thd->time_after_lock - query_start),
+			(ulong) (current_time - query_start_arg),
+			(ulong) (thd->time_after_lock - query_start_arg),
 			(ulong) thd->sent_row_count,
 			(ulong) thd->examined_row_count) == (uint) -1)
 	  tmp_errno=errno;
@@ -1321,11 +1327,11 @@ bool MYSQL_LOG::write(THD *thd,const char *query, uint query_length,
       }
       if (thd->query_start_used)
       {
-	if (query_start != thd->query_start())
+	if (query_start_arg != thd->query_start())
 	{
-	  query_start=thd->query_start();
+	  query_start_arg=thd->query_start();
 	  end=strmov(end,",timestamp=");
-	  end=int10_to_str((long) query_start,end,10);
+	  end=int10_to_str((long) query_start_arg,end,10);
 	}
       }
       if (end != buff)
diff --git a/sql/log_event.cc b/sql/log_event.cc
index c168c951c8f6b79d1d0bb9277ed18508c9a75820..d9ee832f7d3108e687e0c6eabfc9001a9bb32078 100644
--- a/sql/log_event.cc
+++ b/sql/log_event.cc
@@ -235,22 +235,25 @@ const char* Log_event::get_type_str()
 
  ****************************************************************************/
 #ifndef MYSQL_CLIENT
-Log_event::Log_event(THD* thd_arg, uint16 flags_arg)
-  :exec_time(0), flags(flags_arg), cached_event_len(0),
-   temp_buf(0), thd(thd_arg)
+Log_event::Log_event(THD* thd_arg, uint16 flags_arg, bool using_trans)
+  :temp_buf(0), exec_time(0), cached_event_len(0), flags(flags_arg), 
+   thd(thd_arg)
 {
-  if (thd)
-  {
-    server_id = thd->server_id;
-    when      = thd->start_time;
-    log_pos   = thd->log_pos;
-  }
-  else
-  {
-    server_id = ::server_id;
-    when      = time(NULL);
-    log_pos   =0;
-  }
+  server_id=	thd->server_id;
+  when=		thd->start_time;
+  log_pos=	thd->log_pos;
+  cache_stmt=	(using_trans &&
+		 (thd->options & (OPTION_NOT_AUTOCOMMIT | OPTION_BEGIN)));
+}
+
+
+Log_event::Log_event()
+  :temp_buf(0), exec_time(0), cached_event_len(0), flags(0), cache_stmt(0),
+   thd(0)
+{
+  server_id=	::server_id;
+  when=		time(NULL);
+  log_pos=	0;
 }
 #endif // !MYSQL_CLIENT
 
@@ -260,7 +263,7 @@ Log_event::Log_event(THD* thd_arg, uint16 flags_arg)
 
  ****************************************************************************/
 Log_event::Log_event(const char* buf, bool old_format)
-  :cached_event_len(0), temp_buf(0)
+  :temp_buf(0), cached_event_len(0), cache_stmt(0)
 {
   when = uint4korr(buf);
   server_id = uint4korr(buf + SERVER_ID_OFFSET);
@@ -330,11 +333,11 @@ void Log_event::init_show_field_list(List<Item>* field_list)
   Only called by SHOW BINLOG EVENTS
 
  ****************************************************************************/
-int Log_event::net_send(THD* thd, const char* log_name, my_off_t pos)
+int Log_event::net_send(THD* thd_arg, const char* log_name, my_off_t pos)
 {
-  String* packet = &thd->packet;
-  const char* p = strrchr(log_name, FN_LIBCHAR);
-  const char* event_type;
+  String* packet = &thd_arg->packet;
+  const char *p= strrchr(log_name, FN_LIBCHAR);
+  const char *event_type;
   if (p)
     log_name = p + 1;
   
@@ -346,7 +349,7 @@ int Log_event::net_send(THD* thd, const char* log_name, my_off_t pos)
   net_store_data(packet, server_id);
   net_store_data(packet, (longlong) log_pos);
   pack_info(packet);
-  return my_net_write(&thd->net, (char*) packet->ptr(), packet->length());
+  return my_net_write(&thd_arg->net, (char*) packet->ptr(), packet->length());
 }
 #endif // !MYSQL_CLIENT
 
@@ -725,12 +728,10 @@ int Query_log_event::write_data(IO_CACHE* file)
 #ifndef MYSQL_CLIENT
 Query_log_event::Query_log_event(THD* thd_arg, const char* query_arg,
 				 ulong query_length, bool using_trans)
-  :Log_event(thd_arg), data_buf(0), query(query_arg),  db(thd_arg->db),
-  q_len((uint32) query_length),
+  :Log_event(thd_arg, 0, using_trans), data_buf(0), query(query_arg),
+   db(thd_arg->db), q_len((uint32) query_length),
   error_code(thd_arg->killed ? ER_SERVER_SHUTDOWN: thd_arg->net.last_errno),
-  thread_id(thd_arg->thread_id),
-  cache_stmt(using_trans &&
-	     (thd_arg->options & (OPTION_NOT_AUTOCOMMIT | OPTION_BEGIN)))
+  thread_id(thd_arg->thread_id)
 {
   time_t end_time;
   time(&end_time);
@@ -1155,18 +1156,19 @@ int Load_log_event::write_data_body(IO_CACHE* file)
 
  ****************************************************************************/
 #ifndef MYSQL_CLIENT
-Load_log_event::Load_log_event(THD* thd, sql_exchange* ex,
-			       const char* db_arg, const char* table_name_arg,
-			       List<Item>& fields_arg,
-			       enum enum_duplicates handle_dup)
-  :Log_event(thd),thread_id(thd->thread_id), num_fields(0),fields(0),
-  field_lens(0),field_block_len(0),
-  table_name(table_name_arg ? table_name_arg : ""),
-  db(db_arg), fname(ex->file_name)
+Load_log_event::Load_log_event(THD *thd_arg, sql_exchange *ex,
+			       const char *db_arg, const char *table_name_arg,
+			       List<Item> &fields_arg,
+			       enum enum_duplicates handle_dup,
+			       bool using_trans)
+  :Log_event(thd_arg, 0, using_trans), thread_id(thd_arg->thread_id),
+   num_fields(0), fields(0), field_lens(0),field_block_len(0),
+   table_name(table_name_arg ? table_name_arg : ""),
+   db(db_arg), fname(ex->file_name)
 {
   time_t end_time;
   time(&end_time);
-  exec_time = (ulong) (end_time  - thd->start_time);
+  exec_time = (ulong) (end_time  - thd_arg->start_time);
   /* db can never be a zero pointer in 4.0 */
   db_len = (uint32) strlen(db);
   table_name_len = (uint32) strlen(table_name);
@@ -1236,11 +1238,11 @@ Load_log_event::Load_log_event(THD* thd, sql_exchange* ex,
   constructed event.
 
  ****************************************************************************/
-Load_log_event::Load_log_event(const char* buf, int event_len,
-			       bool old_format):
-  Log_event(buf, old_format),num_fields(0),fields(0),
-  field_lens(0),field_block_len(0),
-  table_name(0),db(0),fname(0)
+Load_log_event::Load_log_event(const char *buf, int event_len,
+			       bool old_format)
+  :Log_event(buf, old_format),num_fields(0),fields(0),
+   field_lens(0),field_block_len(0),
+   table_name(0),db(0),fname(0)
 {
   if (!event_len) // derived class, will call copy_log_event() itself
     return;
@@ -1390,14 +1392,14 @@ void Load_log_event::print(FILE* file, bool short_form, char* last_db)
 
  ****************************************************************************/
 #ifndef MYSQL_CLIENT
-void Load_log_event::set_fields(List<Item> &fields)
+void Load_log_event::set_fields(List<Item> &field_list)
 {
   uint i;
-  const char* field = this->fields;
-  for (i = 0; i < num_fields; i++)
+  const char* field = fields;
+  for (i= 0; i < num_fields; i++)
   {
-    fields.push_back(new Item_field(db, table_name, field));	  
-    field += field_lens[i]  + 1;
+    field_list.push_back(new Item_field(db, table_name, field));	  
+    field+= field_lens[i]  + 1;
   }
 }
 #endif // !MYSQL_CLIENT
@@ -1458,8 +1460,8 @@ int Load_log_event::exec_event(NET* net, struct st_relay_log_info* rli)
 	ex.field_term->length(0);
 
       ex.skip_lines = skip_lines;
-      List<Item> fields;
-      set_fields(fields);
+      List<Item> field_list;
+      set_fields(field_list);
       thd->slave_proxy_id = thd->thread_id;
       if (net)
       {
@@ -1470,7 +1472,7 @@ int Load_log_event::exec_event(NET* net, struct st_relay_log_info* rli)
 	*/
 	thd->net.pkt_nr = net->pkt_nr;
       }
-      if (mysql_load(thd, &ex, &tables, fields, handle_dup, net != 0,
+      if (mysql_load(thd, &ex, &tables, field_list, handle_dup, net != 0,
 		     TL_WRITE))
 	thd->query_error = 1;
       if (thd->cuted_fields)
@@ -1795,14 +1797,12 @@ int Intvar_log_event::exec_event(struct st_relay_log_info* rli)
 #ifndef MYSQL_CLIENT
 void Rand_log_event::pack_info(String* packet)
 {
-  char buf1[256], buf[22];
-  String tmp(buf1, sizeof(buf1), system_charset_info);
-  tmp.length(0);
-  tmp.append("randseed1=");
-  tmp.append(llstr(seed1, buf));
-  tmp.append(",randseed2=");
-  tmp.append(llstr(seed2, buf));
-  net_store_data(packet, tmp.ptr(), tmp.length());
+  char buf1[256], *pos;
+  pos= strmov(buf1,"rand_seed1=");
+  pos= int10_to_str((long) seed1, pos, 10);
+  pos= strmov(pos, ",rand_seed2=");
+  pos= int10_to_str((long) seed2, pos, 10);
+  net_store_data(packet, buf1, (uint) (pos-buf1));
 }
 #endif // !MYSQL_CLIENT
 
@@ -1846,8 +1846,8 @@ void Rand_log_event::print(FILE* file, bool short_form, char* last_db)
     print_header(file);
     fprintf(file, "\tRand\n");
   }
-  fprintf(file, "SET RAND SEED1=%s;\n", llstr(seed1, llbuff));
-  fprintf(file, "SET RAND SEED2=%s;\n", llstr(seed2, llbuff));
+  fprintf(file, "SET @@RAND_SEED1=%s, @@RAND_SEED2=%s;\n",
+	  llstr(seed1, llbuff),llstr(seed2, llbuff));
   fflush(file);
 }
 #endif // MYSQL_CLIENT
@@ -1860,8 +1860,8 @@ void Rand_log_event::print(FILE* file, bool short_form, char* last_db)
 #ifndef MYSQL_CLIENT
 int Rand_log_event::exec_event(struct st_relay_log_info* rli)
 {
-  thd->rand.seed1 = seed1;
-  thd->rand.seed2 = seed2;
+  thd->rand.seed1= (ulong) seed1;
+  thd->rand.seed2= (ulong) seed2;
   rli->inc_pending(get_event_len());
   return 0;
 }
@@ -1907,8 +1907,8 @@ void Slave_log_event::pack_info(String* packet)
  ****************************************************************************/
 #ifndef MYSQL_CLIENT
 Slave_log_event::Slave_log_event(THD* thd_arg,
-				 struct st_relay_log_info* rli):
-  Log_event(thd_arg),mem_pool(0),master_host(0)
+				 struct st_relay_log_info* rli)
+  :Log_event(thd_arg, 0, 0), mem_pool(0), master_host(0)
 {
   DBUG_ENTER("Slave_log_event");
   if (!rli->inited)				// QQ When can this happen ?
@@ -2120,11 +2120,13 @@ int Stop_log_event::exec_event(struct st_relay_log_info* rli)
 
  ****************************************************************************/
 #ifndef MYSQL_CLIENT
-Create_file_log_event::Create_file_log_event(THD* thd_arg, sql_exchange* ex,
-		 const char* db_arg, const char* table_name_arg,
-		 List<Item>& fields_arg, enum enum_duplicates handle_dup,
-			char* block_arg, uint block_len_arg)
-  :Load_log_event(thd_arg,ex,db_arg,table_name_arg,fields_arg,handle_dup),
+Create_file_log_event::
+Create_file_log_event(THD* thd_arg, sql_exchange* ex,
+		      const char* db_arg, const char* table_name_arg,
+		      List<Item>& fields_arg, enum enum_duplicates handle_dup,
+		      char* block_arg, uint block_len_arg, bool using_trans)
+  :Load_log_event(thd_arg,ex,db_arg,table_name_arg,fields_arg,handle_dup,
+		  using_trans),
    fake_base(0),block(block_arg),block_len(block_len_arg),
    file_id(thd_arg->file_id = mysql_bin_log.next_file_id())
 {
@@ -2327,9 +2329,10 @@ int Create_file_log_event::exec_event(struct st_relay_log_info* rli)
  ****************************************************************************/
 #ifndef MYSQL_CLIENT  
 Append_block_log_event::Append_block_log_event(THD* thd_arg, char* block_arg,
-					       uint block_len_arg)
-  :Log_event(thd_arg), block(block_arg),block_len(block_len_arg),
-   file_id(thd_arg->file_id)
+					       uint block_len_arg,
+					       bool using_trans)
+  :Log_event(thd_arg,0, using_trans), block(block_arg),
+   block_len(block_len_arg), file_id(thd_arg->file_id)
 {
 }
 #endif // !MYSQL_CLIENT
@@ -2447,8 +2450,8 @@ int Append_block_log_event::exec_event(struct st_relay_log_info* rli)
 
  ****************************************************************************/
 #ifndef MYSQL_CLIENT
-Delete_file_log_event::Delete_file_log_event(THD* thd_arg)
-  :Log_event(thd_arg),file_id(thd_arg->file_id)
+Delete_file_log_event::Delete_file_log_event(THD *thd_arg, bool using_trans)
+  :Log_event(thd_arg, 0, using_trans),file_id(thd_arg->file_id)
 {
 }
 #endif // !MYSQL_CLIENT
@@ -2545,8 +2548,8 @@ int Delete_file_log_event::exec_event(struct st_relay_log_info* rli)
 
  ****************************************************************************/
 #ifndef MYSQL_CLIENT  
-Execute_load_log_event::Execute_load_log_event(THD* thd_arg)
-  :Log_event(thd_arg),file_id(thd_arg->file_id)
+Execute_load_log_event::Execute_load_log_event(THD *thd_arg, bool using_trans)
+  :Log_event(thd_arg, 0, using_trans), file_id(thd_arg->file_id)
 {
 }
 #endif // !MYSQL_CLIENT
@@ -2556,8 +2559,8 @@ Execute_load_log_event::Execute_load_log_event(THD* thd_arg)
   Execute_load_log_event ctor
 
  ****************************************************************************/
-Execute_load_log_event::Execute_load_log_event(const char* buf,int len)
-  :Log_event(buf, 0),file_id(0)
+Execute_load_log_event::Execute_load_log_event(const char* buf, int len)
+  :Log_event(buf, 0), file_id(0)
 {
   if ((uint)len < EXEC_LOAD_EVENT_OVERHEAD)
     return;
diff --git a/sql/log_event.h b/sql/log_event.h
index bf04c4807291d0f2f23387d0ff33f583f55cb3d7..20a134ab3ccc8642d9e9f246750d5117c6fbcab2 100644
--- a/sql/log_event.h
+++ b/sql/log_event.h
@@ -247,18 +247,19 @@ struct st_relay_log_info;
 class Log_event
 {
 public:
+  my_off_t log_pos;
+  char *temp_buf;
   time_t when;
   ulong exec_time;
   uint32 server_id;
-  my_off_t log_pos;
+  uint cached_event_len;
   uint16 flags;
-  int cached_event_len;
-  char* temp_buf;
-
+  bool cache_stmt;
 #ifndef MYSQL_CLIENT
   THD* thd;
 
-  Log_event(THD* thd_arg, uint16 flags_arg = 0);
+  Log_event(THD* thd_arg, uint16 flags_arg, bool cache_stmt);
+  Log_event();
   // if mutex is 0, the read will proceed without mutex
   static Log_event* read_log_event(IO_CACHE* file,
 				   pthread_mutex_t* log_lock,
@@ -301,7 +302,7 @@ class Log_event
   { return 0; }
   virtual Log_event_type get_type_code() = 0;
   virtual bool is_valid() = 0;
-  virtual bool get_cache_stmt() { return 0; }
+  inline bool get_cache_stmt() { return cache_stmt; }
   Log_event(const char* buf, bool old_format);
   virtual ~Log_event() { free_temp_buf();}
   void register_temp_buf(char* buf) { temp_buf = buf; }
@@ -350,14 +351,12 @@ class Query_log_event: public Log_event
   uint16 error_code;
   ulong thread_id;
 #ifndef MYSQL_CLIENT
-  bool cache_stmt;
 
   Query_log_event(THD* thd_arg, const char* query_arg, ulong query_length,
-		  bool using_trans=0);
+		  bool using_trans);
   const char* get_db() { return db; }
   void pack_info(String* packet);
   int exec_event(struct st_relay_log_info* rli);
-  bool get_cache_stmt() { return cache_stmt; }
 #else
   void print(FILE* file, bool short_form = 0, char* last_db = 0);
 #endif
@@ -445,14 +444,15 @@ class Load_log_event: public Log_event
   const char* fname;
   uint32 skip_lines;
   sql_ex_info sql_ex;
-  
+
 #ifndef MYSQL_CLIENT
   String field_lens_buf;
   String fields_buf;
   
   Load_log_event(THD* thd, sql_exchange* ex, const char* db_arg,
 		 const char* table_name_arg,
-		 List<Item>& fields_arg, enum enum_duplicates handle_dup);
+		 List<Item>& fields_arg, enum enum_duplicates handle_dup,
+		 bool using_trans);
   void set_fields(List<Item> &fields_arg);
   void pack_info(String* packet);
   const char* get_db() { return db; }
@@ -468,8 +468,10 @@ class Load_log_event: public Log_event
   Load_log_event(const char* buf, int event_len, bool old_format);
   ~Load_log_event()
   {}
-  Log_event_type get_type_code() { return sql_ex.new_format() ?
-				     NEW_LOAD_EVENT: LOAD_EVENT; }
+  Log_event_type get_type_code()
+  {
+    return sql_ex.new_format() ? NEW_LOAD_EVENT: LOAD_EVENT;
+  }
   int write_data_header(IO_CACHE* file); 
   int write_data_body(IO_CACHE* file); 
   bool is_valid() { return table_name != 0; }
@@ -500,7 +502,7 @@ class Start_log_event: public Log_event
   char server_version[ST_SERVER_VER_LEN];
 
 #ifndef MYSQL_CLIENT
-  Start_log_event() :Log_event((THD*)0),binlog_version(BINLOG_VERSION)
+  Start_log_event() :Log_event(), binlog_version(BINLOG_VERSION)
   {
     created = (uint32) when;
     memcpy(server_version, ::server_version, ST_SERVER_VER_LEN);
@@ -538,7 +540,7 @@ class Intvar_log_event: public Log_event
 
 #ifndef MYSQL_CLIENT  
   Intvar_log_event(THD* thd_arg,uchar type_arg, ulonglong val_arg)
-    :Log_event(thd_arg),val(val_arg),type(type_arg)
+    :Log_event(),val(val_arg),type(type_arg)
   {}
   void pack_info(String* packet);
   int exec_event(struct st_relay_log_info* rli);
@@ -570,7 +572,7 @@ class Rand_log_event: public Log_event
 
 #ifndef MYSQL_CLIENT
   Rand_log_event(THD* thd_arg, ulonglong seed1_arg, ulonglong seed2_arg)
-    :Log_event(thd_arg),seed1(seed1_arg),seed2(seed2_arg)
+    :Log_event(thd_arg,0,0),seed1(seed1_arg),seed2(seed2_arg)
   {}
   void pack_info(String* packet);
   int exec_event(struct st_relay_log_info* rli);
@@ -596,7 +598,7 @@ class Stop_log_event: public Log_event
 {
 public:
 #ifndef MYSQL_CLIENT
-  Stop_log_event() :Log_event((THD*)0)
+  Stop_log_event() :Log_event()
   {}
   int exec_event(struct st_relay_log_info* rli);
 #else
@@ -628,8 +630,9 @@ class Rotate_log_event: public Log_event
   bool alloced;
 #ifndef MYSQL_CLIENT  
   Rotate_log_event(THD* thd_arg, const char* new_log_ident_arg,
-		   uint ident_len_arg = 0,ulonglong pos_arg = 4)
-    : Log_event(thd_arg), new_log_ident(new_log_ident_arg),
+		   uint ident_len_arg = 0,
+		   ulonglong pos_arg = LOG_EVENT_OFFSET)
+    :Log_event(thd_arg,0,0), new_log_ident(new_log_ident_arg),
     pos(pos_arg),ident_len(ident_len_arg ? ident_len_arg :
 			   (uint) strlen(new_log_ident_arg)), alloced(0)
   {}
@@ -678,7 +681,8 @@ class Create_file_log_event: public Load_log_event
 			const char* table_name_arg,
 			List<Item>& fields_arg,
 			enum enum_duplicates handle_dup,
-			char* block_arg, uint block_len_arg);
+			char* block_arg, uint block_len_arg,
+			bool using_trans);
   void pack_info(String* packet);
   int exec_event(struct st_relay_log_info* rli);
 #else
@@ -728,7 +732,7 @@ class Append_block_log_event: public Log_event
   
 #ifndef MYSQL_CLIENT
   Append_block_log_event(THD* thd, char* block_arg,
-			 uint block_len_arg);
+			 uint block_len_arg, bool using_trans);
   int exec_event(struct st_relay_log_info* rli);
   void pack_info(String* packet);
 #else
@@ -754,7 +758,7 @@ class Delete_file_log_event: public Log_event
   uint file_id;
   
 #ifndef MYSQL_CLIENT
-  Delete_file_log_event(THD* thd);
+  Delete_file_log_event(THD* thd, bool using_trans);
   void pack_info(String* packet);
   int exec_event(struct st_relay_log_info* rli);
 #else
@@ -780,7 +784,7 @@ class Execute_load_log_event: public Log_event
   uint file_id;
   
 #ifndef MYSQL_CLIENT
-  Execute_load_log_event(THD* thd);
+  Execute_load_log_event(THD* thd, bool using_trans);
   void pack_info(String* packet);
   int exec_event(struct st_relay_log_info* rli);
 #else
diff --git a/sql/mini_client.cc b/sql/mini_client.cc
index aa84a52eb0bb9dfac4d9983f83354c564474b22d..0f20587ec244eaaab010779dbb6bbc1126fe8b49 100644
--- a/sql/mini_client.cc
+++ b/sql/mini_client.cc
@@ -295,11 +295,11 @@ static int mc_sock_connect(my_socket s, const struct sockaddr *name,
   FD_SET(s, &sfds);
   tv.tv_sec = (long) to;
   tv.tv_usec = 0;
-#ifdef HPUX
+#ifdef HPUX10
   res = select(s+1, NULL, (int*) &sfds, NULL, &tv);
 #else
   res = select(s+1, NULL, &sfds, NULL, &tv);
-#endif
+#endif /* HPUX10 */
   if (res <= 0)					/* Never became writable */
     return(-1);
 
diff --git a/sql/mysql_priv.h b/sql/mysql_priv.h
index 457dbe7a73d88ff5cbdb0fc0e851ac939d54682f..0e3ae0a2af9c445fea3ac0f3a4a22593e7f8939d 100644
--- a/sql/mysql_priv.h
+++ b/sql/mysql_priv.h
@@ -85,6 +85,7 @@ char* query_table_status(THD *thd,const char *db,const char *table_name);
 */
 #define MIN_FILE_LENGTH_TO_USE_ROW_CACHE (16L*1024*1024)
 #define MIN_ROWS_TO_USE_TABLE_CACHE	 100
+#define MIN_ROWS_TO_USE_BULK_INSERT	 100
 
 /*
   The following is used to decide if MySQL should use table scanning
@@ -201,6 +202,11 @@ char* query_table_status(THD *thd,const char *db,const char *table_name);
 #define MODE_SERIALIZABLE		16
 #define MODE_ONLY_FULL_GROUP_BY		32
 #define MODE_NO_UNSIGNED_SUBTRACTION	64
+#define MODE_POSTGRESQL			128
+#define MODE_ORACLE			256
+#define MODE_MSSQL			512
+#define MODE_DB2			1024
+#define MODE_SAPDB			2048
 
 #define RAID_BLOCK_SIZE 1024
 
@@ -322,9 +328,8 @@ void mysql_init_multi_delete(LEX *lex);
 void init_max_user_conn(void);
 void init_update_queries(void);
 void free_max_user_conn(void);
-pthread_handler_decl(handle_one_connection,arg);
-pthread_handler_decl(handle_bootstrap,arg);
-sig_handler end_thread_signal(int sig);
+extern "C" pthread_handler_decl(handle_one_connection,arg);
+extern "C" pthread_handler_decl(handle_bootstrap,arg);
 void end_thread(THD *thd,bool put_in_cache);
 void flush_thread_cache();
 void mysql_execute_command(THD *thd);
@@ -400,8 +405,7 @@ int mysql_explain_union(THD *thd, SELECT_LEX_UNIT *unit,
 int mysql_explain_select(THD *thd, SELECT_LEX *sl, char const *type,
 			 select_result *result);
 int mysql_union(THD *thd, LEX *lex,select_result *result);
-int mysql_derived(THD *thd, LEX *lex, SELECT_LEX_UNIT *s, TABLE_LIST *t,
-		  bool tables_is_opened);
+int mysql_derived(THD *thd, LEX *lex, SELECT_LEX_UNIT *s, TABLE_LIST *t);
 Field *create_tmp_field(THD *thd, TABLE *table,Item *item, Item::Type type,
 			Item_result_field ***copy_func, Field **from_field,
 			bool group,bool modify_item);
@@ -438,14 +442,12 @@ int mysql_drop_index(THD *thd, TABLE_LIST *table_list,
 int mysql_update(THD *thd,TABLE_LIST *tables,List<Item> &fields,
 		 List<Item> &values,COND *conds, 
                  ORDER *order, ha_rows limit,
-		 enum enum_duplicates handle_duplicates,
-		 thr_lock_type lock_type);
+		 enum enum_duplicates handle_duplicates);
 int mysql_insert(THD *thd,TABLE_LIST *table,List<Item> &fields,
-		 List<List_item> &values, enum_duplicates flag,
-		 thr_lock_type lock_type);
+		 List<List_item> &values, enum_duplicates flag);
 void kill_delayed_threads(void);
 int mysql_delete(THD *thd, TABLE_LIST *table, COND *conds, ORDER *order,
-                 ha_rows rows, thr_lock_type lock_type, ulong options);
+                 ha_rows rows, ulong options);
 int mysql_truncate(THD *thd, TABLE_LIST *table_list, bool dont_send_ok=0);
 TABLE *open_ltable(THD *thd, TABLE_LIST *table_list, thr_lock_type update);
 TABLE *open_table(THD *thd,const char *db,const char *table,const char *alias,
@@ -462,7 +464,7 @@ bool table_is_used(TABLE *table, bool wait_for_name_lock);
 bool drop_locked_tables(THD *thd,const char *db, const char *table_name);
 void abort_locked_tables(THD *thd,const char *db, const char *table_name);
 extern const Field *not_found_field;
-Field *find_field_in_tables(THD *thd, Item_field *item, TABLE_LIST *tables,
+Field *find_field_in_tables(THD *thd, Item_ident *item, TABLE_LIST *tables,
 			    bool report_error);
 Field *find_field_in_table(THD *thd,TABLE *table,const char *name,uint length,
 			   bool check_grant,bool allow_rowid);
@@ -511,11 +513,11 @@ int mysqld_show_column_types(THD *thd);
 int mysqld_help (THD *thd, const char *text);
 
 /* sql_prepare.cc */
-int compare_prep_stmt(PREP_STMT *a, PREP_STMT *b, void *not_used);
+int compare_prep_stmt(void *not_used, PREP_STMT *stmt, ulong *key);
 void free_prep_stmt(PREP_STMT *stmt, TREE_FREE mode, void *not_used);
 bool mysql_stmt_prepare(THD *thd, char *packet, uint packet_length);
 void mysql_stmt_execute(THD *thd, char *packet);
-void mysql_stm_close(THD *thd, char *packet);
+void mysql_stmt_free(THD *thd, char *packet);
 void mysql_stmt_get_longdata(THD *thd, char *pos, ulong packet_length);
 int check_insert_fields(THD *thd,TABLE *table,List<Item> &fields,
 			List<Item> &values, ulong counter);
@@ -606,7 +608,7 @@ int write_record(TABLE *table,COPY_INFO *info);
 extern ulong volatile manager_status;
 extern bool volatile manager_thread_in_use, mqh_used;
 extern pthread_t manager_thread;
-pthread_handler_decl(handle_manager, arg);
+extern "C" pthread_handler_decl(handle_manager, arg);
 
 /* sql_test.cc */
 #ifndef DBUG_OFF
@@ -634,6 +636,8 @@ bool open_log(MYSQL_LOG *log, const char *hostname,
 	      const char *index_file_name,
 	      enum_log_type type, bool read_append = 0,
 	      bool no_auto_events = 0);
+/* mysqld.cc */
+void clear_error_message(THD *thd);
 
 /*
   External variables
@@ -759,7 +763,7 @@ bool wait_for_locked_table_names(THD *thd, TABLE_LIST *table_list);
 /* old unireg functions */
 
 void unireg_init(ulong options);
-void unireg_end(int signal);
+void unireg_end(void);
 int rea_create_table(THD *thd, my_string file_name,HA_CREATE_INFO *create_info,
 		     List<create_field> &create_field,
 		     uint key_count,KEY *key_info);
@@ -788,7 +792,7 @@ timestamp_type str_to_TIME(const char *str, uint length, TIME *l_time,
 
 int test_if_number(char *str,int *res,bool allow_wildcards);
 void change_byte(byte *,uint,char,char);
-void unireg_abort(int exit_code);
+extern "C" void unireg_abort(int exit_code);
 void init_read_record(READ_RECORD *info, THD *thd, TABLE *reg_form,
 		      SQL_SELECT *select,
 		      int use_record_cache, bool print_errors);
@@ -819,10 +823,6 @@ bool check_column_name(const char *name);
 bool check_table_name(const char *name, uint length);
 char *get_field(MEM_ROOT *mem,TABLE *table,uint fieldnr);
 int wild_case_compare(CHARSET_INFO *cs, const char *str,const char *wildstr);
-int wild_compare(const char *str,const char *str_end,
-		 const char *wildstr,const char *wildend,char escape);
-int wild_case_compare(CHARSET_INFO *cs, const char *str,const char *str_end,
-		      const char *wildstr,const char *wildend,char escape);
 
 /* from hostname.cc */
 struct in_addr;
diff --git a/sql/mysqld.cc b/sql/mysqld.cc
index c57e0fc38d171bf5cc25441da14bfe4debbedc6e..86da0e846a0ff321504b711b876ef2e06411abea 100644
--- a/sql/mysqld.cc
+++ b/sql/mysqld.cc
@@ -179,10 +179,13 @@ static char szPipeName [ 257 ];
 static SECURITY_ATTRIBUTES saPipeSecurity;
 static SECURITY_DESCRIPTOR sdPipeDescriptor;
 static HANDLE hPipe = INVALID_HANDLE_VALUE;
-static pthread_cond_t COND_handler_count;
 static uint handler_count;
+static bool opt_enable_named_pipe = 0;
 #endif
 #ifdef __WIN__
+static bool opt_console=0,start_mode=0;
+static pthread_cond_t COND_handler_count;
+static uint handler_count;
 static bool opt_console=0, start_mode=0, use_opt_args;
 static int opt_argc;
 static char **opt_argv;
@@ -276,7 +279,7 @@ static char* pidfile_name_ptr= pidfile_name;
 static pthread_t select_thread;
 static my_bool opt_noacl=0, opt_bootstrap=0, opt_myisam_log=0;
 my_bool opt_safe_user_create = 0, opt_no_mix_types = 0;
-my_bool opt_safe_show_db=0, lower_case_table_names, opt_old_rpl_compat;
+my_bool lower_case_table_names, opt_old_rpl_compat;
 my_bool opt_show_slave_auth_info, opt_sql_bin_update = 0;
 my_bool opt_log_slave_updates= 0;
 
@@ -335,13 +338,18 @@ ulong query_cache_limit=0;
 Query_cache query_cache;
 #endif
 
+#ifdef HAVE_SMEM
+static char *shared_memory_base_name=default_shared_memory_base_name;
+static bool opt_enable_shared_memory = 0;
+#endif
+
 volatile ulong cached_thread_count=0;
 
 // replication parameters, if master_host is not NULL, we are a slave
 my_string master_user = (char*) "test", master_password = 0, master_host=0,
   master_info_file = (char*) "master.info",
   relay_log_info_file = (char*) "relay-log.info",
-  master_ssl_key=0, master_ssl_cert=0;
+  master_ssl_key=0, master_ssl_cert=0, master_ssl_capath=0, master_ssl_cipher=0;
 my_string report_user = 0, report_password = 0, report_host=0;
  
 const char *localhost=LOCAL_HOST;
@@ -406,8 +414,12 @@ time_t start_time;
 
 ulong opt_sql_mode = 0L;
 const char *sql_mode_names[] =
-{ "REAL_AS_FLOAT", "PIPES_AS_CONCAT", "ANSI_QUOTES", "IGNORE_SPACE",
-  "SERIALIZE","ONLY_FULL_GROUP_BY", "NO_UNSIGNED_SUBTRACTION",NullS };
+{
+  "REAL_AS_FLOAT", "PIPES_AS_CONCAT", "ANSI_QUOTES", "IGNORE_SPACE",
+  "SERIALIZE", "ONLY_FULL_GROUP_BY", "NO_UNSIGNED_SUBTRACTION",
+  "POSTGRESQL", "ORACLE", "MSSQL", "SAPDB",
+  NullS
+};
 TYPELIB sql_mode_typelib= {array_elements(sql_mode_names)-1,"",
 			   sql_mode_names};
 
@@ -446,20 +458,23 @@ pthread_cond_t eventShutdown;
 #endif
 
 static void start_signal_handler(void);
-static void *signal_hand(void *arg);
+extern "C" pthread_handler_decl(signal_hand, arg);
 static void set_options(void);
 static void get_options(int argc,char **argv);
 static char *get_relative_path(const char *path);
 static void fix_paths(void);
-static pthread_handler_decl(handle_connections_sockets,arg);
-static pthread_handler_decl(kill_server_thread,arg);
+extern "C" pthread_handler_decl(handle_connections_sockets,arg);
+extern "C" pthread_handler_decl(kill_server_thread,arg);
 static int bootstrap(FILE *file);
 static void close_server_sock();
 static bool read_init_file(char *file_name);
 #ifdef __NT__
-static pthread_handler_decl(handle_connections_namedpipes,arg);
+extern "C" pthread_handler_decl(handle_connections_namedpipes,arg);
 #endif
-extern pthread_handler_decl(handle_slave,arg);
+#ifdef HAVE_SMEM
+static pthread_handler_decl(handle_connections_shared_memory,arg);
+#endif
+extern "C" pthread_handler_decl(handle_slave,arg);
 #ifdef SET_RLIMIT_NOFILE
 static uint set_maximum_open_files(uint max_file_limit);
 #endif
@@ -766,14 +781,14 @@ static void __cdecl kill_server(int sig_ptr)
   if (sig != MYSQL_KILL_SIGNAL && sig != 0)
     unireg_abort(1);				/* purecov: inspected */
   else
-    unireg_end(0);
+    unireg_end();
   pthread_exit(0);				/* purecov: deadcode */
   RETURN_FROM_KILL_SERVER;
 }
 
 
 #ifdef USE_ONE_SIGNAL_HAND
-static pthread_handler_decl(kill_server_thread,arg __attribute__((unused)))
+extern "C" pthread_handler_decl(kill_server_thread,arg __attribute__((unused)))
 {
   SHUTDOWN_THD;
   my_thread_init();				// Initialize new thread
@@ -788,7 +803,7 @@ static pthread_handler_decl(kill_server_thread,arg __attribute__((unused)))
 #define sigset signal
 #endif
 
-static sig_handler print_signal_warning(int sig)
+extern "C" sig_handler print_signal_warning(int sig)
 {
   if (!DBUG_IN_USE)
   {
@@ -805,16 +820,33 @@ static sig_handler print_signal_warning(int sig)
 #endif
 }
 
+/*
+  cleanup all memory and end program nicely
 
-void unireg_end(int signal_number __attribute__((unused)))
+  SYNOPSIS
+    unireg_end()
+
+  NOTES
+    This function never returns.
+
+    If SIGNALS_DONT_BREAK_READ is defined, this function is called
+    by the main thread. To get MySQL to shut down nicely in this case
+    (Mac OS X) we have to call exit() instead if pthread_exit().
+*/
+
+void unireg_end(void)
 {
   clean_up();
   my_thread_end();
+#ifdef SIGNALS_DONT_BREAK_READ
+  exit(0);
+#else
   pthread_exit(0);				// Exit is in main thread
+#endif
 }
 
 
-void unireg_abort(int exit_code)
+extern "C" void unireg_abort(int exit_code)
 {
   DBUG_ENTER("unireg_abort");
   if (exit_code)
@@ -860,6 +892,9 @@ void clean_up(bool print_message)
   bitmap_free(&temp_pool);
   free_max_user_conn();
   end_slave_list();
+#ifdef USE_REGEX
+  regex_end();
+#endif
 
 #if !defined(__WIN__) && !defined(EMBEDDED_LIBRARY)
   if (!opt_bootstrap)
@@ -1161,7 +1196,7 @@ void close_connection(NET *net,uint errcode,bool lock)
 	/* Called when a thread is aborted */
 	/* ARGSUSED */
 
-sig_handler end_thread_signal(int sig __attribute__((unused)))
+extern "C" sig_handler end_thread_signal(int sig __attribute__((unused)))
 {
   THD *thd=current_thd;
   DBUG_ENTER("end_thread_signal");
@@ -1252,7 +1287,7 @@ void flush_thread_cache()
 */
 
 #ifdef THREAD_SPECIFIC_SIGPIPE
-static sig_handler abort_thread(int sig __attribute__((unused)))
+extern "C" sig_handler abort_thread(int sig __attribute__((unused)))
 {
   THD *thd=current_thd;
   DBUG_ENTER("abort_thread");
@@ -1326,7 +1361,7 @@ static void start_signal_handler(void)
 #define UNSAFE_DEFAULT_LINUX_THREADS 200
 #endif
 
-static sig_handler handle_segfault(int sig)
+extern "C" sig_handler handle_segfault(int sig)
 {
   THD *thd=current_thd;
   /*
@@ -1403,7 +1438,11 @@ information that should help you find out what is causing the crash.\n");
 #endif /* HAVE_STACKTRACE */
 
  if (test_flags & TEST_CORE_ON_SIGNAL)
+ {
+   fprintf(stderr, "Writing a core file\n");
+   fflush(stderr);
    write_core(sig);
+ }
  exit(1);
 }
 
@@ -1511,7 +1550,7 @@ static void start_signal_handler(void)
 /* This threads handles all signals and alarms */
 
 /* ARGSUSED */
-static void *signal_hand(void *arg __attribute__((unused)))
+extern "C" void *signal_hand(void *arg __attribute__((unused)))
 {
   sigset_t set;
   int sig;
@@ -1639,8 +1678,8 @@ static void *signal_hand(void *arg __attribute__((unused)))
 
 
 /* ARGSUSED */
-static int my_message_sql(uint error, const char *str,
-			  myf MyFlags __attribute__((unused)))
+extern "C" int my_message_sql(uint error, const char *str,
+			      myf MyFlags __attribute__((unused)))
 {
   THD *thd;
   DBUG_ENTER("my_message_sql");
@@ -1660,6 +1699,17 @@ static int my_message_sql(uint error, const char *str,
   DBUG_RETURN(0);
 }
 
+
+/*
+  Forget last error message (if we got one)
+*/
+
+void clear_error_message(THD *thd)
+{
+  thd->net.last_error[0]= 0;
+}
+
+
 #ifdef __WIN__
 
 struct utsname
@@ -1675,7 +1725,7 @@ int uname(struct utsname *a)
 
 
 #ifdef __WIN__
-pthread_handler_decl(handle_shutdown,arg)
+extern "C" pthread_handler_decl(handle_shutdown,arg)
 {
   MSG msg;
   SHUTDOWN_THD;
@@ -1703,7 +1753,7 @@ int __stdcall handle_kill(ulong ctrl_type)
 #endif
 
 #ifdef OS2
-pthread_handler_decl(handle_shutdown,arg)
+extern "C" pthread_handler_decl(handle_shutdown,arg)
 {
   SHUTDOWN_THD;
   my_thread_init();
@@ -1887,8 +1937,6 @@ int main(int argc, char **argv)
     if (!ssl_acceptor_fd)
       opt_use_ssl = 0;
   }
-  if (des_key_file)
-    load_des_key_file(des_key_file);
 #endif /* HAVE_OPENSSL */
 
 #ifdef HAVE_LIBWRAP
@@ -1961,6 +2009,10 @@ int main(int argc, char **argv)
   reset_floating_point_exceptions();
   init_thr_lock();
   init_slave_list();
+#ifdef HAVE_OPENSSL
+  if (des_key_file)
+    load_des_key_file(des_key_file);
+#endif /* HAVE_OPENSSL */
 
   /* Setup log files */
   if (opt_log)
@@ -1987,6 +2039,8 @@ int main(int argc, char **argv)
   if (ha_init())
   {
     sql_print_error("Can't init databases");
+    if (unix_sock != INVALID_SOCKET)
+      unlink(mysql_unix_port);
     exit(1);
   }
   ha_key_cache();
@@ -2022,10 +2076,12 @@ int main(int argc, char **argv)
       pthread_key_create(&THR_MALLOC,NULL))
   {
     sql_print_error("Can't create thread-keys");
+    if (unix_sock != INVALID_SOCKET)
+      unlink(mysql_unix_port);
     exit(1);
   }
   start_signal_handler();				// Creates pidfile
-  if (acl_init(opt_noacl))
+  if (acl_init((THD*) 0, opt_noacl))
   {
     abort_loop=1;
     select_thread_in_use=0;
@@ -2034,10 +2090,12 @@ int main(int argc, char **argv)
     if (!opt_bootstrap)
       (void) my_delete(pidfile_name,MYF(MY_WME));	// Not needed anymore
 #endif
+    if (unix_sock != INVALID_SOCKET)
+      unlink(mysql_unix_port);
     exit(1);
   }
   if (!opt_noacl)
-    (void) grant_init();
+    (void) grant_init((THD*) 0);
   init_max_user_conn();
   init_update_queries();
 
@@ -2123,21 +2181,24 @@ The server will not act as a slave.");
 
   printf(ER(ER_READY),my_progname,server_version,"");
   fflush(stdout);
-
+#if defined(__NT__) || defined(HAVE_SMEM)
 #ifdef __NT__
   if (hPipe == INVALID_HANDLE_VALUE &&
-      (!have_tcpip || opt_disable_networking))
+     (!have_tcpip || opt_disable_networking) &&
+      !opt_enable_shared_memory)
   {
-    sql_print_error("TCP/IP or --enable-named-pipe should be configured on NT OS");
+    sql_print_error("TCP/IP,--shared-memory or --named-pipe should be configured on NT OS");
 	unireg_abort(1);
   }
   else
+#endif
   {
     pthread_mutex_lock(&LOCK_thread_count);
     (void) pthread_cond_init(&COND_handler_count,NULL);
     {
       pthread_t hThread;
       handler_count=0;
+#ifdef __NT__
       if (hPipe != INVALID_HANDLE_VALUE && opt_enable_named_pipe)
       {
 	handler_count++;
@@ -2148,18 +2209,33 @@ The server will not act as a slave.");
 	  handler_count--;
 	}
       }
+#endif
+#ifdef HAVE_SMEM
+      if (opt_enable_shared_memory)
+      {
+        handler_count++;
+        if (pthread_create(&hThread,&connection_attrib,
+                            handle_connections_shared_memory, 0))
+        {
+          sql_print_error("Warning: Can't create thread to handle shared memory");
+          handler_count--;
+        }
+      }
+#endif
       if (have_tcpip && !opt_disable_networking)
       {
 	handler_count++;
 	if (pthread_create(&hThread,&connection_attrib,
 			   handle_connections_sockets, 0))
 	{
-	  sql_print_error("Warning: Can't create thread to handle named pipes");
+	  sql_print_error("Warning: Can't create thread to handle tcp/ip");
 	  handler_count--;
 	}
       }
       while (handler_count > 0)
+      {
 	pthread_cond_wait(&COND_handler_count,&LOCK_thread_count);
+      }
     }
     pthread_mutex_unlock(&LOCK_thread_count);
   }
@@ -2488,7 +2564,7 @@ inline void kill_broken_server()
 
 	/* Handle new connections and spawn new process to handle them */
 
-pthread_handler_decl(handle_connections_sockets,arg __attribute__((unused)))
+extern "C" pthread_handler_decl(handle_connections_sockets,arg __attribute__((unused)))
 {
   my_socket sock,new_sock;
   uint error_count=0;
@@ -2524,7 +2600,7 @@ pthread_handler_decl(handle_connections_sockets,arg __attribute__((unused)))
   while (!abort_loop)
   {
     readFDs=clientFDs;
-#ifdef HPUX
+#ifdef HPUX10
     if (select(max_used_connection,(int*) &readFDs,0,0,0) < 0)
       continue;
 #else
@@ -2538,7 +2614,7 @@ pthread_handler_decl(handle_connections_sockets,arg __attribute__((unused)))
       MAYBE_BROKEN_SYSCALL
       continue;
     }
-#endif	/* HPUX */
+#endif	/* HPUX10 */
     if (abort_loop)
     {
       MAYBE_BROKEN_SYSCALL;
@@ -2695,7 +2771,7 @@ pthread_handler_decl(handle_connections_sockets,arg __attribute__((unused)))
 
 
 #ifdef __NT__
-pthread_handler_decl(handle_connections_namedpipes,arg)
+extern "C" pthread_handler_decl(handle_connections_namedpipes,arg)
 {
   HANDLE hConnectedPipe;
   BOOL fConnected;
@@ -2777,6 +2853,219 @@ pthread_handler_decl(handle_connections_namedpipes,arg)
 }
 #endif /* __NT__ */
 
+/* 
+  Thread of shared memory's service
+
+  SYNOPSIS
+    pthread_handler_decl()
+    handle_connections_shared_memory Thread handle
+    arg                              Arguments of thread
+*/
+#ifdef HAVE_SMEM
+pthread_handler_decl(handle_connections_shared_memory,arg)
+{
+/*  
+  event_connect_request is event object for start connection actions 
+  event_connect_answer is event object for confirm, that server put data
+  handle_connect_file_map is file-mapping object, use for create shared memory  
+  handle_connect_map is pointer on shared memory
+  handle_map is pointer on shared memory for client
+  event_server_wrote,
+  event_server_read,
+  event_client_wrote,
+  event_client_read are events for transfer data between server and client
+  handle_file_map is file-mapping object, use for create shared memory
+*/
+  HANDLE handle_connect_file_map = NULL;
+  char  *handle_connect_map = NULL;
+  HANDLE event_connect_request = NULL;
+  HANDLE event_connect_answer = NULL;
+  ulong smem_buffer_length = shared_memory_buffer_length + 4;
+  ulong connect_number = 1;
+  my_bool error_allow;
+  THD *thd;
+  char tmp[63];
+  char *suffix_pos;
+  char connect_number_char[22], *p;
+  
+  my_thread_init();
+  DBUG_ENTER("handle_connections_shared_memorys");
+  DBUG_PRINT("general",("Waiting for allocated shared memory."));
+
+
+/*
+  The name of event and file-mapping events create agree next rule:
+            shared_memory_base_name+unique_part
+  Where:
+    shared_memory_base_name is unique value for each server
+    unique_part is unique value for each object (events and file-mapping)
+*/
+  suffix_pos = strxmov(tmp,shared_memory_base_name,"_",NullS);
+  strmov(suffix_pos, "CONNECT_REQUEST");  
+  if ((event_connect_request = CreateEvent(NULL,FALSE,FALSE,tmp)) == 0) 
+  {
+    sql_perror("Can't create shared memory service ! The request event don't create.");
+    goto error;
+  }
+  strmov(suffix_pos, "CONNECT_ANSWER");  
+  if ((event_connect_answer = CreateEvent(NULL,FALSE,FALSE,tmp)) == 0) 
+  {
+    sql_perror("Can't create shared memory service ! The answer event don't create.");
+    goto error;
+  }
+  strmov(suffix_pos, "CONNECT_DATA");  
+  if ((handle_connect_file_map = CreateFileMapping(INVALID_HANDLE_VALUE,NULL,PAGE_READWRITE,
+                                 0,sizeof(connect_number),tmp)) == 0) 
+  {
+    sql_perror("Can't create shared memory service ! File mapping don't create.");
+    goto error;
+  }
+  if ((handle_connect_map = (char *)MapViewOfFile(handle_connect_file_map,FILE_MAP_WRITE,0,0,
+                            sizeof(DWORD))) == 0) 
+  {
+    sql_perror("Can't create shared memory service ! Map of memory don't create.");
+    goto error;
+  }
+
+
+  while (!abort_loop)
+  {
+/*
+ Wait a request from client
+*/
+    WaitForSingleObject(event_connect_request,INFINITE);  
+    error_allow = FALSE;
+
+    HANDLE handle_client_file_map = NULL;
+    char  *handle_client_map = NULL;
+    HANDLE event_client_wrote = NULL;
+    HANDLE event_client_read = NULL;
+    HANDLE event_server_wrote = NULL;
+    HANDLE event_server_read = NULL;
+
+    p = int2str(connect_number, connect_number_char, 10);
+/*
+  The name of event and file-mapping events create agree next rule:
+    shared_memory_base_name+unique_part+number_of_connection
+  Where:
+    shared_memory_base_name is uniquel value for each server
+    unique_part is unique value for each object (events and file-mapping)
+    number_of_connection is number of connection between server and client
+*/
+    suffix_pos = strxmov(tmp,shared_memory_base_name,"_",connect_number_char,"_",NullS);
+    strmov(suffix_pos, "DATA");
+    if ((handle_client_file_map = CreateFileMapping(INVALID_HANDLE_VALUE,NULL,
+                                  PAGE_READWRITE,0,smem_buffer_length,tmp)) == 0) 
+    {
+      sql_perror("Can't create connection with client in shared memory service ! File mapping don't create.");
+      error_allow = TRUE;
+      goto errorconn;
+    }
+    if ((handle_client_map = (char*)MapViewOfFile(handle_client_file_map,FILE_MAP_WRITE,0,0,smem_buffer_length)) == 0) 
+    {
+      sql_perror("Can't create connection with client in shared memory service ! Map of memory don't create.");
+      error_allow = TRUE;
+      goto errorconn;
+    }
+
+    strmov(suffix_pos, "CLIENT_WROTE");
+    if ((event_client_wrote = CreateEvent(NULL,FALSE,FALSE,tmp)) == 0) 
+    {
+      sql_perror("Can't create connection with client in shared memory service ! CW event don't create.");
+      error_allow = TRUE;
+      goto errorconn;
+    }
+
+    strmov(suffix_pos, "CLIENT_READ");
+    if ((event_client_read = CreateEvent(NULL,FALSE,FALSE,tmp)) == 0) 
+    {
+      sql_perror("Can't create connection with client in shared memory service ! CR event don't create.");
+      error_allow = TRUE;
+      goto errorconn;
+    }
+
+    strmov(suffix_pos, "SERVER_READ");
+    if ((event_server_read = CreateEvent(NULL,FALSE,FALSE,tmp)) == 0) 
+    {
+      sql_perror("Can't create connection with client in shared memory service ! SR event don't create.");
+      error_allow = TRUE;
+      goto errorconn;
+    }
+
+    strmov(suffix_pos, "SERVER_WROTE");
+    if ((event_server_wrote = CreateEvent(NULL,FALSE,FALSE,tmp)) == 0) 
+    {
+      sql_perror("Can't create connection with client in shared memory service ! SW event don't create.");
+      error_allow = TRUE;
+      goto errorconn;
+    }
+
+    if (abort_loop) break;
+    if ( !(thd = new THD))
+    {
+      error_allow = TRUE;
+      goto errorconn;
+    }
+
+/*
+Send number of connection to client
+*/
+    int4store(handle_connect_map, connect_number);
+      
+/*
+  Send number of connection to client
+*/
+    if (!SetEvent(event_connect_answer)) 
+    {
+      sql_perror("Can't create connection with client in shared memory service ! Can't send answer event.");
+      error_allow = TRUE;
+      goto errorconn;
+    }
+
+/*
+  Set event that client should receive data
+*/
+    if (!SetEvent(event_client_read))
+    {
+      sql_perror("Can't create connection with client in shared memory service ! Can't set client to read's mode.");
+      error_allow = TRUE;
+      goto errorconn;
+    }
+    if (!(thd->net.vio = vio_new_win32shared_memory(&thd->net,handle_client_file_map,handle_client_map,event_client_wrote,
+                         event_client_read,event_server_wrote,event_server_read)) ||
+                          my_net_init(&thd->net, thd->net.vio))
+    {
+      close_connection(&thd->net,ER_OUT_OF_RESOURCES);
+      delete thd;
+      error_allow = TRUE;
+    }
+    /* host name is unknown */
+errorconn:
+    if (error_allow)
+    {
+      if (!handle_client_map) UnmapViewOfFile(handle_client_map);
+      if (!handle_client_file_map) CloseHandle(handle_client_file_map);
+      if (!event_server_wrote) CloseHandle(event_server_wrote);
+      if (!event_server_read) CloseHandle(event_server_read);
+      if (!event_client_wrote) CloseHandle(event_client_wrote);
+      if (!event_client_read) CloseHandle(event_client_read);
+      continue;
+    }
+    thd->host = my_strdup(localhost,MYF(0)); /* Host is unknown */
+    create_new_thread(thd);
+    uint4korr(connect_number++);
+  }
+error:
+  if (!handle_connect_map) UnmapViewOfFile(handle_connect_map);
+  if (!handle_connect_file_map) CloseHandle(handle_connect_file_map);
+  if (!event_connect_answer) CloseHandle(event_connect_answer);
+  if (!event_connect_request) CloseHandle(event_connect_request);
+  pthread_mutex_lock(&LOCK_thread_count);
+  pthread_mutex_unlock(&LOCK_thread_count);
+  DBUG_RETURN(0);
+}
+#endif /* HAVE_SMEM */
+
 
 /******************************************************************************
 ** handle start options
@@ -2807,8 +3096,9 @@ enum options {
   OPT_MASTER_PASSWORD,         OPT_MASTER_PORT,
   OPT_MASTER_INFO_FILE,        OPT_MASTER_CONNECT_RETRY,
   OPT_MASTER_RETRY_COUNT,
-  OPT_MASTER_SSL,             OPT_MASTER_SSL_KEY,
-  OPT_MASTER_SSL_CERT,            
+  OPT_MASTER_SSL,              OPT_MASTER_SSL_KEY,
+  OPT_MASTER_SSL_CERT,         OPT_MASTER_SSL_CAPATH,
+  OPT_MASTER_SSL_CIPHER,
   OPT_SQL_BIN_UPDATE_SAME,     OPT_REPLICATE_DO_DB,      
   OPT_REPLICATE_IGNORE_DB,     OPT_LOG_SLAVE_UPDATES,
   OPT_BINLOG_DO_DB,            OPT_BINLOG_IGNORE_DB,
@@ -2886,7 +3176,9 @@ enum options {
   OPT_INNODB_FORCE_RECOVERY,
   OPT_BDB_CACHE_SIZE,
   OPT_BDB_LOG_BUFFER_SIZE,
-  OPT_BDB_MAX_LOCK
+  OPT_BDB_MAX_LOCK,
+  OPT_ENABLE_SHARED_MEMORY,
+  OPT_SHARED_MEMORY_BASE_NAME
 };
 
 
@@ -2993,6 +3285,11 @@ struct my_option my_long_options[] =
   {"enable-pstack", OPT_DO_PSTACK, "Print a symbolic stack trace on failure",
    (gptr*) &opt_do_pstack, (gptr*) &opt_do_pstack, 0, GET_BOOL, NO_ARG, 0, 0,
    0, 0, 0, 0},
+#ifdef HAVE_SMEM
+  {"shared-memory", OPT_ENABLE_SHARED_MEMORY,
+   "Enable the shared memory.",(gptr*) &opt_enable_shared_memory, (gptr*) &opt_enable_shared_memory,
+   0, GET_BOOL, NO_ARG, 0, 0, 0, 0, 0, 0},
+#endif   
   {"exit-info", 'T', "Used for debugging;  Use at your own risk!", 0, 0, 0,
    GET_LONG, OPT_ARG, 0, 0, 0, 0, 0, 0},
   {"flush", OPT_FLUSH, "Flush tables to disk between SQL commands", 0, 0, 0,
@@ -3118,6 +3415,14 @@ struct my_option my_long_options[] =
    "Master SSL certificate file name. Only applies if you have enabled master-ssl.",
    (gptr*) &master_ssl_cert, (gptr*) &master_ssl_cert, 0, GET_STR, OPT_ARG,
    0, 0, 0, 0, 0, 0},
+  {"master-ssl-capath", OPT_MASTER_SSL_CAPATH,
+   "Master SSL CA path. Only applies if you have enabled master-ssl.",
+   (gptr*) &master_ssl_capath, (gptr*) &master_ssl_capath, 0, GET_STR, OPT_ARG,
+   0, 0, 0, 0, 0, 0},
+  {"master-ssl-cipher", OPT_MASTER_SSL_CIPHER,
+   "Master SSL cipher. Only applies if you have enabled master-ssl.",
+   (gptr*) &master_ssl_cipher, (gptr*) &master_ssl_capath, 0, GET_STR, OPT_ARG,
+   0, 0, 0, 0, 0, 0},
   {"myisam-recover", OPT_MYISAM_RECOVER,
    "Syntax: myisam-recover[=option[,option...]], where option can be DEFAULT, BACKUP or FORCE.",
    (gptr*) &myisam_recover_options_str, (gptr*) &myisam_recover_options_str, 0,
@@ -3207,7 +3512,7 @@ struct my_option my_long_options[] =
    (gptr*) &report_port, (gptr*) &report_port, 0, GET_UINT, REQUIRED_ARG,
    MYSQL_PORT, 0, 0, 0, 0, 0},
   {"rpl-recovery-rank", OPT_RPL_RECOVERY_RANK, "Undocumented",
-   (gptr*) &rpl_recovery_rank, (gptr*) &rpl_recovery_rank, 0, GET_UINT,
+   (gptr*) &rpl_recovery_rank, (gptr*) &rpl_recovery_rank, 0, GET_ULONG,
    REQUIRED_ARG, 0, 0, 0, 0, 0, 0},
   {"relay-log", OPT_RELAY_LOG, "Undocumented",
    (gptr*) &opt_relay_logname, (gptr*) &opt_relay_logname, 0,
@@ -3220,8 +3525,7 @@ struct my_option my_long_options[] =
 #ifndef TO_BE_DELETED
   {"safe-show-database", OPT_SAFE_SHOW_DB,
    "Deprecated option; One should use GRANT SHOW DATABASES instead...",
-   (gptr*) &opt_safe_show_db, (gptr*) &opt_safe_show_db, 0, GET_BOOL, NO_ARG,
-   0, 0, 0, 0, 0, 0},
+   0, 0, 0, GET_NO_ARG, NO_ARG, 0, 0, 0, 0, 0, 0},
 #endif
   {"safe-user-create", OPT_SAFE_USER_CREATE,
    "Don't allow new user creation by the user who has no write privileges to the mysql.user table",
@@ -3234,6 +3538,11 @@ struct my_option my_long_options[] =
   {"set-variable", 'O',
    "Change the value of a variable. Please note that this option is deprecated;you can set variables directly with --variable-name=value.",
    0, 0, 0, GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0},
+#ifdef HAVE_SMEM
+  {"shared_memory_base_name",OPT_SHARED_MEMORY_BASE_NAME,
+   "Base name of shared memory", (gptr*) &shared_memory_base_name, (gptr*) &shared_memory_base_name, 
+   0, GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0},
+#endif
   {"show-slave-auth-info", OPT_SHOW_SLAVE_AUTH_INFO,
    "Show user and password in SHOW SLAVE STATUS",
    (gptr*) &opt_show_slave_auth_info, (gptr*) &opt_show_slave_auth_info, 0,
@@ -3771,6 +4080,7 @@ struct show_var_st status_vars[]= {
   {"Qcache_queries_in_cache",  (char*) &query_cache.queries_in_cache, SHOW_LONG_CONST},
   {"Qcache_inserts",           (char*) &query_cache.inserts,    SHOW_LONG},
   {"Qcache_hits",              (char*) &query_cache.hits,       SHOW_LONG},
+  {"Qcache_lowmem_prunes",     (char*) &query_cache.lowmem_prunes, SHOW_LONG},
   {"Qcache_not_cached",        (char*) &query_cache.refused,    SHOW_LONG},
   {"Qcache_free_memory",       (char*) &query_cache.free_memory, 
    SHOW_LONG_CONST},
@@ -3891,11 +4201,11 @@ static void set_options(void)
 
   /* Set default values for some variables */
   global_system_variables.table_type=DB_TYPE_MYISAM;
-  global_system_variables.tx_isolation=ISO_READ_COMMITTED;
-  global_system_variables.select_limit= (ulong) HA_POS_ERROR;
+  global_system_variables.tx_isolation=ISO_REPEATABLE_READ;
+  global_system_variables.select_limit= (ulonglong) HA_POS_ERROR;
   max_system_variables.select_limit= (ulong) HA_POS_ERROR;
-  global_system_variables.max_join_size= (ulong) HA_POS_ERROR;
-  max_system_variables.max_join_size= (ulong) HA_POS_ERROR;
+  global_system_variables.max_join_size= (ulonglong) HA_POS_ERROR;
+  max_system_variables.max_join_size= (ulonglong) HA_POS_ERROR;
 
 #ifdef __WIN__
   /* Allow Win32 users to move MySQL anywhere */
@@ -3918,7 +4228,7 @@ static void set_options(void)
 }
 
 
-static my_bool
+extern "C" my_bool
 get_one_option(int optid, const struct my_option *opt __attribute__((unused)),
 	       char *argument)
 {
@@ -3931,8 +4241,8 @@ get_one_option(int optid, const struct my_option *opt __attribute__((unused)),
     break;
   case 'a':
     opt_sql_mode = (MODE_REAL_AS_FLOAT | MODE_PIPES_AS_CONCAT |
-		    MODE_ANSI_QUOTES | MODE_IGNORE_SPACE | MODE_SERIALIZABLE
-		    | MODE_ONLY_FULL_GROUP_BY);
+		    MODE_ANSI_QUOTES | MODE_IGNORE_SPACE | MODE_SERIALIZABLE |
+		    MODE_ONLY_FULL_GROUP_BY);
     global_system_variables.tx_isolation= ISO_SERIALIZABLE;
     break;
   case 'b':
@@ -4188,7 +4498,7 @@ get_one_option(int optid, const struct my_option *opt __attribute__((unused)),
     else
     {
       struct hostent *ent;
-      if (!argument || !argument[0])
+      if (argument || argument[0])
 	ent=gethostbyname(argument);
       else
       {
@@ -4363,7 +4673,7 @@ get_one_option(int optid, const struct my_option *opt __attribute__((unused)),
     }
     global_system_variables.tx_isolation= ((opt_sql_mode & MODE_SERIALIZABLE) ?
 					   ISO_SERIALIZABLE :
-					   ISO_READ_COMMITTED);
+					   ISO_REPEATABLE_READ);
     break;
   }
   case OPT_MASTER_PASSWORD:
@@ -4377,7 +4687,6 @@ get_one_option(int optid, const struct my_option *opt __attribute__((unused)),
   }
   return 0;
 }
-
 	/* Initiates DEBUG - but no debugging here ! */
 
 static void get_options(int argc,char **argv)
@@ -4461,9 +4770,17 @@ fn_format_relative_to_data_home(my_string to, const char *name,
 
 static void fix_paths(void)
 {
-  char buff[FN_REFLEN];
-  (void) fn_format(mysql_home,mysql_home,"","",16); // Remove symlinks
+  char buff[FN_REFLEN],*pos;
   convert_dirname(mysql_home,mysql_home,NullS);
+  /* Resolve symlinks to allow 'mysql_home' to be a relative symlink */
+  my_realpath(mysql_home,mysql_home,MYF(0));
+  /* Ensure that mysql_home ends in FN_LIBCHAR */
+  pos=strend(mysql_home);
+  if (pos[-1] != FN_LIBCHAR)
+  {
+    pos[0]= FN_LIBCHAR;
+    pos[1]= 0;
+  }
   convert_dirname(mysql_real_data_home,mysql_real_data_home,NullS);
   convert_dirname(language,language,NullS);
   (void) my_load_path(mysql_home,mysql_home,""); // Resolve current dir
diff --git a/sql/nt_servc.cc b/sql/nt_servc.cc
index 2d0eae125d61bbaa8927de0c37d6f42d75674af9..b917c91ce153654a8bf9386ee6e4398296c5a5e2 100644
--- a/sql/nt_servc.cc
+++ b/sql/nt_servc.cc
@@ -568,31 +568,3 @@ BOOL NTService::is_super_user()
   FreeSid(psidAdministrators);
   return ret_value;
 }
-/* ------------------------------------------------------------------------
- -------------------------------------------------------------------------- */
-BOOL NTService::IsService(LPCSTR ServiceName)
-{
-  BOOL ret_value=FALSE;
-  SC_HANDLE service, scm;
-  
-  if (scm = OpenSCManager(0, 0,SC_MANAGER_ENUMERATE_SERVICE))
-  {
-    if ((service = OpenService(scm,ServiceName, SERVICE_ALL_ACCESS )))
-    {
-      ret_value=TRUE;
-      CloseServiceHandle(service);
-    }
-    CloseServiceHandle(scm);
-  }
-  return ret_value;
-}
-/* ------------------------------------------------------------------------
- -------------------------------------------------------------------------- */
-BOOL NTService::got_service_option(char **argv, char *service_option)
-{
-  char *option;
-  for (option= argv[1]; *option; option++)
-    if (!strcmp(option, service_option))
-      return TRUE;
-  return FALSE;
-}
diff --git a/sql/opt_range.cc b/sql/opt_range.cc
index 9a644553f2689543c3d45f802debd3284371a84b..0fad5769998a770450ca6b7e7b48cfddcc1640e4 100644
--- a/sql/opt_range.cc
+++ b/sql/opt_range.cc
@@ -299,9 +299,6 @@ static SEL_TREE * get_mm_parts(PARAM *param,Field *field,
 			       Item_result cmp_type);
 static SEL_ARG *get_mm_leaf(PARAM *param,Field *field,KEY_PART *key_part,
 			    Item_func::Functype type,Item *value);
-static bool like_range(const char *ptr,uint length,char wild_prefix,
-		       uint field_length, char *min_str,char *max_str,
-		       char max_sort_char,uint *min_length,uint *max_length);
 static SEL_TREE *get_mm_tree(PARAM *param,COND *cond);
 static ha_rows check_quick_select(PARAM *param,uint index,SEL_ARG *key_tree);
 static ha_rows check_quick_keys(PARAM *param,uint index,SEL_ARG *key_tree,
@@ -935,13 +932,16 @@ get_mm_leaf(PARAM *param, Field *field, KEY_PART *key_part,
     String tmp(buff1,sizeof(buff1),default_charset_info),*res;
     uint length,offset,min_length,max_length;
 
-    if (!field->optimize_range((uint) key_part->key))
+    if (!field->optimize_range(param->real_keynr[key_part->key]))
       DBUG_RETURN(0);				// Can't optimize this
     if (!(res= value->val_str(&tmp)))
       DBUG_RETURN(&null_element);
 
-    // Check if this was a function. This should have be optimized away
-    // in the sql_select.cc
+    /*
+      TODO:
+      Check if this was a function. This should have be optimized away
+      in the sql_select.cc
+    */
     if (res != &tmp)
     {
       tmp.copy(*res);				// Get own copy
@@ -970,27 +970,14 @@ get_mm_leaf(PARAM *param, Field *field, KEY_PART *key_part,
     max_str=min_str+length;
     if (maybe_null)
       max_str[0]= min_str[0]=0;
-    if (field->binary())
-      like_error=like_range(res->ptr(),res->length(),wild_prefix,field_length,
-			    min_str+offset,max_str+offset,(char) 255,
-			    &min_length,&max_length);
-    else
-    {
-      CHARSET_INFO *charset=field->charset();
-#ifdef USE_STRCOLL
-      if (use_strnxfrm(charset))
-        like_error= my_like_range(charset,
-                                  res->ptr(),res->length(),wild_prefix,
-                                  field_length, min_str+maybe_null,
-                                  max_str+maybe_null,&min_length,&max_length);
-      else
-#endif
-        like_error=like_range(res->ptr(),res->length(),wild_prefix,
-			      field_length,
-                              min_str+offset,max_str+offset,
-                              charset->max_sort_char,
-                              &min_length,&max_length);
-    }
+
+    like_error= my_like_range(field->charset(),
+                                  res->ptr(),res->length(),
+				  wild_prefix,wild_one,wild_many,
+                                  field_length, 
+				  min_str+offset, max_str+offset,
+				  &min_length,&max_length);
+
     if (like_error)				// Can't optimize with LIKE
       DBUG_RETURN(0);
     if (offset != maybe_null)			// Blob
@@ -1018,13 +1005,15 @@ get_mm_leaf(PARAM *param, Field *field, KEY_PART *key_part,
     DBUG_RETURN(tree);
   }
 
-  if (!field->optimize_range((uint) key_part->key) &&
+  if (!field->optimize_range(param->real_keynr[key_part->key]) &&
       type != Item_func::EQ_FUNC &&
       type != Item_func::EQUAL_FUNC)
     DBUG_RETURN(0);				// Can't optimize this
 
-  /* We can't always use indexes when comparing a string index to a number */
-  /* cmp_type() is checked to allow compare of dates to numbers */
+  /*
+    We can't always use indexes when comparing a string index to a number
+    cmp_type() is checked to allow compare of dates to numbers
+  */
   if (field->result_type() == STRING_RESULT &&
       value->result_type() != STRING_RESULT &&
       field->cmp_type() != value->result_type())
@@ -1032,6 +1021,7 @@ get_mm_leaf(PARAM *param, Field *field, KEY_PART *key_part,
 
   if (value->save_in_field(field) > 0)
   {
+    /* This happens when we try to insert a NULL field in a not null column */
     // TODO; Check if we can we remove the following block.
     if (type == Item_func::EQUAL_FUNC)
     {
@@ -1043,7 +1033,7 @@ get_mm_leaf(PARAM *param, Field *field, KEY_PART *key_part,
       *str = 1;
       DBUG_RETURN(new SEL_ARG(field,str,str));
     }
-    DBUG_RETURN(&null_element);			// NULL is never true
+    DBUG_RETURN(&null_element);			// cmp with NULL is never true
   }
   // Get local copy of key
   char *str= (char*) alloc_root(param->mem_root,
@@ -1051,7 +1041,7 @@ get_mm_leaf(PARAM *param, Field *field, KEY_PART *key_part,
   if (!str)
     DBUG_RETURN(0);
   if (maybe_null)
-    *str=0;					// Not NULL
+    *str= (char) field->is_real_null();		// Set to 1 if null
   field->get_key_image(str+maybe_null,key_part->part_length, key_part->image_type);
   if (!(tree=new SEL_ARG(field,str,str)))
     DBUG_RETURN(0);
@@ -1119,69 +1109,6 @@ get_mm_leaf(PARAM *param, Field *field, KEY_PART *key_part,
 }
 
 
-/*
-** Calculate min_str and max_str that ranges a LIKE string.
-** Arguments:
-** ptr		Pointer to LIKE string.
-** ptr_length	Length of LIKE string.
-** escape	Escape character in LIKE.  (Normally '\').
-**		All escape characters should be removed from min_str and max_str
-** res_length	Length of min_str and max_str.
-** min_str	Smallest case sensitive string that ranges LIKE.
-**		Should be space padded to res_length.
-** max_str	Largest case sensitive string that ranges LIKE.
-**		Normally padded with the biggest character sort value.
-**
-** The function should return 0 if ok and 1 if the LIKE string can't be
-** optimized !
-*/
-
-static bool like_range(const char *ptr,uint ptr_length,char escape,
-		       uint res_length, char *min_str,char *max_str,
-		       char max_sort_chr, uint *min_length, uint *max_length)
-{
-  const char *end=ptr+ptr_length;
-  char *min_org=min_str;
-  char *min_end=min_str+res_length;
-
-  for (; ptr != end && min_str != min_end ; ptr++)
-  {
-    if (*ptr == escape && ptr+1 != end)
-    {
-      ptr++;					// Skip escape
-      *min_str++= *max_str++ = *ptr;
-      continue;
-    }
-    if (*ptr == wild_one)			// '_' in SQL
-    {
-      *min_str++='\0';				// This should be min char
-      *max_str++=max_sort_chr;
-      continue;
-    }
-    if (*ptr == wild_many)			// '%' in SQL
-    {
-      *min_length= (uint) (min_str - min_org);
-      *max_length=res_length;
-      do {
-	*min_str++ = ' ';			// Because if key compression
-	*max_str++ = max_sort_chr;
-      } while (min_str != min_end);
-      return 0;
-    }
-    *min_str++= *max_str++ = *ptr;
-  }
-  *min_length= *max_length = (uint) (min_str - min_org);
-
-  /* Temporary fix for handling wild_one at end of string (key compression) */
-  for (char *tmp= min_str ; tmp > min_org && tmp[-1] == '\0';)
-    *--tmp=' ';
-
-  while (min_str != min_end)
-    *min_str++ = *max_str++ = ' ';		// Because if key compression
-  return 0;
-}
-
-
 /******************************************************************************
 ** Tree manipulation functions
 ** If tree is 0 it means that the condition can't be tested. It refers
@@ -2542,9 +2469,9 @@ int QUICK_SELECT::get_next()
 
     if (range->flag & NO_MIN_RANGE)		// Read first record
     {
-      int error;
-      if ((error=file->index_first(record)))
-	DBUG_RETURN(error);			// Empty table
+      int local_error;
+      if ((local_error=file->index_first(record)))
+	DBUG_RETURN(local_error);		// Empty table
       if (cmp_next(range) == 0)
 	DBUG_RETURN(0);
       range=0;			// No matching records; go to next range
@@ -2578,13 +2505,13 @@ int QUICK_SELECT::get_next()
 	/* compare if found key is over max-value */
 	/* Returns 0 if key <= range->max_key */
 
-int QUICK_SELECT::cmp_next(QUICK_RANGE *range)
+int QUICK_SELECT::cmp_next(QUICK_RANGE *range_arg)
 {
-  if (range->flag & NO_MAX_RANGE)
-    return (0);					/* key can't be to large */
+  if (range_arg->flag & NO_MAX_RANGE)
+    return 0;					/* key can't be to large */
 
   KEY_PART *key_part=key_parts;
-  for (char *key=range->max_key, *end=key+range->max_length;
+  for (char *key=range_arg->max_key, *end=key+range_arg->max_length;
        key < end;
        key+= key_part++->part_length)
   {
@@ -2605,7 +2532,7 @@ int QUICK_SELECT::cmp_next(QUICK_RANGE *range)
     if (cmp > 0)
       return 1;
   }
-  return (range->flag & NEAR_MAX) ? 1 : 0;		// Exact match
+  return (range_arg->flag & NEAR_MAX) ? 1 : 0;		// Exact match
 }
 
 
@@ -2689,9 +2616,9 @@ int QUICK_SELECT_DESC::get_next()
 
     if (range->flag & NO_MAX_RANGE)		// Read last record
     {
-      int error;
-      if ((error=file->index_last(record)))
-	DBUG_RETURN(error);			// Empty table
+      int local_error;
+      if ((local_error=file->index_last(record)))
+	DBUG_RETURN(local_error);		// Empty table
       if (cmp_prev(range) == 0)
 	DBUG_RETURN(0);
       range=0;			// No matching records; go to next range
@@ -2745,16 +2672,18 @@ int QUICK_SELECT_DESC::get_next()
   }
 }
 
+
 /*
- * Returns 0 if found key is inside range (found key >= range->min_key).
- */
-int QUICK_SELECT_DESC::cmp_prev(QUICK_RANGE *range)
+  Returns 0 if found key is inside range (found key >= range->min_key).
+*/
+
+int QUICK_SELECT_DESC::cmp_prev(QUICK_RANGE *range_arg)
 {
-  if (range->flag & NO_MIN_RANGE)
-    return (0);					/* key can't be to small */
+  if (range_arg->flag & NO_MIN_RANGE)
+    return 0;					/* key can't be to small */
 
   KEY_PART *key_part = key_parts;
-  for (char *key = range->min_key, *end = key + range->min_length;
+  for (char *key = range_arg->min_key, *end = key + range_arg->min_length;
        key < end;
        key += key_part++->part_length)
   {
@@ -2778,42 +2707,45 @@ int QUICK_SELECT_DESC::cmp_prev(QUICK_RANGE *range)
     if (cmp < 0)
       return 1;
   }
-  return (range->flag & NEAR_MIN) ? 1 : 0;		// Exact match
+  return (range_arg->flag & NEAR_MIN) ? 1 : 0;		// Exact match
 }
 
+
 /*
  * True if this range will require using HA_READ_AFTER_KEY
    See comment in get_next() about this
  */
 
-bool QUICK_SELECT_DESC::range_reads_after_key(QUICK_RANGE *range)
+bool QUICK_SELECT_DESC::range_reads_after_key(QUICK_RANGE *range_arg)
 {
-  return ((range->flag & (NO_MAX_RANGE | NEAR_MAX)) ||
-	  !(range->flag & EQ_RANGE) ||
-	  head->key_info[index].key_length != range->max_length) ? 1 : 0;
+  return ((range_arg->flag & (NO_MAX_RANGE | NEAR_MAX)) ||
+	  !(range_arg->flag & EQ_RANGE) ||
+	  head->key_info[index].key_length != range_arg->max_length) ? 1 : 0;
 }
 
+
 /* True if we are reading over a key that may have a NULL value */
 
-bool QUICK_SELECT_DESC::test_if_null_range(QUICK_RANGE *range,
+bool QUICK_SELECT_DESC::test_if_null_range(QUICK_RANGE *range_arg,
 					   uint used_key_parts)
 {
   uint offset,end;
   KEY_PART *key_part = key_parts,
            *key_part_end= key_part+used_key_parts;
 
-  for (offset= 0,  end = min(range->min_length, range->max_length) ;
+  for (offset= 0,  end = min(range_arg->min_length, range_arg->max_length) ;
        offset < end && key_part != key_part_end ;
        offset += key_part++->part_length)
   {
     uint null_length=test(key_part->null_bit);
-    if (!memcmp((char*) range->min_key+offset, (char*) range->max_key+offset,
+    if (!memcmp((char*) range_arg->min_key+offset,
+		(char*) range_arg->max_key+offset,
 		key_part->part_length + null_length))
     {
       offset+=null_length;
       continue;
     }
-    if (null_length && range->min_key[offset])
+    if (null_length && range_arg->min_key[offset])
       return 1;				// min_key is null and max_key isn't
     // Range doesn't cover NULL. This is ok if there is no more null parts
     break;
@@ -2826,7 +2758,7 @@ bool QUICK_SELECT_DESC::test_if_null_range(QUICK_RANGE *range,
   */
   if (key_part != key_part_end && key_part->null_bit)
   {
-    if (offset >= range->min_length || range->min_key[offset])
+    if (offset >= range_arg->min_length || range_arg->min_key[offset])
       return 1;					// Could be null
     key_part++;
   }
diff --git a/sql/opt_sum.cc b/sql/opt_sum.cc
index 38365dbb546ac6448f67cb70fc494761da37a54c..1477d46e75652c6d1a98a3a78f4e06fa42825fe4 100644
--- a/sql/opt_sum.cc
+++ b/sql/opt_sum.cc
@@ -37,6 +37,19 @@ int opt_sum_query(TABLE_LIST *tables, List<Item> &all_fields,COND *conds)
   bool recalc_const_item=0;
   table_map removed_tables=0;
   Item *item;
+  COND *org_conds= conds;
+  
+  /* Add all ON conditions to WHERE condition */
+  for (TABLE_LIST *tl=tables; tl ; tl= tl->next)
+  {
+    if (tl->on_expr)
+      conds= and_expressions(conds, tl->on_expr, &org_conds);
+  }
+
+  /*
+    Iterate through item is select part and replace COUNT(), MIN() and MAX()
+    with constants (if possible)
+  */
 
   while ((item= it++))
   {
diff --git a/sql/procedure.h b/sql/procedure.h
index 3434079a8fb587a54804c04ff7039e70ee2495e5..c3280b951d3584427199eac44217dfe0f8141eb7 100644
--- a/sql/procedure.h
+++ b/sql/procedure.h
@@ -62,7 +62,7 @@ class Item_proc_real :public Item_proc
   { value=atof(str); }
   double val() { return value; }
   longlong val_int() { return (longlong) value; }
-  String *val_str(String *s) { s->set(value,decimals,my_thd_charset); return s; }
+  String *val_str(String *s) { s->set(value,decimals,thd_charset()); return s; }
   unsigned int size_of() { return sizeof(*this);}  
 };
 
@@ -80,7 +80,7 @@ class Item_proc_int :public Item_proc
   { value=strtoll(str,NULL,10); }
   double val() { return (double) value; }
   longlong val_int() { return value; }
-  String *val_str(String *s) { s->set(value, my_thd_charset); return s; }
+  String *val_str(String *s) { s->set(value, thd_charset()); return s; }
   unsigned int size_of() { return sizeof(*this);}  
 };
 
@@ -92,9 +92,9 @@ class Item_proc_string :public Item_proc
     { this->max_length=length; }
   enum Item_result result_type () const { return STRING_RESULT; }
   enum_field_types field_type() const { return FIELD_TYPE_STRING; }
-  void set(double nr) { str_value.set(nr, 2, my_thd_charset); }
-  void set(longlong nr) { str_value.set(nr, my_thd_charset); }
-  void set(const char *str, uint length) { str_value.copy(str,length, my_thd_charset); }
+  void set(double nr) { str_value.set(nr, 2, thd_charset()); }
+  void set(longlong nr) { str_value.set(nr, thd_charset()); }
+  void set(const char *str, uint length) { str_value.copy(str,length, thd_charset()); }
   double val() { return atof(str_value.ptr()); }
   longlong val_int() { return strtoll(str_value.ptr(),NULL,10); }
   String *val_str(String*)
diff --git a/sql/repl_failsafe.cc b/sql/repl_failsafe.cc
index 4295a16c54785ced903dc8cbea3e91c6878e4f68..785a253b1ac59b2e84d6f78ad586c4471f840d4b 100644
--- a/sql/repl_failsafe.cc
+++ b/sql/repl_failsafe.cc
@@ -188,14 +188,15 @@ int register_slave(THD* thd, uchar* packet, uint packet_length)
   return 1;
 }
 
-static uint32* slave_list_key(SLAVE_INFO* si, uint* len,
-			     my_bool not_used __attribute__((unused)))
+extern "C" uint32
+*slave_list_key(SLAVE_INFO* si, uint* len,
+		my_bool not_used __attribute__((unused)))
 {
   *len = 4;
   return &si->server_id;
 }
 
-static void slave_info_free(void *s)
+extern "C" void slave_info_free(void *s)
 {
   my_free((gptr) s, MYF(MY_WME));
 }
@@ -203,7 +204,7 @@ static void slave_info_free(void *s)
 void init_slave_list()
 {
   hash_init(&slave_list, system_charset_info, SLAVE_LIST_CHUNK, 0, 0,
-	    (hash_get_key) slave_list_key, slave_info_free, 0);
+	    (hash_get_key) slave_list_key, (hash_free_key) slave_info_free, 0);
   pthread_mutex_init(&LOCK_slave_list, MY_MUTEX_INIT_FAST);
 }
 
diff --git a/sql/set_var.cc b/sql/set_var.cc
index 72579664a3eef12785d288cadf3b59a18441657d..599c4af06ccbc204adf82b556e62b6887e383d9e 100644
--- a/sql/set_var.cc
+++ b/sql/set_var.cc
@@ -154,11 +154,11 @@ sys_var_thd_ulong	sys_max_error_count("max_error_count",
 					    &SV::max_error_count);
 sys_var_thd_ulong	sys_max_heap_table_size("max_heap_table_size",
 						&SV::max_heap_table_size);
-sys_var_thd_ulong	sys_max_join_size("max_join_size",
+sys_var_thd_ulonglong	sys_max_join_size("max_join_size",
 					  &SV::max_join_size,
 					  fix_max_join_size);
 #ifndef TO_BE_DELETED	/* Alias for max_join_size */
-sys_var_thd_ulong	sys_sql_max_join_size("sql_max_join_size",
+sys_var_thd_ulonglong	sys_sql_max_join_size("sql_max_join_size",
 					      &SV::max_join_size,
 					      fix_max_join_size);
 #endif
@@ -202,8 +202,6 @@ sys_var_thd_enum	sys_query_cache_type("query_cache_type",
 					     &SV::query_cache_type,
 					     &query_cache_type_typelib);
 #endif /* HAVE_QUERY_CACHE */
-sys_var_bool_ptr	sys_safe_show_db("safe_show_database",
-					 &opt_safe_show_db);
 sys_var_long_ptr	sys_server_id("server_id",&server_id);
 sys_var_bool_ptr	sys_slave_compressed_protocol("slave_compressed_protocol",
 						      &opt_slave_compressed_protocol);
@@ -282,7 +280,7 @@ static sys_var_thd_bit	sys_unique_checks("unique_checks",
 
 /* Local state variables */
 
-static sys_var_thd_ulong	sys_select_limit("sql_select_limit",
+static sys_var_thd_ulonglong	sys_select_limit("sql_select_limit",
 						 &SV::select_limit);
 static sys_var_timestamp	sys_timestamp("timestamp");
 static sys_var_last_insert_id	sys_last_insert_id("last_insert_id");
@@ -299,6 +297,8 @@ static sys_var_readonly		sys_warning_count("warning_count",
 
 /* alias for last_insert_id() to be compatible with Sybase */
 static sys_var_slave_skip_counter sys_slave_skip_counter("sql_slave_skip_counter");
+static sys_var_rand_seed1	sys_rand_seed1("rand_seed1");
+static sys_var_rand_seed2	sys_rand_seed2("rand_seed2");
 
 
 /*
@@ -370,10 +370,11 @@ sys_var *sys_variables[]=
   &sys_query_cache_type,
 #endif /* HAVE_QUERY_CACHE */
   &sys_quote_show_create,
+  &sys_rand_seed1,
+  &sys_rand_seed2,
   &sys_read_buff_size,
   &sys_read_rnd_buff_size,
   &sys_rpl_recovery_rank,
-  &sys_safe_show_db,
   &sys_safe_updates,
   &sys_select_limit,
   &sys_server_id,
@@ -448,7 +449,7 @@ struct show_var_st init_vars[]= {
   {"innodb_file_io_threads", (char*) &innobase_file_io_threads, SHOW_LONG },
   {"innodb_force_recovery", (char*) &innobase_force_recovery, SHOW_LONG },
   {"innodb_thread_concurrency", (char*) &innobase_thread_concurrency, SHOW_LONG },
-  {"innodb_flush_log_at_trx_commit", (char*) &innobase_flush_log_at_trx_commit, SHOW_LONG},
+  {"innodb_flush_log_at_trx_commit", (char*) &innobase_flush_log_at_trx_commit, SHOW_INT},
   {"innodb_fast_shutdown", (char*) &innobase_fast_shutdown, SHOW_MY_BOOL},
   {"innodb_flush_method",    (char*) &innobase_unix_file_flush_method, SHOW_CHAR_PTR},
   {"innodb_lock_wait_timeout", (char*) &innobase_lock_wait_timeout, SHOW_LONG },
@@ -519,14 +520,19 @@ struct show_var_st init_vars[]= {
   {sys_query_cache_size.name, (char*) &sys_query_cache_size,	    SHOW_SYS},
   {sys_query_cache_type.name, (char*) &sys_query_cache_type,        SHOW_SYS},
 #endif /* HAVE_QUERY_CACHE */
-  {sys_safe_show_db.name,     (char*) &sys_safe_show_db,            SHOW_SYS},
+#ifdef HAVE_SMEM
+  {"shared_memory",           (char*) &opt_enable_shared_memory,    SHOW_MY_BOOL},
+  {"shared_memory_base_name", (char*) &shared_memory_base_name,     SHOW_CHAR_PTR},
+#endif
   {sys_server_id.name,	      (char*) &sys_server_id,		    SHOW_SYS},
   {sys_slave_net_timeout.name,(char*) &sys_slave_net_timeout,	    SHOW_SYS},
   {"skip_external_locking",   (char*) &my_disable_locking,          SHOW_MY_BOOL},
   {"skip_networking",         (char*) &opt_disable_networking,      SHOW_BOOL},
   {"skip_show_database",      (char*) &opt_skip_show_db,            SHOW_BOOL},
   {sys_slow_launch_time.name, (char*) &sys_slow_launch_time,        SHOW_SYS},
+#ifdef HAVE_SYS_UN_H
   {"socket",                  (char*) &mysql_unix_port,             SHOW_CHAR_PTR},
+#endif
   {sys_sort_buffer.name,      (char*) &sys_sort_buffer, 	    SHOW_SYS},
   {"sql_mode",                (char*) &opt_sql_mode,                SHOW_LONG},
   {"table_cache",             (char*) &table_cache_size,            SHOW_LONG},
@@ -594,7 +600,7 @@ static void fix_max_join_size(THD *thd, enum_var_type type)
 {
   if (type != OPT_GLOBAL)
   {
-    if (thd->variables.max_join_size == (ulong) HA_POS_ERROR)
+    if (thd->variables.max_join_size == (ulonglong) HA_POS_ERROR)
       thd->options|= OPTION_BIG_SELECTS;
     else
       thd->options&= ~OPTION_BIG_SELECTS;
@@ -769,7 +775,7 @@ bool sys_var_thd_ulonglong::update(THD *thd,  set_var *var)
 void sys_var_thd_ulonglong::set_default(THD *thd, enum_var_type type)
 {
   if (type == OPT_GLOBAL)
-    global_system_variables.*offset= (ulong) option_limits->def_value;
+    global_system_variables.*offset= (ulonglong) option_limits->def_value;
   else
     thd->variables.*offset= global_system_variables.*offset;
 }
@@ -1069,6 +1075,19 @@ bool sys_var_slave_skip_counter::update(THD *thd, set_var *var)
 }
 
 
+bool sys_var_rand_seed1::update(THD *thd, set_var *var)
+{
+  thd->rand.seed1= (ulong) var->value->val_int();
+  return 0;
+}
+
+bool sys_var_rand_seed2::update(THD *thd, set_var *var)
+{
+  thd->rand.seed2= (ulong) var->value->val_int();
+  return 0;
+}
+
+
 /*
   Functions to update thd->options bits
 */
diff --git a/sql/set_var.h b/sql/set_var.h
index 31154d1e1d7547ce073c0cebb71f786b4d742eda..de1e27e0da8e0ba1ee54d1788e0e403a29264141 100644
--- a/sql/set_var.h
+++ b/sql/set_var.h
@@ -203,6 +203,10 @@ class sys_var_thd_ulonglong :public sys_var_thd
   sys_var_thd_ulonglong(const char *name_arg, ulonglong SV::*offset_arg)
     :sys_var_thd(name_arg), offset(offset_arg)
   {}
+  sys_var_thd_ulonglong(const char *name_arg, ulonglong SV::*offset_arg,
+			sys_after_update_func func)
+    :sys_var_thd(name_arg,func), offset(offset_arg)
+  {}
   bool update(THD *thd, set_var *var);
   void set_default(THD *thd, enum_var_type type);
   SHOW_TYPE type() { return SHOW_LONGLONG; }
@@ -333,6 +337,23 @@ class sys_var_slave_skip_counter :public sys_var
 };
 
 
+class sys_var_rand_seed1 :public sys_var
+{
+public:
+  sys_var_rand_seed1(const char *name_arg) :sys_var(name_arg) {}
+  bool update(THD *thd, set_var *var);
+  bool check_type(enum_var_type type) { return type == OPT_GLOBAL; }
+};
+
+class sys_var_rand_seed2 :public sys_var
+{
+public:
+  sys_var_rand_seed2(const char *name_arg) :sys_var(name_arg) {}
+  bool update(THD *thd, set_var *var);
+  bool check_type(enum_var_type type) { return type == OPT_GLOBAL; }
+};
+
+
 class sys_var_thd_conv_charset :public sys_var_thd
 {
 public:
diff --git a/sql/share/czech/errmsg.txt b/sql/share/czech/errmsg.txt
index c8ac594f00b49c9adea811a15805fe0e9630f131..4838de12ed680963845ab309d9261f3b16c345d7 100644
--- a/sql/share/czech/errmsg.txt
+++ b/sql/share/czech/errmsg.txt
@@ -188,7 +188,7 @@
 "Update tabulky bez WHERE s kl-Bíèem není v módu bezpeèných update dovoleno",
 "Kl-Bíè '%-.64s' v tabulce '%-.64s' neexistuje",
 "Nemohu otev-Bøít tabulku",
-"Handler tabulky nepodporuje check/repair",
+"Handler tabulky nepodporuje %s",
 "Proveden-Bí tohoto pøíkazu není v transakci dovoleno",
 "Chyba %d p-Bøi COMMIT",
 "Chyba %d p-Bøi ROLLBACK",
@@ -252,4 +252,7 @@
 "Subselect returns more than 1 field",
 "Subselect returns more than 1 record",
 "Unknown prepared statement handler (%ld) given to %s",
-"Help database is corrupt or does not exist",
\ No newline at end of file
+"Help database is corrupt or does not exist",
+"Cyclic reference on subqueries",
+"Converting column '%s' from %s to %s",
+"Reference '%-.64s' not supported (%s)",
diff --git a/sql/share/danish/errmsg.txt b/sql/share/danish/errmsg.txt
index 5638260277ea50da0045fdc29a537d1eef9b1b4a..91fa06f184f5ce8b541ce9285d0fa64e3d1d393f 100644
--- a/sql/share/danish/errmsg.txt
+++ b/sql/share/danish/errmsg.txt
@@ -182,7 +182,7 @@
 "Du bruger sikker opdaterings modus ('safe update mode') og du forsøgte at opdatere en tabel uden en WHERE klausul, der gør brug af et KEY felt",
 "Nøglen '%-.64s' eksisterer ikke i tabellen '%-.64s'",
 "Kan ikke åbne tabellen",
-"Denne tabeltype understøtter ikke CHECK/REPAIR",
+"Denne tabeltype understøtter ikke %s",
 "Du må ikke bruge denne kommando i en transaktion",
 "Modtog fejl %d mens kommandoen COMMIT blev udført",
 "Modtog fejl %d mens kommandoen ROLLBACK blev udført",
@@ -246,4 +246,7 @@
 "Subselect returns more than 1 field",
 "Subselect returns more than 1 record",
 "Unknown prepared statement handler (%ld) given to %s",
-"Help database is corrupt or does not exist",
\ No newline at end of file
+"Help database is corrupt or does not exist",
+"Cyclic reference on subqueries",
+"Converting column '%s' from %s to %s",
+"Reference '%-.64s' not supported (%s)",
diff --git a/sql/share/dutch/errmsg.txt b/sql/share/dutch/errmsg.txt
index acbda2829d01c1647b496ae7cc12e02695fc1122..50c70ce0d2cc2dd5386df451221b67852c957616 100644
--- a/sql/share/dutch/errmsg.txt
+++ b/sql/share/dutch/errmsg.txt
@@ -190,7 +190,7 @@
 "U gebruikt 'safe update mode' en u probeerde een tabel te updaten zonder een WHERE met een KEY kolom",
 "Zoeksleutel '%-.64s' bestaat niet in tabel '%-.64s'",
 "Kan tabel niet openen",
-"De 'handler' voor de tabel ondersteund geen check/repair",
+"De 'handler' voor de tabel ondersteund geen %s",
 "Het is u niet toegestaan dit commando uit te voeren binnen een transactie",
 "Kreeg fout %d tijdens COMMIT",
 "Kreeg fout %d tijdens ROLLBACK",
@@ -254,4 +254,7 @@
 "Subselect returns more than 1 field",
 "Subselect returns more than 1 record",
 "Unknown prepared statement handler (%ld) given to %s",
-"Help database is corrupt or does not exist",
\ No newline at end of file
+"Help database is corrupt or does not exist",
+"Cyclic reference on subqueries",
+"Converting column '%s' from %s to %s",
+"Reference '%-.64s' not supported (%s)",
diff --git a/sql/share/english/errmsg.txt b/sql/share/english/errmsg.txt
index 36d8831fd396ff0474c64a46a36d7041c80dfc9c..1c5564b9ad519ac00c3114d3039591c4addd4383 100644
--- a/sql/share/english/errmsg.txt
+++ b/sql/share/english/errmsg.txt
@@ -179,7 +179,7 @@
 "You are using safe update mode and you tried to update a table without a WHERE that uses a KEY column",
 "Key '%-.64s' doesn't exist in table '%-.64s'",
 "Can't open table",
-"The handler for the table doesn't support check/repair",
+"The handler for the table doesn't support %s",
 "You are not allowed to execute this command in a transaction",
 "Got error %d during COMMIT",
 "Got error %d during ROLLBACK",
@@ -243,4 +243,7 @@
 "Subselect returns more than 1 field",
 "Subselect returns more than 1 record",
 "Unknown prepared statement handler (%ld) given to %s",
-"Help database is corrupt or does not exist",
\ No newline at end of file
+"Help database is corrupt or does not exist",
+"Cyclic reference on subqueries",
+"Converting column '%s' from %s to %s",
+"Reference '%-.64s' not supported (%s)",
diff --git a/sql/share/estonian/errmsg.txt b/sql/share/estonian/errmsg.txt
index 96bd758cc6a7b803fddf8825ee8dfe8af9bdf695..8a49cc7fb69f3b1f1e38b1b73aed63d55316fdbc 100644
--- a/sql/share/estonian/errmsg.txt
+++ b/sql/share/estonian/errmsg.txt
@@ -184,7 +184,7 @@
 "Katse muuta tabelit turvalises rezhiimis ilma WHERE klauslita",
 "Võti '%-.64s' ei eksisteeri tabelis '%-.64s'",
 "Ei suuda avada tabelit",
-"Antud tabelitüüp ei toeta CHECK/REPAIR käske",
+"Antud tabelitüüp ei toeta %s käske",
 "Seda käsku ei saa kasutada transaktsiooni sees",
 "Viga %d käsu COMMIT täitmisel",
 "Viga %d käsu ROLLBACK täitmisel",
@@ -248,4 +248,7 @@
 "Subselect returns more than 1 field",
 "Subselect returns more than 1 record",
 "Unknown prepared statement handler (%ld) given to %s",
-"Help database is corrupt or does not exist",
\ No newline at end of file
+"Help database is corrupt or does not exist",
+"Cyclic reference on subqueries",
+"Converting column '%s' from %s to %s",
+"Reference '%-.64s' not supported (%s)",
diff --git a/sql/share/french/errmsg.txt b/sql/share/french/errmsg.txt
index 932182a2c94564f5c1fe1e9cf5d6d669ee141997..a8b602ee2958d66564c5d295792682c7078405d7 100644
--- a/sql/share/french/errmsg.txt
+++ b/sql/share/french/errmsg.txt
@@ -179,7 +179,7 @@
 "Vous êtes en mode 'safe update' et vous essayez de faire un UPDATE sans clause WHERE utilisant un index",
 "L'index '%-.64s' n'existe pas sur la table '%-.64s'",
 "Impossible d'ouvrir la table",
-"Ce type de table ne supporte pas les check/repair",
+"Ce type de table ne supporte pas les %s",
 "Vous n'êtes pas autorisé à exécute cette commande dans une transaction",
 "Erreur %d lors du COMMIT",
 "Erreur %d lors du ROLLBACK",
@@ -243,4 +243,7 @@
 "Subselect returns more than 1 field",
 "Subselect returns more than 1 record",
 "Unknown prepared statement handler (%ld) given to %s",
-"Help database is corrupt or does not exist",
\ No newline at end of file
+"Help database is corrupt or does not exist",
+"Cyclic reference on subqueries",
+"Converting column '%s' from %s to %s",
+"Reference '%-.64s' not supported (%s)",
diff --git a/sql/share/german/errmsg.txt b/sql/share/german/errmsg.txt
index febd723df8952732bbbece0901aad2c01241f537..cb449738d61cf3e67c37f614fa8f5abb38a03b5b 100644
--- a/sql/share/german/errmsg.txt
+++ b/sql/share/german/errmsg.txt
@@ -182,7 +182,7 @@
 "Unter Verwendung des Sicheren Updatemodes wurde versucht eine Tabelle zu updaten ohne eine KEY-Spalte in der WHERE-Klausel",
 "Schlüssel '%-.64s' existiert nicht in der Tabelle '%-.64s'",
 "Kann Tabelle nicht öffnen",
-"Der Tabellen-Handler für diese Tabelle unterstützt kein check/repair",
+"Der Tabellen-Handler für diese Tabelle unterstützt kein %s",
 "Keine Berechtigung dieses Kommando in einer Transaktion auszuführen",
 "Fehler %d wärend COMMIT",
 "Fehler %d wärend ROLLBACK",
@@ -246,4 +246,7 @@
 "Subselect return more than 1 field",
 "Subselect return more than 1 record",
 "Unknown prepared statement handler (%ld) given to %s",
-"Help database is corrupt or does not exist",
\ No newline at end of file
+"Help database is corrupt or does not exist",
+"Cyclic reference on subqueries",
+"Converting column '%s' from %s to %s",
+"Reference '%-.64s' not supported (%s)",
diff --git a/sql/share/greek/errmsg.txt b/sql/share/greek/errmsg.txt
index 9d9aa07af8dcd5b3e49b26ca0ad6b8533f3ef6e1..f6c650468b1230f85ab215df5862ea8f2ed918a7 100644
--- a/sql/share/greek/errmsg.txt
+++ b/sql/share/greek/errmsg.txt
@@ -179,7 +179,7 @@
 "You are using safe update mode and you tried to update a table without a WHERE that uses a KEY column",
 "Key '%-.64s' doesn't exist in table '%-.64s'",
 "Can't open table",
-"The handler for the table doesn't support check/repair",
+"The handler for the table doesn't support %s",
 "You are not allowed to execute this command in a transaction",
 "Got error %d during COMMIT",
 "Got error %d during ROLLBACK",
@@ -243,4 +243,7 @@
 "Subselect returns more than 1 field",
 "Subselect returns more than 1 record",
 "Unknown prepared statement handler (%ld) given to %s",
-"Help database is corrupt or does not exist",
\ No newline at end of file
+"Help database is corrupt or does not exist",
+"Cyclic reference on subqueries",
+"Converting column '%s' from %s to %s",
+"Reference '%-.64s' not supported (%s)",
diff --git a/sql/share/hungarian/errmsg.txt b/sql/share/hungarian/errmsg.txt
index d596c8f3433bfd1c2a3d9482d5d9ca1b5d498c70..fe47d79a101a9e6f75252c00fb641a0970fa3b59 100644
--- a/sql/share/hungarian/errmsg.txt
+++ b/sql/share/hungarian/errmsg.txt
@@ -181,7 +181,7 @@
 "On a biztonsagos update modot hasznalja, es        WHERE that uses a KEY column",
 "A '%-.64s' kulcs nem letezik a '%-.64s' tablaban",
 "Nem tudom megnyitni a tablat",
-"A tabla kezeloje (handler) nem tamogatja az ellenorzest/helyreallitast",
+"A tabla kezeloje (handler) nem tamogatja az %s",
 "Az On szamara nem engedelyezett a parancs vegrehajtasa a tranzakcioban",
 "%d hiba a COMMIT vegrehajtasa soran",
 "%d hiba a ROLLBACK vegrehajtasa soran",
@@ -245,4 +245,7 @@
 "Subselect returns more than 1 field",
 "Subselect returns more than 1 record",
 "Unknown prepared statement handler (%ld) given to %s",
-"Help database is corrupt or does not exist",
\ No newline at end of file
+"Help database is corrupt or does not exist",
+"Cyclic reference on subqueries",
+"Converting column '%s' from %s to %s",
+"Reference '%-.64s' not supported (%s)",
diff --git a/sql/share/italian/errmsg.txt b/sql/share/italian/errmsg.txt
index d9ccf54d7ea6f75618a7c0e53b916a97c228216b..0d951857392d27b682f1918e6afaa2f90e1c8e16 100644
--- a/sql/share/italian/errmsg.txt
+++ b/sql/share/italian/errmsg.txt
@@ -179,7 +179,7 @@
 "In modalita` 'safe update' si e` cercato di aggiornare una tabella senza clausola WHERE su una chiave",
 "La chiave '%-.64s' non esiste nella tabella '%-.64s'",
 "Impossibile aprire la tabella",
-"Il gestore per la tabella non supporta il controllo/riparazione",
+"Il gestore per la tabella non supporta il %s",
 "Non puoi eseguire questo comando in una transazione",
 "Rilevato l'errore %d durante il COMMIT",
 "Rilevato l'errore %d durante il ROLLBACK",
@@ -243,4 +243,7 @@
 "Subselect returns more than 1 field",
 "Subselect returns more than 1 record",
 "Unknown prepared statement handler (%ld) given to %s",
-"Help database is corrupt or does not exist",
\ No newline at end of file
+"Help database is corrupt or does not exist",
+"Cyclic reference on subqueries",
+"Converting column '%s' from %s to %s",
+"Reference '%-.64s' not supported (%s)",
diff --git a/sql/share/japanese/errmsg.txt b/sql/share/japanese/errmsg.txt
index 22a53801efd730c23427f6dbecbd2254852d8ca3..df78901a6e9ac10257cc70e1c0e55a6eec9e8270 100644
--- a/sql/share/japanese/errmsg.txt
+++ b/sql/share/japanese/errmsg.txt
@@ -181,7 +181,7 @@
 "You are using safe update mode and you tried to update a table without a WHERE that uses a KEY column",
 "Key '%-.64s' doesn't exist in table '%-.64s'",
 "Can't open table",
-"The handler for the table doesn't support check/repair",
+"The handler for the table doesn't support %s",
 "You are not allowed to execute this command in a transaction",
 "Got error %d during COMMIT",
 "Got error %d during ROLLBACK",
@@ -245,4 +245,7 @@
 "Subselect returns more than 1 field",
 "Subselect returns more than 1 record",
 "Unknown prepared statement handler (%ld) given to %s",
-"Help database is corrupt or does not exist",
\ No newline at end of file
+"Help database is corrupt or does not exist",
+"Cyclic reference on subqueries",
+"Converting column '%s' from %s to %s",
+"Reference '%-.64s' not supported (%s)",
diff --git a/sql/share/korean/errmsg.txt b/sql/share/korean/errmsg.txt
index 27a8fdde027c54fca2d961224d571401a8fab81b..c20110e1aa5ed1bd620801f14fe19fc617ebef19 100644
--- a/sql/share/korean/errmsg.txt
+++ b/sql/share/korean/errmsg.txt
@@ -179,7 +179,7 @@
 "You are using safe update mode and you tried to update a table without a WHERE that uses a KEY column",
 "Key '%-.64s' doesn't exist in table '%-.64s'",
 "Can't open table",
-"The handler for the table doesn't support check/repair",
+"The handler for the table doesn't support %s",
 "You are not allowed to execute this command in a transaction",
 "Got error %d during COMMIT",
 "Got error %d during ROLLBACK",
@@ -243,4 +243,7 @@
 "Subselect returns more than 1 field",
 "Subselect returns more than 1 record",
 "Unknown prepared statement handler (%ld) given to %s",
-"Help database is corrupt or does not exist",
\ No newline at end of file
+"Help database is corrupt or does not exist",
+"Cyclic reference on subqueries",
+"Converting column '%s' from %s to %s",
+"Reference '%-.64s' not supported (%s)",
diff --git a/sql/share/norwegian-ny/errmsg.txt b/sql/share/norwegian-ny/errmsg.txt
index 8e8b5aa7e6158cb7434227d011e03d8b1c1340ac..c75c3ed6140be69def583c869741af8f0a399d93 100644
--- a/sql/share/norwegian-ny/errmsg.txt
+++ b/sql/share/norwegian-ny/errmsg.txt
@@ -181,7 +181,7 @@
 "You are using safe update mode and you tried to update a table without a WHERE that uses a KEY column",
 "Key '%-.64s' doesn't exist in table '%-.64s'",
 "Can't open table",
-"The handler for the table doesn't support check/repair",
+"The handler for the table doesn't support %s",
 "You are not allowed to execute this command in a transaction",
 "Got error %d during COMMIT",
 "Got error %d during ROLLBACK",
@@ -245,4 +245,7 @@
 "Subselect returns more than 1 field",
 "Subselect returns more than 1 record",
 "Unknown prepared statement handler (%ld) given to %s",
-"Help database is corrupt or does not exist",
\ No newline at end of file
+"Help database is corrupt or does not exist",
+"Cyclic reference on subqueries",
+"Converting column '%s' from %s to %s",
+"Reference '%-.64s' not supported (%s)",
diff --git a/sql/share/norwegian/errmsg.txt b/sql/share/norwegian/errmsg.txt
index 0f4650c186cb38af8c06ed71fd9383084da7b215..b5a660773ab1d14e4379c9f7088d0e8f4f823556 100644
--- a/sql/share/norwegian/errmsg.txt
+++ b/sql/share/norwegian/errmsg.txt
@@ -181,7 +181,7 @@
 "You are using safe update mode and you tried to update a table without a WHERE that uses a KEY column",
 "Key '%-.64s' doesn't exist in table '%-.64s'",
 "Can't open table",
-"The handler for the table doesn't support check/repair",
+"The handler for the table doesn't support %s",
 "You are not allowed to execute this command in a transaction",
 "Got error %d during COMMIT",
 "Got error %d during ROLLBACK",
@@ -245,4 +245,7 @@
 "Subselect returns more than 1 field",
 "Subselect returns more than 1 record",
 "Unknown prepared statement handler (%ld) given to %s",
-"Help database is corrupt or does not exist",
\ No newline at end of file
+"Help database is corrupt or does not exist",
+"Cyclic reference on subqueries",
+"Converting column '%s' from %s to %s",
+"Reference '%-.64s' not supported (%s)",
diff --git a/sql/share/polish/errmsg.txt b/sql/share/polish/errmsg.txt
index 758e96e5ca3d5429f908de5e324453a05c1e6d82..c65a16bf1e43f0abc29915ac55eb92df6403aa40 100644
--- a/sql/share/polish/errmsg.txt
+++ b/sql/share/polish/errmsg.txt
@@ -183,7 +183,7 @@
 "You are using safe update mode and you tried to update a table without a WHERE that uses a KEY column",
 "Key '%-.64s' doesn't exist in table '%-.64s'",
 "Can't open table",
-"The handler for the table doesn't support check/repair",
+"The handler for the table doesn't support %s",
 "You are not allowed to execute this command in a transaction",
 "Got error %d during COMMIT",
 "Got error %d during ROLLBACK",
@@ -247,4 +247,7 @@
 "Subselect returns more than 1 field",
 "Subselect returns more than 1 record",
 "Unknown prepared statement handler (%ld) given to %s",
-"Help database is corrupt or does not exist",
\ No newline at end of file
+"Help database is corrupt or does not exist",
+"Cyclic reference on subqueries",
+"Converting column '%s' from %s to %s",
+"Reference '%-.64s' not supported (%s)",
diff --git a/sql/share/portuguese/errmsg.txt b/sql/share/portuguese/errmsg.txt
index 21ebe5c39dc27a3dcca0a1b29952b9b1822fbf1a..355ae90c1574e1976d055243b856454efb04577b 100644
--- a/sql/share/portuguese/errmsg.txt
+++ b/sql/share/portuguese/errmsg.txt
@@ -179,7 +179,7 @@
 "Você está usando modo de atualização seguro e tentou atualizar uma tabela sem uma cláusula WHERE que use uma coluna chave",
 "Chave '%-.64s' não existe na tabela '%-.64s'",
 "Não pode abrir a tabela",
-"O manipulador de tabela não suporta checagem/reparação (check/repair)",
+"O manipulador de tabela não suporta %s",
 "Não lhe é permitido executar este comando em uma transação",
 "Obteve erro %d durante COMMIT",
 "Obteve erro %d durante ROLLBACK",
@@ -243,4 +243,7 @@
 "Subselect returns more than 1 field",
 "Subselect returns more than 1 record",
 "Unknown prepared statement handler (%ld) given to %s",
-"Help database is corrupt or does not exist",
\ No newline at end of file
+"Help database is corrupt or does not exist",
+"Cyclic reference on subqueries",
+"Converting column '%s' from %s to %s",
+"Reference '%-.64s' not supported (%s)",
diff --git a/sql/share/romanian/errmsg.txt b/sql/share/romanian/errmsg.txt
index c84049d6192003f9762abb86bc28cba6e406d037..c7a5b41deacf5c99acd390a09ad49eb17f7dc793 100644
--- a/sql/share/romanian/errmsg.txt
+++ b/sql/share/romanian/errmsg.txt
@@ -183,7 +183,7 @@
 "You are using safe update mode and you tried to update a table without a WHERE that uses a KEY column",
 "Key '%-.64s' doesn't exist in table '%-.64s'",
 "Can't open table",
-"The handler for the table doesn't support check/repair",
+"The handler for the table doesn't support %s",
 "You are not allowed to execute this command in a transaction",
 "Got error %d during COMMIT",
 "Got error %d during ROLLBACK",
@@ -247,4 +247,7 @@
 "Subselect returns more than 1 field",
 "Subselect returns more than 1 record",
 "Unknown prepared statement handler (%ld) given to %s",
-"Help database is corrupt or does not exist",
\ No newline at end of file
+"Help database is corrupt or does not exist",
+"Cyclic reference on subqueries",
+"Converting column '%s' from %s to %s"
+"Reference '%-.64s' not supported (%s)",
diff --git a/sql/share/russian/errmsg.txt b/sql/share/russian/errmsg.txt
index 0ee79ce5811bf63ab0490be410e6911c5af632be..35134e6d9d582d748541908bea4393a03e112e8f 100644
--- a/sql/share/russian/errmsg.txt
+++ b/sql/share/russian/errmsg.txt
@@ -182,7 +182,7 @@
 "MySQL ÒÁÂÏÔÁÅÔ × ÒÅÖÉÍÅ ÚÁÝÉÔÙ ÏÔ ÄÕÒÁËÏ× (safe_mode) - ÎÅ ÍÏÇÕ UPDATE ÂÅÚ WHERE Ó ËÁËÉÍ-ÎÅÂÕÄØ KEY",
 "éÎÄÅËÓ '%-.64s' ÎÅ ÎÁÊÄÅÎ × ÔÁÂÌÉÃÅ '%-.64s'",
 "îÅ ÍÏÇÕ ÏÔËÒÙÔØ ÔÁÂÌÉÃÕ",
-"äÁÎÎÙÊ ÔÉÐ ÔÁÂÌÉà ÎÅ ÐÏÄÄÅÒÖÉ×ÁÅÔ check/repair",
+"äÁÎÎÙÊ ÔÉÐ ÔÁÂÌÉà ÎÅ ÐÏÄÄÅÒÖÉ×ÁÅÔ ËÏÍÁÎÄÕ %s",
 "üÔÁ ËÏÍÁÎÄÁ ×ÎÕÔÒÉ ÔÒÁÎÚÁËÃÉÉ ÚÁÐÒÅÝÅÎÁ",
 "ïÛÉÂËÁ %d ×Ï ×ÒÅÍÑ COMMIT",
 "ïÛÉÂËÁ %d ×Ï ×ÒÅÍÑ ROLLBACK",
@@ -246,4 +246,7 @@
 "ðÏÄÚÁÐÒÏÓ ×ÏÚ×ÒÁÝÁÅÔ ÂÏÌÅÅ ÏÄÎÏÇÏ ÐÏÌÑ",
 "ðÏÄÚÁÐÒÏÓ ×ÏÚ×ÒÁÝÁÅÔ ÂÏÌÅÅ ÏÄÎÏÊ ÚÁÐÉÓÉ",
 "Unknown prepared statement handler (%ld) given to %s",
-"Help database is corrupt or does not exist",
\ No newline at end of file
+"Help database is corrupt or does not exist",
+"ãÉËÌÉÞÅÓËÁÑ ÓÓÙÌËÁ ÎÁ ÐÏÄÚÁÐÒÏÓ",
+"ðÒÅÏÂÒÁÚÏ×ÁÎÉÅ ÐÏÌÑ '%s' ÉÚ %s × %s",
+"óÓÙÌËÁ '%-.64s' ÎÅ ÐÏÄÄÅÒÖÉ×ÁÅÔÓÑ (%s)",
diff --git a/sql/share/serbian/errmsg.txt b/sql/share/serbian/errmsg.txt
index d120630b636b6d68f23e7771eb9f4891c6ee920d..354c0bdfac46573b572ae753fe96a85bcd2723a6 100644
--- a/sql/share/serbian/errmsg.txt
+++ b/sql/share/serbian/errmsg.txt
@@ -239,4 +239,7 @@
 "Subselect returns more than 1 field",
 "Subselect returns more than 1 record",
 "Unknown prepared statement handler (%ld) given to %s",
-"Help database is corrupt or does not exist",
\ No newline at end of file
+"Help database is corrupt or does not exist",
+"Cyclic reference on subqueries",
+"Converting column '%s' from %s to %s",
+"Reference '%-.64s' not supported (%s)",
diff --git a/sql/share/slovak/errmsg.txt b/sql/share/slovak/errmsg.txt
index eb9e2a240a09f6d55afd572458f031eee19f6b0d..4f49aeb2f6e2c7f33ff0cbc96b222a62143be6f3 100644
--- a/sql/share/slovak/errmsg.txt
+++ b/sql/share/slovak/errmsg.txt
@@ -187,7 +187,7 @@
 "You are using safe update mode and you tried to update a table without a WHERE that uses a KEY column",
 "Key '%-.64s' doesn't exist in table '%-.64s'",
 "Can't open table",
-"The handler for the table doesn't support check/repair",
+"The handler for the table doesn't support %s",
 "You are not allowed to execute this command in a transaction",
 "Got error %d during COMMIT",
 "Got error %d during ROLLBACK",
@@ -251,4 +251,7 @@
 "Subselect returns more than 1 field",
 "Subselect returns more than 1 record",
 "Unknown prepared statement handler (%ld) given to %s",
-"Help database is corrupt or does not exist",
\ No newline at end of file
+"Help database is corrupt or does not exist",
+"Cyclic reference on subqueries",
+"Converting column '%s' from %s to %s",
+"Reference '%-.64s' not supported (%s)",
diff --git a/sql/share/spanish/errmsg.txt b/sql/share/spanish/errmsg.txt
index 0b7de283481619df00240d42b52a884c02bb16b3..1bd4aed6897affb420696f2bc21bbeb851cf6a12 100644
--- a/sql/share/spanish/errmsg.txt
+++ b/sql/share/spanish/errmsg.txt
@@ -180,7 +180,7 @@
 "Tu estás usando modo de actualización segura y tentado actualizar una tabla sin un WHERE que usa una KEY columna",
 "Clave '%-.64s' no existe en la tabla '%-.64s'",
 "No puedo abrir tabla",
-"El manipulador de la tabla no permite soporte para check/repair",
+"El manipulador de la tabla no permite soporte para %s",
 "No tienes el permiso para ejecutar este comando en una transición",
 "Obtenido error %d durante COMMIT",
 "Obtenido error %d durante ROLLBACK",
@@ -244,4 +244,7 @@
 "Subselect returns more than 1 field",
 "Subselect returns more than 1 record",
 "Unknown prepared statement handler (%ld) given to %s",
-"Help database is corrupt or does not exist",
\ No newline at end of file
+"Help database is corrupt or does not exist",
+"Cyclic reference on subqueries",
+"Converting column '%s' from %s to %s",
+"Reference '%-.64s' not supported (%s)",
diff --git a/sql/share/swedish/errmsg.txt b/sql/share/swedish/errmsg.txt
index 052cd1506d3551eb1ea7e2d2637dc77363e20553..af3f7ca33dd3a3fd45ac4216cea37dc09df748db 100644
--- a/sql/share/swedish/errmsg.txt
+++ b/sql/share/swedish/errmsg.txt
@@ -179,7 +179,7 @@
 "Du använder 'säker uppdaterings mod' och försökte uppdatera en table utan en WHERE sats som använder sig av en nyckel",
 "Nyckel '%-.64s' finns inte in tabell '%-.64s'",
 "Kan inte öppna tabellen",
-"Tabellhanteraren för denna tabell kan inte göra check/repair",
+"Tabellhanteraren för denna tabell kan inte göra %s",
 "Du får inte utföra detta kommando i en transaktion",
 "Fick fel %d vid COMMIT",
 "Fick fel %d vid ROLLBACK",
@@ -229,18 +229,21 @@
 "Option '%s' användes två gånger",
 "Användare '%-.64s' har överskridit '%s' (nuvarande värde: %ld)",
 "Du har inte privlegiet '%-.128s' som behövs för denna operation",
-"Variable '%-.64s' is a LOCAL variable and can't be used with SET GLOBAL",
-"Variable '%-.64s' is a GLOBAL variable and should be set with SET GLOBAL",
-"Variable '%-.64s' doesn't have a default value",
-"Variable '%-.64s' can't be set to the value of '%-.64s'",
-"Wrong argument type to variable '%-.64s'",
-"Variable '%-.64s' can only be set, not read",
-"Wrong usage/placement of '%s'",
-"This version of MySQL doesn't yet support '%s'",
-"Got fatal error %d: '%-.128s' from master when reading data from binary log",
-"Wrong foreign key definition for '%-.64s': %s",
-"Key reference and table reference doesn't match",
-"Subselect returns more than 1 field",
-"Subselect returns more than 1 record",
-"Unknown prepared statement handler (%ld) given to %s",
-"Help database is corrupt or does not exist",
\ No newline at end of file
+"Variable '%-.64s' är en LOCAL variabel och kan inte ändrad med SET GLOBAL",
+"Variable '%-.64s' är en GLOBAL variabel och bör sättas med SET GLOBAL",
+"Variable '%-.64s' har inte ett DEFAULT värde",
+"Variable '%-.64s' kan inte be satt till '%-.64s'",
+"Fel typ av argument till variabel '%-.64s'",
+"Variabeln '%-.64s' kan endast sättas, inte läsas",
+"Fel använding/placering av '%s'",
+"Denna version av MySQL kan inte utföra '%s'",
+"Fick fatalt fel %d: '%-.128s' från master vid läsning av binär loggen",
+"Felaktig FOREIGN KEY definition för '%-.64s': %s",
+"Nyckel referensen och table referensen stämmer inte överens",
+"Subselect returnerade mer än 1 fält",
+"Subselect returnerade mer än 1 rad",
+"Okänd PREPARED STATEMENT id (%ld) var given till %s",
+"Hjälp databasen finns inte eller är skadad",
+"Syklisk referens i subselect",
+"Konvertar kolumn '%s' från %s till %s",
+"Reference '%-.64s' not supported (%s)",
diff --git a/sql/share/ukrainian/errmsg.txt b/sql/share/ukrainian/errmsg.txt
index 5cfad494a32848018fbb470a569927c967a201ee..c5bfff130fda16e201721284958e866dffffd743 100644
--- a/sql/share/ukrainian/errmsg.txt
+++ b/sql/share/ukrainian/errmsg.txt
@@ -184,7 +184,7 @@
 "÷É Õ ÒÅÖÉͦ ÂÅÚÐÅÞÎÏÇÏ ÏÎÏ×ÌÅÎÎÑ ÔÁ ÎÁÍÁÇÁ¤ÔÅÓØ ÏÎÏ×ÉÔÉ ÔÁÂÌÉÃÀ ÂÅÚ ÏÐÅÒÁÔÏÒÁ WHERE, ÝÏ ×ÉËÏÒÉÓÔÏ×Õ¤ KEY ÓÔÏ×ÂÅÃØ",
 "ëÌÀÞ '%-.64s' ÎÅ ¦ÓÎÕ¤ × ÔÁÂÌÉæ '%-.64s'",
 "îÅ ÍÏÖÕ ×¦ÄËÒÉÔÉ ÔÁÂÌÉÃÀ",
-"÷ËÁÚ¦×ÎÉË ÔÁÂÌÉæ ΊЦÄÔÒÉÍÕÅ ÐÅÒÅצÒËÕ/צÄÎÏ×ÌÅÎÎÑ",
+"÷ËÁÚ¦×ÎÉË ÔÁÂÌÉæ ΊЦÄÔÒÉÍÕÅ %s",
 "÷ÁÍ ÎÅ ÄÏÚ×ÏÌÅÎÏ ×ÉËÏÎÕ×ÁÔÉ ÃÀ ËÏÍÁÎÄÕ × ÔÒÁÎÚÁËæ§",
 "ïÔÒÉÍÁÎÏ ÐÏÍÉÌËÕ %d Ð¦Ä ÞÁÓ COMMIT",
 "ïÔÒÉÍÁÎÏ ÐÏÍÉÌËÕ %d Ð¦Ä ÞÁÓ ROLLBACK",
@@ -248,4 +248,7 @@
 "ðiÄÚÁÐÉÔ ÐÏ×ÅÒÔÁ¤ ÂiÌØÛ ÎiÖ 1 ÓÔÏ×ÂÅÃØ",
 "ðiÄÚÁÐÉÔ ÐÏ×ÅÒÔÁ¤ ÂiÌØÛ ÎiÖ 1 ÚÁÐÉÓ",
 "Unknown prepared statement handler (%ld) given to %s",
-"Help database is corrupt or does not exist",
\ No newline at end of file
+"Help database is corrupt or does not exist",
+"ãÉËÌiÞÎÅ ÐÏÓÉÌÁÎÎÑ ÎÁ ÐiÄÚÁÐÉÔ",
+"ðÅÒÅÔ×ÏÒÅÎÎÑ ÓÔÏ×ÂÃÁ '%s' Ú %s Õ %s",
+"ðÏÓÉÌÁÎÎÑ '%-.64s' ÎÅ ÐiÄÔÒÉÍÕÅÔÓÑ (%s)",
diff --git a/sql/slave.cc b/sql/slave.cc
index a07fd7ac7d1ed180e30695f51ea90dbcc1f8f2ff..f8acc592afa57365eb142cb7c3b957ed29487bbe 100644
--- a/sql/slave.cc
+++ b/sql/slave.cc
@@ -608,7 +608,7 @@ void init_table_rule_hash(HASH* h, bool* h_inited)
 {
   hash_init(h, system_charset_info,TABLE_RULE_HASH_SIZE,0,0,
 	    (hash_get_key) get_table_key,
-	    (void (*)(void*)) free_table_ent, 0);
+	    (hash_free_key) free_table_ent, 0);
   *h_inited = 1;
 }
 
@@ -638,9 +638,10 @@ static TABLE_RULE_ENT* find_wild(DYNAMIC_ARRAY *a, const char* key, int len)
     {
       TABLE_RULE_ENT* e ;
       get_dynamic(a, (gptr)&e, i);
-      if (!wild_case_compare(system_charset_info, key, key_end, 
+      if (!my_wildcmp(system_charset_info, key, key_end, 
                             (const char*)e->db,
-			    (const char*)(e->db + e->key_len),'\\'))
+			    (const char*)(e->db + e->key_len),
+			    '\\',wild_one,wild_many))
 	return e;
     }
   
@@ -1636,7 +1637,7 @@ bool flush_master_info(MASTER_INFO* mi)
   DBUG_PRINT("enter",("master_pos: %ld", (long) mi->master_log_pos));
 
   my_b_seek(file, 0L);
-  my_b_printf(file, "%s\n%s\n%s\n%s\n%s\n%d\n%d\n%d\n",
+  my_b_printf(file, "%s\n%s\n%s\n%s\n%s\n%d\n%d\n",
 	      mi->master_log_name, llstr(mi->master_log_pos, lbuf),
 	      mi->host, mi->user,
 	      mi->password, mi->port, mi->connect_retry
@@ -1944,7 +1945,7 @@ int check_expected_error(THD* thd, RELAY_LOG_INFO* rli, int expected_error)
 		"Slave: query '%s' partially completed on the master \
 and was aborted. There is a chance that your master is inconsistent at this \
 point. If you are sure that your master is ok, run this query manually on the\
- slave and then restart the slave with SET SQL_SLAVE_SKIP_COUNTER=1;\
+ slave and then restart the slave with SET GLOBAL SQL_SLAVE_SKIP_COUNTER=1;\
  SLAVE START;", thd->query);
     rli->last_slave_errno = expected_error;
     sql_print_error("%s",rli->last_slave_error);
@@ -2024,11 +2025,10 @@ This may also be a network problem, or just a bug in the master or slave code.\
 }
 
 /*****************************************************************************
-
   Slave I/O Thread entry point
-
 *****************************************************************************/
-pthread_handler_decl(handle_slave_io,arg)
+
+extern "C" pthread_handler_decl(handle_slave_io,arg)
 {
   THD *thd; // needs to be first for thread_stack
   MYSQL *mysql;
@@ -2297,11 +2297,10 @@ log space");
 }
 
 /*****************************************************************************
-
   Slave SQL Thread entry point
-
 *****************************************************************************/
-pthread_handler_decl(handle_slave_sql,arg)
+
+extern "C" pthread_handler_decl(handle_slave_sql,arg)
 {
   THD *thd;			/* needs to be first for thread_stack */
   char llbuff[22],llbuff1[22];
@@ -2477,7 +2476,7 @@ static int process_io_create_file(MASTER_INFO* mi, Create_file_log_event* cev)
      in the loop
   */
   {
-    Append_block_log_event aev(thd,0,0);
+    Append_block_log_event aev(thd,0,0,0);
   
     for (;;)
     {
@@ -2490,7 +2489,7 @@ static int process_io_create_file(MASTER_INFO* mi, Create_file_log_event* cev)
       if (unlikely(!num_bytes)) /* eof */
       {
 	net_write_command(net, 0, "", 0, "", 0);/* 3.23 master wants it */
-	Execute_load_log_event xev(thd);
+	Execute_load_log_event xev(thd,0);
 	xev.log_pos = mi->master_log_pos;
 	if (unlikely(mi->rli.relay_log.append(&xev)))
 	{
diff --git a/sql/slave.h b/sql/slave.h
index 74c89f9d755e744766e0a93ea33e70aa25c0f003..2c750e415bcb8702e611e12b6def608cd46317ce 100644
--- a/sql/slave.h
+++ b/sql/slave.h
@@ -436,8 +436,8 @@ int init_relay_log_pos(RELAY_LOG_INFO* rli,const char* log,ulonglong pos,
 int purge_relay_logs(RELAY_LOG_INFO* rli, THD *thd, bool just_reset,
 		     const char** errmsg);
 
-pthread_handler_decl(handle_slave_io,arg);
-pthread_handler_decl(handle_slave_sql,arg);
+extern "C" pthread_handler_decl(handle_slave_io,arg);
+extern "C" pthread_handler_decl(handle_slave_sql,arg);
 extern bool volatile abort_loop;
 extern MASTER_INFO main_mi, *active_mi; /* active_mi for multi-master */
 extern volatile int active_mi_in_use;
diff --git a/sql/sql_acl.cc b/sql/sql_acl.cc
index 5f8cf42c2bf94cd863b6eb4af0276aa86eacc835..d741c53d127563f1c1ea6d6c20e097a0219efb77 100644
--- a/sql/sql_acl.cc
+++ b/sql/sql_acl.cc
@@ -119,6 +119,7 @@ static bool compare_hostname(const acl_host_and_ip *host, const char *hostname,
 
   SYNOPSIS
     acl_init()
+    thd				Thread handler
     dont_read_acl_tables	Set to 1 if run with --skip-grant
 
   RETURN VALUES
@@ -127,9 +128,9 @@ static bool compare_hostname(const acl_host_and_ip *host, const char *hostname,
 */
 
 
-my_bool acl_init(bool dont_read_acl_tables)
+my_bool acl_init(THD *org_thd, bool dont_read_acl_tables)
 {
-  THD  *thd, *org_thd;
+  THD  *thd;
   TABLE_LIST tables[3];
   TABLE *table;
   READ_RECORD read_record_info;
@@ -140,14 +141,13 @@ my_bool acl_init(bool dont_read_acl_tables)
   if (!acl_cache)
     acl_cache=new hash_filo(ACL_CACHE_SIZE,0,0,
 			    (hash_get_key) acl_entry_get_key,
-			    (void (*)(void*)) free);
+			    (hash_free_key) free);
   if (dont_read_acl_tables)
     DBUG_RETURN(0); /* purecov: tested */
 
   /*
     To be able to run this from boot, we allocate a temporary THD
   */
-  org_thd=current_thd;				// Save for restore
   if (!(thd=new THD))
     DBUG_RETURN(1); /* purecov: inspected */
   thd->store_globals();
@@ -339,6 +339,11 @@ my_bool acl_init(bool dont_read_acl_tables)
   delete thd;
   if (org_thd)
     org_thd->store_globals();			/* purecov: inspected */
+  else
+  {
+    /* Remember that we don't have a THD */
+    my_pthread_setspecific_ptr(THR_THD,  0);
+  }
   DBUG_RETURN(return_val);
 }
 
@@ -385,7 +390,7 @@ void acl_reload(THD *thd)
   delete_dynamic(&acl_wild_hosts);
   hash_free(&acl_check_hosts);
 
-  if (acl_init(0))
+  if (acl_init(thd, 0))
   {					// Error. Revert to old list
     acl_free();				/* purecov: inspected */
     acl_hosts=old_acl_hosts;
@@ -1089,7 +1094,7 @@ bool change_password(THD *thd, const char *host, const char *user,
 		acl_user->host.hostname ? acl_user->host.hostname : "",
 		new_password));
   mysql_update_log.write(thd, buff, query_length);
-  Query_log_event qinfo(thd, buff, query_length);
+  Query_log_event qinfo(thd, buff, query_length, 0);
   mysql_bin_log.write(&qinfo);
   DBUG_RETURN(0);
 }
@@ -1352,8 +1357,13 @@ static int replace_user_table(THD *thd, TABLE *table, const LEX_USER &combo,
 				strlen(thd->lex.x509_subject), system_charset_info);
       break;
     case SSL_TYPE_NOT_SPECIFIED:
-    case SSL_TYPE_NONE:				// Impossible
-      break;					// Nothing to do
+      break;
+    case SSL_TYPE_NONE:
+      table->field[24]->store("", 0, system_charset_info);
+      table->field[25]->store("", 0, system_charset_info);
+      table->field[26]->store("", 0, system_charset_info);
+      table->field[27]->store("", 0, system_charset_info);
+      break;
     }
 
     USER_RESOURCES mqh = thd->lex.mqh;
@@ -2275,9 +2285,9 @@ void  grant_free(void)
 
 /* Init grant array if possible */
 
-my_bool grant_init(void)
+my_bool grant_init(THD *org_thd)
 {
-  THD  *thd, *org_thd;
+  THD  *thd;
   TABLE_LIST tables[2];
   MYSQL_LOCK *lock;
   my_bool return_val= 1;
@@ -2294,7 +2304,6 @@ my_bool grant_init(void)
   if (!initialized)
     DBUG_RETURN(0);				/* purecov: tested */
 
-  org_thd=current_thd;
   if (!(thd=new THD))
     DBUG_RETURN(1);				/* purecov: deadcode */
   thd->store_globals();
@@ -2352,13 +2361,18 @@ my_bool grant_init(void)
   delete thd;
   if (org_thd)
     org_thd->store_globals();
+  else
+  {
+    /* Remember that we don't have a THD */
+    my_pthread_setspecific_ptr(THR_THD,  0);
+  }
   DBUG_RETURN(return_val);
 }
 
 
 /* Reload grant array if possible */
 
-void grant_reload(void)
+void grant_reload(THD *thd)
 {
   HASH old_hash_tables;bool old_grant_option;
   MEM_ROOT old_mem;
@@ -2372,7 +2386,7 @@ void grant_reload(void)
   old_grant_option = grant_option;
   old_mem = memex;
 
-  if (grant_init())
+  if (grant_init(thd))
   {						// Error. Revert to old hash
     grant_free();				/* purecov: deadcode */
     hash_tables=old_hash_tables;		/* purecov: deadcode */
diff --git a/sql/sql_acl.h b/sql/sql_acl.h
index 326a55ddd0cb3d146e77d3dd0ed8b68e53e63a2c..6925b6b406cde352f2809b927348461f111c0ee9 100644
--- a/sql/sql_acl.h
+++ b/sql/sql_acl.h
@@ -81,7 +81,7 @@
 
 /* prototypes */
 
-my_bool  acl_init(bool dont_read_acl_tables);
+my_bool  acl_init(THD *thd, bool dont_read_acl_tables);
 void acl_reload(THD *thd);
 void acl_free(bool end=0);
 ulong acl_get(const char *host, const char *ip, const char *bin_ip,
@@ -98,9 +98,9 @@ int mysql_grant(THD *thd, const char *db, List <LEX_USER> &user_list,
 int mysql_table_grant(THD *thd, TABLE_LIST *table, List <LEX_USER> &user_list,
 		      List <LEX_COLUMN> &column_list, ulong rights,
 		      bool revoke);
-my_bool grant_init(void);
+my_bool grant_init(THD *thd);
 void grant_free(void);
-void grant_reload(void);
+void grant_reload(THD *thd);
 bool check_grant(THD *thd, ulong want_access, TABLE_LIST *tables,
 		 uint show_command=0, bool dont_print_error=0);
 bool check_grant_column (THD *thd,TABLE *table, const char *name, uint length,
diff --git a/sql/sql_analyse.cc b/sql/sql_analyse.cc
index 5c735ab35d59641949a86534245fb4947e53a030..f98eb0e0b26265e9747c1028157ac5de1d7f876d 100644
--- a/sql/sql_analyse.cc
+++ b/sql/sql_analyse.cc
@@ -677,7 +677,7 @@ bool analyse::end_of_records()
       case FIELD_TYPE_DECIMAL:
 	ans.append("DECIMAL", 7);
 	// if item is FIELD_ITEM, it _must_be_ Field_num in this case
-	if (((Field_num*) (*f)->item)->zerofill)
+	if (((Field_num*) ((Item_field*) (*f)->item)->field)->zerofill)
 	  ans.append(" ZEROFILL");
 	break;
       default:
diff --git a/sql/sql_base.cc b/sql/sql_base.cc
index 77253d49ed0ad4502909bcc98b733c6bf7cb8ee5..09b29c6b41d5262ab42671310a8333488b905b60 100644
--- a/sql/sql_base.cc
+++ b/sql/sql_base.cc
@@ -39,8 +39,8 @@ static key_map get_key_map_from_key_list(TABLE *table,
 					 List<String> *index_list);
 
 
-static byte *cache_key(const byte *record,uint *length,
-		       my_bool not_used __attribute__((unused)))
+extern "C" byte *table_cache_key(const byte *record,uint *length,
+				 my_bool not_used __attribute__((unused)))
 {
   TABLE *entry=(TABLE*) record;
   *length=entry->key_length;
@@ -50,8 +50,8 @@ static byte *cache_key(const byte *record,uint *length,
 void table_cache_init(void)
 {
   VOID(hash_init(&open_cache,system_charset_info,
-		 table_cache_size+16,0,0,cache_key,
-		 (void (*)(void*)) free_cache_entry,0));
+		 table_cache_size+16,0,0,table_cache_key,
+		 (hash_free_key) free_cache_entry,0));
   mysql_rm_tmp_tables();
 }
 
@@ -536,14 +536,14 @@ bool close_cached_tables(THD *thd, bool if_wait_for_refresh,
     if (!found)
       if_wait_for_refresh=0;			// Nothing to wait for
   }
+  if (!tables)
+    kill_delayed_threads();
   if (if_wait_for_refresh)
   {
     /*
       If there is any table that has a lower refresh_version, wait until
       this is closed (or this thread is killed) before returning
     */
-    if (!tables)
-      kill_delayed_threads();
     thd->mysys_var->current_mutex= &LOCK_open;
     thd->mysys_var->current_cond= &COND_refresh;
     thd->proc_info="Flushing tables";
@@ -699,26 +699,20 @@ void close_temporary_tables(THD *thd)
 {
   TABLE *table,*next;
   char *query, *end;
-  const uint init_query_buf_size = 11;		// "drop table "
   uint query_buf_size; 
   bool found_user_tables = 0;
 
+  if (!thd->temporary_tables)
+    return;
+  
   LINT_INIT(end);
-  query_buf_size = init_query_buf_size;
+  query_buf_size= 50;   // Enough for DROP ... TABLE
 
   for (table=thd->temporary_tables ; table ; table=table->next)
-  {
     query_buf_size += table->key_length;
-  }
-
-  if (query_buf_size == init_query_buf_size)
-    return; // no tables to close
 
   if ((query = alloc_root(&thd->mem_root, query_buf_size)))
-  {
-    memcpy(query, "drop table ", init_query_buf_size);
-    end = query + init_query_buf_size;
-  }
+    end=strmov(query, "DROP /*!40005 TEMPORARY */ TABLE ");
 
   for (table=thd->temporary_tables ; table ; table=next)
   {
@@ -727,12 +721,14 @@ void close_temporary_tables(THD *thd)
       // skip temporary tables not created directly by the user
       if (table->real_name[0] != '#')
       {
-	end = strxmov(end,table->table_cache_key,".",
-		      table->real_name,",", NullS);
-	// here we assume table_cache_key always starts
-	// with \0 terminated db name
+	/*
+	  Here we assume table_cache_key always starts
+	  with \0 terminated db name
+	*/
 	found_user_tables = 1;
       }
+      end = strxmov(end,table->table_cache_key,".",
+		    table->real_name,",", NullS);
     }
     next=table->next;
     close_temporary(table);
@@ -740,7 +736,7 @@ void close_temporary_tables(THD *thd)
   if (query && found_user_tables && mysql_bin_log.is_open())
   {
     /* The -1 is to remove last ',' */
-    Query_log_event qinfo(thd, query, (ulong)(end-query)-1);
+    Query_log_event qinfo(thd, query, (ulong)(end-query)-1, 0);
     qinfo.error_code=0;
     mysql_bin_log.write(&qinfo);
   }
@@ -1435,7 +1431,7 @@ static int open_unireg_entry(THD *thd, TABLE *entry, const char *db,
   int error;
   DBUG_ENTER("open_unireg_entry");
 
-  (void) sprintf(path,"%s/%s/%s",mysql_data_home,db,name);
+  strxmov(path, mysql_data_home, "/", db, "/", name, NullS);
   if (openfrm(path,alias,
 	       (uint) (HA_OPEN_KEYFILE | HA_OPEN_RNDFILE | HA_GET_INDEX |
 		       HA_TRY_READ_ONLY),
@@ -1564,6 +1560,61 @@ int open_tables(THD *thd,TABLE_LIST *start)
 }
 
 
+/*
+  Check that lock is ok for tables; Call start stmt if ok
+
+  SYNOPSIS
+    check_lock_and_start_stmt()
+    thd			Thread handle
+    table_list		Table to check
+    lock_type		Lock used for table
+
+  RETURN VALUES
+  0	ok
+  1	error
+*/
+
+static bool check_lock_and_start_stmt(THD *thd, TABLE *table,
+				      thr_lock_type lock_type)
+{
+  int error;
+  DBUG_ENTER("check_lock_and_start_stmt");
+
+  if ((int) lock_type >= (int) TL_WRITE_ALLOW_READ &&
+      (int) table->reginfo.lock_type < (int) TL_WRITE_ALLOW_READ)
+  {
+    my_printf_error(ER_TABLE_NOT_LOCKED_FOR_WRITE,
+		    ER(ER_TABLE_NOT_LOCKED_FOR_WRITE),
+		    MYF(0),table->table_name);
+    DBUG_RETURN(1);
+  }
+  if ((error=table->file->start_stmt(thd)))
+  {
+    table->file->print_error(error,MYF(0));
+    DBUG_RETURN(1);
+  }
+  DBUG_RETURN(0);
+}
+
+
+/*
+  Open and lock one table
+
+  SYNOPSIS
+    open_ltable()
+    thd			Thread handler
+    table_list		Table to open is first table in this list
+    lock_type		Lock to use for open
+
+  RETURN VALUES
+    table		Opened table
+    0			Error
+  
+    If ok, the following are also set:
+      table_list->lock_type 	lock_type
+      table_list->table		table
+*/
+
 TABLE *open_ltable(THD *thd, TABLE_LIST *table_list, thr_lock_type lock_type)
 {
   TABLE *table;
@@ -1574,10 +1625,9 @@ TABLE *open_ltable(THD *thd, TABLE_LIST *table_list, thr_lock_type lock_type)
   while (!(table=open_table(thd,table_list->db,
 			    table_list->real_name,table_list->alias,
 			    &refresh)) && refresh) ;
+
   if (table)
   {
-    int error;
-
 #if defined( __WIN__) || defined(OS2)
     /* Win32 can't drop a file that is open */
     if (lock_type == TL_WRITE_ALLOW_READ)
@@ -1585,39 +1635,29 @@ TABLE *open_ltable(THD *thd, TABLE_LIST *table_list, thr_lock_type lock_type)
       lock_type= TL_WRITE;
     }
 #endif /* __WIN__ || OS2 */
-
-    table_list->table=table;
+    table_list->lock_type= lock_type;
+    table_list->table=	   table;
     table->grant= table_list->grant;
     if (thd->locked_tables)
     {
-      thd->proc_info=0;
-      if ((int) lock_type >= (int) TL_WRITE_ALLOW_READ &&
-	  (int) table->reginfo.lock_type < (int) TL_WRITE_ALLOW_READ)
-      {
-	my_printf_error(ER_TABLE_NOT_LOCKED_FOR_WRITE,
-			ER(ER_TABLE_NOT_LOCKED_FOR_WRITE),
-			MYF(0),table_list->alias);
-	table=0;
-      }
-      else if ((error=table->file->start_stmt(thd)))
-      {
-	table->file->print_error(error,MYF(0));
-	table=0;
-      }
-      thd->proc_info=0;
-      DBUG_RETURN(table);
+      if (check_lock_and_start_stmt(thd, table, lock_type))
+	table= 0;
+    }
+    else
+    {
+      if ((table->reginfo.lock_type= lock_type) != TL_UNLOCK)
+	if (!(thd->lock=mysql_lock_tables(thd,&table_list->table,1)))
+	  table= 0;
     }
-    if ((table->reginfo.lock_type=lock_type) != TL_UNLOCK)
-      if (!(thd->lock=mysql_lock_tables(thd,&table_list->table,1)))
-	  DBUG_RETURN(0);
   }
   thd->proc_info=0;
   DBUG_RETURN(table);
 }
 
+
 /*
-** Open all tables in list and locks them for read.
-** The lock will automaticly be freed by the close_thread_tables
+  Open all tables in list and locks them for read.
+  The lock will automaticly be freed by close_thread_tables()
 */
 
 int open_and_lock_tables(THD *thd,TABLE_LIST *tables)
@@ -1627,10 +1667,27 @@ int open_and_lock_tables(THD *thd,TABLE_LIST *tables)
   return 0;
 }
 
+
+/*
+  Lock all tables in list
+
+  SYNOPSIS
+    lock_tables()
+    thd			Thread handler
+    tables		Tables to lock
+
+  RETURN VALUES
+   0	ok
+   -1	Error
+*/
+
 int lock_tables(THD *thd,TABLE_LIST *tables)
 {
   TABLE_LIST *table;
-  if (tables && !thd->locked_tables)
+  if (!tables)
+    return 0;
+
+  if (!thd->locked_tables)
   {
     uint count=0;
     for (table = tables ; table ; table=table->next)
@@ -1647,10 +1704,9 @@ int lock_tables(THD *thd,TABLE_LIST *tables)
   {
     for (table = tables ; table ; table=table->next)
     {
-      int error;
-      if ((error=table->table->file->start_stmt(thd)))
+      if (check_lock_and_start_stmt(thd, table->table, table->lock_type))
       {
-	table->table->file->print_error(error,MYF(0));
+	ha_rollback_stmt(thd);
 	return -1;
       }
     }
@@ -1658,10 +1714,11 @@ int lock_tables(THD *thd,TABLE_LIST *tables)
   return 0;
 }
 
+
 /*
-** Open a single table without table caching and don't set it in open_list
-** Used by alter_table to open a temporary table and when creating
-** a temporary table with CREATE TEMPORARY ...
+  Open a single table without table caching and don't set it in open_list
+  Used by alter_table to open a temporary table and when creating
+  a temporary table with CREATE TEMPORARY ...
 */
 
 TABLE *open_temporary_table(THD *thd, const char *path, const char *db,
@@ -1670,11 +1727,13 @@ TABLE *open_temporary_table(THD *thd, const char *path, const char *db,
   TABLE *tmp_table;
   DBUG_ENTER("open_temporary_table");
 
-  // the extra size in my_malloc() is for table_cache_key
-  //  4 bytes for master thread id if we are in the slave
-  //  1 byte to terminate db
-  //  1 byte to terminate table_name
-  // total of 6 extra bytes in my_malloc in addition to table/db stuff
+  /*
+    The extra size in my_malloc() is for table_cache_key
+    4 bytes for master thread id if we are in the slave
+    1 byte to terminate db
+    1 byte to terminate table_name
+    total of 6 extra bytes in my_malloc in addition to table/db stuff
+  */
   if (!(tmp_table=(TABLE*) my_malloc(sizeof(*tmp_table)+(uint) strlen(db)+
 				     (uint) strlen(table_name)+6,
 				     MYF(MY_WME))))
@@ -1748,7 +1807,9 @@ Field *find_field_in_table(THD *thd,TABLE *table,const char *name,uint length,
   }
   else
   {
-    Field **ptr=table->field;
+    Field **ptr;
+    if (!(ptr=table->field))
+      return (Field *)0;
     while ((field = *ptr++))
     {
       if (!my_strcasecmp(system_charset_info, field->field_name, name))
@@ -1801,7 +1862,7 @@ const Field *not_found_field= (Field*) 0x1;
 */
 
 Field *
-find_field_in_tables(THD *thd, Item_field *item, TABLE_LIST *tables,
+find_field_in_tables(THD *thd, Item_ident *item, TABLE_LIST *tables,
 		     bool report_error)
 {
   Field *found=0;
@@ -2001,9 +2062,9 @@ int setup_fields(THD *thd, TABLE_LIST *tables, List<Item> &fields,
     if (item->type() == Item::FIELD_ITEM &&
 	((Item_field*) item)->field_name[0] == '*')
     {
-      uint elem=fields.elements;
+      uint elem= fields.elements;
       if (insert_fields(thd,tables,((Item_field*) item)->db_name,
-			((Item_field*) item)->table_name,&it))
+			((Item_field*) item)->table_name, &it))
 	DBUG_RETURN(-1); /* purecov: inspected */
       if (sum_func_list)
       {
@@ -2019,6 +2080,7 @@ int setup_fields(THD *thd, TABLE_LIST *tables, List<Item> &fields,
     {
       if (item->fix_fields(thd, tables, it.ref()))
 	DBUG_RETURN(-1); /* purecov: inspected */
+      item= *(it.ref()); //Item can be chenged in fix fields
       if (item->with_sum_func && item->type() != Item::SUM_FUNC_ITEM &&
 	  sum_func_list)
 	item->split_sum_func(*sum_func_list);
@@ -2069,6 +2131,7 @@ bool setup_tables(TABLE_LIST *tables)
 	DBUG_RETURN(1);
       table->keys_in_use_for_query &= ~map;
     }
+    table->used_keys &= table->keys_in_use_for_query;
     if (table_list->shared)
     {
       /* Clear query_id that may have been set by previous select */
@@ -2164,8 +2227,8 @@ int setup_conds(THD *thd,TABLE_LIST *tables,COND **conds)
 {
   DBUG_ENTER("setup_conds");
   thd->set_query_id=1;
-  thd->cond_count=0;
-  thd->allow_sum_func=0;
+  
+  thd->cond_count= 0;
   if (*conds)
   {
     thd->where="where clause";
@@ -2200,6 +2263,7 @@ int setup_conds(THD *thd,TABLE_LIST *tables,COND **conds)
       Item_cond_and *cond_and=new Item_cond_and();
       if (!cond_and)				// If not out of memory
 	DBUG_RETURN(1);
+      cond_and->top_level_item();
 
       uint i,j;
       for (i=0 ; i < t1->fields ; i++)
diff --git a/sql/sql_cache.cc b/sql/sql_cache.cc
index 2f236da2aa3044bd16f854df0f68a4fc524afe6a..aa0f5824b4e9e393b6995cfa2a9d2de7ba6c5b1e 100644
--- a/sql/sql_cache.cc
+++ b/sql/sql_cache.cc
@@ -289,7 +289,7 @@ TODO list:
 
       if (thd->temp_tables || global_merge_table_count)
 
-    - Another option would be to set thd->safe_to_cache_query to 0
+    - Another option would be to set thd->lex.safe_to_cache_query to 0
       in 'get_lock_data' if any of the tables was a tmp table or a
       MRG_ISAM table.
       (This could be done with almost no speed penalty)
@@ -473,33 +473,6 @@ byte *query_cache_table_get_key(const byte *record, uint *length,
     Query_cache_query methods
 *****************************************************************************/
 
-void Query_cache_query::init_n_lock()
-{
-  DBUG_ENTER("Query_cache_query::init_n_lock");
-  res=0; wri = 0; len = 0;
-  my_rwlock_init(&lock, NULL);
-  lock_writing();
-  DBUG_PRINT("qcache", ("inited & locked query for block 0x%lx",
-			((byte*) this)-ALIGN_SIZE(sizeof(Query_cache_block))));
-  DBUG_VOID_RETURN;
-}
-
-
-void Query_cache_query::unlock_n_destroy()
-{
-  DBUG_ENTER("Query_cache_query::unlock_n_destroy");
-  DBUG_PRINT("qcache", ("destroyed & unlocked query for block 0x%lx",
-			((byte*)this)-ALIGN_SIZE(sizeof(Query_cache_block))));
-  /*
-    The following call is not needed on system where one can destroy an
-    active semaphore
-  */
-  this->unlock_writing();
-  rwlock_destroy(&lock);
-  DBUG_VOID_RETURN;
-}
-
-
 /*
    Following methods work for block read/write locking only in this
    particular case and in interaction with structure_guard_mutex.
@@ -551,6 +524,34 @@ inline void Query_cache_query::unlock_reading()
   RW_UNLOCK(&lock);
 }
 
+
+void Query_cache_query::init_n_lock()
+{
+  DBUG_ENTER("Query_cache_query::init_n_lock");
+  res=0; wri = 0; len = 0;
+  my_rwlock_init(&lock, NULL);
+  lock_writing();
+  DBUG_PRINT("qcache", ("inited & locked query for block 0x%lx",
+			((byte*) this)-ALIGN_SIZE(sizeof(Query_cache_block))));
+  DBUG_VOID_RETURN;
+}
+
+
+void Query_cache_query::unlock_n_destroy()
+{
+  DBUG_ENTER("Query_cache_query::unlock_n_destroy");
+  DBUG_PRINT("qcache", ("destroyed & unlocked query for block 0x%lx",
+			((byte*)this)-ALIGN_SIZE(sizeof(Query_cache_block))));
+  /*
+    The following call is not needed on system where one can destroy an
+    active semaphore
+  */
+  this->unlock_writing();
+  rwlock_destroy(&lock);
+  DBUG_VOID_RETURN;
+}
+
+
 extern "C"
 {
 byte *query_cache_query_get_key(const byte *record, uint *length,
@@ -714,19 +715,19 @@ void query_cache_invalidate_by_MyISAM_filename(const char *filename)
    Query_cache methods
 *****************************************************************************/
 
-Query_cache::Query_cache(ulong query_cache_limit,
-			 ulong min_allocation_unit,
-			 ulong min_result_data_size,
-			 uint def_query_hash_size ,
-			 uint def_table_hash_size)
+Query_cache::Query_cache(ulong query_cache_limit_arg,
+			 ulong min_allocation_unit_arg,
+			 ulong min_result_data_size_arg,
+			 uint def_query_hash_size_arg,
+			 uint def_table_hash_size_arg)
   :query_cache_size(0),
-   query_cache_limit(query_cache_limit),
+   query_cache_limit(query_cache_limit_arg),
    queries_in_cache(0), hits(0), inserts(0), refused(0),
-   total_blocks(0),
-   min_allocation_unit(ALIGN_SIZE(min_allocation_unit)),
-   min_result_data_size(ALIGN_SIZE(min_result_data_size)),
-   def_query_hash_size(ALIGN_SIZE(def_query_hash_size)),
-   def_table_hash_size(ALIGN_SIZE(def_table_hash_size)),
+   total_blocks(0), lowmem_prunes(0),
+   min_allocation_unit(ALIGN_SIZE(min_allocation_unit_arg)),
+   min_result_data_size(ALIGN_SIZE(min_result_data_size_arg)),
+   def_query_hash_size(ALIGN_SIZE(def_query_hash_size_arg)),
+   def_table_hash_size(ALIGN_SIZE(def_table_hash_size_arg)),
    initialized(0)
 {
   ulong min_needed= (ALIGN_SIZE(sizeof(Query_cache_block)) +
@@ -751,13 +752,13 @@ ulong Query_cache::resize(ulong query_cache_size_arg)
 
 void Query_cache::store_query(THD *thd, TABLE_LIST *tables_used)
 {
-  TABLE_COUNTER_TYPE tables;
+  TABLE_COUNTER_TYPE local_tables;
   ulong tot_length;
   DBUG_ENTER("Query_cache::store_query");
   if (query_cache_size == 0)
     DBUG_VOID_RETURN;
 
-  if ((tables = is_cacheable(thd, thd->query_length,
+  if ((local_tables = is_cacheable(thd, thd->query_length,
 			     thd->query, &thd->lex, tables_used)))
   {
     NET *net = &thd->net;
@@ -803,7 +804,7 @@ void Query_cache::store_query(THD *thd, TABLE_LIST *tables_used)
       Query_cache_block *query_block;
       query_block= write_block_data(tot_length, (gptr) thd->query,
 				    ALIGN_SIZE(sizeof(Query_cache_query)),
-				    Query_cache_block::QUERY, tables, 1);
+				    Query_cache_block::QUERY, local_tables, 1);
       if (query_block != 0)
       {
 	DBUG_PRINT("qcache", ("query block 0x%lx allocated, %lu",
@@ -820,7 +821,7 @@ void Query_cache::store_query(THD *thd, TABLE_LIST *tables_used)
 	  STRUCT_UNLOCK(&structure_guard_mutex);
 	  goto end;
 	}
-	if (!register_all_tables(query_block, tables_used, tables))
+	if (!register_all_tables(query_block, tables_used, local_tables))
 	{
 	  refused++;
 	  DBUG_PRINT("warning", ("tables list including failed"));
@@ -899,7 +900,7 @@ Query_cache::send_result_to_client(THD *thd, char *sql, uint query_length)
   /* Check that we haven't forgot to reset the query cache variables */
   DBUG_ASSERT(thd->net.query_cache_query == 0);
 
-  if (!thd->safe_to_cache_query)
+  if (!thd->lex.safe_to_cache_query)
   {
     DBUG_PRINT("qcache", ("SELECT is non-cacheable"));
     goto err;
@@ -993,7 +994,7 @@ Query_cache::send_result_to_client(THD *thd, char *sql, uint query_length)
 		  table_list.db, table_list.alias));
       refused++;				// This is actually a hit
       STRUCT_UNLOCK(&structure_guard_mutex);
-      thd->safe_to_cache_query=0;		// Don't try to cache this
+      thd->lex.safe_to_cache_query=0;		// Don't try to cache this
       BLOCK_UNLOCK_RD(query_block);
       DBUG_RETURN(-1);				// Privilege error
     }
@@ -1002,7 +1003,7 @@ Query_cache::send_result_to_client(THD *thd, char *sql, uint query_length)
       DBUG_PRINT("qcache", ("Need to check column privileges for %s.%s",
 			    table_list.db, table_list.alias));
       BLOCK_UNLOCK_RD(query_block);
-      thd->safe_to_cache_query=0;		// Don't try to cache this
+      thd->lex.safe_to_cache_query=0;		// Don't try to cache this
       goto err_unlock;				// Parse query
     }
   }
@@ -1527,6 +1528,7 @@ my_bool Query_cache::free_old_query()
     if (query_block != 0)
     {
       free_query(query_block);
+      lowmem_prunes++;
       DBUG_RETURN(0);
     }
   }
@@ -1796,7 +1798,7 @@ inline ulong Query_cache::get_min_append_result_data_size()
 my_bool Query_cache::allocate_data_chain(Query_cache_block **result_block,
 					 ulong data_len,
 					 Query_cache_block *query_block,
-					 my_bool first_block)
+					 my_bool first_block_arg)
 {
   ulong all_headers_len = (ALIGN_SIZE(sizeof(Query_cache_block)) +
 			   ALIGN_SIZE(sizeof(Query_cache_result)));
@@ -1806,7 +1808,7 @@ my_bool Query_cache::allocate_data_chain(Query_cache_block **result_block,
   DBUG_PRINT("qcache", ("data_len %lu, all_headers_len %lu",
 		      data_len, all_headers_len));
 
-  ulong min_size = (first_block ?
+  ulong min_size = (first_block_arg ?
 		    get_min_first_result_data_size():
 		    get_min_append_result_data_size());
   *result_block = allocate_block(max(min_size, align_len),
@@ -1833,7 +1835,7 @@ my_bool Query_cache::allocate_data_chain(Query_cache_block **result_block,
       Query_cache_block *next_block;
       if ((success = allocate_data_chain(&next_block,
 					 len - new_block->length,
-					 query_block, first_block)))
+					 query_block, first_block_arg)))
 	double_linked_list_join(new_block, next_block);
     }
     if (success)
@@ -1902,14 +1904,23 @@ void Query_cache::invalidate_table(Query_cache_block *table_block)
   }
 }
 
+/*
+  Store all used tables
+
+  SYNOPSIS
+    register_all_tables()
+    block		Store tables in this block
+    tables_used		List if used tables
+    tables_arg		Not used ?
+*/
 
 my_bool Query_cache::register_all_tables(Query_cache_block *block,
 					 TABLE_LIST *tables_used,
-					 TABLE_COUNTER_TYPE tables)
+					 TABLE_COUNTER_TYPE tables_arg)
 {
   TABLE_COUNTER_TYPE n;
   DBUG_PRINT("qcache", ("register tables block 0x%lx, n %d, header %x",
-		      (ulong) block, (int) tables,
+		      (ulong) block, (int) tables_arg,
 		      (int) ALIGN_SIZE(sizeof(Query_cache_block))));
 
   Query_cache_block_table *block_table = block->table(0);
@@ -2201,28 +2212,28 @@ void Query_cache::split_block(Query_cache_block *block, ulong len)
 
 
 Query_cache_block *
-Query_cache::join_free_blocks(Query_cache_block *first_block,
+Query_cache::join_free_blocks(Query_cache_block *first_block_arg,
 			      Query_cache_block *block_in_list)
 {
   Query_cache_block *second_block;
   DBUG_ENTER("Query_cache::join_free_blocks");
   DBUG_PRINT("qcache",
 	     ("join first 0x%lx, pnext 0x%lx, in list 0x%lx",
-	      (ulong) first_block, (ulong) first_block->pnext,
+	      (ulong) first_block_arg, (ulong) first_block_arg->pnext,
 	      (ulong) block_in_list));
 
   exclude_from_free_memory_list(block_in_list);
-  second_block = first_block->pnext;
+  second_block = first_block_arg->pnext;
   // May be was not free block
   second_block->used=0;
   second_block->destroy();
   total_blocks--;
 
-  first_block->length += second_block->length;
-  first_block->pnext = second_block->pnext;
-  second_block->pnext->pprev = first_block;
+  first_block_arg->length += second_block->length;
+  first_block_arg->pnext = second_block->pnext;
+  second_block->pnext->pprev = first_block_arg;
 
-  DBUG_RETURN(first_block);
+  DBUG_RETURN(first_block_arg);
 }
 
 
@@ -2439,14 +2450,14 @@ TABLE_COUNTER_TYPE Query_cache::is_cacheable(THD *thd, uint32 query_len,
 					     char *query,
 					     LEX *lex, TABLE_LIST *tables_used)
 {
-  TABLE_COUNTER_TYPE tables = 0;
+  TABLE_COUNTER_TYPE table_count = 0;
   DBUG_ENTER("Query_cache::is_cacheable");
 
   if (lex->sql_command == SQLCOM_SELECT &&
       (thd->variables.query_cache_type == 1 ||
        (thd->variables.query_cache_type == 2 && (lex->select_lex.options &
 						 OPTION_TO_QUERY_CACHE))) &&
-      thd->safe_to_cache_query)
+      lex->safe_to_cache_query)
   {
     my_bool has_transactions = 0;
     DBUG_PRINT("qcache", ("options %lx %lx, type %u",
@@ -2456,7 +2467,7 @@ TABLE_COUNTER_TYPE Query_cache::is_cacheable(THD *thd, uint32 query_len,
 
     for (; tables_used; tables_used= tables_used->next)
     {
-      tables++;
+      table_count++;
       DBUG_PRINT("qcache", ("table %s, db %s, type %u",
 			  tables_used->real_name,
 			  tables_used->db, tables_used->table->db_type));
@@ -2480,7 +2491,7 @@ TABLE_COUNTER_TYPE Query_cache::is_cacheable(THD *thd, uint32 query_len,
       {
 	ha_myisammrg *handler = (ha_myisammrg *)tables_used->table->file;
 	MYRG_INFO *file = handler->myrg_info();
-	tables+= (file->end_table - file->open_tables);
+	table_count+= (file->end_table - file->open_tables);
       }
     }
 
@@ -2490,8 +2501,8 @@ TABLE_COUNTER_TYPE Query_cache::is_cacheable(THD *thd, uint32 query_len,
       DBUG_PRINT("qcache", ("not in autocommin mode"));
       DBUG_RETURN(0);
     }
-    DBUG_PRINT("qcache", ("select is using %d tables", tables));
-    DBUG_RETURN(tables);
+    DBUG_PRINT("qcache", ("select is using %d tables", table_count));
+    DBUG_RETURN(table_count);
   }
 
   DBUG_PRINT("qcache",
diff --git a/sql/sql_cache.h b/sql/sql_cache.h
index f19e6630da5df68b15b8af449cf99b78bd616b61..b15df28f54ba71c1328b6937edf865f0d6502cc9 100644
--- a/sql/sql_cache.h
+++ b/sql/sql_cache.h
@@ -178,7 +178,7 @@ extern "C"
 				  my_bool not_used);
 }
 void query_cache_insert(NET *thd, const char *packet, ulong length);
-void query_cache_invalidate_by_MyISAM_filename(const char* filename);
+extern "C" void query_cache_invalidate_by_MyISAM_filename(const char* filename);
 
 
 struct Query_cache_memory_bin
@@ -219,7 +219,7 @@ class Query_cache
   ulong query_cache_size, query_cache_limit;
   /* statistics */
   ulong free_memory, queries_in_cache, hits, inserts, refused,
-    free_memory_blocks, total_blocks;
+    free_memory_blocks, total_blocks, lowmem_prunes;
 
 protected:
   /*
diff --git a/sql/sql_class.cc b/sql/sql_class.cc
index 887ee26277773c64f6d8087a4a9751b9a899eac7..9bca7245cba7c5a54f6c528acfd1275dbfa7c837 100644
--- a/sql/sql_class.cc
+++ b/sql/sql_class.cc
@@ -59,14 +59,14 @@ template class List_iterator<Alter_column>;
 ** User variables
 ****************************************************************************/
 
-static byte* get_var_key(user_var_entry *entry, uint *length,
-			 my_bool not_used __attribute__((unused)))
+extern "C" byte *get_var_key(user_var_entry *entry, uint *length,
+			     my_bool not_used __attribute__((unused)))
 {
   *length=(uint) entry->name.length;
   return (byte*) entry->name.str;
 }
 
-static void free_var(user_var_entry *entry)
+extern "C" void free_user_var(user_var_entry *entry)
 {
   char *pos= (char*) entry+ALIGN_SIZE(sizeof(*entry));
   if (entry->value && entry->value != pos)
@@ -87,10 +87,7 @@ THD::THD():user_time(0), fatal_error(0),
   host=user=priv_user=db=query=ip=0;
   host_or_ip="unknown ip";
   locked=killed=count_cuted_fields=some_tables_deleted=no_errors=password=
-    query_start_used=safe_to_cache_query=prepare_command=0;
-  pthread_mutex_lock(&LOCK_global_system_variables);
-  variables= global_system_variables;
-  pthread_mutex_unlock(&LOCK_global_system_variables);
+    query_start_used=prepare_command=0;
   db_length=query_length=col_access=0;
   query_error=0;
   next_insert_id=last_insert_id=0;
@@ -107,6 +104,7 @@ THD::THD():user_time(0), fatal_error(0),
   slave_proxy_id = 0;
   file_id = 0;
   cond_count=0;
+  warn_id= 0;
   db_charset=default_charset_info;
   thd_charset=default_charset_info;
   mysys_var=0;
@@ -132,19 +130,12 @@ THD::THD():user_time(0), fatal_error(0),
   server_id = ::server_id;
   slave_net = 0;
   log_pos = 0;
-  server_status= SERVER_STATUS_AUTOCOMMIT;
-  update_lock_default= (variables.low_priority_updates ?
-			TL_WRITE_LOW_PRIORITY :
-			TL_WRITE);
-  options= thd_startup_options;
-  sql_mode=(uint) opt_sql_mode;
-  open_options=ha_open_options;
-  session_tx_isolation= (enum_tx_isolation) variables.tx_isolation;
   command=COM_CONNECT;
   set_query_id=1;
   db_access=NO_ACCESS;
   version=refresh_version;			// For boot
 
+  init();
   /* Initialize sub structures */
   bzero((char*) &mem_root,sizeof(mem_root));
   bzero((char*) &transaction.mem_root,sizeof(transaction.mem_root));
@@ -156,7 +147,7 @@ THD::THD():user_time(0), fatal_error(0),
   user_connect=(USER_CONN *)0;
   hash_init(&user_vars, system_charset_info, USER_VARS_HASH_SIZE, 0, 0,
 	    (hash_get_key) get_var_key,
-	    (void (*)(void*)) free_var,0);
+	    (hash_free_key) free_user_var,0);
 
   /* Prepared statements */
   last_prepared_stmt= 0;
@@ -189,6 +180,48 @@ THD::THD():user_time(0), fatal_error(0),
   }
 }
 
+
+/*
+  Init common variables that has to be reset on start and on change_user
+*/
+
+void THD::init(void)
+{
+  server_status= SERVER_STATUS_AUTOCOMMIT;
+  update_lock_default= (variables.low_priority_updates ?
+			TL_WRITE_LOW_PRIORITY :
+			TL_WRITE);
+  options= thd_startup_options;
+  sql_mode=(uint) opt_sql_mode;
+  open_options=ha_open_options;
+  pthread_mutex_lock(&LOCK_global_system_variables);
+  variables= global_system_variables;
+  pthread_mutex_unlock(&LOCK_global_system_variables);
+  session_tx_isolation= (enum_tx_isolation) variables.tx_isolation;
+}
+
+/*
+  Do what's needed when one invokes change user
+
+  SYNOPSIS
+    change_user()
+
+  IMPLEMENTATION
+    Reset all resources that are connection specific
+*/
+
+
+void THD::change_user(void)
+{
+  cleanup();
+  cleanup_done= 0;
+  init();
+  hash_init(&user_vars, system_charset_info, USER_VARS_HASH_SIZE, 0, 0,
+	    (hash_get_key) get_var_key,
+	    (hash_free_key) free_user_var, 0);
+}
+
+
 /* Do operations that may take a long time */
 
 void THD::cleanup(void)
@@ -206,17 +239,21 @@ void THD::cleanup(void)
     close_thread_tables(this);
   }
   close_temporary_tables(this);
-#ifdef USING_TRANSACTIONS
-  if (opt_using_transactions)
+  hash_free(&user_vars);
+  if (global_read_lock)
+    unlock_global_read_lock(this);
+  if (ull)
   {
-    close_cached_file(&transaction.trans_log);
-    ha_close_connection(this);
+    pthread_mutex_lock(&LOCK_user_locks);
+    item_user_lock_release(ull);
+    pthread_mutex_unlock(&LOCK_user_locks);
+    ull= 0;
   }
-#endif
   cleanup_done=1;
   DBUG_VOID_RETURN;
 }
 
+
 THD::~THD()
 {
   THD_CHECK_SENTRY(this);
@@ -233,15 +270,13 @@ THD::~THD()
   }
   if (!cleanup_done)
     cleanup();
-  if (global_read_lock)
-    unlock_global_read_lock(this);
-  if (ull)
+#ifdef USING_TRANSACTIONS
+  if (opt_using_transactions)
   {
-    pthread_mutex_lock(&LOCK_user_locks);
-    item_user_lock_release(ull);
-    pthread_mutex_unlock(&LOCK_user_locks);
+    close_cached_file(&transaction.trans_log);
+    ha_close_connection(this);
   }
-  hash_free(&user_vars);
+#endif
 
   DBUG_PRINT("info", ("freeing host"));
   if (host != localhost)			// If not pointer to constant
@@ -337,20 +372,21 @@ void THD::add_changed_table(TABLE *table)
   DBUG_VOID_RETURN;
 }
 
+
 void THD::add_changed_table(const char *key, long key_length)
 {
   DBUG_ENTER("THD::add_changed_table(key)");
-  CHANGED_TABLE_LIST** prev = &transaction.changed_tables;
-  CHANGED_TABLE_LIST* curr = transaction.changed_tables;
+  CHANGED_TABLE_LIST **prev_changed = &transaction.changed_tables;
+  CHANGED_TABLE_LIST *curr = transaction.changed_tables;
 
-  for (; curr; prev = &(curr->next), curr = curr->next)
+  for (; curr; prev_changed = &(curr->next), curr = curr->next)
   {
     int cmp =  (long)curr->key_length - (long)key_length;
     if (cmp < 0)
     {
-      list_include(prev, curr, changed_table_dup(key, key_length));
+      list_include(prev_changed, curr, changed_table_dup(key, key_length));
       DBUG_PRINT("info", 
-		 ("key_length %u %u", key_length, (*prev)->key_length));
+		 ("key_length %u %u", key_length, (*prev_changed)->key_length));
       DBUG_VOID_RETURN;
     }
     else if (cmp == 0)
@@ -358,10 +394,10 @@ void THD::add_changed_table(const char *key, long key_length)
       cmp = memcmp(curr->key, key, curr->key_length);
       if (cmp < 0)
       {
-	list_include(prev, curr, changed_table_dup(key, key_length));
+	list_include(prev_changed, curr, changed_table_dup(key, key_length));
 	DBUG_PRINT("info", 
 		   ("key_length %u %u", key_length,
-		    (*prev)->key_length));
+		    (*prev_changed)->key_length));
 	DBUG_VOID_RETURN;
       }
       else if (cmp == 0)
@@ -371,9 +407,9 @@ void THD::add_changed_table(const char *key, long key_length)
       }
     }
   }
-  *prev = changed_table_dup(key, key_length);
+  *prev_changed = changed_table_dup(key, key_length);
   DBUG_PRINT("info", ("key_length %u %u", key_length,
-		      (*prev)->key_length));
+		      (*prev_changed)->key_length));
   DBUG_VOID_RETURN;
 }
 
@@ -434,6 +470,15 @@ void THD::close_active_vio()
 }
 #endif
 
+void THD::add_possible_loop (Item *item)
+{
+  if (!possible_loops)
+  {
+    possible_loops= new List<Item>;
+  }
+  possible_loops->push_back(item);
+}
+
 /*****************************************************************************
 ** Functions to provide a interface to select results
 *****************************************************************************/
@@ -872,9 +917,9 @@ bool select_singleval_subselect::send_data(List<Item> &items)
 {
   DBUG_ENTER("select_singleval_subselect::send_data");
   Item_singleval_subselect *it= (Item_singleval_subselect *)item;
-  if (it->assigned()){
-    thd->fatal_error= 1;
-    my_message(ER_SUBSELECT_NO_1_ROW, ER(ER_SUBSELECT_NO_1_ROW), MYF(0));
+  if (it->assigned())
+  {
+      my_message(ER_SUBSELECT_NO_1_ROW, ER(ER_SUBSELECT_NO_1_ROW), MYF(0));
     DBUG_RETURN(1);
   }
   if (unit->offset_limit_cnt)
diff --git a/sql/sql_class.h b/sql/sql_class.h
index 71f1625309f41ee8ac69504afb94f5b39fe513d3..a521da9a33fddac6fa4575a419b8ac5c4e3368f3 100644
--- a/sql/sql_class.h
+++ b/sql/sql_class.h
@@ -325,7 +325,7 @@ typedef struct st_prep_stmt
   uint param_count;
   uint last_errno;
   char last_error[MYSQL_ERRMSG_SIZE];
-  bool error_in_prepare, long_data_used;
+  bool error_in_prepare, long_data_used, param_inited;
 } PREP_STMT;
 
 
@@ -341,13 +341,14 @@ struct system_variables
 {
   ulonglong myisam_max_extra_sort_file_size;
   ulonglong myisam_max_sort_file_size;
+  ulonglong select_limit;
+  ulonglong max_join_size;
   ulong bulk_insert_buff_size;
   ulong join_buff_size;
   ulong long_query_time;
   ulong max_allowed_packet;
   ulong max_error_count;
   ulong max_heap_table_size;
-  ulong max_join_size;
   ulong max_prep_stmt_count;
   ulong max_sort_length;
   ulong max_tmp_tables;
@@ -361,7 +362,6 @@ struct system_variables
   ulong query_cache_type;
   ulong read_buff_size;
   ulong read_rnd_buff_size;
-  ulong select_limit;
   ulong sortbuff_size;
   ulong table_type;
   ulong tmp_table_size;
@@ -482,11 +482,13 @@ class THD :public ilink {
   USER_CONN *user_connect;
   CHARSET_INFO *db_charset;   
   CHARSET_INFO *thd_charset;
+  List<Item> *possible_loops; // Items that may cause loops in subselects
   List	     <MYSQL_ERROR> warn_list;  
   uint	     warn_count[(uint) MYSQL_ERROR::WARN_LEVEL_END];
   uint	     total_warn_count, old_total_warn_count;
-  ulong	     query_id, version, options, thread_id, col_access;
+  ulong	     query_id, warn_id, version, options, thread_id, col_access;
   ulong      current_stmt_id;
+  ulong	     rand_saved_seed1, rand_saved_seed2;
   long	     dbug_thread_id;
   pthread_t  real_id;
   uint	     current_tablenr,tmp_table,cond_count;
@@ -494,6 +496,7 @@ class THD :public ilink {
   uint32     query_length;
   uint32     db_length;
   uint       select_number;             //number of select (used for EXPLAIN)
+  uint       check_loops_counter;       //last id used to check loops
   /* variables.transaction_isolation is reset to this after each commit */
   enum_tx_isolation session_tx_isolation;
   char	     scramble[9];
@@ -502,13 +505,10 @@ class THD :public ilink {
   bool	     set_query_id,locked,count_cuted_fields,some_tables_deleted;
   bool	     no_errors, allow_sum_func, password, fatal_error;
   bool	     query_start_used,last_insert_id_used,insert_id_used,rand_used;
-  ulonglong  rand_saved_seed1, rand_saved_seed2;
   bool	     system_thread,in_lock_tables,global_read_lock;
   bool       query_error, bootstrap, cleanup_done;
-  bool	     safe_to_cache_query;
   bool	     volatile killed;
   bool       prepare_command;
-  Item_param *params;			// Pointer to array of params
 
   /*
     If we do a purge of binary logs, log index info of the threads
@@ -532,6 +532,8 @@ class THD :public ilink {
 
   THD();
   ~THD();
+  void init(void);
+  void change_user(void);
   void cleanup(void);
   bool store_globals();
 #ifdef SIGNAL_WITH_VIO_CLOSE
@@ -631,6 +633,7 @@ class THD :public ilink {
     net.last_errno= 0;
     net.report_error= 0;
   }
+  void add_possible_loop(Item *);
 };
 
 /*
@@ -929,11 +932,9 @@ class Unique :public Sql_alloc
    ha_rows deleted;
    uint num_of_tables;
    int error;
-   thr_lock_type lock_option;
-   bool do_delete, not_trans_safe;
+   bool do_delete, transactional_tables, log_delayed, normal_tables;
  public:
-   multi_delete(THD *thd, TABLE_LIST *dt, thr_lock_type lock_option_arg,
-		uint num_of_tables);
+   multi_delete(THD *thd, TABLE_LIST *dt, uint num_of_tables);
    ~multi_delete();
    int prepare(List<Item> &list, SELECT_LEX_UNIT *u);
    bool send_fields(List<Item> &list,
@@ -953,7 +954,6 @@ class Unique :public Sql_alloc
    ha_rows updated, found;
    List<Item> fields;
    List <Item> **fields_by_tables;
-   thr_lock_type lock_option;
    enum enum_duplicates dupl;
    uint num_of_tables, num_fields, num_updated, *save_time_stamps, *field_sequence;
    int error;
@@ -961,7 +961,7 @@ class Unique :public Sql_alloc
  public:
    multi_update(THD *thd_arg, TABLE_LIST *ut, List<Item> &fs, 		 
 		enum enum_duplicates handle_duplicates,  
-		thr_lock_type lock_option_arg, uint num);
+		uint num);
    ~multi_update();
    int prepare(List<Item> &list, SELECT_LEX_UNIT *u);
    bool send_fields(List<Item> &list,
diff --git a/sql/sql_db.cc b/sql/sql_db.cc
index b80e25c9f402e9bab8f4e30e01144aca73ffad88..c3e183de0ac72e20dc22b3e60e3c4be8e27fd040 100644
--- a/sql/sql_db.cc
+++ b/sql/sql_db.cc
@@ -220,7 +220,7 @@ int mysql_create_db(THD *thd, char *db, HA_CREATE_INFO *create_info,
     if (!thd->query)				// Only in replication
     {
       query= 	     path;
-      query_length= (uint) (strxmov(path,"create database ", db, NullS) -
+      query_length= (uint) (strxmov(path,"create database `", db, "`", NullS) -
 			    path);
     }
     else
@@ -231,7 +231,7 @@ int mysql_create_db(THD *thd, char *db, HA_CREATE_INFO *create_info,
     mysql_update_log.write(thd, query, query_length);
     if (mysql_bin_log.is_open())
     {
-      Query_log_event qinfo(thd, query, query_length);
+      Query_log_event qinfo(thd, query, query_length, 0);
       mysql_bin_log.write(&qinfo);
     }
     send_ok(thd, result);
@@ -282,7 +282,7 @@ int mysql_alter_db(THD *thd, const char *db, HA_CREATE_INFO *create_info)
   mysql_update_log.write(thd,thd->query, thd->query_length);
   if (mysql_bin_log.is_open())
   {
-    Query_log_event qinfo(thd, thd->query, thd->query_length);
+    Query_log_event qinfo(thd, thd->query, thd->query_length, 0);
     mysql_bin_log.write(&qinfo);
   }
   send_ok(thd, result);
@@ -346,22 +346,25 @@ int mysql_rm_db(THD *thd,char *db,bool if_exists, bool silent)
     query_cache_invalidate1(db);  
     if (!silent)
     {
+      const char *query;
+      ulong query_length;
       if (!thd->query)
       {
-	thd->query = path;
-	thd->query_length = (uint) (strxmov(path,"drop database ", db, NullS)-
-				    path);
+	/* The client used the old obsolete mysql_drop_db() call */
+	query= path;
+	query_length = (uint) (strxmov(path,"drop database `", db, "`",
+				       NullS)- path);
       }
-      mysql_update_log.write(thd, thd->query, thd->query_length);
-      if (mysql_bin_log.is_open())
+      else
       {
-	Query_log_event qinfo(thd, thd->query, thd->query_length);
-	mysql_bin_log.write(&qinfo);
+	query=thd->query;
+	query_length=thd->query_length;
       }
-      if (thd->query == path)
+      mysql_update_log.write(thd, query, query_length);
+      if (mysql_bin_log.is_open())
       {
-	thd->query = 0; // just in case
-	thd->query_length = 0;
+	Query_log_event qinfo(thd, query, query_length, 0);
+	mysql_bin_log.write(&qinfo);
       }
       send_ok(thd,(ulong) deleted);
     }
diff --git a/sql/sql_delete.cc b/sql/sql_delete.cc
index 64945fa2d4d4d91aec9ef974f406cf86fa4a61a8..5b97b2f775037b9b8f7b7f599a27abc2e47794be 100644
--- a/sql/sql_delete.cc
+++ b/sql/sql_delete.cc
@@ -28,36 +28,40 @@
 #include "sql_select.h"
 
 int mysql_delete(THD *thd, TABLE_LIST *table_list, COND *conds, ORDER *order,
-                 ha_rows limit, thr_lock_type lock_type, ulong options)
+                 ha_rows limit, ulong options)
 {
   int		error;
   TABLE		*table;
   SQL_SELECT	*select=0;
   READ_RECORD	info;
   bool 		using_limit=limit != HA_POS_ERROR;
-  bool	        using_transactions;
+  bool		transactional_table, log_delayed, safe_update, const_cond; 
   ha_rows	deleted;
+  TABLE_LIST    *delete_table_list= (TABLE_LIST*) 
+    thd->lex.select_lex.table_list.first;
   DBUG_ENTER("mysql_delete");
 
-  if (!table_list->db)
-    table_list->db=thd->db;
-  if ((thd->options & OPTION_SAFE_UPDATES) && !conds)
-  {
-    send_error(thd,ER_UPDATE_WITHOUT_KEY_IN_SAFE_MODE);
-    DBUG_RETURN(1);
-  }
-
-  if (!(table = open_ltable(thd,table_list, lock_type)))
+  if ((open_and_lock_tables(thd, table_list)))
     DBUG_RETURN(-1);
+  fix_tables_pointers(&thd->lex.select_lex);
+  table= table_list->table;
   table->file->info(HA_STATUS_VARIABLE | HA_STATUS_NO_LOCK);
   thd->proc_info="init";
   table->map=1;
-  if (setup_conds(thd,table_list,&conds) || 
+  if (setup_conds(thd, delete_table_list, &conds) || 
       setup_ftfuncs(&thd->lex.select_lex))
     DBUG_RETURN(-1);
 
+  const_cond= (!conds || conds->const_item());
+  safe_update=test(thd->options & OPTION_SAFE_UPDATES);
+  if (safe_update && const_cond)
+  {
+    send_error(thd,ER_UPDATE_WITHOUT_KEY_IN_SAFE_MODE);
+    DBUG_RETURN(1);
+  }
+
   /* Test if the user wants to delete all rows */
-  if (!using_limit && (!conds || conds->const_item()) &&
+  if (!using_limit && const_cond &&
       !(specialflag & (SPECIAL_NO_NEW_FUNC | SPECIAL_SAFE_MODE)))
   {
     deleted= table->file->records;
@@ -79,9 +83,7 @@ int mysql_delete(THD *thd, TABLE_LIST *table_list, COND *conds, ORDER *order,
   select=make_select(table,0,0,conds,&error);
   if (error)
     DBUG_RETURN(-1);
-  if ((select && select->check_quick(test(thd->options & OPTION_SAFE_UPDATES),
-				     limit)) || 
-      !limit)
+  if ((select && select->check_quick(safe_update, limit)) || !limit)
   {
     delete select;
     send_ok(thd,0L);
@@ -92,7 +94,7 @@ int mysql_delete(THD *thd, TABLE_LIST *table_list, COND *conds, ORDER *order,
   if (!table->quick_keys)
   {
     thd->lex.select_lex.options|=QUERY_NO_INDEX_USED;
-    if ((thd->options & OPTION_SAFE_UPDATES) && limit == HA_POS_ERROR)
+    if (safe_update && !using_limit)
     {
       delete select;
       send_error(thd,ER_UPDATE_WITHOUT_KEY_IN_SAFE_MODE);
@@ -162,22 +164,31 @@ int mysql_delete(THD *thd, TABLE_LIST *table_list, COND *conds, ORDER *order,
     (void) table->file->extra(HA_EXTRA_NORMAL);
 
 cleanup:
-  using_transactions=table->file->has_transactions();
-  if (deleted && (error <= 0 || !using_transactions))
+  transactional_table= table->file->has_transactions();
+  log_delayed= (transactional_table || table->tmp_table);
+  if (deleted && (error <= 0 || !transactional_table))
   {
     mysql_update_log.write(thd,thd->query, thd->query_length);
     if (mysql_bin_log.is_open())
     {
       Query_log_event qinfo(thd, thd->query, thd->query_length, 
-			    using_transactions);
-      if (mysql_bin_log.write(&qinfo) && using_transactions)
+			    log_delayed);
+      if (mysql_bin_log.write(&qinfo) && transactional_table)
 	error=1;
     }
-    if (!using_transactions)
+    if (!log_delayed)
       thd->options|=OPTION_STATUS_NO_TRANS_UPDATE;
   }
-  if (using_transactions && ha_autocommit_or_rollback(thd,error >= 0))
-    error=1;
+  if (transactional_table)
+  {
+    if (ha_autocommit_or_rollback(thd,error >= 0))
+      error=1;
+  }
+
+  /*
+    Store table for future invalidation  or invalidate it in
+    the query cache if something changed
+  */
   if (deleted)
   {
     query_cache_invalidate3(thd, table_list, 1);
@@ -205,19 +216,17 @@ int mysql_delete(THD *thd, TABLE_LIST *table_list, COND *conds, ORDER *order,
 
 #define MEM_STRIP_BUF_SIZE current_thd->variables.sortbuff_size
 
-int refposcmp2(void* arg, const void *a,const void *b)
+extern "C" int refposcmp2(void* arg, const void *a,const void *b)
 {
   return memcmp(a,b, *(int*) arg);
 }
 
 multi_delete::multi_delete(THD *thd_arg, TABLE_LIST *dt,
-			   thr_lock_type lock_option_arg,
 			   uint num_of_tables_arg)
   : delete_tables (dt), thd(thd_arg), deleted(0),
-    num_of_tables(num_of_tables_arg), error(0), lock_option(lock_option_arg),
-    do_delete(false)
+    num_of_tables(num_of_tables_arg), error(0),
+    do_delete(0), transactional_tables(0), log_delayed(0), normal_tables(0)
 {
-  not_trans_safe=false;
   tempfiles = (Unique **) sql_calloc(sizeof(Unique *) * (num_of_tables-1));
 }
 
@@ -268,8 +277,12 @@ multi_delete::initialize_tables(JOIN *join)
       /* Don't use KEYREAD optimization on this table */
       tbl->no_keyread=1;
       walk=walk->next;
-      if (!not_trans_safe && !tbl->file->has_transactions())
-	not_trans_safe=true;
+      if (tbl->file->has_transactions())
+	log_delayed= transactional_tables= 1;
+      else if (tbl->tmp_table != NO_TMP_TABLE)
+	log_delayed= 1;
+      else
+	normal_tables= 1;
     }
   }
   walk= delete_tables;
@@ -375,7 +388,7 @@ void multi_delete::send_error(uint errcode,const char *err)
     In all other cases do attempt deletes ...
   */
   if ((table_being_deleted->table->file->has_transactions() &&
-       table_being_deleted == delete_tables) || !not_trans_safe)
+       table_being_deleted == delete_tables) || !normal_tables)
     ha_rollback_stmt(thd);
   else if (do_delete)
   {
@@ -394,7 +407,7 @@ void multi_delete::send_error(uint errcode,const char *err)
 
 int multi_delete::do_deletes(bool from_send_error)
 {
-  int error = 0, counter = 0;
+  int local_error= 0, counter= 0;
 
   if (from_send_error)
   {
@@ -415,27 +428,26 @@ int multi_delete::do_deletes(bool from_send_error)
     TABLE *table = table_being_deleted->table;
     if (tempfiles[counter]->get(table))
     {
-      error=1;
+      local_error=1;
       break;
     }
 
     READ_RECORD	info;
     init_read_record(&info,thd,table,NULL,0,0);
-    while (!(error=info.read_record(&info)) &&
-	   (!thd->killed ||  from_send_error || not_trans_safe))
+    while (!(local_error=info.read_record(&info)) && !thd->killed)
     {
-      if ((error=table->file->delete_row(table->record[0])))
+      if ((local_error=table->file->delete_row(table->record[0])))
       {
-	table->file->print_error(error,MYF(0));
+	table->file->print_error(local_error,MYF(0));
 	break;
       }
       deleted++;
     }
     end_read_record(&info);
-    if (error == -1)				// End of file
-      error = 0;
+    if (local_error == -1)				// End of file
+      local_error = 0;
   }
-  return error;
+  return local_error;
 }
 
 
@@ -451,15 +463,11 @@ bool multi_delete::send_eof()
   thd->proc_info="deleting from reference tables";
 
   /* Does deletes for the last n - 1 tables, returns 0 if ok */
-  int error = do_deletes(0);		// returns 0 if success
+  int local_error= do_deletes(0);		// returns 0 if success
 
   /* reset used flags */
   thd->proc_info="end";
-  if (error)
-  {
-    ::send_error(thd);
-    return 1;
-  }
+
 
   /*
     Write the SQL statement to the binlog if we deleted
@@ -467,24 +475,25 @@ bool multi_delete::send_eof()
     was a non-transaction-safe table involved, since
     modifications in it cannot be rolled back.
   */
-  if (deleted || not_trans_safe)
+  if (deleted)
   {
     mysql_update_log.write(thd,thd->query,thd->query_length);
     if (mysql_bin_log.is_open())
     {
-      Query_log_event qinfo(thd, thd->query, thd->query_length);
-      if (mysql_bin_log.write(&qinfo) &&
-	  !not_trans_safe)
-	error=1;  // Log write failed: roll back the SQL statement
+      Query_log_event qinfo(thd, thd->query, thd->query_length,
+			    log_delayed);
+      if (mysql_bin_log.write(&qinfo) && !normal_tables)
+	local_error=1;  // Log write failed: roll back the SQL statement
     }
     /* Commit or rollback the current SQL statement */ 
-    VOID(ha_autocommit_or_rollback(thd,error > 0));
-  }
-  if (deleted)
-  {
+    VOID(ha_autocommit_or_rollback(thd,local_error > 0));
+
     query_cache_invalidate3(thd, delete_tables, 1);
   }
-  ::send_ok(thd,deleted);
+  if (local_error)
+    ::send_error(thd);
+  else
+    ::send_ok(thd, deleted);
   return 0;
 }
 
@@ -557,8 +566,9 @@ int mysql_truncate(THD *thd, TABLE_LIST *table_list, bool dont_send_ok)
     if (!ha_supports_generate(table_type))
     {
       /* Probably InnoDB table */
-      DBUG_RETURN(mysql_delete(thd,table_list, (COND*) 0, (ORDER*) 0,
-			       HA_POS_ERROR, TL_WRITE, 0));
+      table_list->lock_type= TL_WRITE;
+      DBUG_RETURN(mysql_delete(thd, table_list, (COND*) 0, (ORDER*) 0,
+			       HA_POS_ERROR, 0));
     }
     if (lock_and_wait_for_table_name(thd, table_list))
       DBUG_RETURN(-1);
@@ -570,6 +580,7 @@ int mysql_truncate(THD *thd, TABLE_LIST *table_list, bool dont_send_ok)
   *fn_ext(path)=0;				// Remove the .frm extension
   error= ha_create_table(path,&create_info,1) ? -1 : 0;
   query_cache_invalidate3(thd, table_list, 0); 
+
 end:
   if (!dont_send_ok)
   {
@@ -578,7 +589,8 @@ int mysql_truncate(THD *thd, TABLE_LIST *table_list, bool dont_send_ok)
       mysql_update_log.write(thd,thd->query,thd->query_length);
       if (mysql_bin_log.is_open())
       {
-	Query_log_event qinfo(thd, thd->query, thd->query_length);
+	Query_log_event qinfo(thd, thd->query, thd->query_length,
+			      thd->tmp_table);
 	mysql_bin_log.write(&qinfo);
       }
       send_ok(thd);		// This should return record count
diff --git a/sql/sql_derived.cc b/sql/sql_derived.cc
index 1335618b90da8d1ad5e03b9df8a2016ec3b363da..6dc001a19324251741baa677daf1e7c6fc1d0035 100644
--- a/sql/sql_derived.cc
+++ b/sql/sql_derived.cc
@@ -28,8 +28,7 @@
 static const char *any_db="*any*";	// Special symbol for check_access
 
 
-int mysql_derived(THD *thd, LEX *lex, SELECT_LEX_UNIT *unit, TABLE_LIST *t,
-		  bool tables_is_opened)
+int mysql_derived(THD *thd, LEX *lex, SELECT_LEX_UNIT *unit, TABLE_LIST *t)
 {
   /*
     TODO: make derived tables with union inside (now only 1 SELECT may be
@@ -51,15 +50,19 @@ int mysql_derived(THD *thd, LEX *lex, SELECT_LEX_UNIT *unit, TABLE_LIST *t,
   if (res)
     DBUG_RETURN(-1);
 
-  for (TABLE_LIST *cursor= (TABLE_LIST *)tables;
-       cursor;
-       cursor=cursor->next)
+  for (SELECT_LEX *ssl= sl; ssl; ssl= ssl->next_select_in_list())
   {
-    if (cursor->derived)
+    TABLE_LIST *t_tables= (TABLE_LIST *)ssl->table_list.first;
+    for (TABLE_LIST *cursor= (TABLE_LIST *)t_tables;
+	 cursor;
+	 cursor=cursor->next)
     {
-      res= mysql_derived(thd, lex, (SELECT_LEX_UNIT *)cursor->derived,
-			 cursor, 0);
-      if (res) DBUG_RETURN(res);
+      if (cursor->derived)
+      {
+	res= mysql_derived(thd, lex, (SELECT_LEX_UNIT *)cursor->derived,
+			   cursor);
+	if (res) DBUG_RETURN(res);
+      }
     }
   }
   Item *item;
@@ -68,7 +71,7 @@ int mysql_derived(THD *thd, LEX *lex, SELECT_LEX_UNIT *unit, TABLE_LIST *t,
   while ((item= it++))
     item_list.push_back(item);
     
-  if (tables_is_opened || !(res=open_and_lock_tables(thd,tables)))
+  if (!(res=open_and_lock_tables(thd,tables)))
   {
     if (setup_fields(thd,tables,item_list,0,0,1))
     {
@@ -89,19 +92,24 @@ int mysql_derived(THD *thd, LEX *lex, SELECT_LEX_UNIT *unit, TABLE_LIST *t,
   
     if ((derived_result=new select_union(table)))
     {
+      derived_result->tmp_table_param=&tmp_table_param;
       unit->offset_limit_cnt= sl->offset_limit;
       unit->select_limit_cnt= sl->select_limit+sl->offset_limit;
       if (unit->select_limit_cnt < sl->select_limit)
 	unit->select_limit_cnt= HA_POS_ERROR;
       if (unit->select_limit_cnt == HA_POS_ERROR)
 	sl->options&= ~OPTION_FOUND_ROWS;
-    
+
+      SELECT_LEX_NODE *save_current_select= lex->current_select;
+      lex->current_select= sl;
       res= mysql_select(thd, tables,  sl->item_list,
 			sl->where, (ORDER *) sl->order_list.first,
 			(ORDER*) sl->group_list.first,
 			sl->having, (ORDER*) NULL,
 			sl->options | thd->options | SELECT_NO_UNLOCK,
 			derived_result, unit, sl, 0);
+      lex->current_select= save_current_select;
+
       if (!res)
       {
 // Here we entirely fix both TABLE_LIST and list of SELECT's as there were no derived tables
@@ -112,8 +120,10 @@ int mysql_derived(THD *thd, LEX *lex, SELECT_LEX_UNIT *unit, TABLE_LIST *t,
 	  t->real_name=table->real_name;
 	  t->table=table;
 	  table->derived_select_number= sl->select_number;
-	  sl->exclude();
-	  t->db= (tables && tables->db && tables->db[0]) ? t->db : thd->db;
+	  table->tmp_table=TMP_TABLE;
+	  if (!lex->describe)
+	    sl->exclude();
+	  t->db=(char *)"";
 	  t->derived=(SELECT_LEX *)0; // just in case ...
 	}
       }
@@ -123,8 +133,6 @@ int mysql_derived(THD *thd, LEX *lex, SELECT_LEX_UNIT *unit, TABLE_LIST *t,
       free_tmp_table(thd,table);
 exit:
     close_thread_tables(thd);
-    if (res > 0)
-      send_error(thd, ER_UNKNOWN_COM_ERROR); // temporary only ...
   }
   DBUG_RETURN(res);
 }
diff --git a/sql/sql_error.cc b/sql/sql_error.cc
index 3d6a0fa24aaf45d8a788020fd93053b83a9b9f81..d2735073461c2a9bb207909df50e319e2a07b7ff 100644
--- a/sql/sql_error.cc
+++ b/sql/sql_error.cc
@@ -51,13 +51,22 @@ This file contains the implementation of error and warnings related
   SYNOPSIS
     mysql_reset_errors()
     thd			Thread handle
+
+  IMPLEMENTATION
+    Don't reset warnings if this has already been called for this query.
+    This may happen if one gets a warning during the parsing stage,
+    in which case push_warnings() has already called this function.
 */  
 
 void mysql_reset_errors(THD *thd)
 {
-  free_root(&thd->warn_root,MYF(0));
-  bzero((char*) thd->warn_count, sizeof(thd->warn_count));
-  thd->warn_list.empty();
+  if (thd->query_id != thd->warn_id)
+  {
+    thd->warn_id= thd->query_id;
+    free_root(&thd->warn_root,MYF(0));
+    bzero((char*) thd->warn_count, sizeof(thd->warn_count));
+    thd->warn_list.empty();
+  }
 }
 
 
@@ -75,6 +84,9 @@ void mysql_reset_errors(THD *thd)
 void push_warning(THD *thd, MYSQL_ERROR::enum_warning_level level, uint code,
 		  const char *msg)
 {
+  if (thd->query_id != thd->warn_id)
+    mysql_reset_errors(thd);
+
   if (thd->warn_list.elements < thd->variables.max_error_count)
   {
     /*
@@ -115,7 +127,7 @@ static const char *warning_level_names[]= {"Note", "Warning", "Error", "?"};
 my_bool mysqld_show_warnings(THD *thd, ulong levels_to_show)
 {  
   List<Item> field_list;
-  DBUG_ENTER("mysqld_show_errors");
+  DBUG_ENTER("mysqld_show_warnings");
 
   field_list.push_back(new Item_empty_string("Level", 7));
   field_list.push_back(new Item_int("Code",0,4));
diff --git a/sql/sql_insert.cc b/sql/sql_insert.cc
index 0a1b4435fff25b1271ac36fb5212b2ce2b4c28c0..295c1e339c5b717dbfa3af48d3d3179d979821cf 100644
--- a/sql/sql_insert.cc
+++ b/sql/sql_insert.cc
@@ -25,7 +25,7 @@ static TABLE *delayed_get_table(THD *thd,TABLE_LIST *table_list);
 static int write_delayed(THD *thd,TABLE *table, enum_duplicates dup,
 			 char *query, uint query_length, bool log_on);
 static void end_delayed_insert(THD *thd);
-static pthread_handler_decl(handle_delayed_insert,arg);
+extern "C" pthread_handler_decl(handle_delayed_insert,arg);
 static void unlink_blobs(register TABLE *table);
 
 /* Define to force use of my_malloc() if the allocated memory block is big */
@@ -98,13 +98,12 @@ check_insert_fields(THD *thd,TABLE *table,List<Item> &fields,
 
 
 int mysql_insert(THD *thd,TABLE_LIST *table_list, List<Item> &fields,
-		 List<List_item> &values_list,enum_duplicates duplic,
-		 thr_lock_type lock_type)
+		 List<List_item> &values_list,enum_duplicates duplic)
 {
   int error;
   bool log_on= ((thd->options & OPTION_UPDATE_LOG) ||
 		!(thd->master_access & SUPER_ACL));
-  bool using_transactions, bulk_insert=0;
+  bool transactional_table, log_delayed, bulk_insert=0;
   uint value_count;
   uint save_time_stamp;
   ulong counter = 1;
@@ -114,6 +113,9 @@ int mysql_insert(THD *thd,TABLE_LIST *table_list, List<Item> &fields,
   List_iterator_fast<List_item> its(values_list);
   List_item *values;
   char *query=thd->query;
+  thr_lock_type lock_type = table_list->lock_type;
+  TABLE_LIST *insert_table_list= (TABLE_LIST*)
+    thd->lex.select_lex.table_list.first;
   DBUG_ENTER("mysql_insert");
 
   /*
@@ -126,7 +128,9 @@ int mysql_insert(THD *thd,TABLE_LIST *table_list, List<Item> &fields,
 	thd->slave_thread)) ||
       (lock_type == TL_WRITE_CONCURRENT_INSERT && duplic == DUP_REPLACE))
     lock_type=TL_WRITE;
+  table_list->lock_type= lock_type;
 
+  int res;
   if (lock_type == TL_WRITE_DELAYED)
   {
     if (thd->locked_tables)
@@ -141,25 +145,34 @@ int mysql_insert(THD *thd,TABLE_LIST *table_list, List<Item> &fields,
 	DBUG_RETURN(-1);
       }
     }
-    if (!(table = delayed_get_table(thd,table_list)) && !thd->fatal_error)
-      table = open_ltable(thd,table_list,lock_type=thd->update_lock_default);
+    if ((table= delayed_get_table(thd,table_list)) && !thd->fatal_error)
+      if (table_list->next && table)
+	res= open_and_lock_tables(thd, table_list->next);
+      else
+	res= (table == 0);
+    else
+      res= open_and_lock_tables(thd, table_list);
   }
   else
-    table = open_ltable(thd,table_list,lock_type);
-  if (!table)
+    res= open_and_lock_tables(thd, table_list);
+  if (res)
     DBUG_RETURN(-1);
+  fix_tables_pointers(&thd->lex.select_lex);
+
+  table= table_list->table;
   thd->proc_info="init";
   thd->used_tables=0;
   save_time_stamp=table->time_stamp;
   values= its++;
   if (check_insert_fields(thd,table,fields,*values,1) ||
-      setup_tables(table_list) || setup_fields(thd,table_list,*values,0,0,0))
+      setup_tables(insert_table_list) ||
+      setup_fields(thd, insert_table_list, *values, 0, 0, 0))
   {
-    table->time_stamp=save_time_stamp;
+    table->time_stamp= save_time_stamp;
     goto abort;
   }
   value_count= values->elements;
-  while ((values = its++))
+  while ((values= its++))
   {
     counter++;
     if (values->elements != value_count)
@@ -170,9 +183,9 @@ int mysql_insert(THD *thd,TABLE_LIST *table_list, List<Item> &fields,
       table->time_stamp=save_time_stamp;
       goto abort;
     }
-    if (setup_fields(thd,table_list,*values,0,0,0))
+    if (setup_fields(thd,insert_table_list,*values,0,0,0))
     {
-      table->time_stamp=save_time_stamp;
+      table->time_stamp= save_time_stamp;
       goto abort;
     }
   }
@@ -194,14 +207,19 @@ int mysql_insert(THD *thd,TABLE_LIST *table_list, List<Item> &fields,
   thd->proc_info="update";
   if (duplic == DUP_IGNORE || duplic == DUP_REPLACE)
     table->file->extra(HA_EXTRA_IGNORE_DUP_KEY);
-  if ((bulk_insert= (values_list.elements > 1 &&
+  if ((bulk_insert= (values_list.elements >= MIN_ROWS_TO_USE_BULK_INSERT &&
 		     lock_type != TL_WRITE_DELAYED &&
 		     !(specialflag & SPECIAL_SAFE_MODE))))
   {
     table->file->extra_opt(HA_EXTRA_WRITE_CACHE,
-			   thd->variables.read_buff_size);
-    table->file->extra_opt(HA_EXTRA_BULK_INSERT_BEGIN,
-			   thd->variables.bulk_insert_buff_size);
+			   min(thd->variables.read_buff_size,
+			       table->avg_row_length*values_list.elements));
+    if (thd->variables.bulk_insert_buff_size)
+      table->file->extra_opt(HA_EXTRA_BULK_INSERT_BEGIN,
+			     min(thd->variables.bulk_insert_buff_size,
+				 (table->total_key_length +
+				  table->keys * TREE_ELEMENT_EXTRA_SIZE)*
+				 values_list.elements));
     table->bulk_insert= 1;
   }
 
@@ -266,10 +284,7 @@ int mysql_insert(THD *thd,TABLE_LIST *table_list, List<Item> &fields,
       info.copied=values_list.elements;
       end_delayed_insert(thd);
     }
-    if (info.copied || info.deleted)
-    {
-      query_cache_invalidate3(thd, table_list, 1);
-    }
+    query_cache_invalidate3(thd, table_list, 1);
   }
   else
   {
@@ -297,22 +312,29 @@ int mysql_insert(THD *thd,TABLE_LIST *table_list, List<Item> &fields,
       thd->insert_id(id);			// For update log
     else if (table->next_number_field)
       id=table->next_number_field->val_int();	// Return auto_increment value
-    using_transactions=table->file->has_transactions();
-    if ((info.copied || info.deleted) && (error <= 0 || !using_transactions))
+    
+    transactional_table= table->file->has_transactions();
+    log_delayed= (transactional_table || table->tmp_table);
+    if ((info.copied || info.deleted) && (error <= 0 || !transactional_table))
     {
       mysql_update_log.write(thd, thd->query, thd->query_length);
       if (mysql_bin_log.is_open())
       {
 	Query_log_event qinfo(thd, thd->query, thd->query_length,
-			      using_transactions);
-	if (mysql_bin_log.write(&qinfo) && using_transactions)
+			      log_delayed);
+	if (mysql_bin_log.write(&qinfo) && transactional_table)
 	  error=1;
       }
-      if (!using_transactions)
+      if (!log_delayed)
 	thd->options|=OPTION_STATUS_NO_TRANS_UPDATE;
     }
-    if (using_transactions)
+    if (transactional_table)
       error=ha_autocommit_or_rollback(thd,error);
+
+    /*
+      Store table for future invalidation  or invalidate it in
+      the query cache if something changed
+    */
     if (info.copied || info.deleted)
     {
       query_cache_invalidate3(thd, table_list, 1);
@@ -913,7 +935,7 @@ void kill_delayed_threads(void)
  * Create a new delayed insert thread
 */
 
-static pthread_handler_decl(handle_delayed_insert,arg)
+extern "C" pthread_handler_decl(handle_delayed_insert,arg)
 {
   delayed_insert *di=(delayed_insert*) arg;
   THD *thd= &di->thd;
@@ -1197,7 +1219,7 @@ bool delayed_insert::handle_inserts(void)
       mysql_update_log.write(&thd,row->query, row->query_length);
       if (using_bin_log)
       {
-	Query_log_event qinfo(&thd, row->query, row->query_length);
+	Query_log_event qinfo(&thd, row->query, row->query_length,0);
 	mysql_bin_log.write(&qinfo);
       }
     }
diff --git a/sql/sql_lex.cc b/sql/sql_lex.cc
index b0050e0fe6dcb370e5b57ac9d8485b578ca05829..5104487c700b7c13fcb83990f78c61f3bc5d1da8 100644
--- a/sql/sql_lex.cc
+++ b/sql/sql_lex.cc
@@ -76,7 +76,7 @@ inline int lex_casecmp(const char *s, const char *t, uint len)
 
 #include "lex_hash.h"
 
-static uchar state_map[256];
+static uchar state_map[256], ident_map[256];
 
 
 void lex_init(void)
@@ -91,7 +91,7 @@ void lex_init(void)
   VOID(pthread_key_create(&THR_LEX,NULL));
 
   /* Fill state_map with states to get a faster parser */
-  for (i=0; i < 256 ; i++)
+  for (i=0; i < sizeof(state_map) ; i++)
   {
     if (my_isalpha(system_charset_info,i))
       state_map[i]=(uchar) STATE_IDENT;
@@ -126,6 +126,20 @@ void lex_init(void)
   {
     state_map[(uchar) '"'] = STATE_USER_VARIABLE_DELIMITER;
   }
+
+  /*
+    Create a second map to make it faster to find identifiers
+  */
+  for (i=0; i < sizeof(ident_map) ; i++)
+  {
+    ident_map[i]= (uchar) (state_map[i] == STATE_IDENT ||
+			   state_map[i] == STATE_NUMBER_IDENT);
+  }
+
+  /* Special handling of hex and binary strings */
+  state_map[(uchar)'x']= state_map[(uchar)'X']= (uchar) STATE_IDENT_OR_HEX;
+  state_map[(uchar)'b']= state_map[(uchar)'b']= (uchar) STATE_IDENT_OR_BIN;
+
   DBUG_VOID_RETURN;
 }
 
@@ -149,11 +163,13 @@ LEX *lex_start(THD *thd, uchar *buf,uint length)
   lex->select_lex.expr_list.empty();
   lex->select_lex.ftfunc_list_alloc.empty();
   lex->select_lex.ftfunc_list= &lex->select_lex.ftfunc_list_alloc;
+  lex->current_select= &lex->select_lex;
   lex->convert_set= (lex->thd= thd)->variables.convert_set;
   lex->yacc_yyss=lex->yacc_yyvs=0;
   lex->ignore_space=test(thd->sql_mode & MODE_IGNORE_SPACE);
   lex->slave_thd_opt=0;
   lex->sql_command=SQLCOM_END;
+  lex->safe_to_cache_query= 1;
   bzero(&lex->mi,sizeof(lex->mi));
   return lex;
 }
@@ -182,7 +198,7 @@ static int find_keyword(LEX *lex, uint len, bool function)
   udf_func *udf;
   if (function && using_udf_functions && (udf=find_udf((char*) tok, len)))
   {
-    lex->thd->safe_to_cache_query=0;
+    lex->safe_to_cache_query=0;
     lex->yylval->udf=udf;
     switch (udf->returns) {
     case STRING_RESULT:
@@ -459,7 +475,7 @@ int yylex(void *arg)
       }
     case STATE_CHAR:			// Unknown or single char token
     case STATE_SKIP:			// This should not happen
-      yylval->lex_str.str=(char*) (lex->ptr=lex->tok_start);// Set to first char
+      yylval->lex_str.str=(char*) (lex->ptr=lex->tok_start);// Set to first chr
       yylval->lex_str.length=1;
       c=yyGet();
       if (c != ')')
@@ -468,12 +484,15 @@ int yylex(void *arg)
 	lex->tok_start=lex->ptr;	// Let tok_start point at next item
       return((int) c);
 
-    case STATE_IDENT:			// Incomplete keyword or ident
-      if ((c == 'x' || c == 'X') && yyPeek() == '\'')
+    case STATE_IDENT_OR_HEX:
+      if (yyPeek() == '\'')
       {					// Found x'hex-number'
-	state=STATE_HEX_NUMBER;
+	state= STATE_HEX_NUMBER;
 	break;
       }
+      /* Fall through */
+    case STATE_IDENT_OR_BIN:		// TODO: Add binary string handling
+    case STATE_IDENT:
 #if defined(USE_MB) && defined(USE_MB_IDENT)
       if (use_mb(system_charset_info))
       {
@@ -488,8 +507,7 @@ int yylex(void *arg)
           }
           lex->ptr += l - 1;
         }
-        while (state_map[c=yyGet()] == STATE_IDENT ||
-               state_map[c] == STATE_NUMBER_IDENT)
+        while (ident_map[c=yyGet()])
         {
           if (my_ismbhead(system_charset_info, c))
           {
@@ -504,15 +522,13 @@ int yylex(void *arg)
       }
       else
 #endif
-        while (state_map[c=yyGet()] == STATE_IDENT ||
-               state_map[c] == STATE_NUMBER_IDENT) ;
+        while (ident_map[c=yyGet()]) ;
       length= (uint) (lex->ptr - lex->tok_start)-1;
       if (lex->ignore_space)
       {
 	for (; state_map[c] == STATE_SKIP ; c= yyGet());
       }
-      if (c == '.' && (state_map[yyPeek()] == STATE_IDENT ||
-		       state_map[yyPeek()] == STATE_NUMBER_IDENT))
+      if (c == '.' && ident_map[yyPeek()])
 	lex->next_state=STATE_IDENT_SEP;
       else
       {					// '(' must follow directly if function
@@ -550,7 +566,7 @@ int yylex(void *arg)
 
     case STATE_NUMBER_IDENT:		// number or ident which num-start
       while (my_isdigit(system_charset_info,(c = yyGet()))) ;
-      if (state_map[c] != STATE_IDENT)
+      if (!ident_map[c])
       {					// Can't be identifier
 	state=STATE_INT_OR_REAL;
 	break;
@@ -575,7 +591,7 @@ int yylex(void *arg)
 	  lex->tok_start[0] == '0' )
       {						// Varbinary
 	while (my_isxdigit(system_charset_info,(c = yyGet()))) ;
-	if ((lex->ptr - lex->tok_start) >= 4 && state_map[c] != STATE_IDENT)
+	if ((lex->ptr - lex->tok_start) >= 4 && !ident_map[c])
 	{
 	  yylval->lex_str=get_token(lex,yyLength());
 	  yylval->lex_str.str+=2;		// Skip 0x
@@ -602,8 +618,7 @@ int yylex(void *arg)
           }
           lex->ptr += l - 1;
         }
-        while (state_map[c=yyGet()] == STATE_IDENT ||
-               state_map[c] == STATE_NUMBER_IDENT)
+        while (ident_map[c=yyGet()])
         {
           if (my_ismbhead(system_charset_info, c))
           {
@@ -618,11 +633,9 @@ int yylex(void *arg)
       }
       else
 #endif
-        while (state_map[c = yyGet()] == STATE_IDENT ||
-               state_map[c] == STATE_NUMBER_IDENT) ;
+        while (ident_map[c = yyGet()]) ;
 
-      if (c == '.' && (state_map[yyPeek()] == STATE_IDENT ||
-		       state_map[yyPeek()] == STATE_NUMBER_IDENT))
+      if (c == '.' && ident_map[yyPeek()])
 	lex->next_state=STATE_IDENT_SEP;// Next is '.'
       // fall through
 
@@ -855,9 +868,8 @@ int yylex(void *arg)
     case STATE_END:
       lex->next_state=STATE_END;
       return(0);			// We found end of input last time
-
-      // Actually real shouldn't start
-      // with . but allow them anyhow
+      
+      /* Actually real shouldn't start with . but allow them anyhow */
     case STATE_REAL_OR_POINT:
       if (my_isdigit(system_charset_info,yyPeek()))
 	state = STATE_REAL;		// Real
@@ -901,8 +913,7 @@ int yylex(void *arg)
 	[(global | local | session) .]variable_name
       */
 
-      while (state_map[c=yyGet()] == STATE_IDENT ||
-	     state_map[c] == STATE_NUMBER_IDENT) ;
+      while (ident_map[c=yyGet()]) ;
       if (c == '.')
 	lex->next_state=STATE_IDENT_SEP;
       length= (uint) (lex->ptr - lex->tok_start)-1;
@@ -961,6 +972,8 @@ void st_select_lex::init_query()
   table_list.next= (byte**) &table_list.first;
   item_list.empty();
   join= 0;
+  olap= UNSPECIFIED_OLAP_TYPE;
+  having_fix_field= 0;
 }
 
 void st_select_lex::init_select()
@@ -978,7 +991,6 @@ void st_select_lex::init_select()
   ftfunc_list_alloc.empty();
   ftfunc_list= &ftfunc_list_alloc;
   linkage= UNSPECIFIED_TYPE;
-  having_fix_field= 0;
 }
 
 /*
@@ -1182,7 +1194,6 @@ bool st_select_lex_unit::create_total_list_n_last_return(THD *thd, st_lex *lex,
 	if (!cursor)
 	{
 	  /* Add not used table to the total table list */
-	  aux->lock_type= lex->lock_option;
 	  if (!(cursor= (TABLE_LIST *) thd->memdup((char*) aux,
 						   sizeof(*aux))))
 	  {
@@ -1285,4 +1296,7 @@ List<String>* st_select_lex::get_ignore_index()
   return ignore_index_ptr;
 }
 
-// There are st_select_lex::add_table_to_list in sql_parse.cc
+/*
+  There are st_select_lex::add_table_to_list & 
+  st_select_lex::set_lock_for_tables in sql_parse.cc
+*/
diff --git a/sql/sql_lex.h b/sql/sql_lex.h
index 59bbb1e220ffcff87952fcc4223c01e48bd391a8..08855ba1a7cf361b6bd2526a42b98aaf4f61e417 100644
--- a/sql/sql_lex.h
+++ b/sql/sql_lex.h
@@ -78,7 +78,7 @@ enum lex_states
   STATE_REAL_OR_POINT, STATE_BOOL, STATE_EOL, STATE_ESCAPE, STATE_LONG_COMMENT,
   STATE_END_LONG_COMMENT, STATE_COLON, STATE_SET_VAR, STATE_USER_END,
   STATE_HOSTNAME, STATE_SKIP, STATE_USER_VARIABLE_DELIMITER, STATE_SYSTEM_VAR,
-  STATE_IDENT_OR_KEYWORD
+  STATE_IDENT_OR_KEYWORD, STATE_IDENT_OR_HEX, STATE_IDENT_OR_BIN
 };
 
 
@@ -240,7 +240,7 @@ class st_select_lex_node {
 					thr_lock_type flags= TL_UNLOCK,
 					List<String> *use_index= 0,
 					List<String> *ignore_index= 0);
-
+  virtual void set_lock_for_tables(thr_lock_type lock_type) {}
   void mark_as_dependent(st_select_lex *last);
 private:
   void fast_exclude();
@@ -295,6 +295,7 @@ class st_select_lex_unit: public st_select_lex_node {
   int cleanup();
   
   friend void mysql_init_query(THD *thd);
+  friend int subselect_union_engine::exec();
 private:
   bool create_total_list_n_last_return(THD *thd, st_lex *lex,
 				       TABLE_LIST ***result);
@@ -337,7 +338,7 @@ class st_select_lex: public st_select_lex_node
   }
   st_select_lex* outer_select();
   st_select_lex* next_select() { return (st_select_lex*) next; }
-  st_select_lex*  next_select_in_list() 
+  st_select_lex* next_select_in_list() 
   {
     return (st_select_lex*) link_next;
   }
@@ -365,6 +366,7 @@ class st_select_lex: public st_select_lex_node
 				thr_lock_type flags= TL_UNLOCK,
 				List<String> *use_index= 0,
 				List<String> *ignore_index= 0);
+  void set_lock_for_tables(thr_lock_type lock_type);
   inline void init_order()
   {
     order_list.elements= 0;
@@ -437,9 +439,10 @@ typedef struct st_lex
   uint grant, grant_tot_col, which_columns;
   uint fk_delete_opt, fk_update_opt, fk_match_option;
   uint param_count;
-  bool drop_primary, drop_if_exists, local_file, olap;
+  bool drop_primary, drop_if_exists, drop_temporary, local_file;
   bool in_comment, ignore_space, verbose, simple_alter;
-  bool derived_tables, describe;
+  bool derived_tables, describe, olap;
+  bool safe_to_cache_query;
   uint slave_thd_opt;
   CHARSET_INFO *charset;
   char *help_arg;
diff --git a/sql/sql_load.cc b/sql/sql_load.cc
index 52d1f3adf48d98aa3c5529fd45bf9930a2c19af5..00450a3b86cc040b3b3d6da600ac045ae1525c6d 100644
--- a/sql/sql_load.cc
+++ b/sql/sql_load.cc
@@ -90,7 +90,7 @@ int mysql_load(THD *thd,sql_exchange *ex,TABLE_LIST *table_list,
   bool is_fifo=0;
   LOAD_FILE_INFO lf_info;
   char * db = table_list->db ? table_list->db : thd->db;
-  bool using_transactions;
+  bool transactional_table, log_delayed;
   DBUG_ENTER("mysql_load");
 
 #ifdef EMBEDDED_LIBRARY
@@ -105,6 +105,9 @@ int mysql_load(THD *thd,sql_exchange *ex,TABLE_LIST *table_list,
   }
   if (!(table = open_ltable(thd,table_list,lock_type)))
     DBUG_RETURN(-1);
+  transactional_table= table->file->has_transactions();
+  log_delayed= (transactional_table || table->tmp_table);
+
   if (!fields.elements)
   {
     Field **field;
@@ -224,6 +227,7 @@ int mysql_load(THD *thd,sql_exchange *ex,TABLE_LIST *table_list,
     lf_info.handle_dup = handle_duplicates;
     lf_info.wrote_create_file = 0;
     lf_info.last_pos_in_file = HA_POS_ERROR;
+    lf_info.log_delayed= log_delayed;
     read_info.set_io_cache_arg((void*) &lf_info);
   }
   restore_record(table,2);
@@ -275,16 +279,16 @@ int mysql_load(THD *thd,sql_exchange *ex,TABLE_LIST *table_list,
   free_blobs(table);				/* if pack_blob was used */
   table->copy_blobs=0;
   thd->count_cuted_fields=0;			/* Don`t calc cuted fields */
-  using_transactions = table->file->has_transactions();
+
   if (error)
   {
-    if (using_transactions)
+    if (transactional_table)
       ha_autocommit_or_rollback(thd,error);
     if (!opt_old_rpl_compat && mysql_bin_log.is_open())
     {
       if (lf_info.wrote_create_file)
       {
-        Delete_file_log_event d(thd);
+        Delete_file_log_event d(thd, log_delayed);
         mysql_bin_log.write(&d);
       }
     }
@@ -297,27 +301,30 @@ int mysql_load(THD *thd,sql_exchange *ex,TABLE_LIST *table_list,
   if (!thd->slave_thread)
     mysql_update_log.write(thd,thd->query,thd->query_length);
 
-  if (!using_transactions)
+  if (!log_delayed)
     thd->options|=OPTION_STATUS_NO_TRANS_UPDATE;
   if (mysql_bin_log.is_open())
   {
-    if (opt_old_rpl_compat && !read_file_from_client)
+    if (opt_old_rpl_compat)
     {
-      Load_log_event qinfo(thd, ex, db, table->table_name, fields, 
-			 handle_duplicates);
-      mysql_bin_log.write(&qinfo);
+      if (!read_file_from_client)
+      {
+	Load_log_event qinfo(thd, ex, db, table->table_name, fields, 
+			     handle_duplicates, log_delayed);
+	mysql_bin_log.write(&qinfo);
+      }
     }
-    if (!opt_old_rpl_compat)
+    else
     {
       read_info.end_io_cache(); // make sure last block gets logged
       if (lf_info.wrote_create_file)
       {
-        Execute_load_log_event e(thd);
+        Execute_load_log_event e(thd, log_delayed);
         mysql_bin_log.write(&e);
       }
     }
   }
-  if (using_transactions)
+  if (transactional_table)
     error=ha_autocommit_or_rollback(thd,error); 
   DBUG_RETURN(error);
 }
diff --git a/sql/sql_manager.cc b/sql/sql_manager.cc
index 13cac83fc3fb2259b56c8dc3e91d65047ae69963..0af6a80d4c253109b399ba32102f6ef8c148fe8e 100644
--- a/sql/sql_manager.cc
+++ b/sql/sql_manager.cc
@@ -32,7 +32,7 @@ pthread_t manager_thread;
 pthread_mutex_t LOCK_manager;
 pthread_cond_t COND_manager;
 
-pthread_handler_decl(handle_manager,arg __attribute__((unused)))
+extern "C" pthread_handler_decl(handle_manager,arg __attribute__((unused)))
 {
   int error = 0;
   ulong status;
diff --git a/sql/sql_parse.cc b/sql/sql_parse.cc
index 28a2db61f6d7c917ed86bf77b6114ea4254bb3de..182ab69308fb20602f3309b587b60602470b0ed0 100644
--- a/sql/sql_parse.cc
+++ b/sql/sql_parse.cc
@@ -74,7 +74,7 @@ const char *command_name[]={
   "Drop DB", "Refresh", "Shutdown", "Statistics", "Processlist",
   "Connect","Kill","Debug","Ping","Time","Delayed_insert","Change user",
   "Binlog Dump","Table Dump",  "Connect Out", "Register Slave",
-  "Prepare", "Prepare Execute", "Long Data"
+  "Prepare", "Prepare Execute", "Long Data", "Close stmt"
 };
 
 static char empty_c_string[1]= {0};		// Used for not defined 'db'
@@ -98,7 +98,17 @@ static void init_signals(void)
 }
 #endif
 
-inline bool end_active_trans(THD *thd)
+static void unlock_locked_tables(THD *thd)
+{
+  if (thd->locked_tables)
+  {
+    thd->lock=thd->locked_tables;
+    thd->locked_tables=0;			// Will be automaticly closed
+    close_thread_tables(thd);			// Free tables
+  }
+}
+
+static bool end_active_trans(THD *thd)
 {
   int error=0;
   if (thd->options & (OPTION_NOT_AUTOCOMMIT | OPTION_BEGIN |
@@ -257,14 +267,14 @@ static bool check_user(THD *thd,enum_server_command command, const char *user,
   started with corresponding variable that is greater then 0.
 */
 
-static byte* get_key_conn(user_conn *buff, uint *length,
-			  my_bool not_used __attribute__((unused)))
+extern "C" byte *get_key_conn(user_conn *buff, uint *length,
+			      my_bool not_used __attribute__((unused)))
 {
   *length=buff->len;
   return (byte*) buff->user;
 }
 
-static void free_user(struct user_conn *uc)
+extern "C" void free_user(struct user_conn *uc)
 {
   my_free((char*) uc,MYF(0));
 }
@@ -273,7 +283,7 @@ void init_max_user_conn(void)
 {
   (void) hash_init(&hash_user_connections,system_charset_info,max_connections,
 		   0,0,
-		   (hash_get_key) get_key_conn, (void (*)(void*)) free_user,
+		   (hash_get_key) get_key_conn, (hash_free_key) free_user,
 		   0);
 }
 
@@ -552,7 +562,13 @@ check_connections(THD *thd)
   {
     /* Do the SSL layering. */
     DBUG_PRINT("info", ("IO layer change in progress..."));
-    sslaccept(ssl_acceptor_fd, net->vio, thd->variables.net_wait_timeout);
+    if (sslaccept(ssl_acceptor_fd, net->vio, thd->variables.net_wait_timeout))
+    {
+      DBUG_PRINT("error", ("Failed to read user information (pkt_len= %lu)",
+			   pkt_len));
+      inc_host_errors(&thd->remote.sin_addr);
+      return(ER_HANDSHAKE_ERROR);    
+    }
     DBUG_PRINT("info", ("Reading user information over SSL layer"));
     if ((pkt_len=my_net_read(net)) == packet_error ||
 	pkt_len < NORMAL_HANDSHAKE_SIZE)
@@ -660,7 +676,7 @@ pthread_handler_decl(handle_one_connection,arg)
       goto end_thread;
     }
 
-    if ((ulong) thd->variables.max_join_size == (ulong) HA_POS_ERROR)
+    if ((ulong) thd->variables.max_join_size == (ulonglong) HA_POS_ERROR)
       thd->options |= OPTION_BIG_SELECTS;
     if (thd->client_capabilities & CLIENT_COMPRESS)
       net->compress=1;				// Use compression
@@ -690,7 +706,7 @@ pthread_handler_decl(handle_one_connection,arg)
 			(net->last_errno ? ER(net->last_errno) :
 			 ER(ER_UNKNOWN_ERROR)));
       send_error(thd,net->last_errno,NullS);
-      thread_safe_increment(aborted_threads,&LOCK_status);
+      statistic_increment(aborted_threads,&LOCK_status);
     }
     
 end_thread:
@@ -711,7 +727,7 @@ pthread_handler_decl(handle_one_connection,arg)
   Used when creating the initial grant tables
 */
 
-pthread_handler_decl(handle_bootstrap,arg)
+extern "C" pthread_handler_decl(handle_bootstrap,arg)
 {
   THD *thd=(THD*) arg;
   FILE *file=bootstrap_file;
@@ -736,7 +752,7 @@ pthread_handler_decl(handle_bootstrap,arg)
 
 #endif
 
-  if ((ulong) thd->variables.max_join_size == (ulong) HA_POS_ERROR)
+  if ((ulong) thd->variables.max_join_size == (ulonglong) HA_POS_ERROR)
     thd->options |= OPTION_BIG_SELECTS;
 
   thd->proc_info=0;
@@ -903,7 +919,7 @@ bool dispatch_command(enum enum_server_command command, THD *thd,
   thd->lex.select_lex.options=0;		// We store status here
   switch (command) {
   case COM_INIT_DB:
-    thread_safe_increment(com_stat[SQLCOM_CHANGE_DB],&LOCK_status);
+    statistic_increment(com_stat[SQLCOM_CHANGE_DB],&LOCK_status);
     if (!mysql_change_db(thd,packet))
       mysql_log.write(thd,command,"%s",thd->db);
     break;
@@ -915,7 +931,7 @@ bool dispatch_command(enum enum_server_command command, THD *thd,
   }
   case COM_TABLE_DUMP:
     {
-      thread_safe_increment(com_other, &LOCK_status);
+      statistic_increment(com_other, &LOCK_status);
       slow_command = TRUE;
       uint db_len = *(uchar*)packet;
       uint tbl_len = *(uchar*)(packet + db_len + 1);
@@ -932,7 +948,10 @@ bool dispatch_command(enum enum_server_command command, THD *thd,
     }
   case COM_CHANGE_USER:
   {
-    thread_safe_increment(com_other,&LOCK_status);
+    thd->change_user();
+    clear_error_message(thd);			// If errors from rollback
+
+    statistic_increment(com_other,&LOCK_status);
     char *user=   (char*) packet;
     char *passwd= strend(user)+1;
     char *db=     strend(passwd)+1;
@@ -985,6 +1004,11 @@ bool dispatch_command(enum enum_server_command command, THD *thd,
     mysql_stmt_prepare(thd, packet, packet_length);
     break;
   }
+  case COM_CLOSE_STMT:
+  {
+    mysql_stmt_free(thd, packet);
+    break;
+  }
   case COM_QUERY:
   {
     if (alloc_query(thd, packet, packet_length))
@@ -1005,7 +1029,7 @@ bool dispatch_command(enum enum_server_command command, THD *thd,
   {
     char *fields;
     TABLE_LIST table_list;
-    thread_safe_increment(com_stat[SQLCOM_SHOW_FIELDS],&LOCK_status);
+    statistic_increment(com_stat[SQLCOM_SHOW_FIELDS],&LOCK_status);
     bzero((char*) &table_list,sizeof(table_list));
     if (!(table_list.db=thd->db))
     {
@@ -1040,7 +1064,7 @@ bool dispatch_command(enum enum_server_command command, THD *thd,
 
   case COM_CREATE_DB:				// QQ: To be removed
     {
-      thread_safe_increment(com_stat[SQLCOM_CREATE_DB],&LOCK_status);
+      statistic_increment(com_stat[SQLCOM_CREATE_DB],&LOCK_status);
       char *db=thd->strdup(packet);
       // null test to handle EOM
       if (!db || !strip_sp(db) || check_db_name(db))
@@ -1058,7 +1082,7 @@ bool dispatch_command(enum enum_server_command command, THD *thd,
     }
   case COM_DROP_DB:				// QQ: To be removed
     {
-      thread_safe_increment(com_stat[SQLCOM_DROP_DB],&LOCK_status);
+      statistic_increment(com_stat[SQLCOM_DROP_DB],&LOCK_status);
       char *db=thd->strdup(packet);
       // null test to handle EOM
       if (!db || !strip_sp(db) || check_db_name(db))
@@ -1079,7 +1103,7 @@ bool dispatch_command(enum enum_server_command command, THD *thd,
     }
   case COM_BINLOG_DUMP:
     {
-      thread_safe_increment(com_other,&LOCK_status);
+      statistic_increment(com_other,&LOCK_status);
       slow_command = TRUE;
       if (check_global_access(thd, REPL_SLAVE_ACL))
 	break;
@@ -1103,7 +1127,7 @@ bool dispatch_command(enum enum_server_command command, THD *thd,
     }
   case COM_REFRESH:
     {
-      thread_safe_increment(com_stat[SQLCOM_FLUSH],&LOCK_status);
+      statistic_increment(com_stat[SQLCOM_FLUSH],&LOCK_status);
       ulong options= (ulong) (uchar) packet[0];
       if (check_global_access(thd,RELOAD_ACL))
 	break;
@@ -1115,7 +1139,7 @@ bool dispatch_command(enum enum_server_command command, THD *thd,
       break;
     }
   case COM_SHUTDOWN:
-    thread_safe_increment(com_other,&LOCK_status);
+    statistic_increment(com_other,&LOCK_status);
     if (check_global_access(thd,SHUTDOWN_ACL))
       break; /* purecov: inspected */
     DBUG_PRINT("quit",("Got shutdown command"));
@@ -1138,7 +1162,7 @@ bool dispatch_command(enum enum_server_command command, THD *thd,
   case COM_STATISTICS:
   {
     mysql_log.write(thd,command,NullS);
-    thread_safe_increment(com_stat[SQLCOM_SHOW_STATUS],&LOCK_status);
+    statistic_increment(com_stat[SQLCOM_SHOW_STATUS],&LOCK_status);
     char buff[200];
     ulong uptime = (ulong) (thd->start_time - start_time);
     sprintf((char*) buff,
@@ -1157,11 +1181,11 @@ bool dispatch_command(enum enum_server_command command, THD *thd,
     break;
   }
   case COM_PING:
-    thread_safe_increment(com_other,&LOCK_status);
+    statistic_increment(com_other,&LOCK_status);
     send_ok(thd);				// Tell client we are alive
     break;
   case COM_PROCESS_INFO:
-    thread_safe_increment(com_stat[SQLCOM_SHOW_PROCESSLIST],&LOCK_status);
+    statistic_increment(com_stat[SQLCOM_SHOW_PROCESSLIST],&LOCK_status);
     if (!thd->priv_user[0] && check_global_access(thd,PROCESS_ACL))
       break;
     mysql_log.write(thd,command,NullS);
@@ -1170,13 +1194,13 @@ bool dispatch_command(enum enum_server_command command, THD *thd,
     break;
   case COM_PROCESS_KILL:
   {
-    thread_safe_increment(com_stat[SQLCOM_KILL],&LOCK_status);
+    statistic_increment(com_stat[SQLCOM_KILL],&LOCK_status);
     ulong id=(ulong) uint4korr(packet);
     kill_one_thread(thd,id);
     break;
   }
   case COM_DEBUG:
-    thread_safe_increment(com_other,&LOCK_status);
+    statistic_increment(com_other,&LOCK_status);
     if (check_global_access(thd, SUPER_ACL))
       break;					/* purecov: inspected */
     mysql_print_status(thd);
@@ -1297,7 +1321,7 @@ mysql_execute_command(THD *thd)
     that is not a SHOW command or a select that only access local
     variables, but for now this is probably good enough.
   */
-  if (tables)
+  if (tables || lex->select_lex.next_select_in_list())
     mysql_reset_errors(thd);
   /*
     Save old warning count to be able to send to client how many warnings we
@@ -1328,81 +1352,34 @@ mysql_execute_command(THD *thd)
 #endif
   }
   
-  select_result *explain_result= 0;  
   /*
     TODO: make derived tables processing 'inside' SELECT processing.
     TODO: solve problem with depended derived tables in subselects
   */
-  if (lex->sql_command == SQLCOM_SELECT && 
-      lex->describe && lex->derived_tables)
-  {
-    if (!(explain_result= new select_send()))
-    {
-      send_error(thd, ER_OUT_OF_RESOURCES);
-      DBUG_VOID_RETURN;
-    }
-    //check rights
-    for (cursor= tables;
-	 cursor;
-	 cursor= cursor->next)
-      if (cursor->derived)
-      {
-	TABLE_LIST *tables= 
-	  (TABLE_LIST *)((SELECT_LEX_UNIT *)
-			 cursor->derived)->first_select()->table_list.first;
-	int res;
-	if (tables)
-	  res= check_table_access(thd,SELECT_ACL, tables);
-	else
-	  res= check_access(thd, SELECT_ACL, any_db);
-	if (res)
-	  DBUG_VOID_RETURN;
-      }
-    thd->send_explain_fields(explain_result);
-    // EXPLAIN derived tables
-    for (cursor= tables;
-	 cursor;
-	 cursor= cursor->next)
-      if (cursor->derived)
-      {
-	SELECT_LEX *select_lex= ((SELECT_LEX_UNIT *)
-				 cursor->derived)->first_select();
-	if (!open_and_lock_tables(thd, 
-				  (TABLE_LIST*) select_lex->table_list.first))
-	{
-	  mysql_explain_select(thd, select_lex,
-			       "DERIVED", explain_result);
-	  // execute derived table SELECT to provide table for other SELECTs
-	  if (mysql_derived(thd, lex, (SELECT_LEX_UNIT *)cursor->derived,
-			    cursor, 1))
+  if (lex->derived_tables)
+  {
+    for (SELECT_LEX *sl= &lex->select_lex; sl; sl= sl->next_select_in_list())
+      if (sl->linkage != DERIVED_TABLE_TYPE)
+	for (TABLE_LIST *cursor= sl->get_table_list();
+	     cursor;
+	     cursor= cursor->next)
+	  if (cursor->derived && (res=mysql_derived(thd, lex,
+						    (SELECT_LEX_UNIT *)
+						    cursor->derived,
+						    cursor)))
+	  {  
+	    if (res < 0 || thd->net.report_error)
+	      send_error(thd,thd->killed ? ER_SERVER_SHUTDOWN : 0);
 	    DBUG_VOID_RETURN;
-	}
-	else
-	  DBUG_VOID_RETURN;
-      }
-      
-  }
-  else if (lex->derived_tables)
-  {
-    for (TABLE_LIST *cursor= tables;
-	 cursor;
-	 cursor= cursor->next)
-      if (cursor->derived && (res=mysql_derived(thd, lex,
-					   (SELECT_LEX_UNIT *)cursor->derived,
-						cursor, 0)))
-      {  
-	if (res < 0)
-	  send_error(thd,thd->killed ? ER_SERVER_SHUTDOWN : 0);
-	DBUG_VOID_RETURN;
-      }
-  }
+	  }
+  } 
   if ((lex->select_lex.next_select_in_list() && 
        lex->unit.create_total_list(thd, lex, &tables)) ||
       (table_rules_on && tables && thd->slave_thread &&
        !tables_ok(thd,tables)))
     DBUG_VOID_RETURN;
 
-  thread_safe_increment(com_stat[lex->sql_command],&LOCK_status);
+  statistic_increment(com_stat[lex->sql_command],&LOCK_status);
   switch (lex->sql_command) {
   case SQLCOM_SELECT:
   {
@@ -1423,10 +1400,11 @@ mysql_execute_command(THD *thd)
       break;					// Error message is given
     }
 
-    unit->offset_limit_cnt= unit->global_parameters->offset_limit;
-    unit->select_limit_cnt= unit->global_parameters->select_limit+
-      unit->global_parameters->offset_limit;
-    if (unit->select_limit_cnt < unit->global_parameters->select_limit)
+    unit->offset_limit_cnt= (ha_rows) unit->global_parameters->offset_limit;
+    unit->select_limit_cnt= (ha_rows) (unit->global_parameters->select_limit+
+      unit->global_parameters->offset_limit);
+    if (unit->select_limit_cnt < 
+	(ha_rows) unit->global_parameters->select_limit)
       unit->select_limit_cnt= HA_POS_ERROR;		// no limit
     if (unit->select_limit_cnt == HA_POS_ERROR)
       select_lex->options&= ~OPTION_FOUND_ROWS;
@@ -1435,37 +1413,25 @@ mysql_execute_command(THD *thd)
     {
       if (lex->describe)
       {
-	if (!explain_result)
-	  if (!(explain_result= new select_send()))
-	  {
-	    send_error(thd, ER_OUT_OF_RESOURCES);
-	    DBUG_VOID_RETURN;
-	  }
-	  else
-	    thd->send_explain_fields(explain_result);
+	if (!(result= new select_send()))
+	{
+	  send_error(thd, ER_OUT_OF_RESOURCES);
+	  DBUG_VOID_RETURN;
+	}
+	else
+	  thd->send_explain_fields(result);
 	fix_tables_pointers(select_lex);
-	res= mysql_explain_union(thd, &thd->lex.unit, explain_result);
+	res= mysql_explain_union(thd, &thd->lex.unit, result);
 	MYSQL_LOCK *save_lock= thd->lock;
 	thd->lock= (MYSQL_LOCK *)0;
-	explain_result->send_eof();
+	result->send_eof();
 	thd->lock= save_lock;
       }
       else
       {
 	if (!result)
 	{
-	  if ((result=new select_send()))
-	  {
-	    /*
-	      Normal select:
-	      Change lock if we are using SELECT HIGH PRIORITY,
-	      FOR UPDATE or IN SHARE MODE
-	    */
-	    TABLE_LIST *table;
-	    for (table = tables ; table ; table=table->next)
-	      table->lock_type= lex->lock_option;
-	  }
-	  else
+	  if (!(result=new select_send()))
 	  {
 	    res= -1;
 #ifdef DELETE_ITEMS
@@ -1689,8 +1655,6 @@ mysql_execute_command(THD *thd)
 	TABLE_LIST *table;
 	if (check_table_access(thd, SELECT_ACL, tables->next))
 	  goto error;				// Error message is given
-	for (table = tables->next ; table ; table=table->next)
-	  table->lock_type= lex->lock_option;
       }
       unit->offset_limit_cnt= select_lex->offset_limit;
       unit->select_limit_cnt= select_lex->select_limit+
@@ -1758,7 +1722,7 @@ mysql_execute_command(THD *thd)
 #else
     {
       ulong priv=0;
-      if (lex->name && strlen(lex->name) > NAME_LEN)
+      if (lex->name && (!lex->name[0] || strlen(lex->name) > NAME_LEN))
       {
 	net_printf(thd,ER_WRONG_TABLE_NAME,lex->name);
 	res=0;
@@ -1932,18 +1896,13 @@ mysql_execute_command(THD *thd)
     }
     if (select_lex->table_list.elements == 1)
     {
-      res = mysql_update(thd,tables,
-			 select_lex->item_list,
-			 lex->value_list,
-			 select_lex->where,
-			 (ORDER *) select_lex->order_list.first,
-			 select_lex->select_limit,
-			 lex->duplicates,
-			 lex->lock_option);
-
-#ifdef DELETE_ITEMS
-      delete select_lex->where;
-#endif
+      res= mysql_update(thd,tables,
+			select_lex->item_list,
+			lex->value_list,
+			select_lex->where,
+			(ORDER *) select_lex->order_list.first,
+			select_lex->select_limit,
+			lex->duplicates);
     }
     else 
     {
@@ -1953,11 +1912,8 @@ mysql_execute_command(THD *thd)
       const char *msg=0;
 
       lex->sql_command=SQLCOM_MULTI_UPDATE;
-      for (auxi=(TABLE_LIST*) tables, table_count=0 ; auxi ; auxi=auxi->next)
-      {
+      for (auxi= (TABLE_LIST*) tables, table_count=0 ; auxi ; auxi=auxi->next)
 	table_count++;
-	auxi->lock_type=TL_WRITE;
-      }
 
       if (select_lex->order_list.elements)
 	msg="ORDER BY";
@@ -1979,8 +1935,7 @@ mysql_execute_command(THD *thd)
 	  !setup_fields(thd,tables,lex->value_list,0,0,0) && 
 	  !thd->fatal_error &&
 	  (result=new multi_update(thd,tables,select_lex->item_list,
-				   lex->duplicates, lex->lock_option,
-				   table_count)))
+				   lex->duplicates, table_count)))
       {
 	List <Item> total_list;
 	List_iterator <Item> field_list(select_lex->item_list);
@@ -2011,8 +1966,7 @@ mysql_execute_command(THD *thd)
     if (grant_option && check_grant(thd,INSERT_ACL,tables))
       goto error;
     res = mysql_insert(thd,tables,lex->field_list,lex->many_values,
-		       lex->duplicates,
-		       lex->lock_option);
+		       lex->duplicates);
     break;
   case SQLCOM_REPLACE:
     if (check_access(thd,INSERT_ACL | DELETE_ACL,
@@ -2023,8 +1977,7 @@ mysql_execute_command(THD *thd)
 
       goto error;
     res = mysql_insert(thd,tables,lex->field_list,lex->many_values,
-		       DUP_REPLACE,
-		       lex->lock_option);
+		       DUP_REPLACE);
     break;
   case SQLCOM_REPLACE_SELECT:
   case SQLCOM_INSERT_SELECT:
@@ -2059,12 +2012,6 @@ mysql_execute_command(THD *thd)
       net_printf(thd,ER_INSERT_TABLE_USED,tables->real_name);
       DBUG_VOID_RETURN;
     }
-    tables->lock_type=TL_WRITE;		// update first table
-    {
-      TABLE_LIST *table;
-      for (table = tables->next ; table ; table=table->next)
-	table->lock_type= lex->lock_option;
-    }
 
     /* Skip first table, which is the table we are inserting in */
     lex->select_lex.table_list.first=
@@ -2103,8 +2050,7 @@ mysql_execute_command(THD *thd)
     tables->grant.want_privilege=(SELECT_ACL & ~tables->grant.privilege);
     res = mysql_delete(thd,tables, select_lex->where,
                        (ORDER*) select_lex->order_list.first,
-                       select_lex->select_limit, lex->lock_option,
-                       select_lex->options);
+                       select_lex->select_limit, select_lex->options);
     break;
   }
   case SQLCOM_DELETE_MULTI:
@@ -2140,7 +2086,7 @@ mysql_execute_command(THD *thd)
 	net_printf(thd,ER_NONUNIQ_TABLE,auxi->real_name);
 	goto error;
       }
-      auxi->lock_type=walk->lock_type=TL_WRITE;
+      walk->lock_type= auxi->lock_type;
       auxi->table_list=  walk;		// Remember corresponding table
     }
     if (add_item_to_list(new Item_null()))
@@ -2155,7 +2101,6 @@ mysql_execute_command(THD *thd)
     for (auxi=(TABLE_LIST*) aux_tables ; auxi ; auxi=auxi->next)
       auxi->table= auxi->table_list->table;
     if (!thd->fatal_error && (result= new multi_delete(thd,aux_tables,
-						       lex->lock_option,
 						       table_count)))
     {
       res= mysql_select(thd,tables,select_lex->item_list,
@@ -2361,11 +2306,7 @@ mysql_execute_command(THD *thd)
       send_ok(thd);
     break;
   case SQLCOM_UNLOCK_TABLES:
-    if (thd->locked_tables)
-    {
-      thd->lock=thd->locked_tables;
-      thd->locked_tables=0;			// Will be automaticly closed
-    }
+    unlock_locked_tables(thd);
     if (thd->options & OPTION_TABLE_LOCK)
     {
       end_active_trans(thd);
@@ -2376,12 +2317,7 @@ mysql_execute_command(THD *thd)
     send_ok(thd);
     break;
   case SQLCOM_LOCK_TABLES:
-    if (thd->locked_tables)
-    {
-      thd->lock=thd->locked_tables;
-      thd->locked_tables=0;			// Will be automaticly closed
-      close_thread_tables(thd);
-    }
+    unlock_locked_tables(thd);
     if (check_db_used(thd,tables) || end_active_trans(thd))
       goto error;
     if (check_table_access(thd, LOCK_TABLES_ACL | SELECT_ACL, tables))
@@ -2531,7 +2467,7 @@ mysql_execute_command(THD *thd)
 	mysql_update_log.write(thd, thd->query, thd->query_length);
 	if (mysql_bin_log.is_open())
 	{
-	  Query_log_event qinfo(thd, thd->query, thd->query_length);
+	  Query_log_event qinfo(thd, thd->query, thd->query_length, 0);
 	  mysql_bin_log.write(&qinfo);
 	}
       }
@@ -2551,7 +2487,7 @@ mysql_execute_command(THD *thd)
 	mysql_update_log.write(thd, thd->query, thd->query_length);
 	if (mysql_bin_log.is_open())
 	{
-	  Query_log_event qinfo(thd, thd->query, thd->query_length);
+	  Query_log_event qinfo(thd, thd->query, thd->query_length, 0);
 	  mysql_bin_log.write(&qinfo);
 	}
 	if (mqh_used && lex->sql_command == SQLCOM_GRANT)
@@ -2768,6 +2704,8 @@ check_table_access(THD *thd, ulong want_access,TABLE_LIST *tables,
   TABLE_LIST *org_tables=tables;
   for (; tables ; tables=tables->next)
   {
+    if (tables->derived || (tables->table && (int)tables->table->tmp_table))
+      continue;
     if ((thd->master_access & want_access) == (want_access & ~EXTRA_ACL) &&
 	thd->db)
       tables->grant.privilege= want_access;
@@ -2784,7 +2722,7 @@ check_table_access(THD *thd, ulong want_access,TABLE_LIST *tables,
 	found=1;
       }
     }
-    else if (tables->db && check_access(thd,want_access,tables->db,&tables->grant.privilege,
+    else if (check_access(thd,want_access,tables->db,&tables->grant.privilege,
 			  0, no_errors))
       return TRUE;
   }
@@ -2901,26 +2839,26 @@ void
 mysql_init_query(THD *thd)
 {
   DBUG_ENTER("mysql_init_query");
-  thd->lex.unit.init_query();
-  thd->lex.unit.init_select();
-  thd->lex.select_lex.init_query();
-  thd->lex.unit.slave= &thd->lex.select_lex;
-  thd->lex.unit.global_parameters= &thd->lex.select_lex; //Global limit & order
-  thd->lex.select_lex.master= &thd->lex.unit;
-  thd->lex.select_lex.prev= &thd->lex.unit.slave;
-  thd->select_number= thd->lex.select_lex.select_number= 1;
-  thd->lex.value_list.empty();
+  LEX *lex=&thd->lex;
+  lex->unit.init_query();
+  lex->unit.init_select();
+  lex->select_lex.init_query();
+  lex->value_list.empty();
+  lex->param_list.empty();
+  lex->unit.global_parameters= lex->unit.slave= lex->current_select= 
+    &lex->select_lex;
+  lex->select_lex.master= &lex->unit;
+  lex->select_lex.prev= &lex->unit.slave;
+  lex->olap=lex->describe=0;
+  lex->derived_tables= false;
+  thd->check_loops_counter= thd->select_number= 
+    lex->select_lex.select_number= 1;
   thd->free_list= 0;
-  thd->lex.current_select= &thd->lex.select_lex;
-  thd->lex.olap=thd->lex.describe=0;
-  thd->lex.select_lex.olap= UNSPECIFIED_OLAP_TYPE;
-  thd->fatal_error= 0;				// Safety
   thd->total_warn_count=0;			// Warnings for this query
   thd->last_insert_id_used= thd->query_start_used= thd->insert_id_used=0;
   thd->sent_row_count= thd->examined_row_count= 0;
-  thd->rand_used=0;
-  thd->safe_to_cache_query= 1;
-  thd->lex.param_list.empty();
+  thd->fatal_error= thd->rand_used= 0;
+  thd->possible_loops= 0;
   DBUG_VOID_RETURN;
 }
 
@@ -2932,7 +2870,6 @@ mysql_init_select(LEX *lex)
   select_lex->init_select();
   select_lex->master_unit()->select_limit= select_lex->select_limit= 
     lex->thd->variables.select_limit;
-  select_lex->olap=   UNSPECIFIED_OLAP_TYPE;
   lex->exchange= 0;
   lex->result= 0;
   lex->proc_list.first= 0;
@@ -3016,14 +2953,13 @@ mysql_parse(THD *thd, char *inBuf, uint length)
 
   mysql_init_query(thd);
   thd->query_length = length;
-  thd->lex.derived_tables= false;
   if (query_cache_send_result_to_client(thd, inBuf, length) <= 0)
   {
     LEX *lex=lex_start(thd, (uchar*) inBuf, length);
     if (!yyparse() && ! thd->fatal_error)
     {
       if (mqh_used && thd->user_connect &&
-	  check_mqh(thd, thd->lex.sql_command))
+	  check_mqh(thd, lex->sql_command))
       {
 	thd->net.error = 0;
       }
@@ -3072,6 +3008,7 @@ bool add_field_to_list(char *field_name, enum_field_types type,
   THD	*thd=current_thd;
   LEX  *lex= &thd->lex;
   uint allowed_type_modifier=0;
+  char warn_buff[MYSQL_ERRMSG_SIZE];
   DBUG_ENTER("add_field_to_list");
 
   if (strlen(field_name) > NAME_LEN)
@@ -3163,8 +3100,6 @@ bool add_field_to_list(char *field_name, enum_field_types type,
     if (!length) new_field->length=20;
     allowed_type_modifier= AUTO_INCREMENT_FLAG;
     break;
-  case FIELD_TYPE_STRING:
-  case FIELD_TYPE_VAR_STRING:
   case FIELD_TYPE_NULL:
   case FIELD_TYPE_GEOMETRY:
     break;
@@ -3175,10 +3110,35 @@ bool add_field_to_list(char *field_name, enum_field_types type,
     if (new_field->decimals)
       new_field->length++;
     break;
+  case FIELD_TYPE_STRING:
+  case FIELD_TYPE_VAR_STRING:
+    if (new_field->length < MAX_FIELD_WIDTH || default_value)
+      break;
+    /* Convert long CHAR() and VARCHAR columns to TEXT or BLOB */
+    new_field->sql_type= FIELD_TYPE_BLOB;
+    sprintf(warn_buff, ER(ER_AUTO_CONVERT), field_name, "CHAR",
+	    (cs == my_charset_bin) ? "BLOB" : "TEXT");
+    push_warning(thd, MYSQL_ERROR::WARN_LEVEL_WARN, ER_AUTO_CONVERT,
+		 warn_buff);
+    /* fall through */
   case FIELD_TYPE_BLOB:
   case FIELD_TYPE_TINY_BLOB:
   case FIELD_TYPE_LONG_BLOB:
   case FIELD_TYPE_MEDIUM_BLOB:
+    if (new_field->length)
+    {
+      /* The user has given a length to the blob column */
+      if (new_field->length < 256)
+	type= FIELD_TYPE_TINY_BLOB;
+      if (new_field->length < 65536)
+	type= FIELD_TYPE_BLOB;
+      else if (new_field->length < 256L*256L*256L)
+	type= FIELD_TYPE_MEDIUM_BLOB;
+      else
+	type= FIELD_TYPE_LONG_BLOB;
+      new_field->length= 0;
+    }
+    new_field->sql_type= type;
     if (default_value)				// Allow empty as default value
     {
       String str,*res;
@@ -3431,7 +3391,8 @@ TABLE_LIST *st_select_lex::add_table_to_list(Table_ident *table,
     DBUG_RETURN(0);				// End of memory
   alias_str= alias ? alias->str : table->table.str;
   if (table->table.length > NAME_LEN ||
-      (table->table.length && check_table_name(table->table.str,table->table.length)) ||
+      (table->table.length &&
+       check_table_name(table->table.str,table->table.length)) ||
       table->db.str && check_db_name(table->db.str))
   {
     net_printf(thd,ER_WRONG_TABLE_NAME,table->table.str);
@@ -3498,14 +3459,49 @@ TABLE_LIST *st_select_lex::add_table_to_list(Table_ident *table,
 }
 
 
+/*
+  Set lock for all tables in current select level
+
+  SYNOPSIS:
+    set_lock_for_tables()
+    lock_type			Lock to set for tables
+
+  NOTE:
+    If lock is a write lock, then tables->updating is set 1
+    This is to get tables_ok to know that the table is updated by the
+    query
+*/
+
+void st_select_lex::set_lock_for_tables(thr_lock_type lock_type)
+{
+  bool for_update= lock_type >= TL_READ_NO_INSERT;
+  DBUG_ENTER("set_lock_for_tables");
+  DBUG_PRINT("enter", ("lock_type: %d  for_update: %d", lock_type,
+		       for_update));
+
+  for (TABLE_LIST *tables= (TABLE_LIST*) table_list.first ;
+       tables ;
+       tables=tables->next)
+  {
+    tables->lock_type= lock_type;
+    tables->updating=  for_update;
+  }
+  DBUG_VOID_RETURN;
+}
+
+
 void add_join_on(TABLE_LIST *b,Item *expr)
 {
-  if (!b->on_expr)
-    b->on_expr=expr;
-  else
+  if (expr)
   {
-    // This only happens if you have both a right and left join
-    b->on_expr=new Item_cond_and(b->on_expr,expr);
+    if (!b->on_expr)
+      b->on_expr=expr;
+    else
+    {
+      // This only happens if you have both a right and left join
+      b->on_expr=new Item_cond_and(b->on_expr,expr);
+    }
+    b->on_expr->top_level_item();
   }
 }
 
@@ -3533,7 +3529,7 @@ bool reload_acl_and_cache(THD *thd, ulong options, TABLE_LIST *tables)
   if (options & REFRESH_GRANT)
   {
     acl_reload(thd);
-    grant_reload();
+    grant_reload(thd);
     if (mqh_used)
       reset_mqh(thd,(LEX_USER *) NULL,true);
   }
diff --git a/sql/sql_prepare.cc b/sql/sql_prepare.cc
index 08377a105017d30de8ca83acc6bc64f71d6d7baf..b631a30fed95a470883b5742c2f25bcc8ab5fea2 100644
--- a/sql/sql_prepare.cc
+++ b/sql/sql_prepare.cc
@@ -20,31 +20,47 @@ This file contains the implementation of prepare and executes.
 
 Prepare:
 
-  - Server gets the query from client with command 'COM_PREPARE'
+  - Server gets the query from client with command 'COM_PREPARE'; 
+    in the following format:
+    [COM_PREPARE:1] [query]
   - Parse the query and recognize any parameter markers '?' and 
-    store its information list lex->param_list
+    store its information list in lex->param_list
+  - Allocate a new statement for this prepare; and keep this in 
+    'thd->prepared_statements' pool.
   - Without executing the query, return back to client the total 
     number of parameters along with result-set metadata information
-    (if any)
+    (if any) in the following format:
+    [STMT_ID:4][Columns:2][Param_count:2][Columns meta info][Params meta info]
      
 Prepare-execute:
 
   - Server gets the command 'COM_EXECUTE' to execute the 
-    previously prepared query.
-  - If there is are any parameters, then replace the markers with the 
-    data supplied by client with the following format:
-    [types_specified(0/1)][type][length][data] .. [type][length]..
+    previously prepared query. If there is any param markers; then client
+    will send the data in the following format:    
+    [COM_EXECUTE:1]
+    [STMT_ID:4]
+    [NULL_BITS:(param_count+7)/8)]
+    [TYPES_SUPPLIED_BY_CLIENT(0/1):1]
+    [[length]data]
+    [[length]data] .. [[length]data]. 
+    (Note: Except for string/binary types; all other types will not be 
+    supplied with length field)
+  - Replace the param items with this new data. If it is a first execute 
+    or types altered by client; then setup the conversion routines.
   - Execute the query without re-parsing and send back the results 
     to client
 
 Long data handling:
+
   - Server gets the long data in pieces with command type 'COM_LONG_DATA'.
   - The packet recieved will have the format as:
-    [COM_LONG_DATA:1][parameter_number:2][type:2][data]
+    [COM_LONG_DATA:1][STMT_ID:4][parameter_number:2][type:2][data]
   - Checks if the type is specified by client, and if yes reads the type, 
     and stores the data in that format.
   - It's up to the client to check for read data ended. The server doesn't
-    care.
+    care; and also server doesn't notify to the client that it got the 
+    data or not; if there is any error; then during execute; the error 
+    will be returned
 
 ***********************************************************************/
 
@@ -53,33 +69,9 @@ Long data handling:
 #include <assert.h> // for DEBUG_ASSERT()
 #include <m_ctype.h>  // for isspace()
 
-extern int yyparse(void);
-static ulong get_param_length(uchar **packet);
-static uint get_buffer_type(uchar **packet);
-static bool param_is_null(uchar **packet);
-static bool setup_param_fields(THD *thd,List<Item> &params);
-static uchar* setup_param_field(Item_param *item_param, uchar *pos,
-				uint buffer_type);
-static void setup_longdata_field(Item_param *item_param, uchar *pos);
-static bool setup_longdata(THD *thd,List<Item> &params);
-static bool send_prepare_results(PREP_STMT *stmt);
-static bool parse_prepare_query(PREP_STMT *stmt, char *packet, uint length);
-static bool mysql_send_insert_fields(PREP_STMT *stmt, TABLE_LIST *table_list, 
-				     List<Item> &fields,
-				     List<List_item> &values_list,
-				     thr_lock_type lock_type);
-static bool mysql_test_insert_fields(PREP_STMT *stmt, TABLE_LIST *table_list, 
-				     List<Item> &fields,
-				     List<List_item> &values_list,
-				     thr_lock_type lock_type);
-static bool mysql_test_upd_fields(PREP_STMT *stmt, TABLE_LIST *table_list,
-				  List<Item> &fields, List<Item> &values,
-				  COND *conds,thr_lock_type lock_type);
-static bool mysql_test_select_fields(PREP_STMT *stmt, TABLE_LIST *tables,
-				     List<Item> &fields, List<Item> &values,
-				     COND *conds, ORDER *order, ORDER *group,
-				     Item *having,thr_lock_type lock_type);
+#define IS_PARAM_NULL(pos, param_no) pos[param_no/8] & (1 << param_no & 7)
 
+extern int yyparse(void);
 
 /*
   Find prepared statement in thd
@@ -114,9 +106,9 @@ static PREP_STMT *find_prepared_statement(THD *thd, ulong stmt_id,
   Compare two prepared statements;  Used to find a prepared statement
 */
 
-int compare_prep_stmt(PREP_STMT *a, PREP_STMT *b, void *not_used)
+int compare_prep_stmt(void *not_used, PREP_STMT *stmt, ulong *key)
 {
-  return (a->stmt_id < b->stmt_id) ? -1 : (a->stmt_id == b->stmt_id) ? 0 : 1;
+  return (stmt->stmt_id == *key) ? 0 : (stmt->stmt_id < *key) ? -1 : 1;
 }
 
 
@@ -132,22 +124,23 @@ int compare_prep_stmt(PREP_STMT *a, PREP_STMT *b, void *not_used)
 */
 
 void free_prep_stmt(PREP_STMT *stmt, TREE_FREE mode, void *not_used)
-{
-  free_root(&stmt->mem_root, MYF(0));
+{   
   free_items(stmt->free_list);
+  free_root(&stmt->mem_root, MYF(0));
 }
 
 /*
   Send prepared stmt info to client after prepare
 */
 
-bool send_prep_stmt(PREP_STMT *stmt, uint columns)
+static bool send_prep_stmt(PREP_STMT *stmt, uint columns)
 {
+  NET  *net=&stmt->thd->net;
   char buff[8];
   int4store(buff, stmt->stmt_id);
   int2store(buff+4, columns);
   int2store(buff+6, stmt->param_count);
-  return my_net_write(&stmt->thd->net, buff, sizeof(buff));
+  return (my_net_write(net, buff, sizeof(buff)) || net_flush(net));
 }
 
 /*
@@ -156,43 +149,15 @@ bool send_prep_stmt(PREP_STMT *stmt, uint columns)
   TODO: Not yet ready
 */
 
-bool send_item_params(PREP_STMT *stmt)
+static bool send_item_params(PREP_STMT *stmt)
 {
+#if 0
   char buff[1];
   buff[0]=0;
-  return my_net_write(&stmt->thd->net, buff, sizeof(buff));
-}
-
-
-
-/*
-  Read the buffer type, this happens only first time        
-*/
-
-static uint get_buffer_type(uchar **packet)
-{
-  reg1 uchar *pos= *packet;
-  (*packet)+= 2;
-  return (uint) uint2korr(pos);
-}
-
-
-/*
-  Check for NULL param data
-
-  RETURN VALUES
-    0	Value was not NULL
-    1	Value was NULL
-*/
-
-static bool param_is_null(uchar **packet)
-{
-  reg1 uchar *pos= *packet;
-  if (*pos == 251)
-  {
-    (*packet)++;
+  if (my_net_write(&stmt->thd->net, buff, sizeof(buff))) 
     return 1;
-  }
+  send_eof(stmt->thd);
+#endif
   return 0;
 }
 
@@ -222,60 +187,103 @@ static ulong get_param_length(uchar **packet)
   (*packet)+=9; // Must be 254 when here 
   return (ulong) uint4korr(pos+1);
 }
+ /*
+  Setup param conversion routines
 
-/*
-  Read and return the data for parameters supplied by client 
+  setup_param_xx()
+  param   Parameter Item
+  pos     Input data buffer
+
+  All these functions reads the data from pos and sets up that data
+  through 'param' and advances the buffer position to predifined
+  length position.
+
+  Make a note that the NULL handling is examined at first execution
+  (i.e. when input types altered) and for all subsequent executions
+  we don't read any values for this.
+
+  RETURN VALUES
+    
 */
 
-static uchar* setup_param_field(Item_param *item_param, 
-				uchar *pos, uint buffer_type)
+static void setup_param_tiny(Item_param *param, uchar **pos)
 {
-  if (param_is_null(&pos))
-  {
-    item_param->set_null();
-    return(pos);
-  }
-  switch (buffer_type) {    
+  param->set_int((longlong)(**pos));
+  *pos+= 1;
+}
+
+static void setup_param_short(Item_param *param, uchar **pos)
+{
+  param->set_int((longlong)sint2korr(*pos));
+  *pos+= 2;
+}
+
+static void setup_param_int32(Item_param *param, uchar **pos)
+{
+  param->set_int((longlong)sint4korr(*pos));
+  *pos+= 4;
+}
+
+static void setup_param_int64(Item_param *param, uchar **pos)
+{
+  param->set_int((longlong)sint8korr(*pos));
+  *pos+= 8;
+}
+
+static void setup_param_float(Item_param *param, uchar **pos)
+{
+  float data;
+  float4get(data,*pos);
+  param->set_double((double) data);
+  *pos+= 4;
+}
+
+static void setup_param_double(Item_param *param, uchar **pos)
+{
+  double data;
+  float8get(data,*pos);
+  param->set_double((double) data);
+  *pos+= 8;
+}
+
+static void setup_param_str(Item_param *param, uchar **pos)
+{
+  ulong len=get_param_length(pos);
+  param->set_value((const char *)*pos, len);
+  *pos+=len;        
+}
+
+static void setup_param_functions(Item_param *param, uchar param_type)
+{
+  switch (param_type) {
   case FIELD_TYPE_TINY:
-    item_param->set_int((longlong)(*pos));
-    pos += 1;
+    param->setup_param_func= setup_param_tiny;
+    param->item_result_type = INT_RESULT;
     break;
   case FIELD_TYPE_SHORT:
-    item_param->set_int((longlong)sint2korr(pos));
-    pos += 2;
-    break;
-  case FIELD_TYPE_INT24:
-    item_param->set_int((longlong)sint4korr(pos));
-    pos += 3;
+    param->setup_param_func= setup_param_short;
+    param->item_result_type = INT_RESULT;
     break;
   case FIELD_TYPE_LONG:
-    item_param->set_int((longlong)sint4korr(pos));
-    pos += 4;
+    param->setup_param_func= setup_param_int32;
+    param->item_result_type = INT_RESULT;
     break;
   case FIELD_TYPE_LONGLONG:
-    item_param->set_int((longlong)sint8korr(pos));
-    pos += 8;
+    param->setup_param_func= setup_param_int64;
+    param->item_result_type = INT_RESULT;
     break;
   case FIELD_TYPE_FLOAT:
-    float data;
-    float4get(data,pos);
-    item_param->set_double((double) data);
-    pos += 4;
+    param->setup_param_func= setup_param_float;
+    param->item_result_type = REAL_RESULT;
     break;
   case FIELD_TYPE_DOUBLE:
-    double j;
-    float8get(j,pos)
-    item_param->set_double(j);
-    pos += 8;
+    param->setup_param_func= setup_param_double;
+    param->item_result_type = REAL_RESULT;
     break;
   default:
-    {      
-      ulong len=get_param_length(&pos);
-      item_param->set_value((const char*)pos,len,current_thd->thd_charset);
-      pos+=len;        
-    }
+    param->setup_param_func= setup_param_str;
+    param->item_result_type = STRING_RESULT;
   }
-  return(pos);
 }
 
 /*
@@ -283,46 +291,48 @@ static uchar* setup_param_field(Item_param *item_param,
   from client ..                                             
 */
 
-static bool setup_param_fields(THD *thd, PREP_STMT *stmt)
-{  
-  DBUG_ENTER("setup_param_fields");  
-#ifdef READY_TO_BE_USED
-  Item_param *item_param;
-  ulong param_count=0;
-  uchar *pos=(uchar*) thd->net.read_pos+1;// skip command type
+static bool setup_params_data(PREP_STMT *stmt)
+{                                       
+  THD *thd= stmt->thd;
+  List<Item> &params= thd->lex.param_list;
+  List_iterator<Item> param_iterator(params);
+  Item_param *param;
+  DBUG_ENTER("setup_params_data");
 
- 
-  if (*pos++) // No types supplied, read only param data
-  {
-    while ((item_param=(Item_param *)it++) && 
-	   (param_count++ < stmt->param_count))
-    {
-      if (item_param->long_data_supplied)
-        continue;
+  uchar *pos=(uchar*) thd->net.read_pos+1+MYSQL_STMT_HEADER; //skip header
+  uchar *read_pos= pos+(stmt->param_count+7) / 8; //skip null bits   
 
-      if (!(pos=setup_param_field(item_param,pos,item_param->buffer_type)))
-        DBUG_RETURN(1);
+  if (*read_pos++) //types supplied / first execute
+  {              
+    /*
+      First execute or types altered by the client, setup the 
+      conversion routines for all parameters (one time)
+    */
+    while ((param= (Item_param *)param_iterator++))
+    {       
+      if (!param->long_data_supplied)
+      {
+        setup_param_functions(param,*read_pos);
+        read_pos+= 2;
+      }
     }
-  }
-  else // Types supplied, read and store it along with param data 
+    param_iterator.rewind();
+  }    
+  ulong param_no= 0;
+  while ((param= (Item_param *)param_iterator++))
   {
-    while ((item_param=(Item_param *)it++) && 
-	   (param_count++ < thd->param_count))
+    if (!param->long_data_supplied)
     {
-      if (item_param->long_data_supplied)
-        continue;
-
-      if (!(pos=setup_param_field(item_param,pos,
-				  item_param->buffer_type=
-				  (enum_field_types) get_buffer_type(&pos))))
-        DBUG_RETURN(1);
+      if (IS_PARAM_NULL(pos,param_no))
+        param->maybe_null=param->null_value=1;
+      else
+        param->setup_param_func(param,&read_pos);
     }
+    param_no++;
   }
-#endif
   DBUG_RETURN(0);
 }
 
-
 /*
   Validates insert fields                                    
 */
@@ -379,8 +389,7 @@ static int check_prepare_fields(THD *thd,TABLE *table, List<Item> &fields,
 static bool mysql_test_insert_fields(PREP_STMT *stmt,
 				     TABLE_LIST *table_list,
 				     List<Item> &fields, 
-				     List<List_item> &values_list,
-				     thr_lock_type lock_type)                                       
+				     List<List_item> &values_list)
 {
   THD *thd= stmt->thd;
   TABLE *table;
@@ -388,7 +397,7 @@ static bool mysql_test_insert_fields(PREP_STMT *stmt,
   List_item *values;
   DBUG_ENTER("mysql_test_insert_fields");
 
-  if (!(table = open_ltable(thd,table_list,lock_type)))
+  if (!(table = open_ltable(thd,table_list,table_list->lock_type)))
     DBUG_RETURN(1);
 
   if ((values= its++))
@@ -431,13 +440,13 @@ static bool mysql_test_insert_fields(PREP_STMT *stmt,
 
 static bool mysql_test_upd_fields(PREP_STMT *stmt, TABLE_LIST *table_list,
 				  List<Item> &fields, List<Item> &values,
-				  COND *conds, thr_lock_type lock_type)
+				  COND *conds)
 {
   THD *thd= stmt->thd;
   TABLE *table;
   DBUG_ENTER("mysql_test_upd_fields");
 
-  if (!(table = open_ltable(thd,table_list,lock_type)))
+  if (!(table = open_ltable(thd,table_list,table_list->lock_type)))
     DBUG_RETURN(1);
 
   if (setup_tables(table_list) || setup_fields(thd,table_list,fields,1,0,0) || 
@@ -469,7 +478,7 @@ static bool mysql_test_upd_fields(PREP_STMT *stmt, TABLE_LIST *table_list,
 static bool mysql_test_select_fields(PREP_STMT *stmt, TABLE_LIST *tables,
 				     List<Item> &fields, List<Item> &values,
 				     COND *conds, ORDER *order, ORDER *group,
-				     Item *having, thr_lock_type lock_type)
+				     Item *having)
 {
   TABLE *table;
   bool hidden_group_fields;
@@ -477,7 +486,7 @@ static bool mysql_test_select_fields(PREP_STMT *stmt, TABLE_LIST *tables,
   List<Item>  all_fields(fields);
   DBUG_ENTER("mysql_test_select_fields");
 
-  if (!(table = open_ltable(thd,tables,lock_type)))
+  if (!(table = open_ltable(thd,tables,TL_READ)))
     DBUG_RETURN(1);
   
   thd->used_tables=0;	// Updated by setup_fields
@@ -550,21 +559,19 @@ static bool send_prepare_results(PREP_STMT *stmt)
 
   case SQLCOM_INSERT:
     if (mysql_test_insert_fields(stmt, tables, lex->field_list,
-				 lex->many_values, lex->lock_option))
+				 lex->many_values))
       goto abort;    
     break;
 
   case SQLCOM_UPDATE:
     if (mysql_test_upd_fields(stmt, tables, select_lex->item_list,
-			      lex->value_list, select_lex->where,
-			      lex->lock_option))
+			      lex->value_list, select_lex->where))
       goto abort;
     break;
 
   case SQLCOM_DELETE:
     if (mysql_test_upd_fields(stmt, tables, select_lex->item_list,
-			      lex->value_list, select_lex->where,
-			      lex->lock_option))
+			      lex->value_list, select_lex->where))
       goto abort;
     break;
 
@@ -572,8 +579,7 @@ static bool send_prepare_results(PREP_STMT *stmt)
     if (mysql_test_select_fields(stmt, tables, select_lex->item_list,
 				 lex->value_list, select_lex->where,
 				 (ORDER*) select_lex->order_list.first,
-				 (ORDER*) select_lex->group_list.first,
-				 select_lex->having, lex->lock_option))
+				 (ORDER*) select_lex->group_list.first, select_lex->having))
       goto abort;
     break;
 
@@ -583,6 +589,8 @@ static bool send_prepare_results(PREP_STMT *stmt)
          Rest fall through to default category, no parsing 
          for non-DML statements 
       */
+      if (send_prep_stmt(stmt, 0))
+        goto abort;
     }
   }
   DBUG_RETURN(0);
@@ -597,7 +605,7 @@ static bool send_prepare_results(PREP_STMT *stmt)
 */
 
 static bool parse_prepare_query(PREP_STMT *stmt,
-				char *packet, uint length)
+		char *packet, uint length)
 {
   bool error= 1;
   THD *thd= stmt->thd;
@@ -606,15 +614,35 @@ static bool parse_prepare_query(PREP_STMT *stmt,
   mysql_log.write(thd,COM_PREPARE,"%s",packet);       
   mysql_init_query(thd);   
   thd->prepare_command=true; 
-  thd->safe_to_cache_query= 0;
+  thd->lex.param_count=0;
 
   LEX *lex=lex_start(thd, (uchar*) packet, length);
+  lex->safe_to_cache_query= 0;
   if (!yyparse() && !thd->fatal_error) 
     error= send_prepare_results(stmt);
   lex_end(lex);
   DBUG_RETURN(error);
 }
 
+/*
+  Initialize parameter items in statement
+*/
+static bool init_param_items(THD *thd, PREP_STMT *stmt)
+{
+#if TO_BE_TESTED
+  Item_param **to;
+  if (!(to= (Item_param *)
+        my_malloc(sizeof(Item_param*) * stmt->param_count, MYF(MY_WME))))
+    return 1;
+  List<Item> &params= thd->lex.param_list;
+  List_iterator<Item> param_iterator(params);
+  while ((to++ = (Item_param *)param_iterator++))
+  {
+    DBUG_PRINT("info",("param: %lx", to));
+  }
+#endif
+  return 0;
+}
 
 /*
   Parse the query and send the total number of parameters 
@@ -648,9 +676,13 @@ bool mysql_stmt_prepare(THD *thd, char *packet, uint packet_length)
     goto err;
 
   if (!(specialflag & SPECIAL_NO_PRIOR))
-    my_pthread_setprio(pthread_self(),WAIT_PRIOR);   
-       
-  stmt.mem_root= thd->mem_root;
+    my_pthread_setprio(pthread_self(),WAIT_PRIOR);
+#if 0
+  if (init_param_items(thd, &stmt))
+    goto err;
+#endif
+  stmt.mem_root= thd->mem_root;  
+  tree_insert(&thd->prepared_statements, (void *)&stmt, 0, (void *)0);
   thd->mem_root= thd_root; // restore main mem_root
   DBUG_RETURN(0);
 
@@ -685,15 +717,13 @@ void mysql_stmt_execute(THD *thd, char *packet)
   /* Check if we got an error when sending long data */
   if (stmt->error_in_prepare)
   {
-    send_error(thd);
+    send_error(thd, stmt->last_errno, stmt->last_error);
     DBUG_VOID_RETURN;
   }
 
-  if (stmt->param_count && setup_param_fields(thd, stmt))
+  if (stmt->param_count && setup_params_data(stmt))
     DBUG_VOID_RETURN;
 
-  MEM_ROOT thd_root= thd->mem_root;
-  thd->mem_root = thd->con_root;
   if (!(specialflag & SPECIAL_NO_PRIOR))
     my_pthread_setprio(pthread_self(),QUERY_PRIOR);  
  
@@ -703,12 +733,11 @@ void mysql_stmt_execute(THD *thd, char *packet)
     mysql_delete(), mysql_update() and mysql_select() to not to 
     have re-check on setup_* and other things ..
   */  
-  mysql_execute_command(thd);
+  mysql_execute_command(stmt->thd);
 
   if (!(specialflag & SPECIAL_NO_PRIOR))
     my_pthread_setprio(pthread_self(), WAIT_PRIOR);
   
-  thd->mem_root= thd_root;
   DBUG_VOID_RETURN;
 }
 
@@ -757,19 +786,21 @@ void mysql_stmt_reset(THD *thd, char *packet)
   Delete a prepared statement from memory
 */
 
-void mysql_stmt_close(THD *thd, char *packet)
+void mysql_stmt_free(THD *thd, char *packet)
 {
   ulong stmt_id= uint4korr(packet);
   PREP_STMT *stmt;
-  DBUG_ENTER("mysql_stmt_close");
+  DBUG_ENTER("mysql_stmt_free");
 
   if (!(stmt=find_prepared_statement(thd, stmt_id, "close")))
   {
     send_error(thd);
     DBUG_VOID_RETURN;
   }
+  stmt->param= 0;
+  my_free((char *)stmt->param, MYF(MY_ALLOW_ZERO_PTR));
   /* Will call free_prep_stmt() */
-  tree_delete(&thd->prepared_statements, (void*) stmt, NULL);
+  tree_delete(&thd->prepared_statements, (void*) &stmt, (void *)0);
   thd->last_prepared_stmt=0;
   DBUG_VOID_RETURN;
 }
@@ -800,17 +831,16 @@ void mysql_stmt_get_longdata(THD *thd, char *pos, ulong packet_length)
   DBUG_ENTER("mysql_stmt_get_longdata");
 
   /* The following should never happen */
-  if (packet_length < 9)
+  if (packet_length < MYSQL_LONG_DATA_HEADER+1)
   {
     my_error(ER_WRONG_ARGUMENTS, MYF(0), "get_longdata");
     DBUG_VOID_RETURN;
   }
 
-  pos++;				// skip command type at first position
   ulong stmt_id=     uint4korr(pos);
   uint param_number= uint2korr(pos+4);
   uint param_type=   uint2korr(pos+6);
-  pos+=8;				// Point to data
+  pos+=MYSQL_LONG_DATA_HEADER;	// Point to data
 
   if (!(stmt=find_prepared_statement(thd, stmt_id, "get_longdata")))
   {
@@ -829,7 +859,8 @@ void mysql_stmt_get_longdata(THD *thd, char *pos, ulong packet_length)
     sprintf(stmt->last_error, ER(ER_WRONG_ARGUMENTS), "get_longdata");
     DBUG_VOID_RETURN;
   }
-  stmt->param[param_number].set_longdata(pos, packet_length-9, current_thd->thd_charset);
+  stmt->param[param_number].set_longdata(pos, packet_length-9);
   stmt->long_data_used= 1;
   DBUG_VOID_RETURN;
 }
+
diff --git a/sql/sql_rename.cc b/sql/sql_rename.cc
index a9ab1776e191f3b1880412bbe932670c32658f84..5b0ec2ec84385bdd3bfa2f1dbab4ad3d0fc77abe 100644
--- a/sql/sql_rename.cc
+++ b/sql/sql_rename.cc
@@ -94,7 +94,7 @@ bool mysql_rename_tables(THD *thd, TABLE_LIST *table_list)
     mysql_update_log.write(thd,thd->query,thd->query_length);
     if (mysql_bin_log.is_open())
     {
-      Query_log_event qinfo(thd, thd->query, thd->query_length);
+      Query_log_event qinfo(thd, thd->query, thd->query_length, 0);
       mysql_bin_log.write(&qinfo);
     }
     send_ok(thd);
diff --git a/sql/sql_repl.cc b/sql/sql_repl.cc
index 93545d1026896b92f0f7e6360881d42e8f2863d9..23951cec29fd022ef76329352884b243f2433229 100644
--- a/sql/sql_repl.cc
+++ b/sql/sql_repl.cc
@@ -941,7 +941,7 @@ int show_binlog_events(THD* thd)
   if (mysql_bin_log.is_open())
   {
     LEX_MASTER_INFO *lex_mi = &thd->lex.mi;
-    uint event_count, limit_start, limit_end;
+    ha_rows event_count, limit_start, limit_end;
     my_off_t pos = lex_mi->pos;
     char search_file_name[FN_REFLEN], *name;
     const char *log_file_name = lex_mi->log_file_name;
@@ -1133,7 +1133,8 @@ int log_loaded_block(IO_CACHE* file)
   lf_info->last_pos_in_file = file->pos_in_file;
   if (lf_info->wrote_create_file)
   {
-    Append_block_log_event a(lf_info->thd, buffer, block_len);
+    Append_block_log_event a(lf_info->thd, buffer, block_len,
+			     lf_info->log_delayed);
     mysql_bin_log.write(&a);
   }
   else
@@ -1141,7 +1142,7 @@ int log_loaded_block(IO_CACHE* file)
     Create_file_log_event c(lf_info->thd,lf_info->ex,lf_info->db,
 			    lf_info->table_name, *lf_info->fields,
 			    lf_info->handle_dup, buffer,
-			    block_len);
+			    block_len, lf_info->log_delayed);
     mysql_bin_log.write(&c);
     lf_info->wrote_create_file = 1;
     DBUG_SYNC_POINT("debug_lock.created_file_event",10);
diff --git a/sql/sql_repl.h b/sql/sql_repl.h
index 197fd03ec7ca0de23ec6489291611799d48e5fda..15435382b080ed21b7d4ea9ccf87ffaf84027848 100644
--- a/sql/sql_repl.h
+++ b/sql/sql_repl.h
@@ -43,13 +43,13 @@ int check_binlog_magic(IO_CACHE* log, const char** errmsg);
 typedef struct st_load_file_info
 {
   THD* thd;
+  my_off_t last_pos_in_file;
   sql_exchange* ex;
   List <Item> *fields;
   enum enum_duplicates handle_dup;
   char* db;
   char* table_name;
-  bool wrote_create_file;
-  my_off_t last_pos_in_file;
+  bool wrote_create_file, log_delayed;
 } LOAD_FILE_INFO;
 
 int log_loaded_block(IO_CACHE* file);
diff --git a/sql/sql_select.cc b/sql/sql_select.cc
index b9efe5477bfc83159101f758b2eeccdab3504eb8..501d54958f10dd1de5b21e4437398255abb0daec 100644
--- a/sql/sql_select.cc
+++ b/sql/sql_select.cc
@@ -199,6 +199,26 @@ void fix_tables_pointers(SELECT_LEX *select_lex)
   }
 }
 
+/*
+  Inline function to setup clauses without sum functions
+*/
+inline int setup_without_group(THD *thd, TABLE_LIST *tables,
+			       List<Item> &fields,
+			       List<Item> &all_fields,
+			       COND **conds,
+			       ORDER *order,
+			       ORDER *group, bool *hidden_group_fields)
+{
+  bool save_allow_sum_func= thd->allow_sum_func;
+  thd->allow_sum_func= 0;
+  int res= (setup_conds(thd,tables, conds) ||
+	    setup_order(thd,tables, fields, all_fields, order) ||
+	    setup_group(thd,tables, fields, all_fields, group,
+			hidden_group_fields));
+  thd->allow_sum_func= save_allow_sum_func;
+  return res;
+}
+
 /*****************************************************************************
   Check fields, find best join, do the select and output fields.
   mysql_select assumes that all tables are already opened
@@ -233,10 +253,8 @@ JOIN::prepare(TABLE_LIST *tables_init,
 
   if (setup_tables(tables_list) ||
       setup_fields(thd,tables_list,fields_list,1,&all_fields,1) ||
-      setup_conds(thd,tables_list,&conds) ||
-      setup_order(thd,tables_list,fields_list,all_fields,order) ||
-      setup_group(thd,tables_list,fields_list,all_fields,group_list,
-                &hidden_group_fields))
+      setup_without_group(thd, tables_list, fields_list, all_fields,
+			  &conds, order, group_list, &hidden_group_fields))
     DBUG_RETURN(-1);				/* purecov: inspected */
 
   if (having)
@@ -324,6 +342,7 @@ JOIN::prepare(TABLE_LIST *tables_init,
   this->group= group_list != 0;
   row_limit= ((select_distinct || order || group_list) ? HA_POS_ERROR :
 	      unit->select_limit_cnt);
+  do_send_rows = (unit->select_limit_cnt) ? 1 : 0;
   this->unit= unit;
 
 #ifdef RESTRICTED_GROUP
@@ -366,19 +385,24 @@ JOIN::optimize()
     {
       conds->fix_fields(thd, tables_list, &conds);
       conds->change_ref_to_fields(thd, tables_list);
+      conds->top_level_item();
       having= 0;
     }
   }
 #endif
 
-  conds=optimize_cond(conds,&cond_value);
-  if (thd->fatal_error || thd->net.report_error)
+  conds= optimize_cond(conds,&cond_value);
+  if (thd->fatal_error)
   {
+    // quick abort
     delete procedure;
-    error = 0;
+    error= 0;
     DBUG_RETURN(1);
-  }
-  if (cond_value == Item::COND_FALSE || !unit->select_limit_cnt)
+  } else if (thd->net.report_error)
+    // normal error processing & cleanup
+    DBUG_RETURN(-1);
+
+  if (cond_value == Item::COND_FALSE || (!unit->select_limit_cnt && !(select_options & OPTION_FOUND_ROWS)))
   {					/* Impossible cond */
     zero_result_cause= "Impossible WHERE";
     DBUG_RETURN(0);
@@ -395,13 +419,7 @@ JOIN::optimize()
 	zero_result_cause= "No matching min/max row";
 	DBUG_RETURN(0);
       }
-      if (select_options & SELECT_DESCRIBE)
-      {
-	select_describe(this, false, false, false,
-			"Select tables optimized away");
-	delete procedure;
-	DBUG_RETURN(1);
-      }
+      zero_result_cause= "Select tables optimized away";
       tables_list= 0;					// All tables resolved
     }
   }
@@ -663,7 +681,8 @@ JOIN::exec()
   {                                           // Only test of functions
     error=0;
     if (select_options & SELECT_DESCRIBE)
-      select_describe(this, false, false, false, "No tables used");
+      select_describe(this, false, false, false,
+		      (zero_result_cause?zero_result_cause:"No tables used"));
     else
     {
       result->send_fields(fields_list,1);
@@ -672,7 +691,10 @@ JOIN::exec()
 	if (do_send_rows && result->send_data(fields_list))
 	  error= 1;
 	else
+	{
 	  error= (int) result->send_eof();
+	  send_records=1;
+	}
       }
       else
 	error=(int) result->send_eof();
@@ -957,6 +979,7 @@ JOIN::exec()
 						      sort_table_cond)))
 	    DBUG_VOID_RETURN;
 	table->select_cond=table->select->cond;
+	table->select_cond->top_level_item();
 	DBUG_EXECUTE("where",print_where(table->select->cond,
 					 "select and having"););
 	having_list= make_cond_for_table(having_list, ~ (table_map) 0,
@@ -994,7 +1017,8 @@ JOIN::exec()
   }
   having=having_list;				// Actually a parameter
   thd->proc_info="Sending data";
-  error=do_select(this, &fields_list, NULL, procedure);
+  error= thd->net.report_error ||
+    do_select(this, &fields_list, NULL, procedure);
   DBUG_VOID_RETURN;
 }
 
@@ -1034,6 +1058,24 @@ JOIN::cleanup(THD *thd)
   DBUG_RETURN(error);
 }
 
+bool JOIN::check_loop(uint id)
+{
+  DBUG_ENTER("JOIN::check_loop");
+  Item *item;
+  List_iterator<Item> it(all_fields);
+  DBUG_PRINT("info", ("all_fields:"));
+  while ((item= it++))
+    if (item->check_loop(id))
+      DBUG_RETURN(1);
+  DBUG_PRINT("info", ("where:"));
+  if (select_lex->where && select_lex->where->check_loop(id))
+    DBUG_RETURN(1);
+  DBUG_PRINT("info", ("having:"));
+  if (select_lex->having && select_lex->having->check_loop(id))
+    DBUG_RETURN(1);
+  DBUG_RETURN(0);
+}
+
 int
 mysql_select(THD *thd, TABLE_LIST *tables, List<Item> &fields, COND *conds,
 	     ORDER *order, ORDER *group,Item *having, ORDER *proc_param,
@@ -1068,6 +1110,23 @@ mysql_select(THD *thd, TABLE_LIST *tables, List<Item> &fields, COND *conds,
     {
       DBUG_RETURN(-1);
     }
+    if (thd->possible_loops)
+    {
+      Item *item;
+      while(thd->possible_loops->elements)
+      {
+	item= thd->possible_loops->pop();
+    	if (item->check_loop(thd->check_loops_counter++))
+	{
+	  delete thd->possible_loops;
+	  thd->possible_loops= 0;
+	  my_message(ER_CYCLIC_REFERENCE, ER(ER_CYCLIC_REFERENCE), MYF(0));
+	  return 1;
+	}
+      }
+      delete thd->possible_loops;
+      thd->possible_loops= 0;
+    }
   }
 
   switch (join->optimize()) 
@@ -1078,7 +1137,7 @@ mysql_select(THD *thd, TABLE_LIST *tables, List<Item> &fields, COND *conds,
     goto err;
   } 
 
-  if (free_join && join->global_optimize())
+  if (thd->net.report_error || (free_join && join->global_optimize()))
     goto err;
 
   join->exec();
@@ -1393,7 +1452,7 @@ make_join_statistics(JOIN *join,TABLE_LIST *tables,COND *conds,
       select->quick=0;
       if (records != HA_POS_ERROR)
       {
-	s->found_records=records;
+	s->records=s->found_records=records;
 	s->read_time= (ha_rows) (s->quick ? s->quick->read_time : 0.0);
       }
     }
@@ -1926,7 +1985,7 @@ static void
 find_best(JOIN *join,table_map rest_tables,uint idx,double record_count,
 	  double read_time)
 {
-  ulong rec;
+  ha_rows rec;
   double tmp;
   THD *thd= join->thd;
 
@@ -2119,7 +2178,7 @@ find_best(JOIN *join,table_map rest_tables,uint idx,double record_count,
 		    records
 		    This gives the formula:
 		    records= (x * (b-a) + a*c-b)/(c-1)
-		    
+
 		    b = records matched by whole key
 		    a = records matched by first key part (10% of all records?)
 		    c = number of key parts in key
@@ -2188,7 +2247,7 @@ find_best(JOIN *join,table_map rest_tables,uint idx,double record_count,
       {						// Check full join
 	if (s->on_expr)
 	{
-	  tmp=s->found_records;			// Can't use read cache
+	  tmp=rows2double(s->found_records);	// Can't use read cache
 	}
 	else
 	{
@@ -2207,11 +2266,11 @@ find_best(JOIN *join,table_map rest_tables,uint idx,double record_count,
 	    will ensure that this will be used
 	  */
 	  best=tmp;
-	  records=s->found_records;
+	  records= rows2double(s->found_records);
 	  best_key=0;
 	}
       }
-      join->positions[idx].records_read=(double) records;
+      join->positions[idx].records_read= records;
       join->positions[idx].key=best_key;
       join->positions[idx].table= s;
       if (!best_key && idx == join->const_tables &&
@@ -2548,7 +2607,7 @@ bool
 store_val_in_field(Field *field,Item *item)
 {
   THD *thd=current_thd;
-  ulong cuted_fields=thd->cuted_fields;
+  ha_rows cuted_fields=thd->cuted_fields;
   thd->count_cuted_fields=1;
   (void) item->save_in_field(field);
   thd->count_cuted_fields=0;
@@ -2577,8 +2636,8 @@ make_simple_join(JOIN *join,TABLE *tmp_table)
   join->sum_funcs=0;
   join->send_records=(ha_rows) 0;
   join->group=0;
-  join->do_send_rows = 1;
   join->row_limit=join->unit->select_limit_cnt;
+  join->do_send_rows = (join->row_limit) ? 1 : 0;
 
   join_tab->cache.buff=0;			/* No cacheing */
   join_tab->table=tmp_table;
@@ -2636,7 +2695,7 @@ make_join_select(JOIN *join,SQL_SELECT *select,COND *cond)
 	use_quick_range=1;
 	tab->use_quick=1;
 	tab->ref.key_parts=0;		// Don't use ref key.
-	join->best_positions[i].records_read=tab->quick->records;
+	join->best_positions[i].records_read= rows2double(tab->quick->records);
       }
 
       COND *tmp=make_cond_for_table(cond,used_tables,current_map);
@@ -2911,30 +2970,42 @@ join_free(JOIN *join)
     */
     if (join->tables > join->const_tables) // Test for not-const tables
       free_io_cache(join->table[join->const_tables]);
-    for (tab=join->join_tab,end=tab+join->tables ; tab != end ; tab++)
-    {
-      if (!join->select_lex->dependent)
+    if (join->select_lex->dependent)
+      for (tab=join->join_tab,end=tab+join->tables ; tab != end ; tab++)
       {
+	if (tab->table)
+	{
+	  if (tab->table->key_read)
+	  {
+	    tab->table->key_read= 0;
+	    tab->table->file->extra(HA_EXTRA_NO_KEYREAD);
+	  }
+	  /* Don't free index if we are using read_record */
+	  if (!tab->read_record.table)
+	    tab->table->file->index_end();
+	}
+      }
+    else
+    {
+      for (tab=join->join_tab,end=tab+join->tables ; tab != end ; tab++)
 	delete tab->select;
 	delete tab->quick;
 	x_free(tab->cache.buff);
-      }
-      if (tab->table)
-      {
-	if (tab->table->key_read)
+	if (tab->table)
 	{
-	  tab->table->key_read=0;
-	  tab->table->file->extra(HA_EXTRA_NO_KEYREAD);
+	  if (tab->table->key_read)
+	  {
+	    tab->table->key_read= 0;
+	    tab->table->file->extra(HA_EXTRA_NO_KEYREAD);
+	  }
+	  /* Don't free index if we are using read_record */
+	  if (!tab->read_record.table)
+	    tab->table->file->index_end();
 	}
-	/* Don't free index if we are using read_record */
-	if (!tab->read_record.table)
-	  tab->table->file->index_end();
+	end_read_record(&tab->read_record);
       }
-      end_read_record(&tab->read_record);
+      join->table= 0;
     }
-    //TODO: is enough join_free at the end of mysql_select?
-    if (!join->select_lex->dependent)
-      join->table=0;
   }
   /*
     We are not using tables anymore
@@ -3896,7 +3967,7 @@ create_tmp_table(THD *thd,TMP_TABLE_PARAM *param,List<Item> &fields,
   *blob_field= 0;				// End marker
 
   /* If result table is small; use a heap */
-  if (blob_count || using_unique_constraint || group_null_items ||
+  if (blob_count || using_unique_constraint ||
       (select_options & (OPTION_BIG_TABLES | SELECT_SMALL_RESULT)) ==
       OPTION_BIG_TABLES)
   {
@@ -4515,7 +4586,7 @@ do_select(JOIN *join,List<Item> *fields,TABLE *table,Procedure *procedure)
     if (error == -1)
       table->file->print_error(my_errno,MYF(0));
   }
-  DBUG_RETURN(error);
+  DBUG_RETURN(error || join->thd->net.report_error);
 }
 
 
@@ -5495,6 +5566,8 @@ end_write_group(JOIN *join, JOIN_TAB *join_tab __attribute__((unused)),
     }
     else
     {
+      if (end_of_records)
+	DBUG_RETURN(0);
       join->first_record=1;
       VOID(test_if_group_changed(join->group_fields));
     }
@@ -5564,6 +5637,7 @@ make_cond_for_table(COND *cond,table_map tables,table_map used_table)
   {
     if (((Item_cond*) cond)->functype() == Item_func::COND_AND_FUNC)
     {
+      /* Create new top level AND item */
       Item_cond_and *new_cond=new Item_cond_and;
       if (!new_cond)
 	return (COND*) 0;			// OOM /* purecov: inspected */
@@ -5601,6 +5675,7 @@ make_cond_for_table(COND *cond,table_map tables,table_map used_table)
 	new_cond->argument_list()->push_back(fix);
       }
       new_cond->used_tables_cache=((Item_cond_or*) cond)->used_tables_cache;
+      new_cond->top_level_item();
       return new_cond;
     }
   }
@@ -5640,6 +5715,9 @@ make_cond_for_table(COND *cond,table_map tables,table_map used_table)
 static Item *
 part_of_refkey(TABLE *table,Field *field)
 {
+  if (!table->reginfo.join_tab)
+    return (Item*) 0;             // field from outer non-select (UPDATE,...)
+
   uint ref_parts=table->reginfo.join_tab->ref.key_parts;
   if (ref_parts)
   {
@@ -5952,6 +6030,7 @@ static bool fix_having(JOIN *join, Item **having)
 						  sort_table_cond)))
 	return 1;
     table->select_cond=table->select->cond;
+    table->select_cond->top_level_item();
     DBUG_EXECUTE("where",print_where(table->select_cond,
 				     "select and having"););
     *having=make_cond_for_table(*having,~ (table_map) 0,~used_tables);
@@ -7380,56 +7459,32 @@ static void select_describe(JOIN *join, bool need_tmp_table, bool need_order,
       {
 	if (tab->use_quick == 2)
 	{
-	  sprintf(buff_ptr,"range checked for each record (index map: %u)",
+	  sprintf(buff_ptr,"; Range checked for each record (index map: %u)",
 		  tab->keys);
 	  buff_ptr=strend(buff_ptr);
 	}
 	else
-	  buff_ptr=strmov(buff_ptr,"where used");
+	  buff_ptr=strmov(buff_ptr,"; Using where");
       }
       if (key_read)
-      {
-	if (buff != buff_ptr)
-	{
-	  buff_ptr[0]=';' ; buff_ptr[1]=' '; buff_ptr+=2;
-	}
-	buff_ptr=strmov(buff_ptr,"Using index");
-      }
+	buff_ptr= strmov(buff_ptr,"; Using index");
       if (table->reginfo.not_exists_optimize)
-      {
-	if (buff != buff_ptr)
-	{
-	  buff_ptr[0]=';' ; buff_ptr[1]=' '; buff_ptr+=2;
-	}
-	buff_ptr=strmov(buff_ptr,"Not exists");
-      }
+	buff_ptr= strmov(buff_ptr,"; Not exists");
       if (need_tmp_table)
       {
 	need_tmp_table=0;
-	if (buff != buff_ptr)
-	{
-	  buff_ptr[0]=';' ; buff_ptr[1]=' '; buff_ptr+=2;
-	}
-	buff_ptr=strmov(buff_ptr,"Using temporary");
+	buff_ptr= strmov(buff_ptr,"; Using temporary");
       }
       if (need_order)
       {
 	need_order=0;
-	if (buff != buff_ptr)
-	{
-	  buff_ptr[0]=';' ; buff_ptr[1]=' '; buff_ptr+=2;
-	}
-	buff_ptr=strmov(buff_ptr,"Using filesort");
+	buff_ptr= strmov(buff_ptr,"; Using filesort");
       }
       if (distinct & test_all_bits(used_tables,thd->used_tables))
-      {
-	if (buff != buff_ptr)
-	{
-	  buff_ptr[0]=';' ; buff_ptr[1]=' '; buff_ptr+=2;
-	}
-	buff_ptr=strmov(buff_ptr,"Distinct");
-      }
-      item_list.push_back(new Item_string(buff,(uint) (buff_ptr - buff),
+	buff_ptr= strmov(buff_ptr,"; Distinct");
+      if (buff_ptr == buff)
+ 	buff_ptr+= 2;				// Skip inital "; "
+      item_list.push_back(new Item_string(buff+2,(uint) (buff_ptr - buff)-2,
 					  default_charset_info));
       // For next iteration
       used_tables|=table->map;
@@ -7461,8 +7516,10 @@ int mysql_explain_union(THD *thd, SELECT_LEX_UNIT *unit, select_result *result)
 			       ((sl->next_select_in_list())?"PRIMARY":
 				"SIMPLE"):
 			       ((sl == first)?
+				((sl->linkage == DERIVED_TABLE_TYPE) ?
+				 "DERIVED":
 				((sl->dependent)?"DEPENDENT SUBSELECT":
-				 "SUBSELECT"):
+				 "SUBSELECT")):
 				((sl->dependent)?"DEPENDENT UNION":
 				 "UNION"))),
 			      result);
@@ -7470,8 +7527,8 @@ int mysql_explain_union(THD *thd, SELECT_LEX_UNIT *unit, select_result *result)
       break;
 
   }
-  if (res > 0)
-    res= -res; // mysql_explain_select do not report error
+  if (res > 0 || thd->net.report_error)
+    res= -1; // mysql_explain_select do not report error
   DBUG_RETURN(res);
 }
 
diff --git a/sql/sql_select.h b/sql/sql_select.h
index c5b5357be50cc1d8cf9317cfa22f994f5246347e..3b89c1ce0d38fd0e977da482f057fff87ba638cc 100644
--- a/sql/sql_select.h
+++ b/sql/sql_select.h
@@ -244,7 +244,8 @@ class JOIN :public Sql_alloc
   int global_optimize();
   int reinit();
   void exec();
-  int cleanup(THD *thd);  
+  int cleanup(THD *thd);
+  bool check_loop(uint id);
 };
 
 
diff --git a/sql/sql_show.cc b/sql/sql_show.cc
index d6fe2f3772ab5642fa2ab4baac3ec59c7ef231dc..ebf5b210d6c68e8ecbff4396b5c909a6621b03f0 100644
--- a/sql/sql_show.cc
+++ b/sql/sql_show.cc
@@ -889,7 +889,7 @@ mysqld_show_keys(THD *thd, TABLE_LIST *table_list)
   field_list.push_back(new Item_empty_string("Column_name",NAME_LEN));
   field_list.push_back(item=new Item_empty_string("Collation",1));
   item->maybe_null=1;
-  field_list.push_back(item=new Item_int("Cardinality",0,11));
+  field_list.push_back(item=new Item_int("Cardinality",0,21));
   item->maybe_null=1;
   field_list.push_back(item=new Item_int("Sub_part",0,3));
   item->maybe_null=1;
@@ -930,8 +930,8 @@ mysqld_show_keys(THD *thd, TABLE_LIST *table_list)
       KEY *key=table->key_info+i;
       if (key->rec_per_key[j])
       {
-        ulong records=(table->file->records / key->rec_per_key[j]);
-        end=int10_to_str((long) records, buff, 10);
+        ha_rows records=(table->file->records / key->rec_per_key[j]);
+        end=longlong10_to_str((longlong) records, buff, 10);
         net_store_data(packet,convert,buff,(uint) (end-buff));
       }
       else
@@ -1140,6 +1140,10 @@ store_create_info(THD *thd, TABLE *table, String *packet)
     if (!found_primary)
      append_identifier(thd,packet,key_info->name);
 
+    if (table->db_type == DB_TYPE_HEAP &&
+	key_info->algorithm == HA_KEY_ALG_BTREE)
+      packet->append(" USING BTREE", 12);
+
     // +BAR: send USING only in non-default case: non-spatial rtree
     if((key_info->algorithm == HA_KEY_ALG_RTREE) &&
        !(key_info->flags & HA_SPATIAL))
@@ -1424,7 +1428,7 @@ int mysqld_show_charsets(THD *thd, const char *wild)
       net_store_data(&packet2,convert,cs[0]->name);
       net_store_data(&packet2,(uint32) cs[0]->number);
       net_store_data(&packet2,(uint32) cs[0]->strxfrm_multiply);
-      net_store_data(&packet2,(uint32) (cs[0]->mbmaxlen ? cs[0]->mbmaxlen : 1));
+      net_store_data(&packet2,(uint32) (cs[0]->mbmaxlen));
 
       if (my_net_write(&thd->net, (char*) packet2.ptr(),packet2.length()))
          goto err;
diff --git a/sql/sql_string.cc b/sql/sql_string.cc
index f0f310045443596f09bc8337b8caa0482e89e0e4..5083fb1310596e35ee1557397a0441ecd8aabad4 100644
--- a/sql/sql_string.cc
+++ b/sql/sql_string.cc
@@ -93,18 +93,36 @@ bool String::realloc(uint32 alloc_length)
 
 bool String::set(longlong num, CHARSET_INFO *cs)
 {
-  if (alloc(21))
+  uint l=20*cs->mbmaxlen+1;
+
+  if (alloc(l))
     return TRUE;
-  str_length=(uint32) (longlong10_to_str(num,Ptr,-10)-Ptr);
+  if (cs->snprintf == my_snprintf_8bit)
+  {
+    str_length=(uint32) (longlong10_to_str(num,Ptr,-10)-Ptr);
+  }
+  else
+  {
+    str_length=cs->snprintf(cs,Ptr,l,"%d",num);
+  }
   str_charset=cs;
   return FALSE;
 }
 
 bool String::set(ulonglong num, CHARSET_INFO *cs)
 {
-  if (alloc(21))
+  uint l=20*cs->mbmaxlen+1;
+
+  if (alloc(l))
     return TRUE;
-  str_length=(uint32) (longlong10_to_str(num,Ptr,10)-Ptr);
+  if (cs->snprintf == my_snprintf_8bit)
+  {
+    str_length=(uint32) (longlong10_to_str(num,Ptr,10)-Ptr);
+  }
+  else
+  {
+    str_length=cs->snprintf(cs,Ptr,l,"%d",num);
+  }
   str_charset=cs;
   return FALSE;
 }
@@ -117,14 +135,14 @@ bool String::set(double num,uint decimals, CHARSET_INFO *cs)
   if (decimals >= NOT_FIXED_DEC)
   {
     sprintf(buff,"%.14g",num);			// Enough for a DATETIME
-    return copy(buff, (uint32) strlen(buff), my_charset_latin1);
+    return copy(buff, (uint32) strlen(buff), my_charset_latin1, cs);
   }
 #ifdef HAVE_FCONVERT
   int decpt,sign;
   char *pos,*to;
 
   VOID(fconvert(num,(int) decimals,&decpt,&sign,buff+1));
-  if (!my_isdigit(system_charset_info, buff[1]))
+  if (!my_isdigit(my_charset_latin1, buff[1]))
   {						// Nan or Inf
     pos=buff+1;
     if (sign)
@@ -132,7 +150,7 @@ bool String::set(double num,uint decimals, CHARSET_INFO *cs)
       buff[0]='-';
       pos=buff;
     }
-    return copy(pos,(uint32) strlen(pos));
+    return copy(pos,(uint32) strlen(pos), my_charset_latin1, cs);
   }
   if (alloc((uint32) ((uint32) decpt+3+decimals)))
     return TRUE;
@@ -182,7 +200,7 @@ bool String::set(double num,uint decimals, CHARSET_INFO *cs)
 #else
   sprintf(buff,"%.*f",(int) decimals,num);
 #endif
-  return copy(buff,(uint32) strlen(buff), my_charset_latin1);
+  return copy(buff,(uint32) strlen(buff), my_charset_latin1, cs);
 #endif
 }
 
@@ -219,6 +237,55 @@ bool String::copy(const char *str,uint32 arg_length, CHARSET_INFO *cs)
   return FALSE;
 }
 
+/* Copy with charset convertion */
+bool String::copy(const char *str,uint32 arg_length, CHARSET_INFO *from, CHARSET_INFO *to)
+{
+  uint32      new_length=to->mbmaxlen*arg_length;
+  int         cnvres;
+  my_wc_t     wc;
+  const uchar *s=(const uchar *)str;
+  const uchar *se=s+arg_length;
+  uchar       *d, *de;
+
+  if (alloc(new_length))
+    return TRUE;
+
+  d=(uchar *)Ptr;
+  de=d+new_length;
+  
+  for (str_length=new_length ; s < se && d < de ; )
+  {
+    if ((cnvres=from->mb_wc(from,&wc,s,se)) > 0 )
+    {
+      s+=cnvres;
+    }
+    else if (cnvres==MY_CS_ILSEQ)
+    {
+      s++;
+      wc='?';
+    }
+    else
+      break;
+
+outp:
+    if((cnvres=to->wc_mb(to,wc,d,de)) >0 )
+    {
+      d+=cnvres;
+    }
+    else if (cnvres==MY_CS_ILUNI && wc!='?')
+    {
+      wc='?';
+      goto outp;
+    }
+    else
+      break;
+  }
+  Ptr[new_length]=0;
+  length((uint32) (d-(uchar *)Ptr));
+  str_charset=to;
+  return FALSE;
+}
+
 /* This is used by mysql.cc */
 
 bool String::fill(uint32 max_length,char fill_char)
@@ -604,261 +671,5 @@ String *copy_if_not_alloced(String *to,String *from,uint32 from_length)
   return to;
 }
 
-/* Make it easier to handle different charactersets */
-
-#ifdef USE_MB
-#define INC_PTR(cs,A,B) A+=((use_mb_flag && \
-                          my_ismbchar(cs,A,B)) ? my_ismbchar(cs,A,B) : 1)
-#else
-#define INC_PTR(cs,A,B) A++
-#endif
-
-/*
-** Compare string against string with wildcard
-**	0 if matched
-**	-1 if not matched with wildcard
-**	 1 if matched with wildcard
-*/
-
-#ifdef LIKE_CMP_TOUPPER
-#define likeconv(s,A) (uchar) my_toupper(s,A)
-#else
-#define likeconv(s,A) (uchar) (s)->sort_order[(uchar) (A)]
-#endif
-
-int wild_case_compare(CHARSET_INFO *cs, const char *str,const char *str_end,
-		      const char *wildstr,const char *wildend,
-		      char escape)
-{
-  int result= -1;				// Not found, using wildcards
-#ifdef USE_MB
-  bool use_mb_flag=use_mb(cs);
-#endif
-  while (wildstr != wildend)
-  {
-    while (*wildstr != wild_many && *wildstr != wild_one)
-    {
-      if (*wildstr == escape && wildstr+1 != wildend)
-	wildstr++;
-#ifdef USE_MB
-      int l;
-      if (use_mb_flag &&
-          (l = my_ismbchar(cs, wildstr, wildend)))
-      {
-	  if (str+l > str_end || memcmp(str, wildstr, l) != 0)
-	      return 1;
-	  str += l;
-	  wildstr += l;
-      }
-      else
-#endif
-      if (str == str_end || likeconv(cs,*wildstr++) != likeconv(cs,*str++))
-	return(1);				// No match
-      if (wildstr == wildend)
-	return (str != str_end);		// Match if both are at end
-      result=1;					// Found an anchor char
-    }
-    if (*wildstr == wild_one)
-    {
-      do
-      {
-	if (str == str_end)			// Skip one char if possible
-	  return (result);
-	INC_PTR(cs,str,str_end);
-      } while (++wildstr < wildend && *wildstr == wild_one);
-      if (wildstr == wildend)
-	break;
-    }
-    if (*wildstr == wild_many)
-    {						// Found wild_many
-      wildstr++;
-      /* Remove any '%' and '_' from the wild search string */
-      for (; wildstr != wildend ; wildstr++)
-      {
-	if (*wildstr == wild_many)
-	  continue;
-	if (*wildstr == wild_one)
-	{
-	  if (str == str_end)
-	    return (-1);
-	  INC_PTR(cs,str,str_end);
-	  continue;
-	}
-	break;					// Not a wild character
-      }
-      if (wildstr == wildend)
-	return(0);				// Ok if wild_many is last
-      if (str == str_end)
-	return -1;
-
-      uchar cmp;
-      if ((cmp= *wildstr) == escape && wildstr+1 != wildend)
-	cmp= *++wildstr;
-#ifdef USE_MB
-      const char* mb = wildstr;
-      int mblen;
-      LINT_INIT(mblen);
-      if (use_mb_flag)
-        mblen = my_ismbchar(cs, wildstr, wildend);
-#endif
-      INC_PTR(cs,wildstr,wildend);		// This is compared trough cmp
-      cmp=likeconv(cs,cmp);   
-      do
-      {
-#ifdef USE_MB
-        if (use_mb_flag)
-	{
-          for (;;)
-          {
-            if (str >= str_end)
-              return -1;
-            if (mblen)
-            {
-              if (str+mblen <= str_end && memcmp(str, mb, mblen) == 0)
-              {
-                str += mblen;
-                break;
-              }
-            }
-            else if (!my_ismbchar(cs, str, str_end) &&
-                     likeconv(cs,*str) == cmp)
-            {
-              str++;
-              break;
-            }
-            INC_PTR(cs,str, str_end);
-          }
-	}
-        else
-        {
-#endif /* USE_MB */
-          while (str != str_end && likeconv(cs,*str) != cmp)
-            str++;
-          if (str++ == str_end) return (-1);
-#ifdef USE_MB
-        }
-#endif
-	{
-	  int tmp=wild_case_compare(cs,str,str_end,wildstr,wildend,escape);
-	  if (tmp <= 0)
-	    return (tmp);
-	}
-      } while (str != str_end && wildstr[0] != wild_many);
-      return(-1);
-    }
-  }
-  return (str != str_end ? 1 : 0);
-}
-
-
-int wild_case_compare(String &match,String &wild, char escape)
-{
-  DBUG_ENTER("wild_case_compare");
-  DBUG_PRINT("enter",("match='%s', wild='%s', escape='%c'"
-			  ,match.ptr(),wild.ptr(),escape));
-  DBUG_RETURN(wild_case_compare(match.str_charset,match.ptr(),match.ptr()+match.length(),
-			   wild.ptr(), wild.ptr()+wild.length(),escape));
-}
-
-/*
-** The following is used when using LIKE on binary strings
-*/
-
-int wild_compare(const char *str,const char *str_end,
-		 const char *wildstr,const char *wildend,char escape)
-{
-  DBUG_ENTER("wild_compare");
-  DBUG_PRINT("enter",("str='%s', str_end='%s', wildstr='%s', wildend='%s', escape='%c'"
-			  ,str,str_end,wildstr,wildend,escape));
-  int result= -1;				// Not found, using wildcards
-  while (wildstr != wildend)
-  {
-    while (*wildstr != wild_many && *wildstr != wild_one)
-    {
-      if (*wildstr == escape && wildstr+1 != wildend)
-	wildstr++;
-      if (str == str_end || *wildstr++ != *str++)
-      {
-	DBUG_RETURN(1);
-      }
-      if (wildstr == wildend)
-      {
-	DBUG_RETURN(str != str_end);		// Match if both are at end
-      }
-      result=1;					// Found an anchor char
-    }
-    if (*wildstr == wild_one)
-    {
-      do
-      {
-	if (str == str_end)			// Skip one char if possible
-	  DBUG_RETURN(result);
-	str++;
-      } while (*++wildstr == wild_one && wildstr != wildend);
-      if (wildstr == wildend)
-	break;
-    }
-    if (*wildstr == wild_many)
-    {						// Found wild_many
-      wildstr++;
-      /* Remove any '%' and '_' from the wild search string */
-      for (; wildstr != wildend ; wildstr++)
-      {
-	if (*wildstr == wild_many)
-	  continue;
-	if (*wildstr == wild_one)
-	{
-	  if (str == str_end)
-	  {
-	    DBUG_RETURN(-1);
-	  }
-	  str++;
-	  continue;
-	}
-	break;					// Not a wild character
-      }
-      if (wildstr == wildend)
-      {
-	DBUG_RETURN(0);				// Ok if wild_many is last
-      }
-      if (str == str_end)
-      {
-	DBUG_RETURN(-1);
-      }
-      char cmp;
-      if ((cmp= *wildstr) == escape && wildstr+1 != wildend)
-	cmp= *++wildstr;
-      wildstr++;				// This is compared trough cmp
-      do
-      {
-	while (str != str_end && *str != cmp)
-	  str++;
-	if (str++ == str_end)
-	{ 
-	  DBUG_RETURN(-1);
-	}
-	{
-	  int tmp=wild_compare(str,str_end,wildstr,wildend,escape);
-	  if (tmp <= 0)
-	  {
-	    DBUG_RETURN(tmp);
-	  }
-	}
-      } while (str != str_end && wildstr[0] != wild_many);
-      DBUG_RETURN(-1);
-    }
-  }
-  DBUG_RETURN(str != str_end ? 1 : 0);
-}
-
-
-int wild_compare(String &match,String &wild, char escape)
-{
-  DBUG_ENTER("wild_compare");
-  DBUG_PRINT("enter",("match='%s', wild='%s', escape='%c'"
-			  ,match.ptr(),wild.ptr(),escape));
-  DBUG_RETURN(wild_compare(match.ptr(),match.ptr()+match.length(),
-		      wild.ptr(), wild.ptr()+wild.length(),escape));
-}
 
 
diff --git a/sql/sql_string.h b/sql/sql_string.h
index 4ac4308f113240e38d5b0181b5b946a6bc237e91..dde67b11d50e1c78bee29d128d339ec660763223 100644
--- a/sql/sql_string.h
+++ b/sql/sql_string.h
@@ -28,8 +28,6 @@ class String;
 int sortcmp(const String *a,const String *b);
 int stringcmp(const String *a,const String *b);
 String *copy_if_not_alloced(String *a,String *b,uint32 arg_length);
-int wild_case_compare(String &match,String &wild,char escape);
-int wild_compare(String &match,String &wild,char escape);
 
 class String
 {
@@ -74,7 +72,7 @@ class String
     { sql_element_free(ptr_arg); }
   ~String() { free(); }
 
-  inline void set_charset(CHARSET_INFO *charset) { str_charset=charset; }
+  inline void set_charset(CHARSET_INFO *charset) { str_charset= charset; }
   inline CHARSET_INFO *charset() const { return str_charset; }
   inline uint32 length() const { return str_length;}
   inline uint32 alloced_length() const { return Alloced_length;}
@@ -179,6 +177,8 @@ class String
   bool copy();					// Alloc string if not alloced
   bool copy(const String &s);			// Allocate new string
   bool copy(const char *s,uint32 arg_length, CHARSET_INFO *cs);	// Allocate new string
+  bool copy(const char*s,uint32 arg_length, CHARSET_INFO *csfrom,
+	    CHARSET_INFO *csto);
   bool append(const String &s);
   bool append(const char *s,uint32 arg_length=0);
   bool append(IO_CACHE* file, uint32 arg_length);
@@ -207,8 +207,6 @@ class String
   friend int sortcmp(const String *a,const String *b);
   friend int stringcmp(const String *a,const String *b);
   friend String *copy_if_not_alloced(String *a,String *b,uint32 arg_length);
-  friend int wild_case_compare(String &match,String &wild,char escape);
-  friend int wild_compare(String &match,String &wild,char escape);
   uint32 numchars();
   int charpos(int i,uint32 offset=0);
 
diff --git a/sql/sql_table.cc b/sql/sql_table.cc
index 5187351258e06b9ef477babe89c2e03651fba47d..00077bda39fb7e2897ed2e342157d737fd682c17 100644
--- a/sql/sql_table.cc
+++ b/sql/sql_table.cc
@@ -110,6 +110,17 @@ int mysql_rm_table_part2_with_lock(THD *thd,
   return error;
 }
 
+/*
+  TODO:
+    When logging to the binary log, we should log
+    tmp_tables and transactional tables as separate statements if we
+    are in a transaction;  This is needed to get these tables into the
+    cached binary log that is only written on COMMIT.
+
+   The current code only writes DROP statements that only uses temporary
+   tables to the cache binary log.  This should be ok on most cases, but
+   not all.
+*/
 
 int mysql_rm_table_part2(THD *thd, TABLE_LIST *tables, bool if_exists,
 			 bool dont_log_query)
@@ -119,7 +130,7 @@ int mysql_rm_table_part2(THD *thd, TABLE_LIST *tables, bool if_exists,
   String wrong_tables;
   db_type table_type;
   int error;
-  bool some_tables_deleted=0;
+  bool some_tables_deleted=0, tmp_table_deleted=0;
   DBUG_ENTER("mysql_rm_table_part2");
 
   for (table=tables ; table ; table=table->next)
@@ -127,7 +138,7 @@ int mysql_rm_table_part2(THD *thd, TABLE_LIST *tables, bool if_exists,
     char *db=table->db ? table->db : thd->db;
     if (!close_temporary_table(thd, db, table->real_name))
     {
-      some_tables_deleted=1;			// Log query
+      tmp_table_deleted=1;
       continue;					// removed temporary table
     }
 
@@ -143,8 +154,8 @@ int mysql_rm_table_part2(THD *thd, TABLE_LIST *tables, bool if_exists,
       DBUG_RETURN(-1);
 
     /* remove form file and isam files */
-    (void) sprintf(path,"%s/%s/%s%s",mysql_data_home,db,table->real_name,
-		   reg_ext);
+    strxmov(path, mysql_data_home, "/", db, "/", table->real_name, reg_ext,
+	    NullS);
     (void) unpack_filename(path,path);
     error=0;
 
@@ -177,7 +188,7 @@ int mysql_rm_table_part2(THD *thd, TABLE_LIST *tables, bool if_exists,
       wrong_tables.append(String(table->real_name,default_charset_info));
     }
   }
-  if (some_tables_deleted)
+  if (some_tables_deleted || tmp_table_deleted)
   {
     query_cache_invalidate3(thd, tables, 0);
     if (!dont_log_query)
@@ -185,7 +196,8 @@ int mysql_rm_table_part2(THD *thd, TABLE_LIST *tables, bool if_exists,
       mysql_update_log.write(thd, thd->query,thd->query_length);
       if (mysql_bin_log.is_open())
       {
-	Query_log_event qinfo(thd, thd->query, thd->query_length);
+	Query_log_event qinfo(thd, thd->query, thd->query_length,
+			      tmp_table_deleted && !some_tables_deleted);
 	mysql_bin_log.write(&qinfo);
       }
     }
@@ -271,7 +283,8 @@ static int sort_keys(KEY *a, KEY *b)
     create_info		Create information (like MAX_ROWS)
     fields		List of fields to create
     keys		List of keys to create
-    tmp_table		Set to 1 if this is a temporary table
+    tmp_table		Set to 1 if this is an internal temporary table
+			(From ALTER TABLE)    
     no_log		Don't log the query to binary log.
 
   DESCRIPTION		       
@@ -523,19 +536,19 @@ int mysql_create_table(THD *thd,const char *db, const char *table_name,
 
   key_iterator.rewind();
   key_number=0;
-  for (; (key=key_iterator++) ; key_info++, key_number++)
+  for (; (key=key_iterator++) ; key_number++)
   {
     uint key_length=0;
     key_part_spec *column;
 
     switch(key->type){
-      case Key::MULTIPLE:
+    case Key::MULTIPLE:
         key_info->flags = 0;
         break;
-      case Key::FULLTEXT:
+    case Key::FULLTEXT:
         key_info->flags = HA_FULLTEXT;
         break;
-      case Key::SPATIAL:
+    case Key::SPATIAL:
         key_info->flags = HA_SPATIAL;
         break;
     case Key::FOREIGN_KEY:
@@ -734,6 +747,7 @@ int mysql_create_table(THD *thd,const char *db, const char *table_name,
       my_error(ER_TOO_LONG_KEY,MYF(0),max_key_length);
       DBUG_RETURN(-1);
     }
+    key_info++;
   }
   if (!unique_key && !primary_key &&
       (file->table_flags() & HA_REQUIRE_PRIMARY_KEY))
@@ -783,7 +797,6 @@ int mysql_create_table(THD *thd,const char *db, const char *table_name,
 
   thd->proc_info="creating table";
 
-  create_info->create_statement = thd->query;
   create_info->table_options=db_options;
   if (rea_create_table(thd, path, create_info, fields, key_count,
 		       key_info_buffer))
@@ -791,16 +804,6 @@ int mysql_create_table(THD *thd,const char *db, const char *table_name,
     /* my_error(ER_CANT_CREATE_TABLE,MYF(0),table_name,my_errno); */
     goto end;
   }
-  if (!tmp_table && !no_log)
-  {
-    // Must be written before unlock
-    mysql_update_log.write(thd,thd->query, thd->query_length);
-    if (mysql_bin_log.is_open())
-    {
-      Query_log_event qinfo(thd, thd->query, thd->query_length);
-      mysql_bin_log.write(&qinfo);
-    }
-  }
   if (create_info->options & HA_LEX_CREATE_TMP_TABLE)
   {
     /* Open table and put in temporary table list */
@@ -810,6 +813,18 @@ int mysql_create_table(THD *thd,const char *db, const char *table_name,
       goto end;
     }
   }
+  if (!tmp_table && !no_log)
+  {
+    // Must be written before unlock
+    mysql_update_log.write(thd,thd->query, thd->query_length);
+    if (mysql_bin_log.is_open())
+    {
+      Query_log_event qinfo(thd, thd->query, thd->query_length,
+			    test(create_info->options &
+				 HA_LEX_CREATE_TMP_TABLE));
+      mysql_bin_log.write(&qinfo);
+    }
+  }
   error=0;
 end:
   VOID(pthread_mutex_unlock(&LOCK_open));
@@ -1254,8 +1269,13 @@ static int mysql_admin_table(THD* thd, TABLE_LIST* tables,
 
     switch (result_code) {
     case HA_ADMIN_NOT_IMPLEMENTED:
-      net_store_data(packet, "error");
-      net_store_data(packet, ER(ER_CHECK_NOT_IMPLEMENTED));
+      {
+        char buf[ERRMSGSIZE+20];
+        my_snprintf(buf, ERRMSGSIZE,
+            ER(ER_CHECK_NOT_IMPLEMENTED), operator_name);
+        net_store_data(packet, "error");
+        net_store_data(packet, buf);
+      }
       break;
 
     case HA_ADMIN_OK:
@@ -1510,7 +1530,7 @@ int mysql_alter_table(THD *thd,char *new_db, char *new_name,
       mysql_update_log.write(thd, thd->query, thd->query_length);
       if (mysql_bin_log.is_open())
       {
-	Query_log_event qinfo(thd, thd->query, thd->query_length);
+	Query_log_event qinfo(thd, thd->query, thd->query_length, 0);
 	mysql_bin_log.write(&qinfo);
       }
       send_ok(thd);
@@ -1886,7 +1906,7 @@ int mysql_alter_table(THD *thd,char *new_db, char *new_name,
     mysql_update_log.write(thd, thd->query,thd->query_length);
     if (mysql_bin_log.is_open())
     {
-      Query_log_event qinfo(thd, thd->query, thd->query_length);
+      Query_log_event qinfo(thd, thd->query, thd->query_length, 0);
       mysql_bin_log.write(&qinfo);
     }
     goto end_temporary;
@@ -2015,7 +2035,7 @@ int mysql_alter_table(THD *thd,char *new_db, char *new_name,
   mysql_update_log.write(thd, thd->query,thd->query_length);
   if (mysql_bin_log.is_open())
   {
-    Query_log_event qinfo(thd, thd->query, thd->query_length);
+    Query_log_event qinfo(thd, thd->query, thd->query_length, 0);
     mysql_bin_log.write(&qinfo);
   }
   VOID(pthread_cond_broadcast(&COND_refresh));
diff --git a/sql/sql_test.cc b/sql/sql_test.cc
index b3bf47e7fd2fd8b9582e5c0a3664b018e117bb33..3fbeaa753db4f083e93daf8be47d9ea1ccae603c 100644
--- a/sql/sql_test.cc
+++ b/sql/sql_test.cc
@@ -41,6 +41,7 @@ static const char *lock_descriptions[] =
   "High priority write lock",
   "Highest priority write lock"
 };
+extern HASH open_cache;
 
 
 #ifndef DBUG_OFF
@@ -64,7 +65,6 @@ print_where(COND *cond,const char *info)
 }
 	/* This is for debugging purposes */
 
-extern HASH open_cache;
 extern TABLE *unused_tables;
 
 void print_cached_tables(void)
diff --git a/sql/sql_udf.cc b/sql/sql_udf.cc
index f45eca0b65f4147455c4997b333d320ee7be8104..35e33caf5728e06c1cd75a9afd9d40a23af13f84 100644
--- a/sql/sql_udf.cc
+++ b/sql/sql_udf.cc
@@ -98,8 +98,8 @@ static void init_syms(udf_func *tmp)
   }
 }
 
-static byte* get_hash_key(const byte *buff,uint *length,
-			  my_bool not_used __attribute__((unused)))
+extern "C" byte* get_hash_key(const byte *buff,uint *length,
+			      my_bool not_used __attribute__((unused)))
 {
   udf_func *udf=(udf_func*) buff;
   *length=(uint) udf->name_length;
diff --git a/sql/sql_union.cc b/sql/sql_union.cc
index 53f89747ce7980b8b1bbebcb4c641bd99121c2b0..0e6de306c0de9f6f833a7a43b09380e43b4b21da 100644
--- a/sql/sql_union.cc
+++ b/sql/sql_union.cc
@@ -78,7 +78,13 @@ bool select_union::send_data(List<Item> &values)
   fill_record(table->field,values);
   if ((write_record(table,&info)))
   {
-    if (create_myisam_from_heap(table, tmp_table_param, info.last_errno, 0))
+    if (thd->net.last_errno == ER_RECORD_FILE_FULL)
+    {
+      thd->clear_error(); // do not report user about table overflow
+      if (create_myisam_from_heap(table, tmp_table_param, info.last_errno, 0))
+	return 1;
+    }
+    else
       return 1;
   }
   return 0;
diff --git a/sql/sql_update.cc b/sql/sql_update.cc
index be69935a49c6eb5280862c81145aa466bfbec95d..409b00b5703d5d1151a8660adfab30176b001c0d 100644
--- a/sql/sql_update.cc
+++ b/sql/sql_update.cc
@@ -50,11 +50,11 @@ int mysql_update(THD *thd,
                  COND *conds,
                  ORDER *order,
 		 ha_rows limit,
-		 enum enum_duplicates handle_duplicates,
-		 thr_lock_type lock_type)
+		 enum enum_duplicates handle_duplicates)
 {
   bool 		using_limit=limit != HA_POS_ERROR;
-  bool		used_key_is_modified, using_transactions;
+  bool		safe_update= thd->options & OPTION_SAFE_UPDATES;
+  bool		used_key_is_modified, transactional_table, log_delayed;
   int		error=0;
   uint		save_time_stamp, used_index, want_privilege;
   ulong		query_id=thd->query_id, timestamp_query_id;
@@ -62,12 +62,17 @@ int mysql_update(THD *thd,
   TABLE		*table;
   SQL_SELECT	*select;
   READ_RECORD	info;
+  TABLE_LIST    *update_table_list= (TABLE_LIST*) 
+    thd->lex.select_lex.table_list.first;
   DBUG_ENTER("mysql_update");
   LINT_INIT(used_index);
   LINT_INIT(timestamp_query_id);
 
-  if (!(table = open_ltable(thd,table_list,lock_type)))
-    DBUG_RETURN(-1); /* purecov: inspected */
+  if ((open_and_lock_tables(thd, table_list)))
+    DBUG_RETURN(-1);
+  fix_tables_pointers(&thd->lex.select_lex);
+  table= table_list->table;
+
   save_time_stamp=table->time_stamp;
   table->file->info(HA_STATUS_VARIABLE | HA_STATUS_NO_LOCK);
   thd->proc_info="init";
@@ -77,8 +82,9 @@ int mysql_update(THD *thd,
   table->quick_keys=0;
   want_privilege=table->grant.want_privilege;
   table->grant.want_privilege=(SELECT_ACL & ~table->grant.privilege);
-  if (setup_tables(table_list) || setup_conds(thd,table_list,&conds)
-                               || setup_ftfuncs(&thd->lex.select_lex))
+  if (setup_tables(update_table_list) || 
+      setup_conds(thd,update_table_list,&conds)
+      || setup_ftfuncs(&thd->lex.select_lex))
     DBUG_RETURN(-1);				/* purecov: inspected */
   old_used_keys=table->used_keys;		// Keys used in WHERE
 
@@ -94,7 +100,7 @@ int mysql_update(THD *thd,
 
   /* Check the fields we are going to modify */
   table->grant.want_privilege=want_privilege;
-  if (setup_fields(thd,table_list,fields,1,0,0))
+  if (setup_fields(thd,update_table_list,fields,1,0,0))
     DBUG_RETURN(-1);				/* purecov: inspected */
   if (table->timestamp_field)
   {
@@ -107,7 +113,7 @@ int mysql_update(THD *thd,
 
   /* Check values */
   table->grant.want_privilege=(SELECT_ACL & ~table->grant.privilege);
-  if (setup_fields(thd,table_list,values,0,0,0))
+  if (setup_fields(thd,update_table_list,values,0,0,0))
   {
     table->time_stamp=save_time_stamp;		// Restore timestamp pointer
     DBUG_RETURN(-1);				/* purecov: inspected */
@@ -117,9 +123,7 @@ int mysql_update(THD *thd,
   table->used_keys=0;
   select=make_select(table,0,0,conds,&error);
   if (error ||
-      (select && select->check_quick(test(thd->options & OPTION_SAFE_UPDATES),
-				     limit)) ||
-      !limit)
+      (select && select->check_quick(safe_update, limit)) || !limit)
   {
     delete select;
     table->time_stamp=save_time_stamp;		// Restore timestamp pointer
@@ -134,7 +138,7 @@ int mysql_update(THD *thd,
   if (!table->quick_keys)
   {
     thd->lex.select_lex.options|=QUERY_NO_INDEX_USED;
-    if ((thd->options & OPTION_SAFE_UPDATES) && limit == HA_POS_ERROR)
+    if (safe_update && !using_limit)
     {
       delete select;
       table->time_stamp=save_time_stamp;
@@ -301,22 +305,31 @@ int mysql_update(THD *thd,
   thd->proc_info="end";
   VOID(table->file->extra(HA_EXTRA_NO_IGNORE_DUP_KEY));
   table->time_stamp=save_time_stamp;	// Restore auto timestamp pointer
-  using_transactions=table->file->has_transactions();
-  if (updated && (error <= 0 || !using_transactions))
+  transactional_table= table->file->has_transactions();
+  log_delayed= (transactional_table || table->tmp_table);
+  if (updated && (error <= 0 || !transactional_table))
   {
     mysql_update_log.write(thd,thd->query,thd->query_length);
     if (mysql_bin_log.is_open())
     {
       Query_log_event qinfo(thd, thd->query, thd->query_length,
-			    using_transactions);
-      if (mysql_bin_log.write(&qinfo) && using_transactions)
-	error=1;
+			    log_delayed);
+      if (mysql_bin_log.write(&qinfo) && transactional_table)
+	error=1;				// Rollback update
     }
-    if (!using_transactions)
+    if (!log_delayed)
       thd->options|=OPTION_STATUS_NO_TRANS_UPDATE;
   }
-  if (using_transactions && ha_autocommit_or_rollback(thd, error >= 0))
-    error=1;
+  if (transactional_table)
+  {
+    if (ha_autocommit_or_rollback(thd, error >= 0))
+      error=1;
+  }
+
+  /*
+    Store table for future invalidation  or invalidate it in
+    the query cache if something changed
+  */
   if (updated)
   {
     query_cache_invalidate3(thd, table_list, 1);
@@ -349,10 +362,12 @@ int mysql_update(THD *thd,
   Update multiple tables from join 
 ***************************************************************************/
 
-multi_update::multi_update(THD *thd_arg, TABLE_LIST *ut, List<Item> &fs, 		 
-			   enum enum_duplicates handle_duplicates,  thr_lock_type lock_option_arg, uint num)
-  : update_tables (ut), thd(thd_arg), updated(0), found(0), fields(fs), lock_option(lock_option_arg),
-    dupl(handle_duplicates), num_of_tables(num), num_fields(0), num_updated(0) , error(0),  do_update(false)
+multi_update::multi_update(THD *thd_arg, TABLE_LIST *ut, List<Item> &fs, 
+			   enum enum_duplicates handle_duplicates, 
+			   uint num)
+  : update_tables (ut), thd(thd_arg), updated(0), found(0), fields(fs),
+    dupl(handle_duplicates), num_of_tables(num), num_fields(0), num_updated(0),
+    error(0),  do_update(false)
 {
   save_time_stamps = (uint *) sql_calloc (sizeof(uint) * num_of_tables);
   tmp_tables = (TABLE **)NULL;
@@ -695,7 +710,7 @@ void multi_update::send_error(uint errcode,const char *err)
 
 int multi_update::do_updates (bool from_send_error)
 {
-  int error = 0, counter = 0;
+  int local_error= 0, counter= 0;
 
   if (from_send_error)
   {
@@ -720,7 +735,7 @@ int multi_update::do_updates (bool from_send_error)
     TABLE *tmp_table=tmp_tables[counter];
     if (tmp_table->file->extra(HA_EXTRA_NO_CACHE))
     {
-      error=1;
+      local_error=1;
       break;
     }
     List<Item> list;
@@ -736,35 +751,36 @@ int multi_update::do_updates (bool from_send_error)
       tmp_table->used_keys&=field->part_of_key;
     }
     tmp_table->used_fields=tmp_table->fields;
-    error=0; list.pop(); // we get position some other way ...
-    error = tmp_table->file->rnd_init(1);
-    if (error) 
-      return error;
-    while (!(error=tmp_table->file->rnd_next(tmp_table->record[0])) &&
+    local_error=0;
+    list.pop();			// we get position some other way ...
+    local_error = tmp_table->file->rnd_init(1);
+    if (local_error) 
+      return local_error;
+    while (!(local_error=tmp_table->file->rnd_next(tmp_table->record[0])) &&
 	   (!thd->killed ||  from_send_error || not_trans_safe))
     {
       found++; 
-      error= table->file->rnd_pos(table->record[0],
-				  (byte*) (*(tmp_table->field))->ptr);
-      if (error)
-	return error;
+      local_error= table->file->rnd_pos(table->record[0],
+					(byte*) (*(tmp_table->field))->ptr);
+      if (local_error)
+	return local_error;
       table->status|= STATUS_UPDATED;
       store_record(table,1); 
-      error= fill_record(*fields_by_tables[counter + 1],list) ||
-	/* compare_record(table, query_id) || */
-	table->file->update_row(table->record[1],table->record[0]);
-      if (error)
+      local_error= (fill_record(*fields_by_tables[counter + 1],list) ||
+		    /* compare_record(table, query_id) || */
+		    table->file->update_row(table->record[1],table->record[0]));
+      if (local_error)
       {
-	table->file->print_error(error,MYF(0));
+	table->file->print_error(local_error,MYF(0));
 	break;
       }
       else
 	updated++;
     }
-    if (error == HA_ERR_END_OF_FILE)
-      error = 0;
+    if (local_error == HA_ERR_END_OF_FILE)
+      local_error = 0;
   }
-  return error;
+  return local_error;
 }
 
 
@@ -775,18 +791,18 @@ bool multi_update::send_eof()
   thd->proc_info="updating the  reference tables";
 
   /* Does updates for the last n - 1 tables, returns 0 if ok */
-  int error = (num_updated) ? do_updates(false) : 0;   /* do_updates returns 0 if success */
+  int local_error = (num_updated) ? do_updates(false) : 0;
 
   /* reset used flags */
 #ifndef NOT_USED
   update_tables->table->no_keyread=0;
 #endif
-  if (error == -1)
-    error = 0;
-  thd->proc_info="end";
-  //TODO error should be sent at the query processing end
-  if (error)
-    send_error(error,"An error occured in multi-table update");
+  if (local_error == -1)
+    local_error= 0;
+  thd->proc_info= "end";
+  // TODO:  Error should be sent at the query processing end
+  if (local_error)
+    send_error(local_error, "An error occured in multi-table update");
 
   /*
     Write the SQL statement to the binlog if we updated
@@ -798,7 +814,7 @@ bool multi_update::send_eof()
   if (updated || not_trans_safe)
   {
     mysql_update_log.write(thd,thd->query,thd->query_length);
-    Query_log_event qinfo(thd, thd->query, thd->query_length);
+    Query_log_event qinfo(thd, thd->query, thd->query_length, 0);
 
     /*
       mysql_bin_log is not open if binlogging or replication
@@ -807,14 +823,14 @@ bool multi_update::send_eof()
 
     if (mysql_bin_log.is_open() &&  mysql_bin_log.write(&qinfo) &&
 	!not_trans_safe)
-      error=1;  /* Log write failed: roll back the SQL statement */
+      local_error=1;  /* Log write failed: roll back the SQL statement */
 
     /* Commit or rollback the current SQL statement */ 
-    VOID(ha_autocommit_or_rollback(thd,error > 0));
+    VOID(ha_autocommit_or_rollback(thd, local_error > 0));
   }
   else
-    error=0; // this can happen only if it is end of file error
-  if (!error) // if the above log write did not fail ...
+    local_error= 0; // this can happen only if it is end of file error
+  if (!local_error) // if the above log write did not fail ...
   {
     char buff[80];
     sprintf(buff,ER(ER_UPDATE_INFO), (long) found, (long) updated,
diff --git a/sql/sql_yacc.yy b/sql/sql_yacc.yy
index e2e17d98f2c0bd36a8674d8254eec4d23f04a765..af5d6690133f3163fba8c0684668d8e700d7b6df 100644
--- a/sql/sql_yacc.yy
+++ b/sql/sql_yacc.yy
@@ -69,6 +69,7 @@ inline Item *or_or_concat(Item* A, Item* B)
   enum Item_cast cast_type;
   enum Item_udftype udf_type;
   CHARSET_INFO *charset;
+  thr_lock_type lock_type;
   interval_type interval;
   st_select_lex *select_lex;
   chooser_compare_func_creator boolfunc2creator;
@@ -88,6 +89,7 @@ bool my_yyoverflow(short **a, YYSTYPE **b,int *yystacksize);
 %token NEXT_SYM
 %token PREV_SYM
 
+%token	DIV_SYM
 %token	EQ
 %token	EQUAL_SYM
 %token	GE
@@ -96,6 +98,7 @@ bool my_yyoverflow(short **a, YYSTYPE **b,int *yystacksize);
 %token	LT
 %token	NE
 %token	IS
+%token	MOD_SYM
 %token	SHIFT_LEFT
 %token	SHIFT_RIGHT
 %token  SET_VAR
@@ -118,6 +121,7 @@ bool my_yyoverflow(short **a, YYSTYPE **b,int *yystacksize);
 %token	CROSS
 %token  CUBE_SYM
 %token	DELETE_SYM
+%token	DUAL_SYM
 %token	DO_SYM
 %token	DROP
 %token	EVENTS_SYM
@@ -170,13 +174,13 @@ bool my_yyoverflow(short **a, YYSTYPE **b,int *yystacksize);
 %token	BOTH
 %token	BTREE_SYM
 %token	BY
+%token	BYTE_SYM
 %token	CACHE_SYM
 %token	CASCADE
 %token	CAST_SYM
 %token	CHARSET
 %token	CHECKSUM_SYM
 %token	CHECK_SYM
-%token	CIPHER
 %token	COMMITTED_SYM
 %token	COLLATE_SYM
 %token	COLUMNS
@@ -202,6 +206,7 @@ bool my_yyoverflow(short **a, YYSTYPE **b,int *yystacksize);
 %token	ESCAPE_SYM
 %token	EXISTS
 %token	EXTENDED_SYM
+%token	FALSE_SYM
 %token	FILE_SYM
 %token	FIRST_SYM
 %token	FIXED_SYM
@@ -232,7 +237,6 @@ bool my_yyoverflow(short **a, YYSTYPE **b,int *yystacksize);
 %token	IN_SYM
 %token	ISOLATION
 %token	ISAM_SYM
-%token	ISSUER
 %token	JOIN_SYM
 %token	KEYS
 %token	KEY_SYM
@@ -252,7 +256,6 @@ bool my_yyoverflow(short **a, YYSTYPE **b,int *yystacksize);
 %token	MASTER_USER_SYM
 %token	MASTER_LOG_FILE_SYM
 %token	MASTER_LOG_POS_SYM
-%token	MASTER_LOG_SEQ_SYM
 %token	MASTER_PASSWORD_SYM
 %token	MASTER_PORT_SYM
 %token	MASTER_CONNECT_RETRY_SYM
@@ -273,10 +276,10 @@ bool my_yyoverflow(short **a, YYSTYPE **b,int *yystacksize);
 %token	NEW_SYM
 %token	NCHAR_SYM
 %token	NOT
-%token  NO_FOREIGN_KEY_CHECKS
 %token	NO_SYM
 %token	NULL_SYM
 %token	NUM
+%token	OFFSET_SYM
 %token	ON
 %token	OPEN_SYM
 %token	OPTION
@@ -303,7 +306,6 @@ bool my_yyoverflow(short **a, YYSTYPE **b,int *yystacksize);
 %token	REAL_NUM
 %token	REFERENCES
 %token	REGEXP
-%token  RELAXED_UNIQUE_CHECKS
 %token	RELOAD
 %token	RENAME
 %token	REPEATABLE_SYM
@@ -317,6 +319,7 @@ bool my_yyoverflow(short **a, YYSTYPE **b,int *yystacksize);
 %token	ROW_SYM
 %token	RTREE_SYM
 %token	SET
+%token	SERIAL_SYM
 %token	SERIALIZABLE_SYM
 %token	SESSION_SYM
 %token	SIMPLE_SYM
@@ -335,6 +338,7 @@ bool my_yyoverflow(short **a, YYSTYPE **b,int *yystacksize);
 %token	TO_SYM
 %token	TRAILING
 %token	TRANSACTION_SYM
+%token	TRUE_SYM
 %token	TYPE_SYM
 %token  TYPES_SYM
 %token	FUNC_ARG0
@@ -352,6 +356,7 @@ bool my_yyoverflow(short **a, YYSTYPE **b,int *yystacksize);
 %token	USE_FRM
 %token	USE_SYM
 %token	USING
+%token	VALUE_SYM
 %token	VALUES
 %token	VARIABLES
 %token	WHERE
@@ -519,7 +524,7 @@ bool my_yyoverflow(short **a, YYSTYPE **b,int *yystacksize);
 %left	'&'
 %left	SHIFT_LEFT SHIFT_RIGHT
 %left	'-' '+'
-%left	'*' '/' '%'
+%left	'*' '/' '%' DIV_SYM MOD_SYM
 %left	NEG '~'
 %left   XOR
 %left   '^'
@@ -543,7 +548,7 @@ bool my_yyoverflow(short **a, YYSTYPE **b,int *yystacksize);
 	table_ident references
 
 %type <simple_string>
-	remember_name remember_end opt_len opt_ident opt_db text_or_password
+	remember_name remember_end opt_ident opt_db text_or_password
 	opt_escape
 
 %type <string>
@@ -553,7 +558,7 @@ bool my_yyoverflow(short **a, YYSTYPE **b,int *yystacksize);
 	type int_type real_type order_dir opt_field_spec lock_option
 	udf_type if_exists opt_local opt_table_options table_options
 	table_option opt_if_not_exists opt_var_type opt_var_ident_type
-	delete_option all_or_any
+	delete_option opt_temporary all_or_any
 
 %type <ulong_num>
 	ULONG_NUM raid_types merge_insert_types
@@ -561,6 +566,9 @@ bool my_yyoverflow(short **a, YYSTYPE **b,int *yystacksize);
 %type <ulonglong_number>
 	ulonglong_num
 
+%type <lock_type>
+	replace_lock_option opt_low_priority insert_lock_option load_data_lock
+
 %type <item>
 	literal text_literal insert_ident order_ident
 	simple_ident select_item2 expr opt_expr opt_else sum_expr in_sum_expr
@@ -636,23 +644,25 @@ bool my_yyoverflow(short **a, YYSTYPE **b,int *yystacksize);
 	field_opt_list opt_binary table_lock_list table_lock varchar
 	ref_list opt_on_delete opt_on_delete_list opt_on_delete_item use
 	opt_delete_options opt_delete_option
-	opt_outer table_list table_name opt_option opt_place opt_low_priority
+	opt_outer table_list table_name opt_option opt_place
 	opt_attribute opt_attribute_list attribute column_list column_list_id
 	opt_column_list grant_privileges opt_table user_list grant_option
 	grant_privilege grant_privilege_list
-	flush_options flush_option insert_lock_option replace_lock_option
+	flush_options flush_option
 	equal optional_braces opt_key_definition key_usage_list2
 	opt_mi_check_type opt_to mi_check_types normal_join
 	table_to_table_list table_to_table opt_table_list opt_as
 	handler_rkey_function handler_read_or_scan
-	single_multi table_wild_list table_wild_one opt_wild union
-	precision union_option opt_on_delete_item subselect_start opt_and
-	subselect_end select_var_list select_var_list_init help
+	single_multi table_wild_list table_wild_one opt_wild
+	union union_option
+	precision opt_on_delete_item subselect_start opt_and
+	subselect_end select_var_list select_var_list_init help opt_len
 END_OF_INPUT
 
 %type <NONE>
 	'-' '+' '*' '/' '%' '(' ')'
-	',' '!' '{' '}' '&' '|' AND OR OR_OR_CONCAT BETWEEN_SYM CASE_SYM THEN_SYM WHEN_SYM
+	',' '!' '{' '}' '&' '|' AND OR OR_OR_CONCAT BETWEEN_SYM CASE_SYM
+	THEN_SYM WHEN_SYM DIV_SYM MOD_SYM
 %%
 
 
@@ -729,7 +739,7 @@ change:
         {
 	  LEX *lex = Lex;
 	  lex->sql_command = SQLCOM_CHANGE_MASTER;
-	  memset(&lex->mi, 0, sizeof(lex->mi));
+	  bzero((char*) &lex->mi, sizeof(lex->mi));
         } master_defs;
 
 master_defs:
@@ -796,7 +806,10 @@ create:
 			 			 ($2 &
 						  HA_LEX_CREATE_TMP_TABLE ?
 						  &tmp_table_alias :
-						  (LEX_STRING*) 0),1))
+						  (LEX_STRING*) 0),1,
+						 ((using_update_log)?
+						  TL_READ_NO_INSERT:
+						  TL_READ)))
 	    YYABORT;
 	  lex->create_list.empty();
 	  lex->key_list.empty();
@@ -989,7 +1002,7 @@ field_list:
 
 
 field_list_item:
-	  field_spec
+	  field_spec check_constraint
 	| field_spec references
 	  {
 	    Lex->col_list.empty();		/* Alloced by sql_alloc */
@@ -1011,10 +1024,16 @@ field_list_item:
 				    lex->fk_match_option));
 	    lex->col_list.empty();		/* Alloced by sql_alloc */
 	  }
-	| opt_constraint CHECK_SYM '(' expr ')'
+	| opt_constraint check_constraint
 	  {
 	    Lex->col_list.empty();		/* Alloced by sql_alloc */
-	  };
+	  }
+	;
+
+check_constraint:
+	/* empty */
+	| CHECK_SYM expr
+	;
 
 opt_constraint:
 	/* empty */
@@ -1040,7 +1059,7 @@ field_spec:
 	};
 
 type:
-	int_type opt_len field_options	{ Lex->length=$2; $$=$1; }
+	int_type opt_len field_options	{ $$=$1; }
 	| real_type opt_precision field_options { $$=$1; }
 	| FLOAT_SYM float_options field_options { $$=FIELD_TYPE_FLOAT; }
 	| BIT_SYM opt_len		{ Lex->length=(char*) "1";
@@ -1059,16 +1078,22 @@ type:
 	| VARBINARY '(' NUM ')' 	{ Lex->length=$3.str;
 					  Lex->charset=my_charset_bin;
 					  $$=FIELD_TYPE_VAR_STRING; }
-	| YEAR_SYM opt_len field_options { $$=FIELD_TYPE_YEAR; Lex->length=$2; }
+	| YEAR_SYM opt_len field_options { $$=FIELD_TYPE_YEAR; }
 	| DATE_SYM			{ $$=FIELD_TYPE_DATE; }
 	| TIME_SYM			{ $$=FIELD_TYPE_TIME; }
-	| TIMESTAMP			{ $$=FIELD_TYPE_TIMESTAMP; }
+	| TIMESTAMP
+	  {
+	    if (current_thd->sql_mode & MODE_SAPDB)
+	      $$=FIELD_TYPE_DATETIME;
+	    else
+	      $$=FIELD_TYPE_TIMESTAMP;	
+	   }
 	| TIMESTAMP '(' NUM ')'		{ Lex->length=$3.str;
 					  $$=FIELD_TYPE_TIMESTAMP; }
 	| DATETIME			{ $$=FIELD_TYPE_DATETIME; }
 	| TINYBLOB			{ Lex->charset=my_charset_bin;
 					  $$=FIELD_TYPE_TINY_BLOB; }
-	| BLOB_SYM			{ Lex->charset=my_charset_bin;
+	| BLOB_SYM opt_len		{ Lex->charset=my_charset_bin;
 					  $$=FIELD_TYPE_BLOB; }
 	| GEOMETRY_SYM			{ Lex->charset=my_charset_bin;
 					  $$=FIELD_TYPE_GEOMETRY; }
@@ -1080,13 +1105,15 @@ type:
 					  $$=FIELD_TYPE_MEDIUM_BLOB; }
 	| LONG_SYM varchar opt_binary	{ $$=FIELD_TYPE_MEDIUM_BLOB; }
 	| TINYTEXT opt_binary		{ $$=FIELD_TYPE_TINY_BLOB; }
-	| TEXT_SYM opt_binary		{ $$=FIELD_TYPE_BLOB; }
+	| TEXT_SYM opt_len opt_binary	{ $$=FIELD_TYPE_BLOB; }
 	| MEDIUMTEXT opt_binary		{ $$=FIELD_TYPE_MEDIUM_BLOB; }
 	| LONGTEXT opt_binary		{ $$=FIELD_TYPE_LONG_BLOB; }
 	| DECIMAL_SYM float_options field_options
 					{ $$=FIELD_TYPE_DECIMAL;}
 	| NUMERIC_SYM float_options field_options
 					{ $$=FIELD_TYPE_DECIMAL;}
+	| FIXED_SYM float_options field_options
+					{ $$=FIELD_TYPE_DECIMAL;}
 	| ENUM {Lex->interval_list.empty();} '(' string_list ')' opt_binary
 	  {
 	    LEX *lex=Lex;
@@ -1098,7 +1125,15 @@ type:
 	    LEX *lex=Lex;
 	    lex->interval=typelib(lex->interval_list);
 	    $$=FIELD_TYPE_SET;
-	  };
+	  }
+	| LONG_SYM opt_binary		{ $$=FIELD_TYPE_MEDIUM_BLOB; }
+	| SERIAL_SYM
+	  {
+	    $$=FIELD_TYPE_LONGLONG;
+	    Lex->type|= (AUTO_INCREMENT_FLAG | NOT_NULL_FLAG | UNSIGNED_FLAG |
+		         UNIQUE_FLAG);
+	  }
+	;
 
 char:
 	CHAR_SYM {}
@@ -1151,8 +1186,8 @@ field_option:
 	| ZEROFILL	{ Lex->type|= UNSIGNED_FLAG | ZEROFILL_FLAG; };
 
 opt_len:
-	/* empty */	{ $$=(char*) 0; }	/* use default length */
-	| '(' NUM ')'	{ $$=$2.str; };
+	/* empty */	{ Lex->length=(char*) 0; } /* use default length */
+	| '(' NUM ')'	{ Lex->length= $2.str; };
 
 opt_precision:
 	/* empty */	{}
@@ -1171,11 +1206,14 @@ attribute:
 	| NOT NULL_SYM	  { Lex->type|= NOT_NULL_FLAG; }
 	| DEFAULT literal { Lex->default_value=$2; }
 	| AUTO_INC	  { Lex->type|= AUTO_INCREMENT_FLAG | NOT_NULL_FLAG; }
-	| PRIMARY_SYM KEY_SYM { Lex->type|= PRI_KEY_FLAG | NOT_NULL_FLAG; }
+	| SERIAL_SYM DEFAULT VALUE_SYM
+	  { Lex->type|= AUTO_INCREMENT_FLAG | NOT_NULL_FLAG | UNIQUE_FLAG; }
+	| opt_primary KEY_SYM { Lex->type|= PRI_KEY_FLAG | NOT_NULL_FLAG; }
 	| UNIQUE_SYM	  { Lex->type|= UNIQUE_FLAG; }
 	| UNIQUE_SYM KEY_SYM { Lex->type|= UNIQUE_KEY_FLAG; }
 	| COMMENT_SYM text_literal { Lex->comment= $2; };
 
+
 charset_name:
 	BINARY
 	{ 
@@ -1209,9 +1247,15 @@ opt_db_default_character_set:
 
 opt_binary:
 	/* empty */			{ Lex->charset=NULL; }
+	| BYTE_SYM			{ Lex->charset=my_charset_bin; }
 	| BINARY			{ Lex->charset=my_charset_bin; }
 	| CHAR_SYM SET charset_name	{ Lex->charset=$3; } ;
 
+
+opt_primary:
+	/* empty */
+	| PRIMARY_SYM
+
 references:
 	REFERENCES table_ident
 	{
@@ -1443,20 +1487,24 @@ opt_to:
 	| EQ		{}
 	| AS		{};
 
+/*
+  The first two deprecate the last two--delete the last two for 4.1 release
+*/
+
 slave:
 	START_SYM SLAVE slave_thread_opts
-         {
-	   LEX *lex=Lex;
-           lex->sql_command = SQLCOM_SLAVE_START;
-	   lex->type = 0;
-         }
-         |
-	STOP_SYM SLAVE slave_thread_opts
-         {
-	   LEX *lex=Lex;
-           lex->sql_command = SQLCOM_SLAVE_STOP;
-	   lex->type = 0;
-         };
+        {
+	  LEX *lex=Lex;
+          lex->sql_command = SQLCOM_SLAVE_START;
+	  lex->type = 0;
+        }
+        | STOP_SYM SLAVE slave_thread_opts
+          {
+	    LEX *lex=Lex;
+            lex->sql_command = SQLCOM_SLAVE_STOP;
+	    lex->type = 0;
+          }
+	;
 
 slave_thread_opts:
 	slave_thread_opt
@@ -1609,14 +1657,16 @@ select_init:
 select_part2:
 	{
 	  LEX *lex=Lex;
-	  lex->lock_option=TL_READ;
-	   mysql_init_select(lex);
+	  if (lex->current_select == &lex->select_lex)
+	    lex->lock_option= TL_READ; /* Only for global SELECT */
+	  mysql_init_select(lex);
 	}
 	select_options select_item_list select_into select_lock_type;
 
 select_into:
 	limit_clause {}
 	| select_from
+	| FROM DUAL_SYM
         | opt_into
 	| opt_into select_from
 	| select_from opt_into;
@@ -1656,7 +1706,7 @@ select_option:
 	      YYABORT;
 	    Select->options|= OPTION_FOUND_ROWS;
 	  }
-	| SQL_NO_CACHE_SYM { current_thd->safe_to_cache_query=0; }
+	| SQL_NO_CACHE_SYM { Lex->safe_to_cache_query=0; }
 	| SQL_CACHE_SYM    { Select->options|= OPTION_TO_QUERY_CACHE; }
 	| ALL		{}
 	;
@@ -1666,18 +1716,15 @@ select_lock_type:
 	| FOR_SYM UPDATE_SYM
 	  {
 	    LEX *lex=Lex;
-	    if (check_simple_select())
-	      YYABORT;	
-	    lex->lock_option= TL_WRITE;
-	    lex->thd->safe_to_cache_query=0;
+	    lex->current_select->set_lock_for_tables(TL_WRITE);
+	    lex->safe_to_cache_query=0;
 	  }
 	| LOCK_SYM IN_SYM SHARE_SYM MODE_SYM
 	  {
 	    LEX *lex=Lex;
-	    if (check_simple_select())
-	      YYABORT;	
-	    lex->lock_option= TL_READ_WITH_SHARED_LOCKS;
-	    lex->thd->safe_to_cache_query=0;
+	    lex->current_select->
+	      set_lock_for_tables(TL_READ_WITH_SHARED_LOCKS);
+	    lex->safe_to_cache_query=0;
 	  }
 	;
 
@@ -1782,6 +1829,8 @@ expr_expr:
 	| expr '-' expr		{ $$= new Item_func_minus($1,$3); }
 	| expr '*' expr		{ $$= new Item_func_mul($1,$3); }
 	| expr '/' expr		{ $$= new Item_func_div($1,$3); }
+	| expr DIV_SYM expr	{ $$= new Item_func_int_div($1,$3); }
+	| expr MOD_SYM expr	{ $$= new Item_func_mod($1,$3); }
 	| expr '|' expr		{ $$= new Item_func_bit_or($1,$3); }
         | expr '^' expr		{ $$= new Item_func_bit_xor($1,$3); }	
 	| expr '&' expr		{ $$= new Item_func_bit_and($1,$3); }
@@ -1826,10 +1875,12 @@ no_in_expr:
 	| no_in_expr '-' expr		{ $$= new Item_func_minus($1,$3); }
 	| no_in_expr '*' expr		{ $$= new Item_func_mul($1,$3); }
 	| no_in_expr '/' expr		{ $$= new Item_func_div($1,$3); }
+	| no_in_expr DIV_SYM expr	{ $$= new Item_func_int_div($1,$3); }
 	| no_in_expr '|' expr		{ $$= new Item_func_bit_or($1,$3); }
         | no_in_expr '^' expr		{ $$= new Item_func_bit_xor($1,$3); }
 	| no_in_expr '&' expr		{ $$= new Item_func_bit_and($1,$3); }
 	| no_in_expr '%' expr		{ $$= new Item_func_mod($1,$3); }
+	| no_in_expr MOD_SYM expr	{ $$= new Item_func_mod($1,$3); }
 	| no_in_expr '+' INTERVAL_SYM expr interval
 	  { $$= new Item_date_add_interval($1,$4,$5,0); }
 	| no_in_expr '-' INTERVAL_SYM expr interval
@@ -1878,10 +1929,12 @@ no_and_expr:
 	| no_and_expr '-' expr		{ $$= new Item_func_minus($1,$3); }
 	| no_and_expr '*' expr		{ $$= new Item_func_mul($1,$3); }
 	| no_and_expr '/' expr		{ $$= new Item_func_div($1,$3); }
+	| no_and_expr DIV_SYM expr	{ $$= new Item_func_int_div($1,$3); }
 	| no_and_expr '|' expr		{ $$= new Item_func_bit_or($1,$3); }
         | no_and_expr '^' expr		{ $$= new Item_func_bit_xor($1,$3); }
 	| no_and_expr '&' expr		{ $$= new Item_func_bit_and($1,$3); }
 	| no_and_expr '%' expr		{ $$= new Item_func_mod($1,$3); }
+	| no_and_expr MOD_SYM expr	{ $$= new Item_func_mod($1,$3); }
 	| no_and_expr '+' INTERVAL_SYM expr interval
 	  { $$= new Item_date_add_interval($1,$4,$5,0); }
 	| no_and_expr '-' INTERVAL_SYM expr interval
@@ -1895,12 +1948,12 @@ simple_expr:
 	| '@' ident_or_text SET_VAR expr
 	  {
 	    $$= new Item_func_set_user_var($2,$4);
-	    current_thd->safe_to_cache_query=0;
+	    Lex->safe_to_cache_query=0;
 	  }
 	| '@' ident_or_text	 
 	  {
 	    $$= new Item_func_get_user_var($2);
-	    current_thd->safe_to_cache_query=0;
+	    Lex->safe_to_cache_query=0;
 	  }
 	| '@' '@' opt_var_ident_type ident_or_text
 	  {
@@ -1954,13 +2007,13 @@ simple_expr:
 	| CONCAT_WS '(' expr ',' expr_list ')'
 	  { $$= new Item_func_concat_ws($3, *$5); }
 	| CURDATE optional_braces
-	  { $$= new Item_func_curdate(); current_thd->safe_to_cache_query=0; }
+	  { $$= new Item_func_curdate(); Lex->safe_to_cache_query=0; }
 	| CURTIME optional_braces
-	  { $$= new Item_func_curtime(); current_thd->safe_to_cache_query=0; }
+	  { $$= new Item_func_curtime(); Lex->safe_to_cache_query=0; }
 	| CURTIME '(' expr ')'
 	  { 
 	    $$= new Item_func_curtime($3); 
-	    current_thd->safe_to_cache_query=0;
+	    Lex->safe_to_cache_query=0;
 	  }
 	| DATE_ADD_INTERVAL '(' expr ',' INTERVAL_SYM expr interval ')'
 	  { $$= new Item_date_add_interval($3,$6,$7,0); }
@@ -1969,7 +2022,7 @@ simple_expr:
 	| DATABASE '(' ')'
 	  { 
 	    $$= new Item_func_database();
-            current_thd->safe_to_cache_query=0; 
+            Lex->safe_to_cache_query=0; 
 	  }
 	| ELT_FUNC '(' expr ',' expr_list ')'
 	  { $$= new Item_func_elt($3, *$5); }
@@ -1978,7 +2031,7 @@ simple_expr:
 	| ENCRYPT '(' expr ')'
 	  {
 	    $$= new Item_func_encrypt($3);
-	    current_thd->safe_to_cache_query=0; 
+	    Lex->safe_to_cache_query=0; 
 	  }
 	| ENCRYPT '(' expr ',' expr ')'   { $$= new Item_func_encrypt($3,$5); }
 	| DECODE_SYM '(' expr ',' TEXT_STRING ')'
@@ -1999,6 +2052,8 @@ simple_expr:
 		{ $$= new Item_func_export_set($3, $5, $7, $9); }
 	| EXPORT_SET '(' expr ',' expr ',' expr ',' expr ',' expr ')'
 		{ $$= new Item_func_export_set($3, $5, $7, $9, $11); }
+	| FALSE_SYM
+	  { $$= new Item_int((char*) "FALSE",0,1); }
 	| FORMAT_SYM '(' expr ',' NUM ')'
 	  { $$= new Item_func_format($3,atoi($5.str)); }
 	| FROM_UNIXTIME '(' expr ')'
@@ -2036,7 +2091,7 @@ simple_expr:
 	| LAST_INSERT_ID '(' expr ')'
 	  {
 	    $$= new Item_func_set_last_insert_id($3);
-	    current_thd->safe_to_cache_query=0;
+	    Lex->safe_to_cache_query=0;
 	  }
 	| LEFT '(' expr ',' expr ')'
 	  { $$= new Item_func_left($3,$5); }
@@ -2065,6 +2120,8 @@ simple_expr:
 	  { $$= new Item_func_geometry_from_text($3); }
 	| MINUTE_SYM '(' expr ')'
 	  { $$= new Item_func_minute($3); }
+	| MOD_SYM '(' expr ',' expr ')'
+	  { $$ = new Item_func_mod( $3, $5); }
 	| MONTH_SYM '(' expr ')'
 	  { $$= new Item_func_month($3); }
  	| MULTILINESTRING '(' expr_list ')'
@@ -2089,9 +2146,9 @@ simple_expr:
  	  { $$= new Item_func_spatial_collection(* $3, 
                        Geometry::wkbMultiPolygon, Geometry::wkbPolygon ); }
 	| NOW_SYM optional_braces
-	  { $$= new Item_func_now(); current_thd->safe_to_cache_query=0;}
+	  { $$= new Item_func_now(); Lex->safe_to_cache_query=0;}
 	| NOW_SYM '(' expr ')'
-	  { $$= new Item_func_now($3); current_thd->safe_to_cache_query=0;}
+	  { $$= new Item_func_now($3); Lex->safe_to_cache_query=0;}
 	| PASSWORD '(' expr ')'
 	  {
 	    $$= new Item_func_password($3);
@@ -2110,9 +2167,9 @@ simple_expr:
 	| POSITION_SYM '(' no_in_expr IN_SYM expr ')'
 	  { $$ = new Item_func_locate($5,$3); }
 	| RAND '(' expr ')'
-	  { $$= new Item_func_rand($3); current_thd->safe_to_cache_query=0;}
+	  { $$= new Item_func_rand($3); Lex->safe_to_cache_query=0;}
 	| RAND '(' ')'
-	  { $$= new Item_func_rand(); current_thd->safe_to_cache_query=0;}
+	  { $$= new Item_func_rand(); Lex->safe_to_cache_query=0;}
 	| REPLACE '(' expr ',' expr ',' expr ')'
 	  { $$= new Item_func_replace($3,$5,$7); }
 	| RIGHT '(' expr ',' expr ')'
@@ -2144,6 +2201,8 @@ simple_expr:
 	  { $$= new Item_func_trim($5,$3); }
 	| TRUNCATE_SYM '(' expr ',' expr ')'
 	  { $$= new Item_func_round($3,$5,1); }
+	| TRUE_SYM
+	  { $$= new Item_int((char*) "TRUE",1,1); }
 	| UDA_CHAR_SUM '(' udf_expr_list ')'
 	  {
 	    if ($3 != NULL)
@@ -2193,12 +2252,12 @@ simple_expr:
 	| UNIX_TIMESTAMP '(' ')'
 	  {
 	    $$= new Item_func_unix_timestamp();
-	    current_thd->safe_to_cache_query=0;
+	    Lex->safe_to_cache_query=0;
 	  }
 	| UNIX_TIMESTAMP '(' expr ')'
 	  { $$= new Item_func_unix_timestamp($3); }
 	| USER '(' ')'
-	  { $$= new Item_func_user(); current_thd->safe_to_cache_query=0; }
+	  { $$= new Item_func_user(); Lex->safe_to_cache_query=0; }
 	| WEEK_SYM '(' expr ')'
 	  { $$= new Item_func_week($3,new Item_int((char*) "0",0,1)); }
 	| WEEK_SYM '(' expr ',' expr ')'
@@ -2212,7 +2271,7 @@ simple_expr:
 	| BENCHMARK_SYM '(' ULONG_NUM ',' expr ')'
 	  { 
 	    $$=new Item_func_benchmark($3,$5);
-	    current_thd->safe_to_cache_query=0;
+	    Lex->safe_to_cache_query=0;
 	  }
 	| EXTRACT_SYM '(' interval FROM expr ')'
 	{ $$=new Item_extract( $3, $5); };
@@ -2262,13 +2321,15 @@ in_sum_expr:
 
 cast_type:
 	BINARY 			{ $$=ITEM_CAST_BINARY; }
+	| CHAR_SYM		{ $$=ITEM_CAST_CHAR; }
 	| SIGNED_SYM		{ $$=ITEM_CAST_SIGNED_INT; }
 	| SIGNED_SYM INT_SYM	{ $$=ITEM_CAST_SIGNED_INT; }
 	| UNSIGNED		{ $$=ITEM_CAST_UNSIGNED_INT; }
 	| UNSIGNED INT_SYM	{ $$=ITEM_CAST_UNSIGNED_INT; }
 	| DATE_SYM		{ $$=ITEM_CAST_DATE; }
 	| TIME_SYM		{ $$=ITEM_CAST_TIME; }
-	| DATETIME		{ $$=ITEM_CAST_DATETIME; };
+	| DATETIME		{ $$=ITEM_CAST_DATETIME; }
+	;
 
 expr_list:
 	{ Select->expr_list.push_front(new List<Item>); }
@@ -2378,8 +2439,9 @@ join_table:
 	}
         table_ident opt_table_alias opt_key_definition
 	{
-	  SELECT_LEX_NODE *sel=Select;
-	  if (!($$= sel->add_table_to_list($2, $3, 0, TL_UNLOCK,
+	  LEX *lex= Lex;
+	  SELECT_LEX_NODE *sel= lex->current_select;
+	  if (!($$= sel->add_table_to_list($2, $3, 0, lex->lock_option,
 					   sel->get_use_index(),
 					   sel->get_ignore_index())))
 	    YYABORT;
@@ -2392,7 +2454,8 @@ join_table:
 	  SELECT_LEX_UNIT *unit= lex->current_select->master_unit();
 	  lex->current_select= unit->outer_select();
 	  if (!($$= lex->current_select->
-                add_table_to_list(new Table_ident(unit), $5, 0, TL_UNLOCK)))
+                add_table_to_list(new Table_ident(unit), $5, 0,
+				  lex->lock_option)))
 	    YYABORT;
 	};
 
@@ -2495,15 +2558,24 @@ opt_table_alias:
 
 where_clause:
 	/* empty */  { Select->select_lex()->where= 0; }  
-	| WHERE expr { Select->select_lex()->where= $2; };
+	| WHERE expr
+	  {
+	    Select->select_lex()->where= $2;
+	    if ($2)
+	      $2->top_level_item();
+	  }
+ 	;
 
 having_clause:
 	/* empty */
 	| HAVING { Select->select_lex()->create_refs= 1; } expr
-	{
-	  SELECT_LEX *sel= Select->select_lex();
-	  sel->having= $3; sel->create_refs=0;
-	};
+	  {
+	    SELECT_LEX *sel= Select->select_lex();
+	    sel->having= $3; sel->create_refs=0;
+	    if ($3)
+	      $3->top_level_item();
+	  }
+	;
 
 opt_escape:
 	ESCAPE_SYM TEXT_STRING	{ $$= $2.str; }
@@ -2568,11 +2640,6 @@ order_clause:
 	ORDER_SYM BY 
         { 
 	  LEX *lex=Lex;
-	  if (lex->sql_command == SQLCOM_MULTI_UPDATE)
-	  {
-	    net_printf(lex->thd, ER_WRONG_USAGE, "UPDATE", "ORDER BY");
-	    YYABORT;
-	  }	
 	  if (lex->current_select->linkage != GLOBAL_OPTIONS_TYPE &&
 	      lex->current_select->select_lex()->olap !=
 	      UNSPECIFIED_OLAP_TYPE)
@@ -2598,7 +2665,7 @@ order_dir:
 
 limit_clause:
 	/* empty */ {}
-	| LIMIT ULONG_NUM
+	| LIMIT 
 	  {
 	    LEX *lex= Lex;
 	    if (lex->current_select->linkage != GLOBAL_OPTIONS_TYPE &&
@@ -2609,35 +2676,36 @@ limit_clause:
 		        "LIMIT");
 	      YYABORT;
 	    }
+	  }
+	  limit_options
+	;
+
+limit_options:
+	ULONG_NUM
+	  {
+            SELECT_LEX_NODE *sel= Select;
+            sel->select_limit= $1;
+            sel->offset_limit= 0L;
+	  }
+	| ULONG_NUM ',' ULONG_NUM
+	  {
 	    SELECT_LEX_NODE *sel= Select;
-	    sel->select_limit= $2;
-	    sel->offset_limit= 0L;
+	    sel->select_limit= $3;
+	    sel->offset_limit= $1;
 	  }
-	| LIMIT ULONG_NUM ',' ULONG_NUM
+	| ULONG_NUM OFFSET_SYM ULONG_NUM
 	  {
-	    LEX *lex=Lex;
-	    if (lex->current_select->linkage != GLOBAL_OPTIONS_TYPE &&
-                lex->current_select->select_lex()->olap !=
-		UNSPECIFIED_OLAP_TYPE)
-	    {
-	      net_printf(lex->thd, ER_WRONG_USAGE, "CUBE/ROLLUP",
-		        "LIMIT");
-	      YYABORT;
-	    }	      
-	    SELECT_LEX_NODE *sel= lex->current_select;
-	    sel->select_limit= $4;
-	    sel->offset_limit= $2;
-	  };
+	    SELECT_LEX_NODE *sel= Select;
+	    sel->select_limit= $1;
+	    sel->offset_limit= $3;
+	  }
+	;
+
 
 delete_limit_clause:
 	/* empty */
 	{
 	  LEX *lex=Lex;
-	  if (lex->sql_command == SQLCOM_MULTI_UPDATE)
-	  {
-	    net_printf(lex->thd, ER_WRONG_USAGE, "DELETE", "LIMIT");
-	    YYABORT;
-	  }
 	  lex->current_select->select_limit= HA_POS_ERROR;
 	}
 	| LIMIT ulonglong_num
@@ -2666,7 +2734,7 @@ procedure_clause:
 	    lex->proc_list.next= (byte**) &lex->proc_list.first;
 	    if (add_proc_to_list(new Item_field(NULL,NULL,$2.str)))
 	      YYABORT;
-	    current_thd->safe_to_cache_query=0;
+	    Lex->safe_to_cache_query=0;
 	  }
 	  '(' procedure_list ')';
 
@@ -2738,7 +2806,7 @@ opt_into:
 	}
         | INTO select_var_list_init
 	{
-	  current_thd->safe_to_cache_query=0;
+	  Lex->safe_to_cache_query=0;
 	}
         ;
 
@@ -2759,11 +2827,12 @@ do:	DO_SYM
 */
 
 drop:
-	DROP TABLE_SYM if_exists table_list opt_restrict
+	DROP opt_temporary TABLE_SYM if_exists table_list opt_restrict
 	{
 	  LEX *lex=Lex;
 	  lex->sql_command = SQLCOM_DROP_TABLE;
-	  lex->drop_if_exists = $3;
+	  lex->drop_temporary= $2;
+	  lex->drop_if_exists= $4;
 	}
 	| DROP INDEX ident ON table_ident {}
 	  {
@@ -2799,15 +2868,32 @@ table_name:
 	{ if (!Select->add_table_to_list($1, NULL, 1)) YYABORT; };
 
 if_exists:
-	/* empty */ { $$=0; }
-	| IF EXISTS { $$= 1; };
+	/* empty */ { $$= 0; }
+	| IF EXISTS { $$= 1; }
+	;
 
+opt_temporary:
+	/* empty */ { $$= 0; }
+	| TEMPORARY { $$= 1; }
+	;
 /*
 ** Insert : add new data to table
 */
 
 insert:
-	INSERT { Lex->sql_command = SQLCOM_INSERT; } insert_lock_option opt_ignore insert2 insert_field_spec;
+	INSERT
+	{
+	  LEX *lex= Lex;
+	  lex->sql_command = SQLCOM_INSERT;
+	  /* for subselects */
+          lex->lock_option= (using_update_log) ? TL_READ_NO_INSERT : TL_READ;
+	} insert_lock_option
+	opt_ignore insert2 
+	{
+	  Select->set_lock_for_tables($3);
+	}
+	insert_field_spec
+	;
 
 replace:
 	REPLACE
@@ -2816,17 +2902,23 @@ replace:
 	  lex->sql_command = SQLCOM_REPLACE;
 	  lex->duplicates= DUP_REPLACE;
 	}
-	replace_lock_option insert2 insert_field_spec;
+	replace_lock_option insert2
+	{
+	  Select->set_lock_for_tables($3);
+	}
+	insert_field_spec
+	;
 
 insert_lock_option:
-	/* empty */	{ Lex->lock_option= TL_WRITE_CONCURRENT_INSERT; }
-	| LOW_PRIORITY	{ Lex->lock_option= TL_WRITE_LOW_PRIORITY; }
-	| DELAYED_SYM	{ Lex->lock_option= TL_WRITE_DELAYED; }
-	| HIGH_PRIORITY { Lex->lock_option= TL_WRITE; };
+	/* empty */	{ $$= TL_WRITE_CONCURRENT_INSERT; }
+	| LOW_PRIORITY	{ $$= TL_WRITE_LOW_PRIORITY; }
+	| DELAYED_SYM	{ $$= TL_WRITE_DELAYED; }
+	| HIGH_PRIORITY { $$= TL_WRITE; }
+	;	
 
 replace_lock_option:
-	opt_low_priority {}
-	| DELAYED_SYM	{ Lex->lock_option= TL_WRITE_DELAYED; };
+	opt_low_priority { $$= $1; }
+	| DELAYED_SYM	 { $$= TL_WRITE_DELAYED; };
 
 insert2:
 	INTO insert_table {}
@@ -2863,6 +2955,7 @@ fields:
 
 insert_values:
 	VALUES	values_list  {}
+	| VALUE_SYM values_list  {}
 	| SELECT_SYM
 	  {
 	    LEX *lex=Lex;
@@ -2872,7 +2965,8 @@ insert_values:
 	    mysql_init_select(lex);
 	  }
 	  select_options select_item_list select_from select_lock_type
-          union {};
+          union {}
+	;
 
 values_list:
 	values_list ','  no_braces
@@ -2939,13 +3033,18 @@ expr_or_default:
 /* Update rows in a table */
 
 update:
-        UPDATE_SYM 
+	UPDATE_SYM 
 	{ 
 	  LEX *lex= Lex;
           lex->sql_command= SQLCOM_UPDATE;
           lex->select_lex.init_order();
         }
-        opt_low_priority opt_ignore join_table_list SET update_list where_clause opt_order_clause delete_limit_clause;
+        opt_low_priority opt_ignore join_table_list
+	SET update_list where_clause opt_order_clause delete_limit_clause
+	{
+	  Select->set_lock_for_tables($3);
+	}
+	;
 
 update_list:
 	update_list ',' simple_ident equal expr
@@ -2960,8 +3059,8 @@ update_list:
 	  };
 
 opt_low_priority:
-	/* empty */	{ Lex->lock_option= current_thd->update_lock_default; }
-	| LOW_PRIORITY	{ Lex->lock_option= TL_WRITE_LOW_PRIORITY; };
+	/* empty */	{ $$= current_thd->update_lock_default; }
+	| LOW_PRIORITY	{ $$= TL_WRITE_LOW_PRIORITY; };
 
 /* Delete rows from a table */
 
@@ -2974,13 +3073,20 @@ delete:
 	  lex->lock_option= lex->thd->update_lock_default;
 	  lex->select_lex.init_order();
 	}
-	opt_delete_options single_multi	{};
+	opt_delete_options single_multi {}
+	;
 
 single_multi:
- 	FROM table_name where_clause opt_order_clause delete_limit_clause {}
+ 	FROM table_ident
+	{
+	  if (!Select->add_table_to_list($2, NULL, 1, Lex->lock_option))
+	    YYABORT;
+	}
+	where_clause opt_order_clause
+	delete_limit_clause
 	| table_wild_list
 	  { mysql_init_multi_delete(Lex); }
-	   FROM join_table_list where_clause
+          FROM join_table_list where_clause
 	| FROM table_wild_list
 	  { mysql_init_multi_delete(Lex); }
 	  USING join_table_list where_clause;
@@ -2990,18 +3096,19 @@ table_wild_list:
 	  | table_wild_list ',' table_wild_one {};
 
 table_wild_one:
-	 ident opt_wild
-	 {
-	    if (!Select->add_table_to_list(new Table_ident($1), NULL, 1,
-					   TL_WRITE))
-	      YYABORT;
-         }
-	 | ident '.' ident opt_wild
-	   {
-	     if (!Select->add_table_to_list(new Table_ident($1, $3, 0), NULL,
-					    1, TL_WRITE))
+	ident opt_wild
+	{
+	  if (!Select->add_table_to_list(new Table_ident($1), NULL, 1,
+	      Lex->lock_option))
+	    YYABORT;
+        }
+	| ident '.' ident opt_wild
+	  {
+	    if (!Select->add_table_to_list(new Table_ident($1, $3, 0), NULL, 1,
+				    	   Lex->lock_option))
 	      YYABORT;
-	   };
+	  }
+	;
 
 opt_wild:
 	/* empty */	{} 
@@ -3023,7 +3130,8 @@ truncate:
 	  lex->sql_command= SQLCOM_TRUNCATE;
 	  lex->select_lex.options= 0;
 	  lex->select_lex.init_order();
-	  lex->lock_option= lex->thd->update_lock_default; };
+	}
+	;
 
 opt_table_sym:
 	/* empty */
@@ -3315,7 +3423,8 @@ load:	LOAD DATA_SYM load_data_lock opt_local INFILE TEXT_STRING
 	{
 	  LEX *lex=Lex;
 	  lex->sql_command= SQLCOM_LOAD;
-	  lex->local_file= $4;
+	  lex->lock_option= $3;
+	  lex->local_file=  $4;
 	  if (!(lex->exchange= new sql_exchange($6.str,0)))
 	    YYABORT;
 	  lex->field_list.empty();
@@ -3345,9 +3454,9 @@ opt_local:
 	| LOCAL_SYM	{ $$=1;};
 
 load_data_lock:
-	/* empty */	{ Lex->lock_option= current_thd->update_lock_default; }
-	| CONCURRENT	{ Lex->lock_option= TL_WRITE_CONCURRENT_INSERT ; }
-	| LOW_PRIORITY	{ Lex->lock_option= TL_WRITE_LOW_PRIORITY; };
+	/* empty */	{ $$= current_thd->update_lock_default; }
+	| CONCURRENT	{ $$= TL_WRITE_CONCURRENT_INSERT ; }
+	| LOW_PRIORITY	{ $$= TL_WRITE_LOW_PRIORITY; };
 
 
 opt_duplicate:
@@ -3490,12 +3599,13 @@ ident:
 	IDENT	    { $$=$1; }
 	| keyword
 	{
-	  LEX *lex;
-	  $$.str=sql_strmake($1.str,$1.length);
+	  LEX *lex= Lex;
+	  $$.str= lex->thd->strmake($1.str,$1.length);
 	  $$.length=$1.length;
-	  if ((lex=Lex)->next_state != STATE_END)
+	  if (lex->next_state != STATE_END)
 	    lex->next_state=STATE_OPERATOR_OR_IDENT;
-	};
+	}
+	;
 
 ident_or_text:
 	ident 		{ $$=$1;}
@@ -3534,11 +3644,11 @@ keyword:
 	| BIT_SYM		{}
 	| BOOL_SYM		{}
 	| BOOLEAN_SYM		{}
+	| BYTE_SYM		{}
 	| CACHE_SYM		{}
 	| CHANGED		{}
 	| CHARSET		{}
 	| CHECKSUM_SYM		{}
-	| CHECK_SYM		{}
 	| CIPHER_SYM		{}
 	| CLIENT_SYM		{}
 	| CLOSE_SYM		{}
@@ -3557,6 +3667,7 @@ keyword:
 	| DIRECTORY_SYM		{}
 	| DO_SYM		{}
 	| DUMPFILE		{}
+	| DUAL_SYM		{}
 	| DYNAMIC_SYM		{}
 	| END			{}
 	| ENUM			{}
@@ -3617,6 +3728,7 @@ keyword:
 	| NEW_SYM		{}
 	| NO_SYM		{}
 	| NONE_SYM		{}
+	| OFFSET_SYM		{}
 	| OPEN_SYM		{}
 	| PACK_KEYS_SYM		{}
 	| PARTIAL		{}
@@ -3646,6 +3758,7 @@ keyword:
 	| ROW_FORMAT_SYM	{}
 	| ROW_SYM		{}
 	| SECOND_SYM		{}
+	| SERIAL_SYM		{}
 	| SERIALIZABLE_SYM	{}
 	| SESSION_SYM		{}
 	| SIGNED_SYM		{}
@@ -3674,6 +3787,7 @@ keyword:
 	| UNCOMMITTED_SYM	{}
 	| USE_FRM		{}
 	| VARIABLES		{}
+	| VALUE_SYM		{}
 	| WORK_SYM		{}
 	| YEAR_SYM		{}
 	;
@@ -4200,7 +4314,7 @@ rollback:
 */
 
 
-union:	
+union:
 	/* empty */ {}
 	|UNION_SYM    union_option
 	{
@@ -4224,11 +4338,15 @@ union:
 	;
 
 union_opt:
-	union {}
-	| optional_order_or_limit {};
+	union_list {}
+	| optional_order_or_limit {}
+	;
 
 optional_order_or_limit:
-	/* empty */ {}
+      	/* empty 
+           intentional reduce/reduce conflict here !!!
+           { code } below should not be executed
+           when neither ORDER BY nor LIMIT are used */ {}
 	|
 	  {
 	    LEX *lex=Lex;
diff --git a/sql/stacktrace.c b/sql/stacktrace.c
index 1aba73dda333655faf401f6c6f84546504e609fc..f5c0a59b572ff1e06d8daa41d6981623bb8ac60c 100644
--- a/sql/stacktrace.c
+++ b/sql/stacktrace.c
@@ -206,7 +206,7 @@ resolve it\n");
 
 /* Produce a core for the thread */
 
-#ifdef HAVE_LINUXTHREADS
+#ifdef NOT_USED /* HAVE_LINUXTHREADS */
 void write_core(int sig)
 {
   signal(sig, SIG_DFL);
diff --git a/sql/table.cc b/sql/table.cc
index bad453f2cade98d906100aa23f0d16c746449a64..84a072c886d1a0975e573f3b674fb23dcf595250 100644
--- a/sql/table.cc
+++ b/sql/table.cc
@@ -95,15 +95,15 @@ int openfrm(const char *name, const char *alias, uint db_stat, uint prgflag,
 
   if (my_read(file,(byte*) head,64,MYF(MY_NABP))) goto err_not_open;
   if (head[0] != (uchar) 254 || head[1] != 1 ||
-      (head[2] < FRM_VER && head[2] > FRM_VER+2))
-    goto err_not_open; /* purecov: inspected */
+      (head[2] != FRM_VER && head[2] > FRM_VER+2))
+    goto err_not_open;				/* purecov: inspected */
   new_field_pack_flag=head[27];
   new_frm_ver= (head[2] - FRM_VER);
   field_pack_length= new_frm_ver < 2 ? 11 : 15;
 
   error=3;
   if (!(pos=get_form_pos(file,head,(TYPELIB*) 0)))
-    goto err_not_open; /* purecov: inspected */
+    goto err_not_open;				/* purecov: inspected */
   *fn_ext(index_file)='\0';			// Remove .frm extension
 
   outparam->db_type=ha_checktype((enum db_type) (uint) *(head+3));
@@ -145,7 +145,7 @@ int openfrm(const char *name, const char *alias, uint db_stat, uint prgflag,
     goto err_not_open; /* purecov: inspected */
   bzero((char*) keyinfo,n_length);
   outparam->key_info=keyinfo;
-  outparam->max_key_length=0;
+  outparam->max_key_length= outparam->total_key_length= 0;
   key_part= (KEY_PART_INFO*) (keyinfo+keys);
   strpos=disk_buff+6;
 
@@ -203,11 +203,13 @@ int openfrm(const char *name, const char *alias, uint db_stat, uint prgflag,
     }
     set_if_bigger(outparam->max_key_length,keyinfo->key_length+
 		  keyinfo->key_parts);
+    outparam->total_key_length+= keyinfo->key_length;
     if (keyinfo->flags & HA_NOSAME)
       set_if_bigger(outparam->max_unique_length,keyinfo->key_length);
   }
   keynames=(char*) key_part;
   strpos+= (strmov(keynames, (char *) strpos) - keynames)+1;
+
   outparam->reclength = uint2korr((head+16));
   if (*(head+26) == 1)
     outparam->system=1;				/* one-record-database */
@@ -391,6 +393,11 @@ int openfrm(const char *name, const char *alias, uint db_stat, uint prgflag,
 		  (TYPELIB*) 0),
 		 outparam->fieldnames.type_names[i],
 		 outparam);
+    if (!reg_field)				// Not supported field type
+    {
+      error= 4;
+      goto err_not_open;			/* purecov: inspected */
+    }
     reg_field->comment=comment;
     reg_field->set_charset(charset);
     if (!(reg_field->flags & NOT_NULL_FLAG))
diff --git a/sql/table.h b/sql/table.h
index d09194442c826ffc268c9ea74b532ff11b7e567b..18079e183ce99b943b8b6deb6b5b31dde1972911 100644
--- a/sql/table.h
+++ b/sql/table.h
@@ -58,6 +58,7 @@ struct st_table {
   uint reclength;			/* Recordlength */
   uint rec_buff_length;
   uint keys,key_parts,primary_key,max_key_length,max_unique_length;
+  uint total_key_length;
   uint uniques;
   uint null_fields;			/* number of null fields */
   uint blob_fields;			/* number of blob fields */
diff --git a/strings/Makefile.am b/strings/Makefile.am
index 917183320e038c1d01bded3e30aa79d402b4c63d..ac0b6d7f1e05beac3092328b944c16481769da04 100644
--- a/strings/Makefile.am
+++ b/strings/Makefile.am
@@ -16,7 +16,7 @@
 
 # This file is public domain and comes with NO WARRANTY of any kind
 
-INCLUDES =		@MT_INCLUDES@ -I$(srcdir)/../include -I../include
+INCLUDES =		@MT_INCLUDES@ -I$(top_srcdir)/include
 pkglib_LIBRARIES =	libmystrings.a
 
 # Exact one of ASSEMBLER_X
@@ -24,11 +24,11 @@ if ASSEMBLER_x86
 ASRCS		= strings-x86.s longlong2str-x86.s
 CSRCS		= bfill.c bmove.c bmove512.c bchange.c strxnmov.c int2str.c str2int.c r_strinstr.c atof.c bcmp.c strtol.c strtoul.c strtoll.c strtoull.c llstr.c strnlen.c ctype.c ctype-simple.c ctype-mb.c ctype-big5.c ctype-czech.c ctype-euc_kr.c ctype-gb2312.c ctype-gbk.c ctype-latin1_de.c ctype-sjis.c ctype-tis620.c ctype-ujis.c ctype-utf8.c ctype-win1250ch.c ctype-bin.c
 else
-if ASSEMBLER_sparc
+if ASSEMBLER_sparc32
 # These file MUST all be on the same line!! Otherwise automake
 # generats a very broken makefile
-ASRCS		= bmove_upp-sparc.s strappend-sparc.s strend-sparc.s strinstr-sparc.s strmake-sparc.s strmov-sparc.s strnmov-sparc.s strstr-sparc.s strxmov-sparc.s
-CSRCS		= strcont.c strfill.c strcend.c is_prefix.c longlong2str.c bfill.c bmove.c bmove512.c bchange.c strxnmov.c int2str.c str2int.c r_strinstr.c atof.c bcmp.c strtol.c strtoul.c strtoll.c strtoull.c llstr.c strnlen.c ctype.c ctype-simple.c ctype-mb.c ctype-big5.c ctype-czech.c ctype-euc_kr.c ctype-gb2312.c ctype-gbk.c ctype-latin1_de.c ctype-sjis.c ctype-tis620.c ctype-ujis.c ctype-utf8.c ctype-win1250ch.c ctype-bin.c
+ASRCS		= bmove_upp-sparc.s strappend-sparc.s strend-sparc.s strinstr-sparc.s strmake-sparc.s strmov-sparc.s strnmov-sparc.s strstr-sparc.s
+CSRCS		= strcont.c strfill.c strcend.c is_prefix.c longlong2str.c bfill.c bmove.c bmove512.c bchange.c strxnmov.c int2str.c str2int.c r_strinstr.c atof.c bcmp.c strtol.c strtoul.c strtoll.c strtoull.c llstr.c strnlen.c strxmov.c ctype.c ctype-simple.c ctype-mb.c ctype-big5.c ctype-czech.c ctype-euc_kr.c ctype-gb2312.c ctype-gbk.c ctype-latin1_de.c ctype-sjis.c ctype-tis620.c ctype-ujis.c ctype-utf8.c ctype-win1250ch.c ctype-bin.c
 else
 #no assembler
 ASRCS		=
@@ -68,8 +68,11 @@ conf_to_src_LDFLAGS= @NOINST_LDFLAGS@
 if ASSEMBLER
 # On Linux gcc can compile the assembly files
 %.o	: %.s
-	$(AS) -o $@ $<
+	$(AS) $(ASFLAGS) -o $@ $<
 endif
 
+str_test: str_test.c $(LIBRARIES)
+	$(LINK) $(FLAGS) -DMAIN $(srcdir)/str_test.c $(LDADD) $(LIBS)
+
 # Don't update the files from bitkeeper
 %::SCCS/s.%
diff --git a/strings/bmove_upp-sparc.s b/strings/bmove_upp-sparc.s
index 4fae7f5cc7c9f40d3932c9d454a5688069fd91c8..f38c391f8ab23a18d0168d9a0e6dfa6fd1b9ec7c 100644
--- a/strings/bmove_upp-sparc.s
+++ b/strings/bmove_upp-sparc.s
@@ -27,11 +27,11 @@ bmove_upp:
 	nop
 .loop:
 	sub	%o1, 1, %o1
-	ldub	[%o1], %g2
+	ldub	[%o1], %o3
 	sub	%o0, 1, %o0
 	subcc	%o2, 1, %o2
 	bcc	.loop
-	stb	%g2, [%o0]
+	stb	%o3, [%o0]
 .end:
 	retl
 	nop
diff --git a/strings/ctype-big5.c b/strings/ctype-big5.c
index b9011ac12aa5bd88f5cb185c24099045909b3064..39ddee854ff543e601ee326f1248fc8f6e37426e 100644
--- a/strings/ctype-big5.c
+++ b/strings/ctype-big5.c
@@ -331,11 +331,10 @@ static int my_strxfrm_big5(uchar * dest, const uchar * src, int len)
 */
 
 #define max_sort_char ((char) 255)
-#define wild_one '_'
-#define wild_many '%'
 
 static my_bool my_like_range_big5(CHARSET_INFO *cs __attribute__((unused)),
-		           const char *ptr,uint ptr_length,pchar escape,
+		           const char *ptr,uint ptr_length,
+		           int escape, int w_one, int w_many,
 		           uint res_length, char *min_str,char *max_str,
 		           uint *min_length,uint *max_length)
 {
@@ -357,13 +356,13 @@ static my_bool my_like_range_big5(CHARSET_INFO *cs __attribute__((unused)),
       *min_str++= *max_str++ = *ptr;
       continue;
     }
-    if (*ptr == wild_one)		/* '_' in SQL */
+    if (*ptr == w_one)		/* '_' in SQL */
     {
       *min_str++='\0';			/* This should be min char */
       *max_str++=max_sort_char;
       continue;
     }
-    if (*ptr == wild_many)		/* '%' in SQL */
+    if (*ptr == w_many)		/* '%' in SQL */
     {
       *min_length= (uint) (min_str-min_org);
       *max_length= res_length;
@@ -6232,6 +6231,7 @@ CHARSET_INFO my_charset_big5 =
     my_strnncoll_big5,
     my_strnxfrm_big5,
     my_like_range_big5,
+    my_wildcmp_mb,
     2,			/* mbmaxlen   */
     ismbchar_big5,
     ismbhead_big5,
@@ -6247,7 +6247,13 @@ CHARSET_INFO my_charset_big5 =
     my_strncasecmp_mb,
     my_hash_caseup_simple,
     my_hash_sort_simple,
-    0
+    0,
+    my_snprintf_8bit,
+    my_strtol_8bit,
+    my_strtoul_8bit,
+    my_strtoll_8bit,
+    my_strtoull_8bit,
+    my_strtod_8bit
 };
 
 
diff --git a/strings/ctype-bin.c b/strings/ctype-bin.c
index 0a90a1e26e51967f6439d8ef22993182c8503c01..2573ec89660c2fd43b2ab2bfd0178b4405d7f4c2 100644
--- a/strings/ctype-bin.c
+++ b/strings/ctype-bin.c
@@ -145,11 +145,101 @@ void my_hash_sort_bin(CHARSET_INFO *cs __attribute__((unused)),
 }
 
 
+static int my_wildcmp_bin(CHARSET_INFO *cs,
+			   const char *str,const char *str_end,
+			   const char *wildstr,const char *wildend,
+			   int escape, int w_one, int w_many)
+{
+  int result= -1;				// Not found, using wildcards
+  
+  while (wildstr != wildend)
+  {
+    while (*wildstr != w_many && *wildstr != w_one)
+    {
+      if (*wildstr == escape && wildstr+1 != wildend)
+	wildstr++;
+      if (str == str_end || *wildstr++ != *str++)
+      {
+	return(1);
+      }
+      if (wildstr == wildend)
+      {
+	return(str != str_end);			// Match if both are at end
+      }
+      result=1;					// Found an anchor char
+    }
+    if (*wildstr == w_one)
+    {
+      do
+      {
+	if (str == str_end)			// Skip one char if possible
+	  return(result);
+	str++;
+      } while (*++wildstr == w_one && wildstr != wildend);
+      if (wildstr == wildend)
+	break;
+    }
+    if (*wildstr == w_many)
+    {						// Found w_many
+      char cmp;
+      
+      wildstr++;
+      /* Remove any '%' and '_' from the wild search string */
+      for (; wildstr != wildend ; wildstr++)
+      {
+	if (*wildstr == w_many)
+	  continue;
+	if (*wildstr == w_one)
+	{
+	  if (str == str_end)
+	  {
+	    return(-1);
+	  }
+	  str++;
+	  continue;
+	}
+	break;					// Not a wild character
+      }
+      if (wildstr == wildend)
+      {
+	return(0);				// Ok if w_many is last
+      }
+      if (str == str_end)
+      {
+	return(-1);
+      }
+      
+      if ((cmp= *wildstr) == escape && wildstr+1 != wildend)
+	cmp= *++wildstr;
+      wildstr++;				// This is compared trough cmp
+      do
+      {
+	while (str != str_end && *str != cmp)
+	  str++;
+	if (str++ == str_end)
+	{ 
+	  return(-1);
+	}
+	{
+	  int tmp=my_wildcmp_bin(cs,str,str_end,wildstr,wildend,escape,w_one,w_many);
+	  if (tmp <= 0)
+	  {
+	    return(tmp);
+	  }
+	}
+      } while (str != str_end && wildstr[0] != w_many);
+      return(-1);
+    }
+  }
+  return(str != str_end ? 1 : 0);
+}
+
+
 
 static CHARSET_INFO my_charset_bin_st =
 {
-    63,				/* number       */
-    MY_CS_COMPILED|MY_CS_BINSORT,/* state         */
+    63,				/* number        */
+    MY_CS_COMPILED|MY_CS_BINSORT,/* state        */
     "binary",			/* name          */
     "",				/* comment       */
     NULL,			/* ctype         */
@@ -161,8 +251,9 @@ static CHARSET_INFO my_charset_bin_st =
     0,				/* strxfrm_multiply */
     my_strnncoll_binary,	/* strnncoll     */
     NULL,			/* strxnfrm      */
-    NULL,			/* like_rabge    */
-    0,				/* mbmaxlen      */
+    my_like_range_simple,	/* like_range    */
+    my_wildcmp_bin,		/* wildcmp       */
+    1,				/* mbmaxlen      */
     NULL,			/* ismbchar      */
     NULL,			/* ismbhead      */
     NULL,			/* mbcharlen     */
@@ -177,7 +268,14 @@ static CHARSET_INFO my_charset_bin_st =
     my_strncasecmp_bin,		/* strncasecmp   */
     my_hash_caseup_bin,		/* hash_caseup   */
     my_hash_sort_bin,		/* hash_sort     */
-    255				/* max_sort_char */
+    255,			/* max_sort_char */
+    my_snprintf_8bit,		/* snprintf      */
+    my_strtol_8bit,
+    my_strtoul_8bit,
+    my_strtoll_8bit,
+    my_strtoull_8bit,
+    my_strtod_8bit
+
 };
 
 
diff --git a/strings/ctype-czech.c b/strings/ctype-czech.c
index e6cab722a8e436868c5e165ee100fe4993f55990..ea3cc702abdb66fff4d0c653ca046cc2a07a2d41 100644
--- a/strings/ctype-czech.c
+++ b/strings/ctype-czech.c
@@ -375,13 +375,12 @@ static int my_strnxfrm_czech(CHARSET_INFO *cs __attribute__((unused)),
 
 #define min_sort_char ' '
 #define max_sort_char '9'
-#define wild_one '_'
-#define wild_many '%'
 
 #define EXAMPLE
 
 static my_bool my_like_range_czech(CHARSET_INFO *cs __attribute__((unused)),
-                            const char *ptr,uint ptr_length,pchar escape,
+                            const char *ptr,uint ptr_length,
+                            int escape, int w_one, int w_many,
 		            uint res_length, char *min_str,char *max_str,
 		            uint *min_length,uint *max_length)
 {
@@ -393,9 +392,9 @@ static my_bool my_like_range_czech(CHARSET_INFO *cs __attribute__((unused)),
 
   for (; ptr != end && min_str != min_end ; ptr++)
   {
-    if (*ptr == wild_one)		/* '_' in SQL */
+    if (*ptr == w_one)		/* '_' in SQL */
     { break; }
-    if (*ptr == wild_many)		/* '%' in SQL */
+    if (*ptr == w_many)		/* '%' in SQL */
     { break; }
 
     if (*ptr == escape && ptr+1 != end)
@@ -610,7 +609,8 @@ CHARSET_INFO my_charset_czech =
     my_strnncoll_czech,
     my_strnxfrm_czech,
     my_like_range_czech,
-    0,			/* mbmaxlen  */
+    my_wildcmp_8bit,
+    1,			/* mbmaxlen  */
     NULL,		/* ismbchar  */
     NULL,		/* ismbhead  */
     NULL,		/* mbcharlen */
@@ -625,7 +625,13 @@ CHARSET_INFO my_charset_czech =
     my_strncasecmp_8bit,
     my_hash_caseup_simple,
     my_hash_sort_simple,
-    0
+    0,
+    my_snprintf_8bit,
+    my_strtol_8bit,
+    my_strtoul_8bit,
+    my_strtoll_8bit,
+    my_strtoull_8bit,
+    my_strtod_8bit
 };
 
 #endif
diff --git a/strings/ctype-euc_kr.c b/strings/ctype-euc_kr.c
index a7d6044b378b5656283ed64e0799aaa5bd59d8a2..8a614851fe31e69f79e35f1dc177c36233e5d85a 100644
--- a/strings/ctype-euc_kr.c
+++ b/strings/ctype-euc_kr.c
@@ -8648,8 +8648,9 @@ CHARSET_INFO my_charset_euc_kr =
     0,			/* strxfrm_multiply */
     my_strnncoll_simple,/* strnncoll  */
     NULL,		/* strnxfrm   */
-    NULL,		/* like_range */
-    2,			/* mbmaxlen */
+    my_like_range_simple,/* like_range */
+    my_wildcmp_mb,	/* wildcmp    */
+    2,			/* mbmaxlen   */
     ismbchar_euc_kr,
     ismbhead_euc_kr,
     mbcharlen_euc_kr,
@@ -8664,7 +8665,13 @@ CHARSET_INFO my_charset_euc_kr =
     my_strncasecmp_mb,
     my_hash_caseup_simple,
     my_hash_sort_simple,
-    0
+    0,
+    my_snprintf_8bit,
+    my_strtol_8bit,
+    my_strtoul_8bit,
+    my_strtoll_8bit,
+    my_strtoull_8bit,
+    my_strtod_8bit
 };
 
 #endif
diff --git a/strings/ctype-gb2312.c b/strings/ctype-gb2312.c
index e931c7c1f319734994a5fecc00ccbe50f18bc7a3..7a8e9f011a054722acc8fd8f2a3e633c8ad5c2b0 100644
--- a/strings/ctype-gb2312.c
+++ b/strings/ctype-gb2312.c
@@ -5698,8 +5698,9 @@ CHARSET_INFO my_charset_gb2312 =
     0,			/* strxfrm_multiply */
     my_strnncoll_simple,/* strnncoll  */
     NULL,		/* strnxfrm   */
-    NULL,		/* like_range */
-    2,			/* mbmaxlen */
+    my_like_range_simple,/* like_range */
+    my_wildcmp_mb,	/* wildcmp    */
+    2,			/* mbmaxlen   */
     ismbchar_gb2312,
     ismbhead_gb2312,
     mbcharlen_gb2312,
@@ -5714,7 +5715,13 @@ CHARSET_INFO my_charset_gb2312 =
     my_strncasecmp_mb,
     my_hash_caseup_simple,
     my_hash_sort_simple,
-    0
+    0,
+    my_snprintf_8bit,
+    my_strtol_8bit,
+    my_strtoul_8bit,
+    my_strtoll_8bit,
+    my_strtoull_8bit,
+    my_strtod_8bit
 };
 
 #endif
diff --git a/strings/ctype-gbk.c b/strings/ctype-gbk.c
index 0f2de81ccb6058301935c3412e593a761a246d92..504039a4e59610d55f1948be8ff9ba629d081d84 100644
--- a/strings/ctype-gbk.c
+++ b/strings/ctype-gbk.c
@@ -2650,11 +2650,10 @@ int my_strnxfrm_gbk(CHARSET_INFO *cs __attribute__((unused)),
 */
 
 #define max_sort_char ((uchar) 255)
-#define wild_one '_'
-#define wild_many '%'
 
 extern my_bool my_like_range_gbk(CHARSET_INFO *cs __attribute__((unused)),
-                                 const char *ptr,uint ptr_length,pchar escape,
+                                 const char *ptr,uint ptr_length,
+                                 int escape, int w_one, int w_many,
                                  uint res_length, char *min_str,char *max_str,
                                  uint *min_length,uint *max_length)
 {
@@ -2676,13 +2675,13 @@ extern my_bool my_like_range_gbk(CHARSET_INFO *cs __attribute__((unused)),
       *min_str++= *max_str++ = *ptr;
       continue;
     }
-    if (*ptr == wild_one)		/* '_' in SQL */
+    if (*ptr == w_one)		/* '_' in SQL */
     {
       *min_str++='\0';			/* This should be min char */
       *max_str++=max_sort_char;
       continue;
     }
-    if (*ptr == wild_many)		/* '%' in SQL */
+    if (*ptr == w_many)		/* '%' in SQL */
     {
       *min_length= (uint) (min_str - min_org);
       *max_length= res_length;
@@ -9887,6 +9886,7 @@ CHARSET_INFO my_charset_gbk =
     my_strnncoll_gbk,
     my_strnxfrm_gbk,
     my_like_range_gbk,
+    my_wildcmp_mb,	/* wildcmp  */
     2,			/* mbmaxlen */
     ismbchar_gbk,
     ismbhead_gbk,
@@ -9902,7 +9902,13 @@ CHARSET_INFO my_charset_gbk =
     my_strncasecmp_mb,
     my_hash_caseup_simple,
     my_hash_sort_simple,
-    0
+    0,
+    my_snprintf_8bit,
+    my_strtol_8bit,
+    my_strtoul_8bit,
+    my_strtoll_8bit,
+    my_strtoull_8bit,
+    my_strtod_8bit
 };
 
 
diff --git a/strings/ctype-latin1_de.c b/strings/ctype-latin1_de.c
index 040bd11b5e9d9c8d45807b4cfd16d83b9f6b218d..13a35e3c82e335140b124e15c155d1f95bec653d 100644
--- a/strings/ctype-latin1_de.c
+++ b/strings/ctype-latin1_de.c
@@ -358,12 +358,11 @@ static int my_strnxfrm_latin1_de(CHARSET_INFO *cs __attribute__((unused)),
 
 #define min_sort_char ((char) 0)
 #define max_sort_char ((char) 255)
-#define wild_one '_'
-#define wild_many '%'
 
 static my_bool my_like_range_latin1_de(CHARSET_INFO *cs __attribute__((unused)),
 				const char *ptr, uint ptr_length,
-				pchar escape, uint res_length,
+				int escape, int w_one, int w_many,
+				uint res_length,
 				char *min_str, char *max_str,
 				uint *min_length, uint *max_length)
 {
@@ -379,13 +378,13 @@ static my_bool my_like_range_latin1_de(CHARSET_INFO *cs __attribute__((unused)),
       *min_str++ = *max_str++ = *ptr;
       continue;
     }
-    if (*ptr == wild_one)		/* '_' in SQL */
+    if (*ptr == w_one)		/* '_' in SQL */
     {
       *min_str++ = min_sort_char;
       *max_str++ = max_sort_char;
       continue;
     }
-    if (*ptr == wild_many)		/* '%' in SQL */
+    if (*ptr == w_many)		/* '%' in SQL */
     {
       *min_length = (uint)(min_str - min_org);
       *max_length = res_length;
@@ -399,7 +398,7 @@ static my_bool my_like_range_latin1_de(CHARSET_INFO *cs __attribute__((unused)),
   }
   *min_length = *max_length = (uint) (min_str - min_org);
 
-  /* Temporary fix for handling wild_one at end of string (key compression) */
+  /* Temporary fix for handling w_one at end of string (key compression) */
   {
     char *tmp;
     for (tmp= min_str ; tmp > min_org && tmp[-1] == '\0';)
@@ -414,10 +413,10 @@ static my_bool my_like_range_latin1_de(CHARSET_INFO *cs __attribute__((unused)),
 
 CHARSET_INFO my_charset_latin1_de =
 {
-    31,			/* number */
-    MY_CS_COMPILED,	/* state      */
-    "latin1_de",	/* name */
-    "",			/* comment    */
+    31,			/* number    */
+    MY_CS_COMPILED,	/* state     */
+    "latin1_de",	/* name      */
+    "",			/* comment   */
     ctype_latin1_de,
     to_lower_latin1_de,
     to_upper_latin1_de,
@@ -428,22 +427,29 @@ CHARSET_INFO my_charset_latin1_de =
     my_strnncoll_latin1_de,
     my_strnxfrm_latin1_de,
     my_like_range_latin1_de,
-    0,			/* mbmaxlen  */
+    my_wildcmp_8bit,	/* wildcmp   */
+    1,			/* mbmaxlen  */
     NULL,		/* ismbchar  */
     NULL,		/* ismbhead  */
     NULL,		/* mbcharlen */
-    my_mb_wc_8bit,	/* mb_wc   */
-    my_wc_mb_8bit,	/* wc_mb   */
+    my_mb_wc_8bit,	/* mb_wc     */
+    my_wc_mb_8bit,	/* wc_mb     */
     my_caseup_str_8bit,
     my_casedn_str_8bit,
     my_caseup_8bit,
     my_casedn_8bit,
-    NULL,		/* tosort      */
+    NULL,		/* tosort    */
     my_strcasecmp_8bit,
     my_strncasecmp_8bit,
     my_hash_caseup_simple,
     my_hash_sort_simple,
-    0
+    0,
+    my_snprintf_8bit,
+    my_strtol_8bit,
+    my_strtoul_8bit,
+    my_strtoll_8bit,
+    my_strtoull_8bit,
+    my_strtod_8bit
 };
 
 #endif
diff --git a/strings/ctype-mb.c b/strings/ctype-mb.c
index aa475e281d011151dff970cd2bdd1be2340f8e0f..092b7aa4f0ffa3000b8fd2aed5fbad84988f53db 100644
--- a/strings/ctype-mb.c
+++ b/strings/ctype-mb.c
@@ -138,4 +138,142 @@ int my_strncasecmp_mb(CHARSET_INFO * cs,
   return 0;
 }
 
+
+/*
+** Compare string against string with wildcard
+**	0 if matched
+**	-1 if not matched with wildcard
+**	 1 if matched with wildcard
+*/
+
+#define INC_PTR(cs,A,B) A+=((use_mb_flag && \
+                          my_ismbchar(cs,A,B)) ? my_ismbchar(cs,A,B) : 1)
+
+#ifdef LIKE_CMP_TOUPPER
+#define likeconv(s,A) (uchar) my_toupper(s,A)
+#else
+#define likeconv(s,A) (uchar) (s)->sort_order[(uchar) (A)]
+#endif
+
+int my_wildcmp_mb(CHARSET_INFO *cs,
+		  const char *str,const char *str_end,
+		  const char *wildstr,const char *wildend,
+		  int escape, int w_one, int w_many)
+{
+  int result= -1;				// Not found, using wildcards
+
+  bool use_mb_flag=use_mb(cs);
+
+  while (wildstr != wildend)
+  {
+    while (*wildstr != w_many && *wildstr != w_one)
+    {
+      int l;
+      if (*wildstr == escape && wildstr+1 != wildend)
+	wildstr++;
+      if (use_mb_flag &&
+          (l = my_ismbchar(cs, wildstr, wildend)))
+      {
+	  if (str+l > str_end || memcmp(str, wildstr, l) != 0)
+	      return 1;
+	  str += l;
+	  wildstr += l;
+      }
+      else
+      if (str == str_end || likeconv(cs,*wildstr++) != likeconv(cs,*str++))
+	return(1);				// No match
+      if (wildstr == wildend)
+	return (str != str_end);		// Match if both are at end
+      result=1;					// Found an anchor char
+    }
+    if (*wildstr == w_one)
+    {
+      do
+      {
+	if (str == str_end)			// Skip one char if possible
+	  return (result);
+	INC_PTR(cs,str,str_end);
+      } while (++wildstr < wildend && *wildstr == w_one);
+      if (wildstr == wildend)
+	break;
+    }
+    if (*wildstr == w_many)
+    {						// Found w_many
+      uchar cmp;
+      const char* mb = wildstr;
+      int mblen;
+      
+      wildstr++;
+      /* Remove any '%' and '_' from the wild search string */
+      for (; wildstr != wildend ; wildstr++)
+      {
+	if (*wildstr == w_many)
+	  continue;
+	if (*wildstr == w_one)
+	{
+	  if (str == str_end)
+	    return (-1);
+	  INC_PTR(cs,str,str_end);
+	  continue;
+	}
+	break;					// Not a wild character
+      }
+      if (wildstr == wildend)
+	return(0);				// Ok if w_many is last
+      if (str == str_end)
+	return -1;
+      
+      if ((cmp= *wildstr) == escape && wildstr+1 != wildend)
+	cmp= *++wildstr;
+	
+      mb=wildstr;
+      LINT_INIT(mblen);
+      if (use_mb_flag)
+        mblen = my_ismbchar(cs, wildstr, wildend);
+      INC_PTR(cs,wildstr,wildend);		// This is compared trough cmp
+      cmp=likeconv(cs,cmp);   
+      do
+      {
+        if (use_mb_flag)
+	{
+          for (;;)
+          {
+            if (str >= str_end)
+              return -1;
+            if (mblen)
+            {
+              if (str+mblen <= str_end && memcmp(str, mb, mblen) == 0)
+              {
+                str += mblen;
+                break;
+              }
+            }
+            else if (!my_ismbchar(cs, str, str_end) &&
+                     likeconv(cs,*str) == cmp)
+            {
+              str++;
+              break;
+            }
+            INC_PTR(cs,str, str_end);
+          }
+	}
+        else
+        {
+          while (str != str_end && likeconv(cs,*str) != cmp)
+            str++;
+          if (str++ == str_end) return (-1);
+        }
+	{
+	  int tmp=my_wildcmp_mb(cs,str,str_end,wildstr,wildend,escape,w_one,w_many);
+	  if (tmp <= 0)
+	    return (tmp);
+	}
+      } while (str != str_end && wildstr[0] != w_many);
+      return(-1);
+    }
+  }
+  return (str != str_end ? 1 : 0);
+}
+
+
 #endif
diff --git a/strings/ctype-simple.c b/strings/ctype-simple.c
index f27b113376b83f354a3085fef280470f85f217a6..f9a9caad206631eae4b8fa513d99eb57f4436dec 100644
--- a/strings/ctype-simple.c
+++ b/strings/ctype-simple.c
@@ -15,8 +15,10 @@
    Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA */
 
 #include <my_global.h>
+#include "my_sys.h"
 #include "m_ctype.h"
-#include "dbug.h"
+#include "m_string.h"
+#include "stdarg.h"
 #include "assert.h"
 
 int my_strnxfrm_simple(CHARSET_INFO * cs, 
@@ -120,6 +122,76 @@ int my_wc_mb_8bit(CHARSET_INFO *cs,my_wc_t wc,
 }
 
 
+#ifdef NOT_USED
+static int my_vsnprintf_8bit(char *to, size_t n, const char* fmt, va_list ap)
+{
+  char *start=to, *end=to+n-1;
+  for (; *fmt ; fmt++)
+  {
+    if (fmt[0] != '%')
+    {
+      if (to == end)			/* End of buffer */
+	break;
+      *to++= *fmt;			/* Copy ordinary char */
+      continue;
+    }
+    /* Skip if max size is used (to be compatible with printf) */
+    fmt++;
+    while (my_isdigit(system_charset_info,*fmt) || *fmt == '.' || *fmt == '-')
+      fmt++;
+    if (*fmt == 'l')
+      fmt++;
+    if (*fmt == 's')				/* String parameter */
+    {
+      reg2 char	*par = va_arg(ap, char *);
+      uint plen,left_len = (uint)(end-to);
+      if (!par) par = (char*)"(null)";
+      plen = (uint) strlen(par);
+      if (left_len <= plen)
+	plen = left_len - 1;
+      to=strnmov(to,par,plen);
+      continue;
+    }
+    else if (*fmt == 'd' || *fmt == 'u')	/* Integer parameter */
+    {
+      register int iarg;
+      if ((uint) (end-to) < 16)
+	break;
+      iarg = va_arg(ap, int);
+      if (*fmt == 'd')
+	to=int10_to_str((long) iarg,to, -10);
+      else
+	to=int10_to_str((long) (uint) iarg,to,10);
+      continue;
+    }
+    /* We come here on '%%', unknown code or too long parameter */
+    if (to == end)
+      break;
+    *to++='%';				/* % used as % or unknown code */
+  }
+  DBUG_ASSERT(to <= end);
+  *to='\0';				/* End of errmessage */
+  return (uint) (to - start);
+}
+#endif
+
+int my_snprintf_8bit(CHARSET_INFO *cs  __attribute__((unused)),
+		     char* to, uint n  __attribute__((unused)),
+		     const char* fmt, ...)
+{
+  va_list args;
+  va_start(args,fmt);
+#ifdef NOT_USED
+  return my_vsnprintf_8bit(to, n, fmt, args);
+#endif
+  /* 
+     FIXME: generally not safe, but it is OK for now
+     FIXME: as far as it's not called unsafely in the current code
+  */
+  return vsprintf(to,fmt,args); /* FIXME */
+}
+
+
 
 #ifndef NEW_HASH_FUNCTION
 
@@ -171,3 +243,196 @@ void my_hash_sort_simple(CHARSET_INFO *cs,
     nr2[0]+=3;
   }
 }
+
+long        my_strtol_8bit(CHARSET_INFO *cs __attribute__((unused)),
+			   const char *s, char **e, int base)
+{
+  return strtol(s,e,base);
+}
+
+ulong      my_strtoul_8bit(CHARSET_INFO *cs __attribute__((unused)),
+			   const char *s, char **e, int base)
+{
+  return strtoul(s,e,base);
+}
+
+longlong   my_strtoll_8bit(CHARSET_INFO *cs __attribute__((unused)),
+			   const char *s, char **e, int base)
+{
+  return strtoll(s,e,base);
+}
+
+ulonglong my_strtoull_8bit(CHARSET_INFO *cs __attribute__((unused)),
+			   const char *s, char **e, int base)
+{
+  return strtoul(s,e,base);
+}
+
+double      my_strtod_8bit(CHARSET_INFO *cs __attribute__((unused)),
+			   const char *s, char **e)
+{
+  return strtod(s,e);
+}
+
+
+/*
+** Compare string against string with wildcard
+**	0 if matched
+**	-1 if not matched with wildcard
+**	 1 if matched with wildcard
+*/
+
+#ifdef LIKE_CMP_TOUPPER
+#define likeconv(s,A) (uchar) my_toupper(s,A)
+#else
+#define likeconv(s,A) (uchar) (s)->sort_order[(uchar) (A)]
+#endif
+
+#define INC_PTR(cs,A,B) A++
+
+
+int my_wildcmp_8bit(CHARSET_INFO *cs,
+		    const char *str,const char *str_end,
+		    const char *wildstr,const char *wildend,
+		    int escape, int w_one, int w_many)
+{
+  int result= -1;				// Not found, using wildcards
+
+  while (wildstr != wildend)
+  {
+    while (*wildstr != w_many && *wildstr != w_one)
+    {
+      if (*wildstr == escape && wildstr+1 != wildend)
+	wildstr++;
+
+      if (str == str_end || likeconv(cs,*wildstr++) != likeconv(cs,*str++))
+	return(1);				// No match
+      if (wildstr == wildend)
+	return (str != str_end);		// Match if both are at end
+      result=1;					// Found an anchor char
+    }
+    if (*wildstr == w_one)
+    {
+      do
+      {
+	if (str == str_end)			// Skip one char if possible
+	  return (result);
+	INC_PTR(cs,str,str_end);
+      } while (++wildstr < wildend && *wildstr == w_one);
+      if (wildstr == wildend)
+	break;
+    }
+    if (*wildstr == w_many)
+    {						// Found w_many
+      uchar cmp;
+      
+      wildstr++;
+      /* Remove any '%' and '_' from the wild search string */
+      for (; wildstr != wildend ; wildstr++)
+      {
+	if (*wildstr == w_many)
+	  continue;
+	if (*wildstr == w_one)
+	{
+	  if (str == str_end)
+	    return (-1);
+	  INC_PTR(cs,str,str_end);
+	  continue;
+	}
+	break;					// Not a wild character
+      }
+      if (wildstr == wildend)
+	return(0);				// Ok if w_many is last
+      if (str == str_end)
+	return -1;
+      
+      if ((cmp= *wildstr) == escape && wildstr+1 != wildend)
+	cmp= *++wildstr;
+
+      INC_PTR(cs,wildstr,wildend);		// This is compared trough cmp
+      cmp=likeconv(cs,cmp);   
+      do
+      {
+          while (str != str_end && likeconv(cs,*str) != cmp)
+            str++;
+          if (str++ == str_end) return (-1);
+	{
+	  int tmp=my_wildcmp_8bit(cs,str,str_end,wildstr,wildend,escape,w_one,w_many);
+	  if (tmp <= 0)
+	    return (tmp);
+	}
+      } while (str != str_end && wildstr[0] != w_many);
+      return(-1);
+    }
+  }
+  return (str != str_end ? 1 : 0);
+}
+
+
+/*
+** Calculate min_str and max_str that ranges a LIKE string.
+** Arguments:
+** ptr		Pointer to LIKE string.
+** ptr_length	Length of LIKE string.
+** escape	Escape character in LIKE.  (Normally '\').
+**		All escape characters should be removed from min_str and max_str
+** res_length	Length of min_str and max_str.
+** min_str	Smallest case sensitive string that ranges LIKE.
+**		Should be space padded to res_length.
+** max_str	Largest case sensitive string that ranges LIKE.
+**		Normally padded with the biggest character sort value.
+**
+** The function should return 0 if ok and 1 if the LIKE string can't be
+** optimized !
+*/
+
+my_bool my_like_range_simple(CHARSET_INFO *cs,
+				const char *ptr,uint ptr_length,
+				int escape, int w_one, int w_many,
+				uint res_length,
+				char *min_str,char *max_str,
+				uint *min_length,uint *max_length)
+{
+  const char *end=ptr+ptr_length;
+  char *min_org=min_str;
+  char *min_end=min_str+res_length;
+
+  for (; ptr != end && min_str != min_end ; ptr++)
+  {
+    if (*ptr == escape && ptr+1 != end)
+    {
+      ptr++;					// Skip escape
+      *min_str++= *max_str++ = *ptr;
+      continue;
+    }
+    if (*ptr == w_one)				// '_' in SQL
+    {
+      *min_str++='\0';				// This should be min char
+      *max_str++=cs->max_sort_char;
+      continue;
+    }
+    if (*ptr == w_many)				// '%' in SQL
+    {
+      *min_length= (uint) (min_str - min_org);
+      *max_length=res_length;
+      do {
+	*min_str++ = ' ';			// Because if key compression
+	*max_str++ = cs->max_sort_char;
+      } while (min_str != min_end);
+      return 0;
+    }
+    *min_str++= *max_str++ = *ptr;
+  }
+  *min_length= *max_length = (uint) (min_str - min_org);
+
+  /* Temporary fix for handling w_one at end of string (key compression) */
+  {
+    char *tmp;
+    for (tmp= min_str ; tmp > min_org && tmp[-1] == '\0';)
+      *--tmp=' ';
+  }
+
+  while (min_str != min_end)
+    *min_str++ = *max_str++ = ' ';		// Because if key compression
+  return 0;
+}
diff --git a/strings/ctype-sjis.c b/strings/ctype-sjis.c
index 9c8ac8d0c16b7a5ff31bd91b858e1ab9eb38a442..91a9fae55faac20141516c6b41af5a16cf17a346 100644
--- a/strings/ctype-sjis.c
+++ b/strings/ctype-sjis.c
@@ -263,11 +263,10 @@ static int my_strnxfrm_sjis(CHARSET_INFO *cs __attribute__((unused)),
 */
 
 #define max_sort_char ((char) 255)
-#define wild_one '_'
-#define wild_many '%'
 
 static my_bool my_like_range_sjis(CHARSET_INFO *cs __attribute__((unused)),
-                           const char *ptr,uint ptr_length,pchar escape,
+                           const char *ptr,uint ptr_length,
+                           int escape, int w_one, int w_many,
                            uint res_length, char *min_str,char *max_str,
                            uint *min_length,uint *max_length)
 {
@@ -290,13 +289,13 @@ static my_bool my_like_range_sjis(CHARSET_INFO *cs __attribute__((unused)),
 	*min_str++ = *max_str++ = *ptr++;
       continue;
     }
-    if (*ptr == wild_one) {		/* '_' in SQL */
+    if (*ptr == w_one) {		/* '_' in SQL */
       *min_str++ = '\0';		/* This should be min char */
       *max_str++ = max_sort_char;
       ptr++;
       continue;
     }
-    if (*ptr == wild_many) {		/* '%' in SQL */
+    if (*ptr == w_many) {		/* '%' in SQL */
       *min_length = (uint)(min_str - min_org);
       *max_length = res_length;
       do {
@@ -4474,6 +4473,7 @@ CHARSET_INFO my_charset_sjis =
     my_strnncoll_sjis,
     my_strnxfrm_sjis,
     my_like_range_sjis,
+    my_wildcmp_mb,	/* wildcmp  */
     2,			/* mbmaxlen */
     ismbchar_sjis,
     ismbhead_sjis,
@@ -4489,7 +4489,13 @@ CHARSET_INFO my_charset_sjis =
     my_strncasecmp_8bit,
     my_hash_caseup_simple,
     my_hash_sort_simple,
-    0
+    0,
+    my_snprintf_8bit,
+    my_strtol_8bit,
+    my_strtoul_8bit,
+    my_strtoll_8bit,
+    my_strtoull_8bit,
+    my_strtod_8bit
 };
 
 #endif
diff --git a/strings/ctype-tis620.c b/strings/ctype-tis620.c
index 88549e7ee690603f0a9e470e38096b6ad888d09c..86056e4f55c89f71d4b35c9745334bbd52b93dcc 100644
--- a/strings/ctype-tis620.c
+++ b/strings/ctype-tis620.c
@@ -610,11 +610,10 @@ int my_strxfrm_tis620(uchar * dest, const uchar * src, int len)
    thai2sortable string. min_str and max_str will be use for comparison and
    converted there. */
 #define max_sort_chr ((char) 255)
-#define wild_one '_'
-#define wild_many '%'
 
 my_bool my_like_range_tis620(CHARSET_INFO *cs __attribute__((unused)),
-                       const char *ptr, uint ptr_length, pchar escape,
+                       const char *ptr, uint ptr_length,
+                       int escape, int w_one, int w_many,
 		       uint res_length, char *min_str, char *max_str,
 		       uint *min_length, uint *max_length)
 {
@@ -630,13 +629,13 @@ my_bool my_like_range_tis620(CHARSET_INFO *cs __attribute__((unused)),
       *min_str++= *max_str++ = *ptr;
       continue;
     }
-    if (*ptr == wild_one)			/* '_' in SQL */
+    if (*ptr == w_one)			/* '_' in SQL */
     {
       *min_str++='\0';				/* This should be min char */
       *max_str++=max_sort_chr;
       continue;
     }
-    if (*ptr == wild_many)			/* '%' in SQL */
+    if (*ptr == w_many)			/* '%' in SQL */
     {
       *min_length= (uint) (min_str - min_org);
       *max_length=res_length;
@@ -688,10 +687,10 @@ void ThNormalize(uchar* ptr, uint field_length, const uchar* from, uint length)
 
 CHARSET_INFO my_charset_tis620 =
 {
-    18,			/* number */
-    MY_CS_COMPILED,	/* state      */
-    "tis620",		/* name */
-    "",			/* comment    */
+    18,			/* number    */
+    MY_CS_COMPILED,	/* state     */
+    "tis620",		/* name      */
+    "",			/* comment   */
     ctype_tis620,
     to_lower_tis620,
     to_upper_tis620,
@@ -702,22 +701,29 @@ CHARSET_INFO my_charset_tis620 =
     my_strnncoll_tis620,
     my_strnxfrm_tis620,
     my_like_range_tis620,
-    0,			/* mbmaxlen  */
+    my_wildcmp_8bit,	/* wildcmp   */
+    1,			/* mbmaxlen  */
     NULL,		/* ismbchar  */
     NULL,		/* ismbhead  */
     NULL,		/* mbcharlen */
-    my_mb_wc_8bit,	/* mb_wc   */
-    my_wc_mb_8bit,	/* wc_mb   */
+    my_mb_wc_8bit,	/* mb_wc     */
+    my_wc_mb_8bit,	/* wc_mb     */
     my_caseup_str_8bit,
     my_casedn_str_8bit,
     my_caseup_8bit,
     my_casedn_8bit,
-    NULL,		/* tosort      */
+    NULL,		/* tosort    */
     my_strcasecmp_8bit,
     my_strncasecmp_8bit,
     my_hash_caseup_simple,
     my_hash_sort_simple,
-    0
+    0,
+    my_snprintf_8bit,
+    my_strtol_8bit,
+    my_strtoul_8bit,
+    my_strtoll_8bit,
+    my_strtoull_8bit,
+    my_strtod_8bit
 };
 
 
diff --git a/strings/ctype-ujis.c b/strings/ctype-ujis.c
index cb1da080951be6202c576b9bd512729a5304ec29..7ae229c01357b5f408be974c407f32ad4f607cfe 100644
--- a/strings/ctype-ujis.c
+++ b/strings/ctype-ujis.c
@@ -8430,9 +8430,9 @@ my_wc_mb_euc_jp(CHARSET_INFO *c,my_wc_t wc, unsigned char *s, unsigned char *e)
 CHARSET_INFO my_charset_ujis =
 {
     12,			/* number       */
-    MY_CS_COMPILED,	/* state      */
+    MY_CS_COMPILED,	/* state        */
     "ujis",		/* name         */
-    "",			/* comment    */
+    "",			/* comment      */
     ctype_ujis,
     to_lower_ujis,
     to_upper_ujis,
@@ -8442,7 +8442,8 @@ CHARSET_INFO my_charset_ujis =
     0,			/* strxfrm_multiply */
     NULL,		/* strnncoll    */
     NULL,		/* strnxfrm     */
-    NULL,		/* like_range   */
+    my_like_range_simple,/* like_range   */
+    my_wildcmp_mb,	/* wildcmp      */
     3,			/* mbmaxlen     */
     ismbchar_ujis,
     ismbhead_ujis,
@@ -8458,7 +8459,13 @@ CHARSET_INFO my_charset_ujis =
     my_strncasecmp_mb,
     my_hash_caseup_simple,
     my_hash_sort_simple,
-    0
+    0,
+    my_snprintf_8bit,
+    my_strtol_8bit,
+    my_strtoul_8bit,
+    my_strtoll_8bit,
+    my_strtoull_8bit,
+    my_strtod_8bit
 };
 
 
diff --git a/strings/ctype-utf8.c b/strings/ctype-utf8.c
index 81671e28c3f41b22aeea5e7bd3cb0f72125fe00c..b471a37a852ca6d9f6f93f436789ccac6363bce6 100644
--- a/strings/ctype-utf8.c
+++ b/strings/ctype-utf8.c
@@ -1955,9 +1955,9 @@ static int my_mbcharlen_utf8(CHARSET_INFO *cs  __attribute__((unused)) , uint c)
 CHARSET_INFO my_charset_utf8 =
 {
     33,			/* number       */
-    MY_CS_COMPILED,	/* state      */
+    MY_CS_COMPILED,	/* state        */
     "utf8",		/* name         */
-    "",			/* comment    */
+    "",			/* comment      */
     ctype_utf8,		/* ctype        */
     to_lower_utf8,	/* to_lower     */
     to_upper_utf8,	/* to_upper     */
@@ -1967,7 +1967,8 @@ CHARSET_INFO my_charset_utf8 =
     1,			/* strxfrm_multiply */
     my_strnncoll_utf8,	/* strnncoll    */
     my_strnxfrm_utf8,	/* strnxfrm     */
-    NULL,		/* like_range   */
+    my_like_range_simple,/* like_range   */
+    my_wildcmp_mb,	/* wildcmp      */
     3,			/* mbmaxlen     */
     my_ismbchar_utf8,	/* ismbchar     */
     my_ismbhead_utf8,	/* ismbhead     */
@@ -1978,12 +1979,18 @@ CHARSET_INFO my_charset_utf8 =
     my_casedn_str_utf8,
     my_caseup_utf8,
     my_casedn_utf8,
-    NULL,		/* tosort      */
+    NULL,		/* tosort       */
     my_strcasecmp_utf8,
     my_strncasecmp_utf8,
-    my_hash_caseup_utf8,/* hash_caseup */
-    my_hash_sort_utf8,	/* hash_sort   */
-    0
+    my_hash_caseup_utf8,/* hash_caseup  */
+    my_hash_sort_utf8,	/* hash_sort    */
+    0,
+    my_snprintf_8bit,
+    my_strtol_8bit,
+    my_strtoul_8bit,
+    my_strtoll_8bit,
+    my_strtoull_8bit,
+    my_strtod_8bit
 };
 
 
@@ -2345,12 +2352,130 @@ static int my_mbcharlen_ucs2(CHARSET_INFO *cs  __attribute__((unused)) ,
 }
 
 
+#include <m_string.h>
+#include <stdarg.h>
+#include <assert.h>
+
+static int my_vsnprintf_ucs2(char *dst, uint n, const char* fmt, va_list ap)
+{
+  char *start=dst, *end=dst+n-1;
+  for (; *fmt ; fmt++)
+  {
+    if (fmt[0] != '%')
+    {
+      if (dst == end)			/* End of buffer */
+	break;
+      
+      *dst++='\0'; *dst++= *fmt;	/* Copy ordinary char */
+      continue;
+    }
+    
+    fmt++;
+    
+    /* Skip if max size is used (to be compatible with printf) */
+    while ( (*fmt>='0' && *fmt<='9') || *fmt == '.' || *fmt == '-')
+      fmt++;
+    
+    if (*fmt == 'l')
+      fmt++;
+    
+    if (*fmt == 's')				/* String parameter */
+    {
+      reg2 char	*par = va_arg(ap, char *);
+      uint plen;
+      uint left_len = (uint)(end-dst);
+      if (!par) par = (char*)"(null)";
+      plen = (uint) strlen(par);
+      if (left_len <= plen*2)
+	plen = left_len/2 - 1;
+
+      for ( ; plen ; plen--, dst+=2, par++)
+      {
+        dst[0]='\0';
+        dst[1]=par[0];
+      }
+      continue;
+    }
+    else if (*fmt == 'd' || *fmt == 'u')	/* Integer parameter */
+    {
+      register int iarg;
+      char nbuf[16];
+      char *pbuf=nbuf;
+      
+      if ((uint) (end-dst) < 32)
+	break;
+      iarg = va_arg(ap, int);
+      if (*fmt == 'd')
+	int10_to_str((long) iarg, nbuf, -10);
+      else
+	int10_to_str((long) (uint) iarg,nbuf,10);
+
+      for (; pbuf[0]; pbuf++)
+      {
+        *dst++='\0';
+        *dst++=*pbuf;
+      }
+      continue;
+    }
+    
+    /* We come here on '%%', unknown code or too long parameter */
+    if (dst == end)
+      break;
+    *dst++='\0';
+    *dst++='%';				/* % used as % or unknown code */
+  }
+  
+  DBUG_ASSERT(dst <= end);
+  *dst='\0';				/* End of errmessage */
+  return (uint) (dst - start);
+}
+
+static int my_snprintf_ucs2(CHARSET_INFO *cs __attribute__((unused))
+			    ,char* to, uint n, const char* fmt, ...)
+{
+  va_list args;
+  va_start(args,fmt);
+  return my_vsnprintf_ucs2(to, n, fmt, args);
+}
+
+
+static long my_strtol_ucs2(CHARSET_INFO *cs __attribute__((unused)),
+			   const char *s, char **e, int base)
+{
+  return strtol(s,e,base);
+}
+
+static ulong my_strtoul_ucs2(CHARSET_INFO *cs __attribute__((unused)),
+			   const char *s, char **e, int base)
+{
+  return strtoul(s,e,base);
+}
+
+static longlong my_strtoll_ucs2(CHARSET_INFO *cs __attribute__((unused)),
+			   const char *s, char **e, int base)
+{
+  return strtoll(s,e,base);
+}
+
+static ulonglong my_strtoull_ucs2(CHARSET_INFO *cs __attribute__((unused)),
+			   const char *s, char **e, int base)
+{
+  return strtoul(s,e,base);
+}
+
+double my_strtod_ucs2(CHARSET_INFO *cs __attribute__((unused)),
+			   const char *s, char **e)
+{
+  return strtod(s,e);
+}
+
+
 CHARSET_INFO my_charset_ucs2 =
 {
     35,			/* number       */
-    MY_CS_COMPILED,	/* state      */
+    MY_CS_COMPILED,	/* state        */
     "ucs2",		/* name         */
-    "",			/* comment    */
+    "",			/* comment      */
     ctype_ucs2,		/* ctype        */
     to_lower_ucs2,	/* to_lower     */
     to_upper_ucs2,	/* to_upper     */
@@ -2360,7 +2485,8 @@ CHARSET_INFO my_charset_ucs2 =
     1,			/* strxfrm_multiply */
     my_strnncoll_ucs2,	/* strnncoll    */
     my_strnxfrm_ucs2,	/* strnxfrm     */
-    NULL,		/* like_range   */
+    my_like_range_simple,/* like_range   */
+    my_wildcmp_mb,	/* wildcmp      */
     2,			/* mbmaxlen     */
     my_ismbchar_ucs2,	/* ismbchar     */
     my_ismbhead_ucs2,	/* ismbhead     */
@@ -2371,12 +2497,18 @@ CHARSET_INFO my_charset_ucs2 =
     my_casedn_str_ucs2,
     my_caseup_ucs2,
     my_casedn_ucs2,
-    NULL,		/* tosort      */
+    NULL,		/* tosort       */
     my_strcasecmp_ucs2,
     my_strncasecmp_ucs2,
-    my_hash_caseup_ucs2,/* hash_caseup */
-    my_hash_sort_ucs2,	/* hash_sort   */
-    0
+    my_hash_caseup_ucs2,/* hash_caseup  */
+    my_hash_sort_ucs2,	/* hash_sort    */
+    0,
+    my_snprintf_ucs2,
+    my_strtol_ucs2,
+    my_strtoul_ucs2,
+    my_strtoll_ucs2,
+    my_strtoull_ucs2,
+    my_strtod_ucs2
 };
 
 
diff --git a/strings/ctype-win1250ch.c b/strings/ctype-win1250ch.c
index f64eddd2c2bef8d5700e260e082ff4e39ab7d91a..73e4a5745af23736b831a3e4550af652ad453174 100644
--- a/strings/ctype-win1250ch.c
+++ b/strings/ctype-win1250ch.c
@@ -555,8 +555,6 @@ static uchar NEAR like_range_prefix_max_win1250ch[] = {
 
 #define min_sort_char '\x00'
 #define max_sort_char '\xff'
-#define wild_one '_'
-#define wild_many '%'
 
 /*
 ** Calculate min_str and max_str that ranges a LIKE string.
@@ -577,7 +575,8 @@ static uchar NEAR like_range_prefix_max_win1250ch[] = {
 
 static my_bool my_like_range_win1250ch(CHARSET_INFO *cs __attribute__((unused)),
 	const char *ptr, uint ptr_length,
-	pchar escape, uint res_length,
+	int escape, int w_one, int w_many,
+	uint res_length,
 	char *min_str, char *max_str,
 	uint *min_length, uint *max_length) {
 
@@ -589,10 +588,10 @@ static my_bool my_like_range_win1250ch(CHARSET_INFO *cs __attribute__((unused)),
 	/* return 1; */
 
 	for (; ptr != end && min_str != min_end ; ptr++) {
-		if (*ptr == wild_one) {		/* '_' in SQL */
+		if (*ptr == w_one) {		/* '_' in SQL */
 			break;
 		}
-		if (*ptr == wild_many) {	/* '%' in SQL */
+		if (*ptr == w_many) {	/* '%' in SQL */
 			break;
 		}
 		if (*ptr == escape && ptr + 1 != end) {	/* Skip escape */
@@ -636,7 +635,8 @@ CHARSET_INFO my_charset_win1250ch =
     my_strnncoll_win1250ch,
     my_strnxfrm_win1250ch,
     my_like_range_win1250ch,
-    0,				/* mbmaxlen  */
+    my_wildcmp_8bit,		/* wildcmp   */
+    1,				/* mbmaxlen  */
     NULL,			/* ismbchar  */
     NULL,			/* ismbhead  */
     NULL,			/* mbcharlen */
@@ -646,12 +646,18 @@ CHARSET_INFO my_charset_win1250ch =
     my_casedn_str_8bit,
     my_caseup_8bit,
     my_casedn_8bit,
-    NULL,			/* tosort      */
+    NULL,			/* tosort     */
     my_strcasecmp_8bit,
     my_strncasecmp_8bit,
     my_hash_caseup_simple,
     my_hash_sort_simple,
-    0
+    0,
+    my_snprintf_8bit,
+    my_strtol_8bit,
+    my_strtoul_8bit,
+    my_strtoll_8bit,
+    my_strtoull_8bit,
+    my_strtod_8bit
 };
 
 
diff --git a/strings/ctype.c b/strings/ctype.c
index 1358fced15cd80a2ae33abbf00ae749e5944533c..7ce259bc00fc6c1aa5796fbf39139419e5be152b 100644
--- a/strings/ctype.c
+++ b/strings/ctype.c
@@ -2822,8 +2822,9 @@ static CHARSET_INFO compiled_charsets[] = {
     0,			/* strxfrm_multiply */
     my_strnncoll_simple,/* strnncoll  */
     NULL,		/* strnxfrm   */
-    NULL,		/* like_range */
-    0,			/* mbmaxlen   */
+    my_like_range_simple,/* like_range */
+    my_wildcmp_8bit,	/* wildcmp    */
+    1,			/* mbmaxlen   */
     NULL,		/* ismbchar   */
     NULL,		/* ismbhead   */
     NULL,		/* mbcharlen  */
@@ -2838,7 +2839,13 @@ static CHARSET_INFO compiled_charsets[] = {
     my_strncasecmp_8bit,
     my_hash_caseup_simple,
     my_hash_sort_simple,
-    0
+    0,
+    my_snprintf_8bit,
+    my_strtol_8bit,
+    my_strtoul_8bit,
+    my_strtoll_8bit,
+    my_strtoull_8bit,
+    my_strtod_8bit
   },
 #endif
 
@@ -2858,8 +2865,9 @@ static CHARSET_INFO compiled_charsets[] = {
     0,			/* strxfrm_multiply */
     my_strnncoll_simple,/* strnncoll  */
     NULL,		/* strnxfrm   */
-    NULL,		/* like_range */
-    0,			/* mbmaxlen   */
+    my_like_range_simple,/* like_range */
+    my_wildcmp_8bit,	/* wildcmp    */
+    1,			/* mbmaxlen   */
     NULL,		/* ismbchar   */
     NULL,		/* ismbhead   */
     NULL,		/* mbcharlen  */
@@ -2874,7 +2882,13 @@ static CHARSET_INFO compiled_charsets[] = {
     my_strncasecmp_8bit,
     my_hash_caseup_simple,
     my_hash_sort_simple,
-    0
+    0,
+    my_snprintf_8bit
+    my_strtol_8bit,
+    my_strtoul_8bit,
+    my_strtoll_8bit,
+    my_strtoull_8bit,
+    my_strtod_8bit
   },
 #endif
 
@@ -2893,8 +2907,9 @@ static CHARSET_INFO compiled_charsets[] = {
     0,			/* strxfrm_multiply */
     my_strnncoll_simple,/* strnncoll  */
     NULL,		/* strnxfrm   */
-    NULL,		/* like_range */
-    0,			/* mbmaxlen  */
+    my_like_range_simple,/* like_range */
+    my_wildcmp_8bit,	/* wildcmp    */
+    1,			/* mbmaxlen  */
     NULL,		/* ismbchar  */
     NULL,		/* ismbhead  */
     NULL,		/* mbcharlen */
@@ -2909,7 +2924,13 @@ static CHARSET_INFO compiled_charsets[] = {
     my_strncasecmp_8bit,
     my_hash_caseup_simple,
     my_hash_sort_simple,
-    0
+    0,
+    my_snprintf_8bit
+    my_strtol_8bit,
+    my_strtoul_8bit,
+    my_strtoll_8bit,
+    my_strtoull_8bit,
+    my_strtod_8bit
   },
 #endif
 
@@ -2928,8 +2949,9 @@ static CHARSET_INFO compiled_charsets[] = {
     0,			/* strxfrm_multiply */
     my_strnncoll_simple,/* strnncoll  */
     NULL,		/* strnxfrm   */
-    NULL,		/* like_range */
-    0,			/* mbmaxlen  */
+    my_like_range_simple,/* like_range */
+    my_wildcmp_8bit,	/* wildcmp    */
+    1,			/* mbmaxlen  */
     NULL,		/* ismbchar  */
     NULL,		/* ismbhead  */
     NULL,		/* mbcharlen */
@@ -2944,7 +2966,13 @@ static CHARSET_INFO compiled_charsets[] = {
     my_strncasecmp_8bit,
     my_hash_caseup_simple,
     my_hash_sort_simple,
-    0
+    0,
+    my_snprintf_8bit
+    my_strtol_8bit,
+    my_strtoul_8bit,
+    my_strtoll_8bit,
+    my_strtoull_8bit,
+    my_strtod_8bit
   },
 #endif
 
@@ -2964,8 +2992,9 @@ static CHARSET_INFO compiled_charsets[] = {
     0,			/* strxfrm_multiply */
     my_strnncoll_simple,/* strnncoll  */
     NULL,		/* strnxfrm   */
-    NULL,		/* like_range */
-    0,			/* mbmaxlen  */
+    my_like_range_simple,/* like_range */
+    my_wildcmp_8bit,	/* wildcmp    */
+    1,			/* mbmaxlen  */
     NULL,		/* ismbchar  */
     NULL,		/* ismbhead  */
     NULL,		/* mbcharlen */
@@ -2980,7 +3009,13 @@ static CHARSET_INFO compiled_charsets[] = {
     my_strncasecmp_8bit,
     my_hash_caseup_simple,
     my_hash_sort_simple,
-    0
+    0,
+    my_snprintf_8bit
+    my_strtol_8bit,
+    my_strtoul_8bit,
+    my_strtoll_8bit,
+    my_strtoull_8bit,
+    my_strtod_8bit
   },
 #endif
 
@@ -2999,8 +3034,9 @@ static CHARSET_INFO compiled_charsets[] = {
     0,			/* strxfrm_multiply */
     my_strnncoll_simple,/* strnncoll  */
     NULL,		/* strnxfrm   */
-    NULL,		/* like_range */
-    0,			/* mbmaxlen  */
+    my_like_range_simple,/* like_range */
+    my_wildcmp_8bit,	/* wildcmp    */
+    1,			/* mbmaxlen  */
     NULL,		/* ismbchar  */
     NULL,		/* ismbhead  */
     NULL,		/* mbcharlen */
@@ -3015,7 +3051,13 @@ static CHARSET_INFO compiled_charsets[] = {
     my_strncasecmp_8bit,
     my_hash_caseup_simple,
     my_hash_sort_simple,
-    0
+    0,
+    my_snprintf_8bit
+    my_strtol_8bit,
+    my_strtoul_8bit,
+    my_strtoll_8bit,
+    my_strtoull_8bit,
+    my_strtod_8bit
   },
 #endif
 
@@ -3034,8 +3076,9 @@ static CHARSET_INFO compiled_charsets[] = {
     0,			/* strxfrm_multiply */
     my_strnncoll_simple,/* strnncoll  */
     NULL,		/* strnxfrm   */
-    NULL,		/* like_range */
-    0,			/* mbmaxlen  */
+    my_like_range_simple,/* like_range */
+    my_wildcmp_8bit,	/* wildcmp    */
+    1,			/* mbmaxlen  */
     NULL,		/* ismbchar  */
     NULL,		/* ismbhead  */
     NULL,		/* mbcharlen */
@@ -3050,7 +3093,13 @@ static CHARSET_INFO compiled_charsets[] = {
     my_strncasecmp_8bit,
     my_hash_caseup_simple,
     my_hash_sort_simple,
-    0
+    0,
+    my_snprintf_8bit
+    my_strtol_8bit,
+    my_strtoul_8bit,
+    my_strtoll_8bit,
+    my_strtoull_8bit,
+    my_strtod_8bit
   },
 #endif
 
@@ -3069,8 +3118,9 @@ static CHARSET_INFO compiled_charsets[] = {
     0,			/* strxfrm_multiply */
     my_strnncoll_simple,/* strnncoll  */
     NULL,		/* strnxfrm   */
-    NULL,		/* like_range */
-    0,			/* mbmaxlen  */
+    my_like_range_simple,/* like_range */
+    my_wildcmp_8bit,	/* wildcmp    */
+    1,			/* mbmaxlen  */
     NULL,		/* ismbchar  */
     NULL,		/* ismbhead  */
     NULL,		/* mbcharlen */
@@ -3085,7 +3135,13 @@ static CHARSET_INFO compiled_charsets[] = {
     my_strncasecmp_8bit,
     my_hash_caseup_simple,
     my_hash_sort_simple,
-    0
+    0,
+    my_snprintf_8bit
+    my_strtol_8bit,
+    my_strtoul_8bit,
+    my_strtoll_8bit,
+    my_strtoull_8bit,
+    my_strtod_8bit
   },
 #endif
 
@@ -3105,8 +3161,9 @@ static CHARSET_INFO compiled_charsets[] = {
     0,			/* strxfrm_multiply */
     my_strnncoll_simple,/* strnncoll  */
     NULL,		/* strnxfrm   */
-    NULL,		/* like_range */
-    0,			/* mbmaxlen  */
+    my_like_range_simple,/* like_range */
+    my_wildcmp_8bit,	/* wildcmp    */
+    1,			/* mbmaxlen  */
     NULL,		/* ismbchar  */
     NULL,		/* ismbhead  */
     NULL,		/* mbcharlen */
@@ -3121,7 +3178,13 @@ static CHARSET_INFO compiled_charsets[] = {
     my_strncasecmp_8bit,
     my_hash_caseup_simple,
     my_hash_sort_simple,
-    0
+    0,
+    my_snprintf_8bit
+    my_strtol_8bit,
+    my_strtoul_8bit,
+    my_strtoll_8bit,
+    my_strtoull_8bit,
+    my_strtod_8bit
   },
 #endif
 
@@ -3140,8 +3203,9 @@ static CHARSET_INFO compiled_charsets[] = {
     0,			/* strxfrm_multiply */
     my_strnncoll_simple,/* strnncoll  */
     NULL,		/* strnxfrm   */
-    NULL,		/* like_range */
-    0,			/* mbmaxlen  */
+    my_like_range_simple,/* like_range */
+    my_wildcmp_8bit,	/* wildcmp    */
+    1,			/* mbmaxlen  */
     NULL,		/* ismbchar  */
     NULL,		/* ismbhead  */
     NULL,		/* mbcharlen */
@@ -3156,7 +3220,13 @@ static CHARSET_INFO compiled_charsets[] = {
     my_strncasecmp_8bit,
     my_hash_caseup_simple,
     my_hash_sort_simple,
-    0
+    0,
+    my_snprintf_8bit
+    my_strtol_8bit,
+    my_strtoul_8bit,
+    my_strtoll_8bit,
+    my_strtoull_8bit,
+    my_strtod_8bit
   },
 #endif
 
@@ -3175,8 +3245,9 @@ static CHARSET_INFO compiled_charsets[] = {
     0,			/* strxfrm_multiply */
     my_strnncoll_simple,/* strnncoll  */
     NULL,		/* strnxfrm   */
-    NULL,		/* like_range */
-    0,			/* mbmaxlen  */
+    my_like_range_simple,/* like_range */
+    my_wildcmp_8bit,	/* wildcmp    */
+    1,			/* mbmaxlen  */
     NULL,		/* ismbchar  */
     NULL,		/* ismbhead  */
     NULL,		/* mbcharlen */
@@ -3191,7 +3262,13 @@ static CHARSET_INFO compiled_charsets[] = {
     my_strncasecmp_8bit,
     my_hash_caseup_simple,
     my_hash_sort_simple,
-    0
+    0,
+    my_snprintf_8bit
+    my_strtol_8bit,
+    my_strtoul_8bit,
+    my_strtoll_8bit,
+    my_strtoull_8bit,
+    my_strtod_8bit
   },
 #endif
 
@@ -3210,8 +3287,9 @@ static CHARSET_INFO compiled_charsets[] = {
     0,			/* strxfrm_multiply */
     my_strnncoll_simple,/* strnncoll  */
     NULL,		/* strnxfrm   */
-    NULL,		/* like_range */
-    0,			/* mbmaxlen  */
+    my_like_range_simple,/* like_range */
+    my_wildcmp_8bit,	/* wildcmp    */
+    1,			/* mbmaxlen  */
     NULL,		/* ismbchar  */
     NULL,		/* ismbhead  */
     NULL,		/* mbcharlen */
@@ -3226,7 +3304,13 @@ static CHARSET_INFO compiled_charsets[] = {
     my_strncasecmp_8bit,
     my_hash_caseup_simple,
     my_hash_sort_simple,
-    0
+    0,
+    my_snprintf_8bit
+    my_strtol_8bit,
+    my_strtoul_8bit,
+    my_strtoll_8bit,
+    my_strtoull_8bit,
+    my_strtod_8bit
   },
 #endif
 
@@ -3245,8 +3329,9 @@ static CHARSET_INFO compiled_charsets[] = {
     0,			/* strxfrm_multiply */
     my_strnncoll_simple,/* strnncoll  */
     NULL,		/* strnxfrm   */
-    NULL,		/* like_range */
-    0,			/* mbmaxlen  */
+    my_like_range_simple,/* like_range */
+    my_wildcmp_8bit,	/* wildcmp    */
+    1,			/* mbmaxlen  */
     NULL,		/* ismbchar  */
     NULL,		/* ismbhead  */
     NULL,		/* mbcharlen */
@@ -3261,7 +3346,13 @@ static CHARSET_INFO compiled_charsets[] = {
     my_strncasecmp_8bit,
     my_hash_caseup_simple,
     my_hash_sort_simple,
-    0
+    0,
+    my_snprintf_8bit
+    my_strtol_8bit,
+    my_strtoul_8bit,
+    my_strtoll_8bit,
+    my_strtoull_8bit,
+    my_strtod_8bit
   },
 #endif
 
@@ -3280,8 +3371,9 @@ static CHARSET_INFO compiled_charsets[] = {
     0,			/* strxfrm_multiply */
     my_strnncoll_simple,/* strnncoll  */
     NULL,		/* strnxfrm   */
-    NULL,		/* like_range */
-    0,			/* mbmaxlen  */
+    my_like_range_simple,/* like_range */
+    my_wildcmp_8bit,	/* wildcmp    */
+    1,			/* mbmaxlen  */
     NULL,		/* ismbchar  */
     NULL,		/* ismbhead  */
     NULL,		/* mbcharlen */
@@ -3296,7 +3388,13 @@ static CHARSET_INFO compiled_charsets[] = {
     my_strncasecmp_8bit,
     my_hash_caseup_simple,
     my_hash_sort_simple,
-    0
+    0,
+    my_snprintf_8bit
+    my_strtol_8bit,
+    my_strtoul_8bit,
+    my_strtoll_8bit,
+    my_strtoull_8bit,
+    my_strtod_8bit
   },
 #endif
 
@@ -3315,8 +3413,9 @@ static CHARSET_INFO compiled_charsets[] = {
     0,			/* strxfrm_multiply */
     my_strnncoll_simple,/* strnncoll  */
     NULL,		/* strnxfrm   */
-    NULL,		/* like_range */
-    0,			/* mbmaxlen  */
+    my_like_range_simple,/* like_range */
+    my_wildcmp_8bit,	/* wildcmp    */
+    1,			/* mbmaxlen  */
     NULL,		/* ismbchar  */
     NULL,		/* ismbhead  */
     NULL,		/* mbcharlen */
@@ -3331,7 +3430,13 @@ static CHARSET_INFO compiled_charsets[] = {
     my_strncasecmp_8bit,
     my_hash_caseup_simple,
     my_hash_sort_simple,
-    0
+    0,
+    my_snprintf_8bit
+    my_strtol_8bit,
+    my_strtoul_8bit,
+    my_strtoll_8bit,
+    my_strtoull_8bit,
+    my_strtod_8bit
   },
 #endif
 
@@ -3351,8 +3456,9 @@ static CHARSET_INFO compiled_charsets[] = {
     0,			/* strxfrm_multiply */
     my_strnncoll_simple,/* strnncoll  */
     NULL,		/* strnxfrm   */
-    NULL,		/* like_range */
-    0,			/* mbmaxlen  */
+    my_like_range_simple,/* like_range */
+    my_wildcmp_8bit,	/* wildcmp    */
+    1,			/* mbmaxlen  */
     NULL,		/* ismbchar  */
     NULL,		/* ismbhead  */
     NULL,		/* mbcharlen */
@@ -3367,7 +3473,13 @@ static CHARSET_INFO compiled_charsets[] = {
     my_strncasecmp_8bit,
     my_hash_caseup_simple,
     my_hash_sort_simple,
-    0
+    0,
+    my_snprintf_8bit
+    my_strtol_8bit,
+    my_strtoul_8bit,
+    my_strtoll_8bit,
+    my_strtoull_8bit,
+    my_strtod_8bit
   },
 #endif
 
@@ -3386,8 +3498,9 @@ static CHARSET_INFO compiled_charsets[] = {
     0,			/* strxfrm_multiply */
     my_strnncoll_simple,/* strnncoll  */
     NULL,		/* strnxfrm   */
-    NULL,		/* like_range */
-    0,			/* mbmaxlen  */
+    my_like_range_simple,/* like_range */
+    my_wildcmp_8bit,	/* wildcmp    */
+    1,			/* mbmaxlen  */
     NULL,		/* ismbchar  */
     NULL,		/* ismbhead  */
     NULL,		/* mbcharlen */
@@ -3402,7 +3515,13 @@ static CHARSET_INFO compiled_charsets[] = {
     my_strncasecmp_8bit,
     my_hash_caseup_simple,
     my_hash_sort_simple,
-    0
+    0,
+    my_snprintf_8bit
+    my_strtol_8bit,
+    my_strtoul_8bit,
+    my_strtoll_8bit,
+    my_strtoull_8bit,
+    my_strtod_8bit
   },
 #endif
 
@@ -3422,8 +3541,9 @@ static CHARSET_INFO compiled_charsets[] = {
     0,			/* strxfrm_multiply */
     my_strnncoll_simple,/* strnncoll  */
     NULL,		/* strnxfrm   */
-    NULL,		/* like_range */
-    0,			/* mbmaxlen  */
+    my_like_range_simple,/* like_range */
+    my_wildcmp_8bit,	/* wildcmp    */
+    1,			/* mbmaxlen  */
     NULL,		/* ismbchar  */
     NULL,		/* ismbhead  */
     NULL,		/* mbcharlen */
@@ -3438,7 +3558,13 @@ static CHARSET_INFO compiled_charsets[] = {
     my_strncasecmp_8bit,
     my_hash_caseup_simple,
     my_hash_sort_simple,
-    0
+    0,
+    my_snprintf_8bit
+    my_strtol_8bit,
+    my_strtoul_8bit,
+    my_strtoll_8bit,
+    my_strtoull_8bit,
+    my_strtod_8bit
   },
 #endif
 
@@ -3458,8 +3584,9 @@ static CHARSET_INFO compiled_charsets[] = {
     0,			/* strxfrm_multiply */
     my_strnncoll_simple,/* strnncoll  */
     NULL,		/* strnxfrm   */
-    NULL,		/* like_range */
-    0,			/* mbmaxlen  */
+    my_like_range_simple,/* like_range */
+    my_wildcmp_8bit,	/* wildcmp    */
+    1,			/* mbmaxlen  */
     NULL,		/* ismbchar  */
     NULL,		/* ismbhead  */
     NULL,		/* mbcharlen */
@@ -3474,7 +3601,13 @@ static CHARSET_INFO compiled_charsets[] = {
     my_strncasecmp_8bit,
     my_hash_caseup_simple,
     my_hash_sort_simple,
-    0
+    0,
+    my_snprintf_8bit
+    my_strtol_8bit,
+    my_strtoul_8bit,
+    my_strtoll_8bit,
+    my_strtoull_8bit,
+    my_strtod_8bit
   },
 #endif
 
@@ -3493,8 +3626,9 @@ static CHARSET_INFO compiled_charsets[] = {
     0,			/* strxfrm_multiply */
     my_strnncoll_simple,/* strnncoll  */
     NULL,		/* strnxfrm   */
-    NULL,		/* like_range */
-    0,			/* mbmaxlen  */
+    my_like_range_simple,/* like_range */
+    my_wildcmp_8bit,	/* wildcmp    */
+    1,			/* mbmaxlen  */
     NULL,		/* ismbchar  */
     NULL,		/* ismbhead  */
     NULL,		/* mbcharlen */
@@ -3509,7 +3643,13 @@ static CHARSET_INFO compiled_charsets[] = {
     my_strncasecmp_8bit,
     my_hash_caseup_simple,
     my_hash_sort_simple,
-    0
+    0,
+    my_snprintf_8bit
+    my_strtol_8bit,
+    my_strtoul_8bit,
+    my_strtoll_8bit,
+    my_strtoull_8bit,
+    my_strtod_8bit
   },
 #endif
 
@@ -3528,8 +3668,9 @@ static CHARSET_INFO compiled_charsets[] = {
     0,			/* strxfrm_multiply */
     my_strnncoll_simple,/* strnncoll  */
     NULL,		/* strnxfrm   */
-    NULL,		/* like_range */
-    0,			/* mbmaxlen  */
+    my_like_range_simple,/* like_range */
+    my_wildcmp_8bit,	/* wildcmp    */
+    1,			/* mbmaxlen  */
     NULL,		/* ismbchar  */
     NULL,		/* ismbhead  */
     NULL,		/* mbcharlen */
@@ -3544,7 +3685,13 @@ static CHARSET_INFO compiled_charsets[] = {
     my_strncasecmp_8bit,
     my_hash_caseup_simple,
     my_hash_sort_simple,
-    0
+    0,
+    my_snprintf_8bit
+    my_strtol_8bit,
+    my_strtoul_8bit,
+    my_strtoll_8bit,
+    my_strtoull_8bit,
+    my_strtod_8bit
   },
 #endif
 
@@ -3563,8 +3710,9 @@ static CHARSET_INFO compiled_charsets[] = {
     0,			/* strxfrm_multiply */
     my_strnncoll_simple,/* strnncoll  */
     NULL,		/* strnxfrm   */
-    NULL,		/* like_range */
-    0,			/* mbmaxlen  */
+    my_like_range_simple,/* like_range */
+    my_wildcmp_8bit,	/* wildcmp    */
+    1,			/* mbmaxlen  */
     NULL,		/* ismbchar  */
     NULL,		/* ismbhead  */
     NULL,		/* mbcharlen */
@@ -3579,7 +3727,13 @@ static CHARSET_INFO compiled_charsets[] = {
     my_strncasecmp_8bit,
     my_hash_caseup_simple,
     my_hash_sort_simple,
-    0
+    0,
+    my_snprintf_8bit
+    my_strtol_8bit,
+    my_strtoul_8bit,
+    my_strtoll_8bit,
+    my_strtoull_8bit,
+    my_strtod_8bit
   },
 #endif
 
@@ -3598,8 +3752,9 @@ static CHARSET_INFO compiled_charsets[] = {
     0,			/* strxfrm_multiply */
     my_strnncoll_simple,/* strnncoll  */
     NULL,		/* strnxfrm   */
-    NULL,		/* like_range */
-    0,			/* mbmaxlen  */
+    my_like_range_simple,/* like_range */
+    my_wildcmp_8bit,	/* wildcmp    */
+    1,			/* mbmaxlen  */
     NULL,		/* ismbchar  */
     NULL,		/* ismbhead  */
     NULL,		/* mbcharlen */
@@ -3614,7 +3769,13 @@ static CHARSET_INFO compiled_charsets[] = {
     my_strncasecmp_8bit,
     my_hash_caseup_simple,
     my_hash_sort_simple,
-    0
+    0,
+    my_snprintf_8bit
+    my_strtol_8bit,
+    my_strtoul_8bit,
+    my_strtoll_8bit,
+    my_strtoull_8bit,
+    my_strtod_8bit
   },
 #endif
 
@@ -3630,9 +3791,10 @@ static CHARSET_INFO compiled_charsets[] = {
     NULL,		/* tab_to_uni   */
     NULL,		/* tab_from_uni */
     0,
-    NULL,
-    NULL,
-    NULL,
+    NULL,		/* strnncoll    */
+    NULL,		/* strnxfrm     */
+    NULL,		/* like_range   */
+    NULL,		/* wildcmp      */
     0,
     NULL,
     NULL,
@@ -3650,7 +3812,13 @@ static CHARSET_INFO compiled_charsets[] = {
     NULL,
     NULL,		/* hash_caseup */
     NULL,		/* hash_sort   */
-    0
+    0,
+    NULL,
+    NULL,
+    NULL,
+    NULL,
+    NULL,
+    NULL
   }
 };
 
diff --git a/strings/do_ctype.c b/strings/do_ctype.c
index 14ede6891daf2b960e0bcbf0347aabbdb0d26b57..f51770e3633f4e3d0a829dd67dbf517710ca9e1f 100644
--- a/strings/do_ctype.c
+++ b/strings/do_ctype.c
@@ -145,7 +145,7 @@ void init_case_convert()
   higher_pos= (uchar * ) "\217\216\231\232\220"; /* Extra chars to konv. */
   lower_pos=  (uchar * ) "\206\204\224\201\202";
 #else
-#if defined(HPUX) && ASCII_BITS_USED == 8
+#if defined(HPUX10) && ASCII_BITS_USED == 8
   higher_pos= (uchar * ) "\xd0\xd8\xda\xdb\xdc\xd3";
   lower_pos=  (uchar * ) "\xd4\xcc\xce\xdf\xc9\xd7";
 #else
@@ -160,7 +160,7 @@ void init_case_convert()
   lower_pos=  (uchar * ) "{}|`~";
 #endif
 #endif /* USE_INTERNAL_CTYPE */
-#endif /* HPUX */
+#endif /* HPUX10 */
 #endif /* MSDOS */
 
   while (*higher_pos)
@@ -176,7 +176,7 @@ void init_case_convert()
   higher_pos= (uchar *) "\217\216\231\232\220";
   lower_pos=  (uchar *) "\216\217\231YE";
 #else
-#if defined(HPUX) && ASCII_BITS_USED == 8
+#if defined(HPUX10) && ASCII_BITS_USED == 8
   higher_pos= lower_pos= (uchar *) "";		/* Tecknen i r{tt ordning */
 #else
 #ifdef USE_ISO_8859_1				/* As in USG5 ICL-386 */
@@ -186,7 +186,7 @@ void init_case_convert()
   higher_pos= (uchar *) "][\\~`";		/* R{tt ordning p} tecknen */
   lower_pos= (uchar *)	"[\\]YE";		/* Ordning enligt ascii */
 #endif /* USE_ISO_8859_1 */
-#endif /* HPUX */
+#endif /* HPUX10 */
 #endif /* MSDOS */
 
   while (*higher_pos)
diff --git a/strings/str_test.c b/strings/str_test.c
index bef48814f6d59936d671a17eb8df0849a0e91db1..0c3ff471ad7f45bbc5cac723f55196f9621a81dd 100644
--- a/strings/str_test.c
+++ b/strings/str_test.c
@@ -130,9 +130,6 @@ int main(void)
   if (errors)
     fputs("--- Some functions doesn't work!! Fix them\n",stderr);
   return(errors > 0);
-
-  fputs("Fatal error\n",stderr);
-  return(2);
 } /* main */
 
 
diff --git a/strings/strappend-sparc.s b/strings/strappend-sparc.s
index 69bb555aa47fb4f36ec6b786b9a0010a97450b2d..30b621c3fce2d04ef0a5d206dae95812d0ea51df 100644
--- a/strings/strappend-sparc.s
+++ b/strings/strappend-sparc.s
@@ -22,28 +22,28 @@
 	.type	 strappend,#function
 	.proc	020
 strappend:
-	add	%o0, %o1, %g3		! g3 = endpos
-	ldsb	[%o0], %g2
+	add	%o0, %o1, %o3		! o3 = endpos
+	ldsb	[%o0], %o4
 .loop1:
 	add	%o0, 1, %o0		! find end of str
-	cmp	%g2, 0
+	cmp	%o4, 0
 	bne,a	.loop1
-	ldsb	[%o0], %g2
+	ldsb	[%o0], %o4
 	
 	sub	%o0, 1, %o0
-	cmp	%o0, %g3
+	cmp	%o0, %o3
 	bgeu	.end
 	nop
 	
 	stb	%o2, [%o0]
 .loop2:
 	add	%o0, 1, %o0
-	cmp	%o0, %g3
+	cmp	%o0, %o3
 	blu,a	.loop2
 	stb	%o2, [%o0]
 .end:
 	retl
-	stb	%g0, [%g3]
+	stb	%g0, [%o3]
 .strappend_end:
 	.size	 strappend,.strappend_end-strappend
 	.ident	"Matt Wagner & Monty"
diff --git a/strings/strend-sparc.s b/strings/strend-sparc.s
index fd1dba4d36f8ddf14de180673142db0c5da4319f..0f19f6a435a67fa5a18922a1e9635dd87446c002 100644
--- a/strings/strend-sparc.s
+++ b/strings/strend-sparc.s
@@ -22,12 +22,12 @@
 	.type	 strend,#function
 	.proc	0102
 strend:
-	ldsb	[%o0], %g2		! Handle first char differently to make
+	ldsb	[%o0], %o3		! Handle first char differently to make
 .loop:					! a faster loop
 	add	%o0, 1, %o0
-	cmp	%g2, 0
+	cmp	%o3, 0
 	bne,a	.loop
-	ldsb	[%o0], %g2
+	ldsb	[%o0], %o3
 	retl
 	sub	%o0,1,%o0
 .strend_end:
diff --git a/strings/strmake-sparc.s b/strings/strmake-sparc.s
index 9fe72a9f9a2dd1f681590586725339996706a743..4effe95774e06c88d343ddb026a9389ada5b9369 100644
--- a/strings/strmake-sparc.s
+++ b/strings/strmake-sparc.s
@@ -25,16 +25,16 @@ strmake:
 	orcc	%g0,%o2,%g0
 	be,a	.end
 	nop
-	ldsb	[%o1],%g2
+	ldsb	[%o1],%o3
 .loop:	
-	stb	%g2,[%o0]
-	cmp	%g2,0
+	stb	%o3,[%o0]
+	cmp	%o3,0
 	be	.end		! Jump to end on end of string
 	add	%o1,1,%o1
 	add	%o0,1,%o0
 	subcc	%o2,1,%o2
 	bne,a	.loop
-	ldsb	[%o1],%g2
+	ldsb	[%o1],%o3
 .end:
 	retl
 	stb	%g0,[%o0]
diff --git a/strings/strmov-sparc.s b/strings/strmov-sparc.s
index 6114b0bf6e268cff30414c385e31100d8847171c..3536685b47bbc99276eee54ee7785fd54fb929e1 100644
--- a/strings/strmov-sparc.s
+++ b/strings/strmov-sparc.s
@@ -23,10 +23,10 @@
 	.proc	0102
 strmov:
 .loop:
-	ldub	[%o1], %g2
-	stb	%g2, [%o0]
+	ldub	[%o1], %o3
+	stb	%o3, [%o0]
 	add	%o1, 1, %o1
-	cmp	%g2, 0
+	cmp	%o3, 0
 	bne,a	.loop
 	add	%o0, 1, %o0
 	retl
diff --git a/strings/strnmov-sparc.s b/strings/strnmov-sparc.s
index 2dfcb95ab762432787217f6e0f39934966ca3c0d..f681318f410f1c677a63210fb39d291995b1b37b 100644
--- a/strings/strnmov-sparc.s
+++ b/strings/strnmov-sparc.s
@@ -25,16 +25,16 @@ strnmov:
 	orcc	%g0,%o2,%g0
 	be,a	.end
 	nop
-	ldsb	[%o1],%g2
+	ldsb	[%o1],%o3
 .loop:	
-	stb	%g2,[%o0]
-	cmp	%g2,0
+	stb	%o3,[%o0]
+	cmp	%o3,0
 	be	.end		! Jump to end on end of string
 	add	%o1,1,%o1
 	add	%o0,1,%o0
 	subcc	%o2,1,%o2
 	bne,a	.loop
-	ldsb	[%o1],%g2
+	ldsb	[%o1],%o3
 .end:
 	retl
 	nop
diff --git a/strings/strstr-sparc.s b/strings/strstr-sparc.s
index 1263236f107029e69bee2a174efef4a1de055bf9..eb658e9f7f0a401c7b303a5481535895725c1b6f 100644
--- a/strings/strstr-sparc.s
+++ b/strings/strstr-sparc.s
@@ -33,10 +33,10 @@ strstr:
 
 	ldsb	[%o1],%o2		! o2= First char of search
 .top:
-	ldsb	[%o0],%g3		! g3= First char of rest of str
-	cmp	%g3,0
+	ldsb	[%o0],%o4		! o4= First char of rest of str
+	cmp	%o4,0
 	be	.abort			! Found end null		; 
-	cmp	%g3,%o2
+	cmp	%o4,%o2
 	bne	.top
 	add	%o0,1,%o0
 
@@ -45,20 +45,20 @@ strstr:
 !      while (*j)
 !	if (*i++ != *j++) goto skipp;
 
-	or	%g0,%o0,%g2
-	add	%o1,1,%g3		! g3= search+1
+	or	%g0,%o0,%o3
+	add	%o1,1,%o4		! o4= search+1
 	ldsb	[%o0],%o5		! o5= [current_str+1]
 
 .loop2:
-	ldsb	[%g3],%g4
-	add	%g3,1,%g3
+	ldsb	[%o4],%g4
+	add	%o4,1,%o4
 	cmp	%g4,0
 	be	.end	
 	cmp	%o5,%g4
 	bne	.top
-	add	%g2,1,%g2
+	add	%o3,1,%o3
 	ba	.loop2
-	ldsb	[%g2],%o5
+	ldsb	[%o3],%o5
 
 .end:
 	retl
diff --git a/strings/strxmov-sparc.s b/strings/strxmov-sparc.s
index e65b56d317dd1dc59d26f164b4d8cf42f361c7df..b4ca531d2e434b49c04b20bbd95bdd2e15af8124 100644
--- a/strings/strxmov-sparc.s
+++ b/strings/strxmov-sparc.s
@@ -15,12 +15,17 @@
 ! Software Foundation, Inc., 59 Temple Place - Suite 330, Boston,
 ! MA 02111-1307, USA
 
+!
+! Note that this function only works on 32 bit sparc systems
+! on 64 bits the offsets to %sp are different !
+
 	.file	"strxmov-sparc.s"
 .section	".text"
 	.align 4
 	.global strxmov
 	.type	 strxmov,#function
 	.proc	0102
+	
 strxmov:
 	st	%o2, [%sp+76]		! store 3rd param before other params
 	st	%o3, [%sp+80]		! store 4th param "   "
@@ -28,18 +33,18 @@ strxmov:
 	st	%o4, [%sp+84]		! store 5th param
 	be	.end
 	st	%o5, [%sp+88]		! store last
-	add	%sp, 76, %g2		! put pointer to 3rd arg
+	add	%sp, 76, %o4		! put pointer to 3rd arg
 .loop:
-	ldub	[%o1], %g1		! set values of src (o1)
+	ldub	[%o1], %o5		! set values of src (o1)
 	add	%o1, 1, %o1		! inc src
-	stb	%g1, [%o0]		!   and dst (o2) equal
-	cmp	%g1, 0			! second while cmp
+	stb	%o5, [%o0]		!   and dst (o2) equal
+	cmp	%o5, 0			! second while cmp
 	bne,a	.loop
 	add	%o0, 1, %o0		! inc dst
-	ld	[%g2], %o1		! get next param
+	ld	[%o4], %o1		! get next param
 	cmp	%o1, 0			! check if last param
 	bne	.loop
-	add	%g2, 4, %g2		! advance to next param
+	add	%o4, 4, %o4		! advance to next param
 .end:
 	retl
 	stb	%g0, [%o0]
diff --git a/support-files/mysql.server.sh b/support-files/mysql.server.sh
index 7493fd298567e9c094a390570908bb889367b054..139bbb3fd6b1b1ccd477a60aafb5af8ed2dbb7db 100644
--- a/support-files/mysql.server.sh
+++ b/support-files/mysql.server.sh
@@ -5,7 +5,7 @@
 # Mysql daemon start/stop script.
 
 # Usually this is put in /etc/init.d (at least on machines SYSV R4 based
-# systems) and linked to /etc/rc3.d/S99mysql and /etc/rc0.d/S01mysql.
+# systems) and linked to /etc/rc3.d/S99mysql and /etc/rc0.d/K01mysql.
 # When this is done the mysql server will be started when the machine is
 # started and shut down when the systems goes down.
 
diff --git a/tests/Makefile.am b/tests/Makefile.am
index 241caf7446561fa25de83f5f8017de8a8c3d43f3..5dc6871bd43ac444e168c212cee0376640b6c40c 100644
--- a/tests/Makefile.am
+++ b/tests/Makefile.am
@@ -24,14 +24,12 @@ EXTRA_DIST =		auto_increment.res auto_increment.tst \
 			insert_and_repair.pl \
 			grant.pl grant.res test_delayed_insert.pl \
 			pmail.pl mail_to_db.pl table_types.pl \
-			udf_test udf_test.res 
+			udf_test udf_test.res myisam-big-rows.tst
 
 #
 # C Test for 4.1 protocol
 #
-INCLUDES =		-I$(srcdir)/../include $(openssl_includes) \
-			-I../include -I$(srcdir)/.. -I$(top_srcdir) \
-			-I..
+INCLUDES =		-I$(top_srcdir)/include $(openssl_includes)
 LIBS =			@CLIENT_LIBS@
 LDADD =			@CLIENT_EXTRA_LDFLAGS@ ../libmysql/libmysqlclient.la
 noinst_PROGRAMS =	client_test
diff --git a/tests/client_test.c b/tests/client_test.c
index a00c475129d50bf0d4b8b1d0f8f39daf899a2c53..280df2bf717a25bb65e8541bb730fcec2b0ea780 100644
--- a/tests/client_test.c
+++ b/tests/client_test.c
@@ -48,15 +48,22 @@
 #define false 0
 #endif
 
+#ifndef bzero
+#define bzero(A,B) memset(A,0,B)
+#endif
+
 /* set default options */
-static char *opt_db=(char *)"test";
-static char *opt_user=(char *)"root";
-static char *opt_password=(char *)"";
+static char *opt_db=0;
+static char *opt_user=0;
+static char *opt_password=0;
 static char *opt_host=0;
 static char *opt_unix_socket=0;
 static uint  opt_port;
 static my_bool tty_password=0;
 
+static MYSQL *mysql=0;
+static char query[255];
+
 #define myheader(str) { printf("\n\n#######################\n"); \
                         printf("%s",str); \
                         printf("\n#######################\n"); \
@@ -64,9 +71,9 @@ static my_bool tty_password=0;
 
 #define init_bind(x) (bzero(x,sizeof(x)))
 
-void print_error(MYSQL *mysql, const char *msg)
+void print_error(const char *msg)
 {  
-  if(mysql)
+  if (mysql)
   {
     fprintf(stderr,"\n [MySQL]%s \n",mysql_error(mysql));
   }
@@ -75,14 +82,14 @@ void print_error(MYSQL *mysql, const char *msg)
 
 void print_st_error(MYSQL_STMT *stmt, const char *msg)
 {  
-  if(stmt)
+  if (stmt)
   {
     fprintf(stderr,"\n [MySQL]%s \n",mysql_stmt_error(stmt));
   }
   else if(msg) fprintf(stderr, "%s\n", msg);
 }
 
-#define myerror(mysql, msg) print_error(mysql, msg)
+#define myerror(msg) print_error(msg)
 #define mysterror(stmt, msg) print_st_error(stmt, msg)
 
 #define myassert(x) if(x) {\
@@ -94,17 +101,17 @@ void print_st_error(MYSQL_STMT *stmt, const char *msg)
   exit(1);\
 }
 
-#define myquery(mysql,r) \
+#define myquery(r) \
 if( r != 0) \
 { \
-  myerror(mysql,NULL); \
+  myerror(NULL); \
   myassert(true);\
 }
 
-#define myquery_r(mysql,r) \
+#define myquery_r(r) \
 if( r != 0) \
 { \
-  myerror(mysql,NULL); \
+  myerror(NULL); \
   myassert_r(true);\
 }
 
@@ -115,17 +122,17 @@ if( r != 0) \
   myassert(true);\
 }
 
-#define myxquery(mysql,stmt) \
+#define myxquery(stmt) \
 if( stmt == 0) \
 { \
-  myerror(mysql,NULL); \
+  myerror(NULL); \
   myassert(true);\
 }
 
-#define myxquery_r(mysql,stmt) \
+#define myxquery_r(stmt) \
 if( stmt == 0) \
 { \
-  myerror(mysql,NULL); \
+  myerror(NULL); \
   myassert_r(true);\
 } \
 else myassert(true);
@@ -137,40 +144,37 @@ if( r != 0) \
   myassert_r(true);\
 }
 
-#define mytest(mysql,x) if(!x) {myerror(mysql,NULL);myassert(true);}
-#define mytest_r(mysql,x) if(x) {myerror(mysql,NULL);myassert(true);}
+#define mytest(x) if(!x) {myerror(NULL);myassert(true);}
+#define mytest_r(x) if(x) {myerror(NULL);myassert(true);}
 
 /********************************************************
 * connect to the server                                 *
 *********************************************************/
-MYSQL *client_connect()
+static void client_connect()
 {
-  MYSQL *mysql;
-
   myheader("client_connect");  
 
   if(!(mysql = mysql_init(NULL)))
   { 
-	  myerror(NULL, "mysql_init() failed");
+	  myerror("mysql_init() failed");
     exit(0);
   }
   if (!(mysql_real_connect(mysql,opt_host,opt_user,
-			   opt_password, opt_db, opt_port,
+			   opt_password, opt_db ? opt_db:"test", opt_port,
 			   opt_unix_socket, 0)))
   {
-    myerror(mysql, "connection failed");
+    myerror("connection failed");
     exit(0);
   }    
 
   /* set AUTOCOMMIT to ON*/
   mysql_autocommit(mysql, true);
-  return(mysql);
 }
 
 /********************************************************
 * close the connection                                  *
 *********************************************************/
-void client_disconnect(MYSQL *mysql)
+void client_disconnect()
 {
   myheader("client_disconnect");
 
@@ -180,39 +184,39 @@ void client_disconnect(MYSQL *mysql)
 /********************************************************
 * query processing                                      *
 *********************************************************/
-void client_query(MYSQL *mysql)
+void client_query()
 {
   int rc;
 
   myheader("client_query");
 
   rc = mysql_query(mysql,"DROP TABLE IF EXISTS myclient_test");
-  myquery(mysql,rc);
+  myquery(rc);
 
   rc = mysql_query(mysql,"CREATE TABLE myclient_test(id int primary key auto_increment,\
                                               name varchar(20))");
-  myquery(mysql,rc);
+  myquery(rc);
   
   rc = mysql_query(mysql,"CREATE TABLE myclient_test(id int, name varchar(20))");
-  myquery_r(mysql,rc);
+  myquery_r(rc);
   
   rc = mysql_query(mysql,"INSERT INTO myclient_test(name) VALUES('mysql')");
-  myquery(mysql,rc);
+  myquery(rc);
   
   rc = mysql_query(mysql,"INSERT INTO myclient_test(name) VALUES('monty')");
-  myquery(mysql,rc);
-  
+  myquery(rc);
+
   rc = mysql_query(mysql,"INSERT INTO myclient_test(name) VALUES('venu')");
-  myquery(mysql,rc);
-  
+  myquery(rc);
+
   rc = mysql_query(mysql,"INSERT INTO myclient_test(name) VALUES('deleted')");
-  myquery(mysql,rc);
+  myquery(rc);
 
   rc = mysql_query(mysql,"UPDATE myclient_test SET name='updated' WHERE name='deleted'");
-  myquery(mysql,rc);
-  
+  myquery(rc);
+
   rc = mysql_query(mysql,"UPDATE myclient_test SET id=3 WHERE name='updated'");
-  myquery_r(mysql,rc);
+  myquery_r(rc);
 }
 
 /********************************************************
@@ -226,12 +230,12 @@ void my_print_dashes(MYSQL_RES *result)
   mysql_field_seek(result,0);
   fputc('\t',stdout);
   fputc('+', stdout);
-  
+
   for(i=0; i< mysql_num_fields(result); i++)
   {
     field = mysql_fetch_field(result);
     for(j=0; j < field->max_length+2; j++)
-      fputc('-',stdout);    
+      fputc('-',stdout);
     fputc('+',stdout);
   }
   fputc('\n',stdout);
@@ -247,7 +251,7 @@ void my_print_result_metadata(MYSQL_RES *result)
   unsigned int field_count;
 
   mysql_field_seek(result,0);
-  fputc('\n', stdout);  
+  fputc('\n', stdout);
 
   field_count = mysql_num_fields(result);
   for(i=0; i< field_count; i++)
@@ -263,7 +267,7 @@ void my_print_result_metadata(MYSQL_RES *result)
   my_print_dashes(result);
   fputc('\t',stdout);
   fputc('|', stdout);
-  
+
   mysql_field_seek(result,0);
   for(i=0; i< field_count; i++)
   {
@@ -277,7 +281,7 @@ void my_print_result_metadata(MYSQL_RES *result)
 /********************************************************
 * process the result set                                *
 *********************************************************/
-int my_process_result_set(MYSQL *mysql, MYSQL_RES *result)
+int my_process_result_set(MYSQL_RES *result)
 {
   MYSQL_ROW    row;
   MYSQL_FIELD  *field;
@@ -287,7 +291,7 @@ int my_process_result_set(MYSQL *mysql, MYSQL_RES *result)
   my_print_result_metadata(result);
 
   while((row = mysql_fetch_row(result)) != NULL)
-  {   
+  {
     mysql_field_seek(result,0);
     fputc('\t',stdout);
     fputc('|',stdout);
@@ -310,49 +314,83 @@ int my_process_result_set(MYSQL *mysql, MYSQL_RES *result)
 
   if (mysql_errno(mysql) != 0)
     fprintf(stderr, "\n\tmysql_fetch_row() failed\n");
-  else 
+  else
     fprintf(stdout,"\n\t%d rows returned\n", row_count);
   return(row_count);
 }
 
+static void verify_col_data(const char *table, const char *col, const char *exp_data)
+{
+  MYSQL_STMT *stmt;
+  MYSQL_BIND  bind[1];
+  char        data[255];
+  int         rc;
+  
+  init_bind(bind);
+  
+  bind[0].buffer_type=FIELD_TYPE_STRING;
+  bind[0].buffer= (char *)data;
+  bind[0].buffer_length= sizeof(data);
+
+  sprintf(query, "SELECT `%s` FROM `%s`", col, table);
+
+  printf("\n %s", query);
+  stmt = mysql_prepare(mysql, query, strlen(query));
+  myxquery(stmt);
+
+  rc = mysql_bind_result(stmt,bind);
+  mystmt(stmt, rc);
+
+  rc = mysql_execute(stmt);
+  mystmt(stmt, rc);
+
+  rc = mysql_fetch(stmt);
+  mystmt(stmt,rc);
+
+  printf("\n data : %s (expected: %s)",data, exp_data);
+  assert(strcmp(data,exp_data)==0);
+
+  mysql_stmt_close(stmt);
+}
+
 /********************************************************
 * store result processing                               *
 *********************************************************/
-void client_store_result(MYSQL *mysql)
+void client_store_result()
 {
   MYSQL_RES *result;
   int       rc;
-  
+
   myheader("client_store_result");
 
   rc = mysql_query(mysql, "SELECT * FROM myclient_test");
-  myquery(mysql,rc);
-    
+  myquery(rc);
+
   /* get the result */
   result = mysql_store_result(mysql);
-  mytest(mysql,result);
+  mytest(result);
 
-  my_process_result_set(mysql,result);
+  my_process_result_set(result);
   mysql_free_result(result);
 }
 
 /********************************************************
 * use result processing                                 *
 *********************************************************/
-void client_use_result(MYSQL *mysql)
+void client_use_result()
 {
   MYSQL_RES *result;
   int       rc;
   myheader("client_use_result");
 
-  rc = mysql_query(mysql, "SELECT * FROM myclient_test");    
-  myquery(mysql,rc);
+  rc = mysql_query(mysql, "SELECT * FROM myclient_test");
+  myquery(rc);
 
   /* get the result */
   result = mysql_use_result(mysql);
-  mytest(mysql,result);
+  mytest(result);
 
-  my_process_result_set(mysql,result);
+  my_process_result_set(result);
   mysql_free_result(result);
 }
 
@@ -360,7 +398,7 @@ void client_use_result(MYSQL *mysql)
 /********************************************************
 * query processing                                      *
 *********************************************************/
-void test_debug_example(MYSQL *mysql)
+void test_debug_example()
 {
   int rc;
   MYSQL_RES *result;
@@ -368,35 +406,35 @@ void test_debug_example(MYSQL *mysql)
   myheader("test_debug_example");
 
   rc = mysql_query(mysql,"DROP TABLE IF EXISTS test_debug_example");
-  myquery(mysql,rc);
+  myquery(rc);
 
   rc = mysql_query(mysql,"CREATE TABLE test_debug_example(id int primary key auto_increment,\
                                               name varchar(20),xxx int)");
-  myquery(mysql,rc);
-  
+  myquery(rc);
+
   rc = mysql_query(mysql,"INSERT INTO test_debug_example(name) VALUES('mysql')");
-  myquery(mysql,rc);
+  myquery(rc);
 
   rc = mysql_query(mysql,"UPDATE test_debug_example SET name='updated' WHERE name='deleted'");
-  myquery(mysql,rc);
+  myquery(rc);
 
   rc = mysql_query(mysql,"SELECT * FROM test_debug_example");
-  myquery(mysql,rc);
-    
+  myquery(rc);
+
   result = mysql_use_result(mysql);
-  mytest(mysql,result);
+  mytest(result);
 
-  my_process_result_set(mysql,result);  
+  my_process_result_set(result);
   mysql_free_result(result);
 
   rc = mysql_query(mysql,"DROP TABLE test_debug_example");
-  myquery(mysql,rc);
+  myquery(rc);
 }
 
 /********************************************************
 * to test autocommit feature                            *
 *********************************************************/
-void test_tran_bdb(MYSQL *mysql)
+void test_tran_bdb()
 {
   MYSQL_RES *result;
   MYSQL_ROW row;
@@ -406,75 +444,75 @@ void test_tran_bdb(MYSQL *mysql)
 
   /* set AUTOCOMMIT to OFF */
   rc = mysql_autocommit(mysql, false);
-  myquery(mysql,rc);
+  myquery(rc);
+
+  rc = mysql_query(mysql,"DROP TABLE IF EXISTS my_demo_transaction");
+  myquery(rc);
+
 
-  rc = mysql_query(mysql,"DROP TABLE IF EXISTS my_demo_transaction");  
-  myquery(mysql,rc);  
-    
-    
   rc = mysql_commit(mysql);
-  myquery(mysql,rc);
+  myquery(rc);
 
   /* create the table 'mytran_demo' of type BDB' or 'InnoDB' */
   rc = mysql_query(mysql,"CREATE TABLE my_demo_transaction(col1 int ,col2 varchar(30)) TYPE = BDB");
-  myquery(mysql,rc);  
+  myquery(rc);
 
   rc = mysql_commit(mysql);
-  myquery(mysql,rc);
+  myquery(rc);
 
   /* insert a row and commit the transaction */
   rc = mysql_query(mysql,"INSERT INTO my_demo_transaction VALUES(10,'venu')");
-  myquery(mysql,rc);  
+  myquery(rc);
 
   rc = mysql_commit(mysql);
-  myquery(mysql,rc);
+  myquery(rc);
 
     /* now insert the second row, and rollback the transaction */
   rc = mysql_query(mysql,"INSERT INTO my_demo_transaction VALUES(20,'mysql')");
-  myquery(mysql,rc);  
+  myquery(rc);
 
   rc = mysql_rollback(mysql);
-  myquery(mysql,rc);
+  myquery(rc);
 
   /* delete first row, and rollback it */
   rc = mysql_query(mysql,"DELETE FROM my_demo_transaction WHERE col1 = 10");
-  myquery(mysql,rc); 
+  myquery(rc);
 
   rc = mysql_rollback(mysql);
-  myquery(mysql,rc);
+  myquery(rc);
 
   /* test the results now, only one row should exists */
   rc = mysql_query(mysql,"SELECT * FROM my_demo_transaction");
-  myquery(mysql,rc);
-    
+  myquery(rc);
+
   /* get the result */
   result = mysql_store_result(mysql);
-  mytest(mysql,result);
+  mytest(result);
 
-  my_process_result_set(mysql,result);  
+  my_process_result_set(result);
 
   /* test the results now, only one row should exists */
   rc = mysql_query(mysql,"SELECT * FROM my_demo_transaction");
-  myquery(mysql,rc);
-    
+  myquery(rc);
+
   /* get the result */
   result = mysql_use_result(mysql);
-  mytest(mysql,result);
-  
+  mytest(result);
+
   row = mysql_fetch_row(result);
-  mytest(mysql,row);
-  
+  mytest(row);
+
   row = mysql_fetch_row(result);
-  mytest_r(mysql,row);
+  mytest_r(row);
 
-  mysql_free_result(result); 
+  mysql_free_result(result);
   mysql_autocommit(mysql,true);
 }
 
 /********************************************************
 * to test autocommit feature                            *
 *********************************************************/
-void test_tran_innodb(MYSQL *mysql)
+void test_tran_innodb()
 {
   MYSQL_RES *result;
   MYSQL_ROW row;
@@ -484,68 +522,68 @@ void test_tran_innodb(MYSQL *mysql)
 
   /* set AUTOCOMMIT to OFF */
   rc = mysql_autocommit(mysql, false);
-  myquery(mysql,rc);
+  myquery(rc);
+
+  rc = mysql_query(mysql,"DROP TABLE IF EXISTS my_demo_transaction");
+  myquery(rc);
 
-  rc = mysql_query(mysql,"DROP TABLE IF EXISTS my_demo_transaction");  
-  myquery(mysql,rc);     
-    
   rc = mysql_commit(mysql);
-  myquery(mysql,rc);
+  myquery(rc);
 
   /* create the table 'mytran_demo' of type BDB' or 'InnoDB' */
   rc = mysql_query(mysql,"CREATE TABLE my_demo_transaction(col1 int ,col2 varchar(30)) TYPE = InnoDB");
-  myquery(mysql,rc);  
+  myquery(rc);
 
   rc = mysql_commit(mysql);
-  myquery(mysql,rc);
+  myquery(rc);
 
   /* insert a row and commit the transaction */
   rc = mysql_query(mysql,"INSERT INTO my_demo_transaction VALUES(10,'venu')");
-  myquery(mysql,rc);  
+  myquery(rc);
 
   rc = mysql_commit(mysql);
-  myquery(mysql,rc);
+  myquery(rc);
 
     /* now insert the second row, and rollback the transaction */
   rc = mysql_query(mysql,"INSERT INTO my_demo_transaction VALUES(20,'mysql')");
-  myquery(mysql,rc);  
+  myquery(rc);
 
   rc = mysql_rollback(mysql);
-  myquery(mysql,rc);
+  myquery(rc);
 
   /* delete first row, and rollback it */
   rc = mysql_query(mysql,"DELETE FROM my_demo_transaction WHERE col1 = 10");
-  myquery(mysql,rc); 
+  myquery(rc);
 
   rc = mysql_rollback(mysql);
-  myquery(mysql,rc);
+  myquery(rc);
 
   /* test the results now, only one row should exists */
   rc = mysql_query(mysql,"SELECT * FROM my_demo_transaction");
-  myquery(mysql,rc);
-    
+  myquery(rc);
+
   /* get the result */
   result = mysql_store_result(mysql);
-  mytest(mysql,result);
+  mytest(result);
 
-  my_process_result_set(mysql,result);  
+  my_process_result_set(result);
 
   /* test the results now, only one row should exists */
   rc = mysql_query(mysql,"SELECT * FROM my_demo_transaction");
-  myquery(mysql,rc);
-    
+  myquery(rc);
+
   /* get the result */
   result = mysql_use_result(mysql);
-  mytest(mysql,result);
-  
+  mytest(result);
+
   row = mysql_fetch_row(result);
-  mytest(mysql,row);
-  
+  mytest(row);
+
   row = mysql_fetch_row(result);
-  mytest_r(mysql,row);
+  mytest_r(row);
 
   mysql_free_result(result);
-  mysql_autocommit(mysql,true);    
+  mysql_autocommit(mysql,true);
 }
 
 
@@ -553,27 +591,26 @@ void test_tran_innodb(MYSQL *mysql)
  To test simple prepares of all DML statements
 *********************************************************/
 
-void test_prepare_simple(MYSQL *mysql)
+void test_prepare_simple()
 {
   MYSQL_STMT *stmt;
   int        rc,param_count;
-  const char *query;
 
-  myheader("test_prepare_simple"); 
-  
-  rc = mysql_query(mysql,"DROP TABLE IF EXISTS test_prepare_simple");  
-  myquery(mysql,rc);     
-    
+  myheader("test_prepare_simple");
+
+  rc = mysql_query(mysql,"DROP TABLE IF EXISTS test_prepare_simple");
+  myquery(rc);
+
   rc = mysql_commit(mysql);
-  myquery(mysql,rc);
+  myquery(rc);
 
   rc = mysql_query(mysql,"CREATE TABLE test_prepare_simple(id int, name varchar(50))");
-  myquery(mysql,rc);  
+  myquery(rc);
 
   /* alter table */
-  query = "ALTER TABLE test_prepare_simple ADD new char(20)";
+  strcpy(query,"ALTER TABLE test_prepare_simple ADD new char(20)");
   stmt = mysql_prepare(mysql, query, strlen(query));
-  myxquery(mysql,stmt);   
+  myxquery(stmt);
 
   param_count = mysql_param_count(stmt);
   fprintf(stdout,"\n total parameters in alter:%d\n", param_count);
@@ -581,9 +618,9 @@ void test_prepare_simple(MYSQL *mysql)
   mysql_stmt_close(stmt);
 
   /* insert */
-  query = "INSERT INTO test_prepare_simple VALUES(?,?)";
+  strcpy(query,"INSERT INTO test_prepare_simple VALUES(?,?)");
   stmt = mysql_prepare(mysql, query, strlen(query));
-  myxquery(mysql,stmt);   
+  myxquery(stmt);
 
   param_count = mysql_param_count(stmt);
   fprintf(stdout,"\n total parameters in insert:%d\n", param_count);
@@ -591,9 +628,9 @@ void test_prepare_simple(MYSQL *mysql)
   mysql_stmt_close(stmt);
 
   /* update */
-  query = "UPDATE test_prepare_simple SET id=? WHERE id=? AND name= ?";
+  strcpy(query,"UPDATE test_prepare_simple SET id=? WHERE id=? AND name= ?");
   stmt = mysql_prepare(mysql, query, strlen(query));
-  myxquery(mysql,stmt);   
+  myxquery(stmt);
 
   param_count = mysql_param_count(stmt);
   fprintf(stdout,"\n total parameters in update:%d\n", param_count);
@@ -601,9 +638,9 @@ void test_prepare_simple(MYSQL *mysql)
   mysql_stmt_close(stmt);
 
   /* delete */
-  query = "DELETE FROM test_prepare_simple WHERE id=10";
+  strcpy(query,"DELETE FROM test_prepare_simple WHERE id=10");
   stmt = mysql_prepare(mysql, query, strlen(query));
-  myxquery(mysql,stmt);   
+  myxquery(stmt);
 
   param_count = mysql_param_count(stmt);
   fprintf(stdout,"\n total parameters in delete:%d\n", param_count);
@@ -614,9 +651,9 @@ void test_prepare_simple(MYSQL *mysql)
   mysql_stmt_close(stmt);
 
   /* delete */
-  query = "DELETE FROM test_prepare_simple WHERE id=?";
+  strcpy(query,"DELETE FROM test_prepare_simple WHERE id=?");
   stmt = mysql_prepare(mysql, query, strlen(query));
-  myxquery(mysql,stmt);   
+  myxquery(stmt);
 
   param_count = mysql_param_count(stmt);
   fprintf(stdout,"\n total parameters in delete:%d\n", param_count);
@@ -627,9 +664,9 @@ void test_prepare_simple(MYSQL *mysql)
   mysql_stmt_close(stmt);
 
   /* select */
-  query = "SELECT * FROM test_prepare_simple WHERE id=? AND name= ?";
+  strcpy(query,"SELECT * FROM test_prepare_simple WHERE id=? AND name= ?");
   stmt = mysql_prepare(mysql, query, strlen(query));
-  myxquery(mysql,stmt);   
+  myxquery(stmt);
 
   param_count = mysql_param_count(stmt);
   fprintf(stdout,"\n total parameters in select:%d\n", param_count);
@@ -639,35 +676,33 @@ void test_prepare_simple(MYSQL *mysql)
 
   /* now fetch the results ..*/
   rc = mysql_commit(mysql);
-  myquery(mysql,rc);
+  myquery(rc);
 }
 
 
 /********************************************************
 * to test simple prepare field results                  *
 *********************************************************/
-void test_prepare_field_result(MYSQL *mysql)
+void test_prepare_field_result()
 {
   MYSQL_STMT *stmt;
   int        rc,param_count;
-  const char *query;
 
-  myheader("test_prepare_field_result"); 
- 
-  rc = mysql_query(mysql,"DROP TABLE IF EXISTS test_prepare_field_result");  
-  myquery(mysql,rc);     
-    
+  myheader("test_prepare_field_result");
+
+  rc = mysql_query(mysql,"DROP TABLE IF EXISTS test_prepare_field_result");
+  myquery(rc);
+
   rc = mysql_commit(mysql);
-  myquery(mysql,rc);
+  myquery(rc);
 
   rc = mysql_query(mysql,"CREATE TABLE test_prepare_field_result(id int, name varchar(50), extra int)");
-  myquery(mysql,rc);  
-
+  myquery(rc); 
 
   /* insert */
-  query = "SELECT id,name FROM test_prepare_field_result WHERE id=?";
+  strcpy(query,"SELECT id,name FROM test_prepare_field_result WHERE id=?");
   stmt = mysql_prepare(mysql, query, strlen(query));
-  myxquery(mysql,stmt);   
+  myxquery(stmt);
 
   param_count = mysql_param_count(stmt);
   fprintf(stdout,"\n total parameters in insert:%d\n", param_count);
@@ -676,49 +711,48 @@ void test_prepare_field_result(MYSQL *mysql)
 
   /* now fetch the results ..*/
   rc = mysql_commit(mysql);
-  myquery(mysql,rc);
+  myquery(rc);
 }
 
 
 /********************************************************
 * to test simple prepare field results                  *
 *********************************************************/
-void test_prepare_syntax(MYSQL *mysql)
+void test_prepare_syntax()
 {
   MYSQL_STMT *stmt;
   int        rc;
-  const char *query;
 
-  myheader("test_prepare_syntax"); 
- 
-  rc = mysql_query(mysql,"DROP TABLE IF EXISTS test_prepare_syntax");  
-  myquery(mysql,rc);     
-    
+  myheader("test_prepare_syntax");
+
+  rc = mysql_query(mysql,"DROP TABLE IF EXISTS test_prepare_syntax");
+  myquery(rc);
+
   rc = mysql_commit(mysql);
-  myquery(mysql,rc);
+  myquery(rc);
 
   rc = mysql_query(mysql,"CREATE TABLE test_prepare_syntax(id int, name varchar(50), extra int)");
-  myquery(mysql,rc); 
+  myquery(rc);
 
-  query = "INSERT INTO test_prepare_syntax VALUES(?";
+  strcpy(query,"INSERT INTO test_prepare_syntax VALUES(?");
   stmt = mysql_prepare(mysql, query, strlen(query));
-  myxquery_r(mysql,stmt);    
+  myxquery_r(stmt);
 
-  query = "SELECT id,name FROM test_prepare_syntax WHERE id=? AND WHERE";
+  strcpy(query,"SELECT id,name FROM test_prepare_syntax WHERE id=? AND WHERE");
   stmt = mysql_prepare(mysql, query, strlen(query));
-  myxquery_r(mysql,stmt);   
+  myxquery_r(stmt);
 
   /* now fetch the results ..*/
   rc = mysql_commit(mysql);
-  myquery(mysql,rc);
+  myquery(rc);
 }
 
 
 /********************************************************
 * to test simple prepare                                *
 *********************************************************/
-void test_prepare(MYSQL *mysql)
-{  
+void test_prepare()
+{
   MYSQL_STMT *stmt;
   int        rc,param_count;
   char       query[200];
@@ -730,30 +764,30 @@ void test_prepare(MYSQL *mysql)
   double     real_data;
   double     double_data;
   MYSQL_RES  *result;
-  MYSQL_BIND bind[8];  
+  MYSQL_BIND bind[8];
 
-  myheader("test_prepare"); 
+  myheader("test_prepare");
 
   init_bind(bind);
   rc = mysql_autocommit(mysql, true);
-  myquery(mysql,rc);
+  myquery(rc);
+
+  rc = mysql_query(mysql,"DROP TABLE IF EXISTS my_prepare");
+  myquery(rc);
 
-  rc = mysql_query(mysql,"DROP TABLE IF EXISTS my_prepare");  
-  myquery(mysql,rc);     
-    
   rc = mysql_commit(mysql);
-  myquery(mysql,rc);
+  myquery(rc);
 
   rc = mysql_query(mysql,"CREATE TABLE my_prepare(col1 tinyint,\
                                 col2 varchar(50), col3 int,\
                                 col4 smallint, col5 bigint, \
                                 col6 float, col7 double )");
-  myquery(mysql,rc);  
+  myquery(rc);
 
   /* insert by prepare */
   strcpy(query,"INSERT INTO my_prepare VALUES(?,?,?,?,?,?,?)");
   stmt = mysql_prepare(mysql, query, strlen(query));
-  myxquery(mysql,stmt);   
+  myxquery(stmt);
 
   param_count = mysql_param_count(stmt);
   fprintf(stdout," total parameters in insert:%d\n", param_count);
@@ -765,22 +799,23 @@ void test_prepare(MYSQL *mysql)
   /* string */
   bind[1].buffer_type=FIELD_TYPE_STRING;
   bind[1].buffer=str_data;
+  bind[1].buffer_length=sizeof(str_data);
   /* integer */
   bind[2].buffer_type=FIELD_TYPE_LONG;
-  bind[2].buffer= (gptr)&int_data;	
+  bind[2].buffer= (gptr)&int_data;
   /* short */
   bind[3].buffer_type=FIELD_TYPE_SHORT;
-  bind[3].buffer= (gptr)&small_data;	
+  bind[3].buffer= (gptr)&small_data;
   /* bigint */
   bind[4].buffer_type=FIELD_TYPE_LONGLONG;
-  bind[4].buffer= (gptr)&big_data;		
+  bind[4].buffer= (gptr)&big_data;
   /* float */
   bind[5].buffer_type=FIELD_TYPE_DOUBLE;
-  bind[5].buffer= (gptr)&real_data;		
+  bind[5].buffer= (gptr)&real_data;
   /* double */
   bind[6].buffer_type=FIELD_TYPE_DOUBLE;
-  bind[6].buffer= (gptr)&double_data;	
-      
+  bind[6].buffer= (gptr)&double_data;
+
   rc = mysql_bind_param(stmt,bind);
   mystmt(stmt, rc);
 
@@ -807,17 +842,17 @@ void test_prepare(MYSQL *mysql)
 
   /* now fetch the results ..*/
   rc = mysql_commit(mysql);
-  myquery(mysql,rc);
+  myquery(rc);
 
   /* test the results now, only one row should exists */
   rc = mysql_query(mysql,"SELECT * FROM my_prepare");
-  myquery(mysql,rc);
-    
+  myquery(rc);
+
   /* get the result */
   result = mysql_store_result(mysql);
-  mytest(mysql,result);
+  mytest(result);
 
-  assert((int)tiny_data == my_process_result_set(mysql,result));  
+  assert((int)tiny_data == my_process_result_set(result));
   mysql_free_result(result);
 
 }
@@ -825,37 +860,37 @@ void test_prepare(MYSQL *mysql)
 /********************************************************
 * to test double comparision                            *
 *********************************************************/
-void test_double_compare(MYSQL *mysql)
-{  
+void test_double_compare()
+{
   MYSQL_STMT *stmt;
   int        rc,param_count;
   char       query[200],real_data[10], tiny_data;
   double     double_data;
   MYSQL_RES  *result;
-  MYSQL_BIND bind[3];  
+  MYSQL_BIND bind[3];
 
-  myheader("test_double_compare"); 
+  myheader("test_double_compare");
 
   init_bind(bind);
   rc = mysql_autocommit(mysql, true);
-  myquery(mysql,rc);
+  myquery(rc);
+
+  rc = mysql_query(mysql,"DROP TABLE IF EXISTS test_double_compare");
+  myquery(rc);
 
-  rc = mysql_query(mysql,"DROP TABLE IF EXISTS test_double_compare");  
-  myquery(mysql,rc);     
-    
   rc = mysql_commit(mysql);
-  myquery(mysql,rc);
+  myquery(rc);
 
   rc = mysql_query(mysql,"CREATE TABLE test_double_compare(col1 tinyint,\
                                 col2 float, col3 double )");
-  myquery(mysql,rc);  
+  myquery(rc);
 
   rc = mysql_query(mysql,"INSERT INTO test_double_compare VALUES(1,10.2,34.5)");
-  myquery(mysql,rc);  
+  myquery(rc);
 
   strcpy(query, "UPDATE test_double_compare SET col1=100 WHERE col1 = ? AND col2 = ? AND COL3 = ?");
   stmt = mysql_prepare(mysql,query, strlen(query));
-  myxquery(mysql,stmt);   
+  myxquery(stmt);
 
   param_count = mysql_param_count(stmt);
   fprintf(stdout," total parameters in update:%d\n", param_count);
@@ -865,11 +900,12 @@ void test_double_compare(MYSQL *mysql)
   bind[0].buffer=(gptr)&tiny_data;
   /* string->float */
   bind[1].buffer_type=FIELD_TYPE_STRING;
-  bind[1].buffer= (gptr)&real_data;		
+  bind[1].buffer= (gptr)&real_data;
+  bind[1].buffer_length=10;  
   /* double */
   bind[2].buffer_type=FIELD_TYPE_DOUBLE;
-  bind[2].buffer= (gptr)&double_data;	
-      
+  bind[2].buffer= (gptr)&double_data;
+
   tiny_data = 1;
   strcpy(real_data,"10.2");
   double_data = 34.5;
@@ -881,22 +917,22 @@ void test_double_compare(MYSQL *mysql)
 
   rc = (int)mysql_affected_rows(mysql);
   printf("\n total affected rows:%d",rc);
-  
+
   mysql_stmt_close(stmt);
 
   /* now fetch the results ..*/
   rc = mysql_commit(mysql);
-  myquery(mysql,rc);
+  myquery(rc);
 
   /* test the results now, only one row should exists */
   rc = mysql_query(mysql,"SELECT * FROM test_double_compare");
-  myquery(mysql,rc);
-    
+  myquery(rc);
+
   /* get the result */
   result = mysql_store_result(mysql);
-  mytest(mysql,result);
+  mytest(result);
 
-  assert((int)tiny_data == my_process_result_set(mysql,result));  
+  assert((int)tiny_data == my_process_result_set(result));
   mysql_free_result(result);
 
 }
@@ -907,43 +943,43 @@ void test_double_compare(MYSQL *mysql)
 /********************************************************
 * to test simple null                                   *
 *********************************************************/
-void test_null(MYSQL *mysql)
+void test_null()
 {
   MYSQL_STMT *stmt;
   int        rc,param_count;
-  const char *query;
   int        nData=1;
   MYSQL_RES  *result;
-  MYSQL_BIND bind[2];  
+  MYSQL_BIND bind[2];
 
-  myheader("test_null"); 
+  myheader("test_null");
 
   init_bind(bind);
-  rc = mysql_query(mysql,"DROP TABLE IF EXISTS test_null");  
-  myquery(mysql,rc);     
-    
+  rc = mysql_query(mysql,"DROP TABLE IF EXISTS test_null");
+  myquery(rc);
+
   rc = mysql_commit(mysql);
-  myquery(mysql,rc);
+  myquery(rc);
 
   rc = mysql_query(mysql,"CREATE TABLE test_null(col1 int,col2 varchar(50))");
-  myquery(mysql,rc);  
+  myquery(rc);
 
   /* insert by prepare, wrong column name */
-  query = "INSERT INTO test_null(col3,col2) VALUES(?,?)";
+  strcpy(query,"INSERT INTO test_null(col3,col2) VALUES(?,?)");
   stmt = mysql_prepare(mysql, query, strlen(query));
-  myxquery_r(mysql,stmt);   
+  myxquery_r(stmt);
 
-  query = "INSERT INTO test_null(col1,col2) VALUES(?,?)";
+  strcpy(query,"INSERT INTO test_null(col1,col2) VALUES(?,?)");
   stmt = mysql_prepare(mysql, query, strlen(query));
-  myxquery(mysql,stmt);   
+  myxquery(stmt);
 
   param_count = mysql_param_count(stmt);
   fprintf(stdout," total parameters in insert:%d\n", param_count);
   assert(param_count == 2);
 
   bind[0].is_null=1;
-  bind[1].is_null=1;		/* string data */
-      
+  bind[0].buffer_type=MYSQL_TYPE_NULL;
+  bind[1]=bind[0];		/* string data */
+
   rc = mysql_bind_param(stmt,bind);
   mystmt(stmt, rc);
 
@@ -957,19 +993,18 @@ void test_null(MYSQL *mysql)
 
   /* now fetch the results ..*/
   rc = mysql_commit(mysql);
-  myquery(mysql,rc);
+  myquery(rc);
 
   /* test the results now, only one row should exists */
   rc = mysql_query(mysql,"SELECT * FROM test_null");
-  myquery(mysql,rc);
-    
+  myquery(rc);
+
   /* get the result */
   result = mysql_store_result(mysql);
-  mytest(mysql,result);
+  mytest(result);
 
-  assert(nData == my_process_result_set(mysql,result));  
+  assert(nData == my_process_result_set(result));
   mysql_free_result(result);
-
 }
 
 
@@ -977,20 +1012,19 @@ void test_null(MYSQL *mysql)
 /********************************************************
 * to test simple select                                 *
 *********************************************************/
-void test_select_simple(MYSQL *mysql)
+void test_select_simple()
 {
   MYSQL_STMT *stmt;
   int        rc,length;
   const char query[100];
   MYSQL_RES  *result;
 
-  myheader("test_select_simple"); 
-
+  myheader("test_select_simple");
 
   /* insert by prepare */
   strcpy((char *)query, "SHOW TABLES FROM mysql");
   stmt = mysql_prepare(mysql, query, strlen(query));
-  myxquery(mysql,stmt);   
+  myxquery(stmt);
 
   length = mysql_param_count(stmt);
   fprintf(stdout," total parameters in select:%d\n", length);
@@ -998,25 +1032,27 @@ void test_select_simple(MYSQL *mysql)
 
   rc = mysql_execute(stmt);
   mystmt(stmt, rc);
-    
+
   /* get the result */
   result = mysql_store_result(mysql);
-  mytest(mysql,result);
+  mytest(result);
 
-  my_process_result_set(mysql,result);  
+  my_process_result_set(result);
   mysql_free_result(result);
-  
+
+  mysql_stmt_close(stmt);
+
 #if 0
   strcpy((char *)query , "SELECT @@ VERSION");
   length = strlen(query);
   rc = mysql_query(mysql,query);
-  mytest(mysql,rc);
-    
+  myquery(rc);
+
   /* get the result */
   result = mysql_store_result(mysql);
-  mytest(mysql,result);
+  mytest(result);
 
-  my_process_result_set(mysql,result);  
+  my_process_result_set(result);
   mysql_free_result(result);
 #endif
 }
@@ -1025,52 +1061,51 @@ void test_select_simple(MYSQL *mysql)
 /********************************************************
 * to test simple select                                 *
 *********************************************************/
-void test_select(MYSQL *mysql)
+void test_select()
 {
   MYSQL_STMT *stmt;
   int        rc,param_count=0;
-  const char *query;
   char       *szData=(char *)"updated-value";
   int        nData=1;
-  MYSQL_BIND bind[2];  
+  MYSQL_BIND bind[2];
   MYSQL_RES  *result;
-  
 
-  myheader("test_select"); 
+
+  myheader("test_select");
 
   init_bind(bind);
   rc = mysql_autocommit(mysql,true);
-  myquery(mysql,rc);     
+  myquery(rc);
+
+  rc = mysql_query(mysql,"DROP TABLE IF EXISTS test_select");
+  myquery(rc);
 
-  rc = mysql_query(mysql,"DROP TABLE IF EXISTS test_select");  
-  myquery(mysql,rc);     
-    
   rc = mysql_commit(mysql);
-  myquery(mysql,rc);
+  myquery(rc);
 
   rc = mysql_query(mysql,"CREATE TABLE test_select(id int,name varchar(50))");
-  myquery(mysql,rc);  
-    
+  myquery(rc);
+
   rc = mysql_commit(mysql);
-  myquery(mysql,rc);
+  myquery(rc);
 
   /* insert a row and commit the transaction */
   rc = mysql_query(mysql,"INSERT INTO test_select VALUES(10,'venu')");
-  myquery(mysql,rc);  
+  myquery(rc);
 
   rc = mysql_commit(mysql);
-  myquery(mysql,rc);
+  myquery(rc);
 
     /* now insert the second row, and rollback the transaction */
   rc = mysql_query(mysql,"INSERT INTO test_select VALUES(20,'mysql')");
-  myquery(mysql,rc);  
+  myquery(rc);
 
   rc = mysql_commit(mysql);
-  myquery(mysql,rc);
+  myquery(rc);
 
-  query = "SELECT * FROM test_select WHERE id=? AND name=?";
+  strcpy(query,"SELECT * FROM test_select WHERE id=? AND name=?");
   stmt = mysql_prepare(mysql, query, strlen(query));
-  myxquery(mysql,stmt);   
+  myxquery(stmt);
 
   param_count = mysql_param_count(stmt);
   fprintf(stdout," total parameters in select:%d\n", param_count);
@@ -1081,20 +1116,21 @@ void test_select(MYSQL *mysql)
   szData=(char *)"venu";
   bind[1].buffer_type=FIELD_TYPE_STRING;
   bind[1].buffer=szData;
+  bind[1].buffer_length=4;
   bind[0].buffer=(gptr)&nData;
   bind[0].buffer_type=FIELD_TYPE_LONG;
-      
+
   rc = mysql_bind_param(stmt,bind);
   mystmt(stmt, rc);
 
   rc = mysql_execute(stmt);
   mystmt(stmt, rc);
-    
+
   /* get the result */
   result = mysql_store_result(mysql);
-  mytest(mysql,result);
+  mytest(result);
 
-  assert( 1 == my_process_result_set(mysql,result));  
+  assert( 1 == my_process_result_set(result));
   mysql_free_result(result);
 
   mysql_stmt_close(stmt);
@@ -1108,48 +1144,46 @@ void test_select(MYSQL *mysql)
 /********************************************************
 * to test simple update                                *
 *********************************************************/
-void test_simple_update(MYSQL *mysql)
+void test_simple_update()
 {
   MYSQL_STMT *stmt;
   int        rc,param_count;
-  const char *query;
-  char       *szData=(char *)"updated-value";
+  char       szData[25];
   int        nData=1;
   MYSQL_RES  *result;
-  MYSQL_BIND bind[2];  
-  
+  MYSQL_BIND bind[2];   
 
-  myheader("test_simple_update"); 
+  myheader("test_simple_update");
 
   init_bind(bind);
   rc = mysql_autocommit(mysql,true);
-  myquery(mysql,rc);     
+  myquery(rc);
+
+  rc = mysql_query(mysql,"DROP TABLE IF EXISTS test_update");
+  myquery(rc);
 
-  rc = mysql_query(mysql,"DROP TABLE IF EXISTS test_update");  
-  myquery(mysql,rc);     
-    
   rc = mysql_commit(mysql);
-  myquery(mysql,rc);
+  myquery(rc);
 
   rc = mysql_query(mysql,"CREATE TABLE test_update(col1 int,\
                                 col2 varchar(50), col3 int )");
-  myquery(mysql,rc);  
-    
+  myquery(rc);
+
   rc = mysql_commit(mysql);
-  myquery(mysql,rc);
+  myquery(rc);
 
   rc = mysql_query(mysql,"INSERT INTO test_update VALUES(1,'MySQL',100)");
-  myquery(mysql,rc);  
-  
+  myquery(rc);
+
   assert(1 == mysql_affected_rows(mysql));
 
   rc = mysql_commit(mysql);
-  myquery(mysql,rc);
+  myquery(rc);
 
   /* insert by prepare */
-  query = "UPDATE test_update SET col2=? WHERE col1=?";
+  strcpy(query,"UPDATE test_update SET col2=? WHERE col1=?");
   stmt = mysql_prepare(mysql, query, strlen(query));
-  myxquery(mysql,stmt);   
+  myxquery(stmt);
 
   param_count = mysql_param_count(stmt);
   fprintf(stdout," total parameters in update:%d\n", param_count);
@@ -1158,9 +1192,10 @@ void test_simple_update(MYSQL *mysql)
   nData=1;
   bind[0].buffer_type=FIELD_TYPE_STRING;
   bind[0].buffer=szData;		/* string data */
+  bind[0].buffer_length=sprintf(szData,"updated-data");
   bind[1].buffer=(gptr)&nData;
   bind[1].buffer_type=FIELD_TYPE_LONG;
-      
+
   rc = mysql_bind_param(stmt,bind);
   mystmt(stmt, rc);
 
@@ -1172,17 +1207,17 @@ void test_simple_update(MYSQL *mysql)
 
   /* now fetch the results ..*/
   rc = mysql_commit(mysql);
-  myquery(mysql,rc);
+  myquery(rc);
 
   /* test the results now, only one row should exists */
   rc = mysql_query(mysql,"SELECT * FROM test_update");
-  myquery(mysql,rc);
-    
+  myquery(rc);
+
   /* get the result */
   result = mysql_store_result(mysql);
-  mytest(mysql,result);
+  mytest(result);
 
-  assert(1 == my_process_result_set(mysql,result));  
+  assert(1 == my_process_result_set(result));
   mysql_free_result(result);
 }
 
@@ -1190,53 +1225,58 @@ void test_simple_update(MYSQL *mysql)
 /********************************************************
 * to test simple long data handling                     *
 *********************************************************/
-void test_long_data(MYSQL *mysql)
+void test_long_data()
 {
   MYSQL_STMT *stmt;
-  int        rc,param_count;
-  const char *query;
+  int        rc,param_count, int_data=10;
   char       *data=NullS;
   MYSQL_RES  *result;
-  MYSQL_BIND bind[2];  
-  
+  MYSQL_BIND bind[3];
 
-  myheader("test_long_data"); 
+
+  myheader("test_long_data");
 
   init_bind(bind);
   rc = mysql_autocommit(mysql,true);
-  myquery(mysql,rc);     
+  myquery(rc);
+
+  rc = mysql_query(mysql,"DROP TABLE IF EXISTS test_long_data");
+  myquery(rc);
 
-  rc = mysql_query(mysql,"DROP TABLE IF EXISTS test_long_data");  
-  myquery(mysql,rc);     
-    
   rc = mysql_commit(mysql);
-  myquery(mysql,rc);
+  myquery(rc);
 
   rc = mysql_query(mysql,"CREATE TABLE test_long_data(col1 int,\
                                 col2 long varchar, col3 long varbinary)");
-  myquery(mysql,rc);  
-    
+  myquery(rc);
+
   rc = mysql_commit(mysql);
-  myquery(mysql,rc);
+  myquery(rc);
+
+  strcpy(query,"INSERT INTO test_long_data(col1,col2) VALUES(?)");
+  stmt = mysql_prepare(mysql, query, strlen(query));
+  myxquery_r(stmt);
 
-  query = "INSERT INTO test_long_data(col2) VALUES(?)";
+  strcpy(query,"INSERT INTO test_long_data(col1,col2,col3) VALUES(?,?,?)");
   stmt = mysql_prepare(mysql, query, strlen(query));
-  myxquery(mysql,stmt);     
+  myxquery(stmt);
 
   param_count = mysql_param_count(stmt);
   fprintf(stdout," total parameters in insert:%d\n", param_count);
-  assert(param_count == 1);
+  assert(param_count == 3);
 
-  bind[0].buffer=data;		  /* string data */
-  bind[0].is_long_data=1;   /* specify long data suppy during run-time */
+  bind[0].buffer=(char *)&int_data;
+  bind[0].buffer_type=FIELD_TYPE_LONG;
+  bind[1].is_long_data=1;   /* specify long data suppy during run-time */
 
   /* Non string or binary type, error */
-  bind[0].buffer_type=FIELD_TYPE_LONG;
+  bind[1].buffer_type=FIELD_TYPE_LONG;
   rc = mysql_bind_param(stmt,bind);
   fprintf(stdout,"mysql_bind_param() returned %d\n",rc);
   mystmt_r(stmt, rc);
-  
-  bind[0].buffer_type=FIELD_TYPE_STRING;
+
+  bind[1].buffer_type=FIELD_TYPE_STRING;
+  bind[2]=bind[1];
   rc = mysql_bind_param(stmt,bind);
   mystmt(stmt, rc);
 
@@ -1247,11 +1287,11 @@ void test_long_data(MYSQL *mysql)
   data = (char *)"Micheal";
 
   /* supply data in pieces */
-  rc = mysql_send_long_data(stmt,0,data,7,1);
+  rc = mysql_send_long_data(stmt,1,data,7,1);
   mystmt(stmt, rc);
 
-  /* try to execute mysql_execute() now, it should return 
-     MYSQL_NEED_DATA as the long data supply is not yet over 
+  /* try to execute mysql_execute() now, it should return
+     MYSQL_NEED_DATA as the long data supply is not yet over
   */
   rc = mysql_execute(stmt);
   fprintf(stdout,"mysql_execute() returned %d\n",rc);
@@ -1259,13 +1299,12 @@ void test_long_data(MYSQL *mysql)
 
   /* append data again ..*/
 
-  /* supply data in pieces */
+  /* Indicate end of data */
   data = (char *)" 'monty' widenius";
-  rc = mysql_send_long_data(stmt,0,data,17,0);
+  rc = mysql_send_long_data(stmt,1,data,17,1);
   mystmt(stmt, rc);
 
-  /* Indiate end of data supply */
-  rc = mysql_send_long_data(stmt,0,0,0,1);
+  rc = mysql_send_long_data(stmt,2,"Venu (venu@mysql.com",4,1);
   mystmt(stmt, rc);
 
   /* execute */
@@ -1274,55 +1313,54 @@ void test_long_data(MYSQL *mysql)
   mystmt(stmt,rc);
 
   rc = mysql_commit(mysql);
-  myquery(mysql,rc);
+  myquery(rc);
 
   /* now fetch the results ..*/
-  rc = mysql_query(mysql,"SELECT col2 FROM test_long_data");
-  myquery(mysql,rc);
-    
+  rc = mysql_query(mysql,"SELECT * FROM test_long_data");
+  myquery(rc);
+
   /* get the result */
   result = mysql_store_result(mysql);
-  mytest(mysql,result);
+  mytest(result);
 
-  assert(1 == my_process_result_set(mysql,result));  
+  assert(1 == my_process_result_set(result));
   mysql_free_result(result);
 }
 
 /********************************************************
 * to test long data (string) handling                   *
 *********************************************************/
-void test_long_data_str(MYSQL *mysql)
+void test_long_data_str()
 {
   MYSQL_STMT *stmt;
   int        rc,param_count;
-  const char *query;
   char       data[255];
   long       length;
   MYSQL_RES  *result;
-  MYSQL_BIND bind[2];  
-  
+  MYSQL_BIND bind[2];
+
 
-  myheader("test_long_data_str"); 
+  myheader("test_long_data_str");
 
   init_bind(bind);
   rc = mysql_autocommit(mysql,true);
-  myquery(mysql,rc);     
+  myquery(rc);
+
+  rc = mysql_query(mysql,"DROP TABLE IF EXISTS test_long_data_str");
+  myquery(rc);
 
-  rc = mysql_query(mysql,"DROP TABLE IF EXISTS test_long_data_str");  
-  myquery(mysql,rc);     
-    
   rc = mysql_commit(mysql);
-  myquery(mysql,rc);
+  myquery(rc);
 
   rc = mysql_query(mysql,"CREATE TABLE test_long_data_str(id int, longstr long varchar)");
-  myquery(mysql,rc);  
-    
+  myquery(rc);
+
   rc = mysql_commit(mysql);
-  myquery(mysql,rc);
+  myquery(rc);
 
-  query = "INSERT INTO test_long_data_str VALUES(?,?)";
+  strcpy(query,"INSERT INTO test_long_data_str VALUES(?,?)");
   stmt = mysql_prepare(mysql, query, strlen(query));
-  myxquery(mysql,stmt);     
+  myxquery(stmt);
 
   param_count = mysql_param_count(stmt);
   fprintf(stdout," total parameters in insert:%d\n", param_count);
@@ -1354,8 +1392,8 @@ void test_long_data_str(MYSQL *mysql)
       mystmt(stmt, rc);
     }
 
-    /* try to execute mysql_execute() now, it should return 
-       MYSQL_NEED_DATA as the long data supply is not yet over 
+    /* try to execute mysql_execute() now, it should return
+       MYSQL_NEED_DATA as the long data supply is not yet over
     */
     rc = mysql_execute(stmt);
     fprintf(stdout,"mysql_execute() returned %d\n",rc);
@@ -1374,17 +1412,17 @@ void test_long_data_str(MYSQL *mysql)
   mysql_stmt_close(stmt);
 
   rc = mysql_commit(mysql);
-  myquery(mysql,rc);
+  myquery(rc);
 
   /* now fetch the results ..*/
   rc = mysql_query(mysql,"SELECT LENGTH(longstr), longstr FROM test_long_data_str");
-  myquery(mysql,rc);
-    
+  myquery(rc);
+
   /* get the result */
   result = mysql_store_result(mysql);
-  mytest(mysql,result);
+  mytest(result);
 
-  assert(1 == my_process_result_set(mysql,result));  
+  assert(1 == my_process_result_set(result));
   mysql_free_result(result);
 }
 
@@ -1392,38 +1430,37 @@ void test_long_data_str(MYSQL *mysql)
 /********************************************************
 * to test long data (string) handling                   *
 *********************************************************/
-void test_long_data_str1(MYSQL *mysql)
+void test_long_data_str1()
 {
   MYSQL_STMT *stmt;
   int        rc,param_count;
-  const char *query;
   char       *data=(char *)"MySQL AB";
   int        length;
   MYSQL_RES  *result;
-  MYSQL_BIND bind[2];  
-  
+  MYSQL_BIND bind[2];
+
 
-  myheader("test_long_data_str1"); 
+  myheader("test_long_data_str1");
 
   init_bind(bind);
   rc = mysql_autocommit(mysql,true);
-  myquery(mysql,rc);     
+  myquery(rc);
+
+  rc = mysql_query(mysql,"DROP TABLE IF EXISTS test_long_data_str");
+  myquery(rc);
 
-  rc = mysql_query(mysql,"DROP TABLE IF EXISTS test_long_data_str");  
-  myquery(mysql,rc);     
-    
   rc = mysql_commit(mysql);
-  myquery(mysql,rc);
+  myquery(rc);
 
   rc = mysql_query(mysql,"CREATE TABLE test_long_data_str(longstr long varchar,blb long varbinary)");
-  myquery(mysql,rc);  
-    
+  myquery(rc);
+
   rc = mysql_commit(mysql);
-  myquery(mysql,rc);
+  myquery(rc);
 
-  query = "INSERT INTO test_long_data_str VALUES(?,?)";
+  strcpy(query,"INSERT INTO test_long_data_str VALUES(?,?)");
   stmt = mysql_prepare(mysql, query, strlen(query));
-  myxquery(mysql,stmt);     
+  myxquery(stmt);
 
   param_count = mysql_param_count(stmt);
   fprintf(stdout," total parameters in insert:%d\n", param_count);
@@ -1457,8 +1494,8 @@ void test_long_data_str1(MYSQL *mysql)
       rc = mysql_send_long_data(stmt,1,data,2,0);
       mystmt(stmt, rc);
     }
-    /* try to execute mysql_execute() now, it should return 
-       MYSQL_NEED_DATA as the long data supply is not yet over 
+    /* try to execute mysql_execute() now, it should return
+       MYSQL_NEED_DATA as the long data supply is not yet over
     */
     rc = mysql_execute(stmt);
     fprintf(stdout,"mysql_execute() returned %d\n",rc);
@@ -1468,14 +1505,14 @@ void test_long_data_str1(MYSQL *mysql)
   /* Indiate end of data supply */
   rc = mysql_send_long_data(stmt,1,0,0,1);
   mystmt(stmt, rc);
-  
+
   rc = mysql_execute(stmt);
   fprintf(stdout,"mysql_execute() returned %d\n",rc);
   assert(rc == MYSQL_NEED_DATA);
 
   rc = mysql_send_long_data(stmt,0,0,0,1);
   mystmt(stmt, rc);
-  
+
   /* execute */
   rc = mysql_execute(stmt);
   fprintf(stdout,"mysql_execute() returned %d\n",rc);
@@ -1484,17 +1521,17 @@ void test_long_data_str1(MYSQL *mysql)
   mysql_stmt_close(stmt);
 
   rc = mysql_commit(mysql);
-  myquery(mysql,rc);
+  myquery(rc);
 
   /* now fetch the results ..*/
   rc = mysql_query(mysql,"SELECT LENGTH(longstr),longstr,LENGTH(blb),blb FROM test_long_data_str");
-  myquery(mysql,rc);
-    
+  myquery(rc);
+
   /* get the result */
   result = mysql_store_result(mysql);
-  mytest(mysql,result);
+  mytest(result);
 
-  assert(1 == my_process_result_set(mysql,result));  
+  assert(1 == my_process_result_set(result));
   mysql_free_result(result);
 }
 
@@ -1502,38 +1539,37 @@ void test_long_data_str1(MYSQL *mysql)
 /********************************************************
 * to test long data (binary) handling                   *
 *********************************************************/
-void test_long_data_bin(MYSQL *mysql)
+void test_long_data_bin()
 {
   MYSQL_STMT *stmt;
   int        rc,param_count;
-  const char *query;
   char       data[255];
   int        length;
   MYSQL_RES  *result;
-  MYSQL_BIND bind[2];  
-  
+  MYSQL_BIND bind[2];
+
 
-  myheader("test_long_data_bin"); 
+  myheader("test_long_data_bin");
 
   init_bind(bind);
   rc = mysql_autocommit(mysql,true);
-  myquery(mysql,rc);     
+  myquery(rc);
+
+  rc = mysql_query(mysql,"DROP TABLE IF EXISTS test_long_data_bin");
+  myquery(rc);
 
-  rc = mysql_query(mysql,"DROP TABLE IF EXISTS test_long_data_bin");  
-  myquery(mysql,rc);     
-    
   rc = mysql_commit(mysql);
-  myquery(mysql,rc);
+  myquery(rc);
 
   rc = mysql_query(mysql,"CREATE TABLE test_long_data_bin(id int, longbin long varbinary)");
-  myquery(mysql,rc);  
-    
+  myquery(rc);
+
   rc = mysql_commit(mysql);
-  myquery(mysql,rc);
+  myquery(rc);
 
-  query = "INSERT INTO test_long_data_bin VALUES(?,?)";
+  strcpy(query,"INSERT INTO test_long_data_bin VALUES(?,?)");
   stmt = mysql_prepare(mysql, query, strlen(query));
-  myxquery(mysql,stmt);     
+  myxquery(stmt);
 
   param_count = mysql_param_count(stmt);
   fprintf(stdout," total parameters in insert:%d\n", param_count);
@@ -1564,8 +1600,8 @@ void test_long_data_bin(MYSQL *mysql)
       mystmt(stmt, rc);
     }
 
-    /* try to execute mysql_execute() now, it should return 
-       MYSQL_NEED_DATA as the long data supply is not yet over 
+    /* try to execute mysql_execute() now, it should return
+       MYSQL_NEED_DATA as the long data supply is not yet over
     */
     rc = mysql_execute(stmt);
     fprintf(stdout,"mysql_execute() returned %d\n",rc);
@@ -1584,17 +1620,17 @@ void test_long_data_bin(MYSQL *mysql)
   mysql_stmt_close(stmt);
 
   rc = mysql_commit(mysql);
-  myquery(mysql,rc);
+  myquery(rc);
 
   /* now fetch the results ..*/
   rc = mysql_query(mysql,"SELECT LENGTH(longbin), longbin FROM test_long_data_bin");
-  myquery(mysql,rc);
-    
+  myquery(rc);
+
   /* get the result */
   result = mysql_store_result(mysql);
-  mytest(mysql,result);
+  mytest(result);
 
-  assert(1 == my_process_result_set(mysql,result));  
+  assert(1 == my_process_result_set(result));
   mysql_free_result(result);
 }
 
@@ -1602,65 +1638,63 @@ void test_long_data_bin(MYSQL *mysql)
 /********************************************************
 * to test simple delete                                 *
 *********************************************************/
-void test_simple_delete(MYSQL *mysql)
+void test_simple_delete()
 {
   MYSQL_STMT *stmt;
   int        rc,param_count;
-  const char *query;
   char       szData[30]={0};
   int        nData=1;
   MYSQL_RES  *result;
-  MYSQL_BIND bind[2];  
-  
+  MYSQL_BIND bind[2];
 
-  myheader("test_simple_delete"); 
+
+  myheader("test_simple_delete");
 
   init_bind(bind);
   rc = mysql_autocommit(mysql,true);
-  myquery(mysql,rc);     
+  myquery(rc);
+
+  rc = mysql_query(mysql,"DROP TABLE IF EXISTS test_simple_delete");
+  myquery(rc);
 
-  rc = mysql_query(mysql,"DROP TABLE IF EXISTS test_simple_delete");  
-  myquery(mysql,rc);     
-    
   rc = mysql_commit(mysql);
-  myquery(mysql,rc);
+  myquery(rc);
 
   rc = mysql_query(mysql,"CREATE TABLE test_simple_delete(col1 int,\
                                 col2 varchar(50), col3 int )");
-  myquery(mysql,rc);  
-    
+  myquery(rc);
+
   rc = mysql_commit(mysql);
-  myquery(mysql,rc);
+  myquery(rc);
 
   rc = mysql_query(mysql,"INSERT INTO test_simple_delete VALUES(1,'MySQL',100)");
-  myquery(mysql,rc);  
-  
+  myquery(rc);
+
   assert(1 == mysql_affected_rows(mysql));
 
   rc = mysql_commit(mysql);
-  myquery(mysql,rc);
+  myquery(rc);
 
   /* insert by prepare */
-  query = "DELETE FROM test_simple_delete WHERE col1=? AND col2=? AND col3=100";
+  strcpy(query,"DELETE FROM test_simple_delete WHERE col1=? AND col2=? AND col3=100");
   stmt = mysql_prepare(mysql, query, strlen(query));
-  myxquery(mysql,stmt);   
+  myxquery(stmt);
 
   param_count = mysql_param_count(stmt);
   fprintf(stdout," total parameters in delete:%d\n", param_count);
   assert(param_count == 2);
 
   nData=1;
+  strcpy(szData,"MySQL");
+  bind[1].buffer_length = 5;
   bind[1].buffer_type=FIELD_TYPE_STRING;
-  bind[1].buffer=szData;		/* string data */  
+  bind[1].buffer=szData;		/* string data */
   bind[0].buffer=(gptr)&nData;
   bind[0].buffer_type=FIELD_TYPE_LONG;
-      
+
   rc = mysql_bind_param(stmt,bind);
   mystmt(stmt, rc);
 
-  strcpy(szData,"MySQL");
-  //bind[1].buffer_length = 5;
-  nData=1;
   rc = mysql_execute(stmt);
   mystmt(stmt, rc);
   assert(1 == mysql_affected_rows(mysql));
@@ -1669,17 +1703,17 @@ void test_simple_delete(MYSQL *mysql)
 
   /* now fetch the results ..*/
   rc = mysql_commit(mysql);
-  myquery(mysql,rc);
+  myquery(rc);
 
   /* test the results now, only one row should exists */
   rc = mysql_query(mysql,"SELECT * FROM test_simple_delete");
-  myquery(mysql,rc);
-    
+  myquery(rc);
+
   /* get the result */
   result = mysql_store_result(mysql);
-  mytest(mysql,result);
+  mytest(result);
 
-  assert(0 == my_process_result_set(mysql,result));  
+  assert(0 == my_process_result_set(result));
   mysql_free_result(result);
 }
 
@@ -1688,78 +1722,76 @@ void test_simple_delete(MYSQL *mysql)
 /********************************************************
 * to test simple update                                 *
 *********************************************************/
-void test_update(MYSQL *mysql)
+void test_update()
 {
   MYSQL_STMT *stmt;
   int        rc,param_count;
-  const char *query;
-  char       *szData=(char *)"updated-value";
+  char       szData[25];
   int        nData=1;
   MYSQL_RES  *result;
-  MYSQL_BIND bind[2];  
-  
+  MYSQL_BIND bind[2];
+
 
-  myheader("test_update"); 
+  myheader("test_update");
 
   init_bind(bind);
   rc = mysql_autocommit(mysql,true);
-  myquery(mysql,rc);     
+  myquery(rc);
+
+  rc = mysql_query(mysql,"DROP TABLE IF EXISTS test_update");
+  myquery(rc);
 
-  rc = mysql_query(mysql,"DROP TABLE IF EXISTS test_update");  
-  myquery(mysql,rc);     
-    
   rc = mysql_commit(mysql);
-  myquery(mysql,rc);
+  myquery(rc);
 
   rc = mysql_query(mysql,"CREATE TABLE test_update(col1 int primary key auto_increment,\
                                 col2 varchar(50), col3 int )");
-  myquery(mysql,rc);  
-    
+  myquery(rc);
+
   rc = mysql_commit(mysql);
-  myquery(mysql,rc);
+  myquery(rc);
 
-  query = "INSERT INTO test_update(col2,col3) VALUES(?,?)";
+  strcpy(query,"INSERT INTO test_update(col2,col3) VALUES(?,?)");
   stmt = mysql_prepare(mysql, query, strlen(query));
-  myxquery(mysql,stmt);   
+  myxquery(stmt);
 
   param_count = mysql_param_count(stmt);
   fprintf(stdout," total parameters in insert:%d\n", param_count);
   assert(param_count == 2);
 
   /* string data */
-  szData=(char *)"inserted-data";
   bind[0].buffer_type=FIELD_TYPE_STRING;
   bind[0].buffer=szData;
+  bind[0].buffer_length=sprintf(szData,"inserted-data");
   bind[1].buffer=(gptr)&nData;
   bind[1].buffer_type=FIELD_TYPE_LONG;
-      
+
   rc = mysql_bind_param(stmt,bind);
   mystmt(stmt, rc);
 
   nData=100;
   rc = mysql_execute(stmt);
   mystmt(stmt, rc);
-  
+
   assert(1 == mysql_affected_rows(mysql));
   mysql_stmt_close(stmt);
 
-  /* insert by prepare */
-  query = "UPDATE test_update SET col2=? WHERE col3=?";
+  strcpy(query,"UPDATE test_update SET col2=? WHERE col3=?");
   stmt = mysql_prepare(mysql, query, strlen(query));
-  myxquery(mysql,stmt);   
+  myxquery(stmt);
 
   param_count = mysql_param_count(stmt);
   fprintf(stdout," total parameters in update:%d\n", param_count);
   assert(param_count == 2);
-  nData=100;szData=(char *)"updated-data";
+  nData=100;
+
 
-  
   bind[0].buffer_type=FIELD_TYPE_STRING;
   bind[0].buffer=szData;
+  bind[0].buffer_length=sprintf(szData,"updated-data");
   bind[1].buffer=(gptr)&nData;
   bind[1].buffer_type=FIELD_TYPE_LONG;
 
-      
   rc = mysql_bind_param(stmt,bind);
   mystmt(stmt, rc);
 
@@ -1771,17 +1803,17 @@ void test_update(MYSQL *mysql)
 
   /* now fetch the results ..*/
   rc = mysql_commit(mysql);
-  myquery(mysql,rc);
+  myquery(rc);
 
   /* test the results now, only one row should exists */
   rc = mysql_query(mysql,"SELECT * FROM test_update");
-  myquery(mysql,rc);
-    
+  myquery(rc);
+
   /* get the result */
   result = mysql_store_result(mysql);
-  mytest(mysql,result);
+  mytest(result);
 
-  assert(1 == my_process_result_set(mysql,result));  
+  assert(1 == my_process_result_set(result));
   mysql_free_result(result);
 }
 
@@ -1789,29 +1821,28 @@ void test_update(MYSQL *mysql)
 /********************************************************
 * to test simple prepare                                *
 *********************************************************/
-void test_init_prepare(MYSQL *mysql)
+void test_init_prepare()
 {
   MYSQL_STMT *stmt;
   int        param_count, rc;
-  const char *query;
   MYSQL_RES  *result;
 
-  myheader("test_init_prepare"); 
-  
-  rc = mysql_query(mysql,"DROP TABLE IF EXISTS my_prepare");  
-  myquery(mysql,rc);     
-    
+  myheader("test_init_prepare");
+
+  rc = mysql_query(mysql,"DROP TABLE IF EXISTS my_prepare");
+  myquery(rc);
+
   rc = mysql_commit(mysql);
-  myquery(mysql,rc);
+  myquery(rc);
 
   rc = mysql_query(mysql,"CREATE TABLE my_prepare(col1 int ,col2 varchar(50))");
-  myquery(mysql,rc);  
-  
- 
+  myquery(rc);
+
+
   /* insert by prepare */
-  query = "INSERT INTO my_prepare VALUES(10,'venu')";
+  strcpy(query,"INSERT INTO my_prepare VALUES(10,'venu')");
   stmt = mysql_prepare(mysql, query, strlen(query));
-  myxquery(mysql,stmt);   
+  myxquery(stmt);
 
   param_count = mysql_param_count(stmt);
   fprintf(stdout," total parameters in insert:%d\n", param_count);
@@ -1824,17 +1855,17 @@ void test_init_prepare(MYSQL *mysql)
 
   /* now fetch the results ..*/
   rc = mysql_commit(mysql);
-  myquery(mysql,rc);
+  myquery(rc);
 
   /* test the results now, only one row should exists */
   rc = mysql_query(mysql,"SELECT * FROM my_prepare");
-  myquery(mysql,rc);
-    
+  myquery(rc);
+
   /* get the result */
   result = mysql_store_result(mysql);
-  mytest(mysql,result);
+  mytest(result);
 
-  assert(1 == my_process_result_set(mysql,result));  
+  assert(1 == my_process_result_set(result));
   mysql_free_result(result);
 }
 
@@ -1842,55 +1873,56 @@ void test_init_prepare(MYSQL *mysql)
 /********************************************************
 * to test simple bind result                            *
 *********************************************************/
-void test_bind_result(MYSQL *mysql)
+void test_bind_result()
 {
   MYSQL_STMT *stmt;
   int        rc;
   const char query[100];
   int        nData;
   char       szData[100];
-  MYSQL_BIND bind[2];  
+  MYSQL_BIND bind[2];
 
   myheader("test_bind_result");
 
   init_bind(bind);
-  rc = mysql_query(mysql,"DROP TABLE IF EXISTS test_bind_result");  
-  myquery(mysql,rc);     
-    
+  rc = mysql_query(mysql,"DROP TABLE IF EXISTS test_bind_result");
+  myquery(rc);
+
   rc = mysql_commit(mysql);
-  myquery(mysql,rc);
+  myquery(rc);
 
   rc = mysql_query(mysql,"CREATE TABLE test_bind_result(col1 int ,col2 varchar(50))");
-  myquery(mysql,rc);       
-    
+  myquery(rc);
+
   rc = mysql_commit(mysql);
-  myquery(mysql,rc);
+  myquery(rc);
 
   rc = mysql_query(mysql,"INSERT INTO test_bind_result VALUES(10,'venu')");
-  myquery(mysql,rc);  
+  myquery(rc);
 
   rc = mysql_query(mysql,"INSERT INTO test_bind_result VALUES(20,'MySQL')");
-  myquery(mysql,rc);  
-    
+  myquery(rc);
+
   rc = mysql_commit(mysql);
-  myquery(mysql,rc);
+  myquery(rc);
 
-  /* fetch */   
+  /* fetch */
 
   bind[0].buffer_type=FIELD_TYPE_LONG;
   bind[0].buffer= (gptr) &nData;	/* integer data */
   bind[1].buffer_type=FIELD_TYPE_STRING;
   bind[1].buffer=szData;		/* string data */
-  
+  bind[1].buffer_length=sizeof(szData);
+
   strcpy((char *)query , "SELECT * FROM test_bind_result");
   stmt = mysql_prepare(mysql, query, strlen(query));
-  myxquery(mysql,stmt);   
-  
+  myxquery(stmt);
+
   rc = mysql_bind_result(stmt,bind);
-  mystmt(stmt, rc);  
+  mystmt(stmt, rc);
 
   rc = mysql_execute(stmt);
-  mystmt(stmt, rc); 
+  mystmt(stmt, rc);
 
   rc = mysql_fetch(stmt);
   mystmt(stmt,rc);
@@ -1915,30 +1947,29 @@ void test_bind_result(MYSQL *mysql)
 /********************************************************
 * to test simple prepare with all possible types        *
 *********************************************************/
-void test_prepare_ext(MYSQL *mysql)
+void test_prepare_ext()
 {
   MYSQL_STMT *stmt;
   int        rc,param_count;
-  char       *query;
+  char       *sql;
   int        nData=1;
   MYSQL_RES  *result;
   char       tData=1;
   short      sData=10;
   longlong   bData=20;
-  MYSQL_BIND bind_int[6];   
+  MYSQL_BIND bind_int[6];
 
+  myheader("test_prepare_ext");
 
-  myheader("test_prepare_ext"); 
-  
   init_bind(bind_int);
 
-  rc = mysql_query(mysql,"DROP TABLE IF EXISTS test_prepare_ext");  
-  myquery(mysql,rc);     
-    
+  rc = mysql_query(mysql,"DROP TABLE IF EXISTS test_prepare_ext");
+  myquery(rc);
+
   rc = mysql_commit(mysql);
-  myquery(mysql,rc);
+  myquery(rc);
 
-  query = (char *)"CREATE TABLE test_prepare_ext\
+  sql = (char *)"CREATE TABLE test_prepare_ext\
 			(\
 			c1  tinyint,\
 			c2  smallint,\
@@ -1973,13 +2004,13 @@ void test_prepare_ext(MYSQL *mysql)
 			c31 enum('one','two','three'),\
 			c32 set('monday','tuesday','wednesday'))";
 
-  rc = mysql_query(mysql,query);
-  myquery(mysql,rc);  
+  rc = mysql_query(mysql,sql);
+  myquery(rc);
 
   /* insert by prepare - all integers */
-  query = (char *)"INSERT INTO test_prepare_ext(c1,c2,c3,c4,c5,c6) VALUES(?,?,?,?,?,?)";
+  strcpy(query,(char *)"INSERT INTO test_prepare_ext(c1,c2,c3,c4,c5,c6) VALUES(?,?,?,?,?,?)");
   stmt = mysql_prepare(mysql,query, strlen(query));
-  myquery(mysql,rc);  
+  myquery(rc);
 
   param_count = mysql_param_count(stmt);
   fprintf(stdout," total parameters in insert:%d\n", param_count);
@@ -2008,7 +2039,7 @@ void test_prepare_ext(MYSQL *mysql)
   /*bigint*/
   bind_int[5].buffer_type=FIELD_TYPE_LONGLONG;
   bind_int[5].buffer= (void *)&bData;
-  
+
   rc = mysql_bind_param(stmt,bind_int);
   mystmt(stmt, rc);
 
@@ -2024,17 +2055,17 @@ void test_prepare_ext(MYSQL *mysql)
 
   /* now fetch the results ..*/
   rc = mysql_commit(mysql);
-  myquery(mysql,rc);
+  myquery(rc);
 
   /* test the results now, only one row should exists */
   rc = mysql_query(mysql,"SELECT c1,c2,c3,c4,c5,c6 FROM test_prepare_ext");
-  myquery(mysql,rc);
-    
+  myquery(rc);
+
   /* get the result */
   result = mysql_store_result(mysql);
-  mytest(mysql,result);
+  mytest(result);
 
-  assert(nData == my_process_result_set(mysql,result));  
+  assert(nData == my_process_result_set(result));
   mysql_free_result(result);
 }
 
@@ -2044,93 +2075,93 @@ void test_prepare_ext(MYSQL *mysql)
 /********************************************************
 * to test real and alias names                          *
 *********************************************************/
-void test_field_names(MYSQL *mysql)
+void test_field_names()
 {
   int        rc;
   MYSQL_RES  *result;
-  
-  myheader("test_field_names"); 
+
+  myheader("test_field_names");
 
   printf("\n%d,%d,%d",MYSQL_TYPE_DECIMAL,MYSQL_TYPE_NEWDATE,MYSQL_TYPE_ENUM);
-  rc = mysql_query(mysql,"DROP TABLE IF EXISTS test_field_names1");  
-  myquery(mysql,rc);     
+  rc = mysql_query(mysql,"DROP TABLE IF EXISTS test_field_names1");
+  myquery(rc);
+
+  rc = mysql_query(mysql,"DROP TABLE IF EXISTS test_field_names2");
+  myquery(rc);
 
-  rc = mysql_query(mysql,"DROP TABLE IF EXISTS test_field_names2");  
-  myquery(mysql,rc);     
-    
   rc = mysql_commit(mysql);
-  myquery(mysql,rc);
+  myquery(rc);
 
   rc = mysql_query(mysql,"CREATE TABLE test_field_names1(id int,name varchar(50))");
-  myquery(mysql,rc);   
+  myquery(rc);
 
   rc = mysql_query(mysql,"CREATE TABLE test_field_names2(id int,name varchar(50))");
-  myquery(mysql,rc);     
-    
+  myquery(rc);
+
   rc = mysql_commit(mysql);
-  myquery(mysql,rc);
-    
+  myquery(rc);
+
   /* with table name included with true column name */
   rc = mysql_query(mysql,"SELECT id as 'id-alias' FROM test_field_names1");
-  myquery(mysql,rc);
-    
+  myquery(rc);
+
   result = mysql_use_result(mysql);
-  mytest(mysql,result);
+  mytest(result);
 
-  assert(0 == my_process_result_set(mysql,result));  
-  mysql_free_result(result);  
+  assert(0 == my_process_result_set(result));
+  mysql_free_result(result);
 
   /* with table name included with true column name */
   rc = mysql_query(mysql,"SELECT t1.id as 'id-alias',test_field_names2.name FROM test_field_names1 t1,test_field_names2");
-  myquery(mysql,rc);
-    
+  myquery(rc);
+
   result = mysql_use_result(mysql);
-  mytest(mysql,result);
+  mytest(result);
 
-  assert(0 == my_process_result_set(mysql,result));  
+  assert(0 == my_process_result_set(result));
   mysql_free_result(result);
 }
 
 /********************************************************
 * to test warnings                                      *
 *********************************************************/
-void test_warnings(MYSQL *mysql)
+void test_warnings()
 {
   int        rc;
   MYSQL_RES  *result;
-  
-  myheader("test_warnings"); 
 
-  rc = mysql_query(mysql,"USE test");  
-  myquery(mysql,rc);     
-  
-  rc = mysql_query(mysql,"SHOW WARNINGS");  
-  myquery(mysql,rc);     
-    
+  myheader("test_warnings");
+
+  rc = mysql_query(mysql,"USE test");
+  myquery(rc);
+
+  rc = mysql_query(mysql,"SHOW WARNINGS");
+  myquery(rc);
+
   result = mysql_use_result(mysql);
-  mytest(mysql,result);
+  mytest(result);
 
-  my_process_result_set(mysql,result);  
+  my_process_result_set(result);
   mysql_free_result(result);
 }
 
 /********************************************************
 * to test errors                                        *
 *********************************************************/
-void test_errors(MYSQL *mysql)
+void test_errors()
 {
   int        rc;
   MYSQL_RES  *result;
-  
-  myheader("test_errors"); 
-  
-  rc = mysql_query(mysql,"SHOW ERRORS");  
-  myquery(mysql,rc);     
-    
+
+  myheader("test_errors");
+
+  rc = mysql_query(mysql,"SHOW ERRORS");
+  myquery(rc);
+
   result = mysql_use_result(mysql);
-  mytest(mysql,result);
+  mytest(result);
 
-  my_process_result_set(mysql,result);  
+  my_process_result_set(result);
   mysql_free_result(result);
 }
 
@@ -2139,36 +2170,36 @@ void test_errors(MYSQL *mysql)
 /********************************************************
 * to test simple prepare-insert                         *
 *********************************************************/
-void test_insert(MYSQL *mysql)
-{  
+void test_insert()
+{
   MYSQL_STMT *stmt;
-  int        rc,param_count;
+  int        rc,param_count, length;
   char       query[200];
   char       str_data[50];
   char       tiny_data;
   MYSQL_RES  *result;
-  MYSQL_BIND bind[2];  
+  MYSQL_BIND bind[2];
 
-  myheader("test_insert"); 
+  myheader("test_insert");
 
   rc = mysql_autocommit(mysql, true);
-  myquery(mysql,rc);
+  myquery(rc);
+
+  rc = mysql_query(mysql,"DROP TABLE IF EXISTS test_prep_insert");
+  myquery(rc);
 
-  rc = mysql_query(mysql,"DROP TABLE IF EXISTS test_prep_insert");  
-  myquery(mysql,rc);     
-    
   rc = mysql_commit(mysql);
-  myquery(mysql,rc);
+  myquery(rc);
 
   rc = mysql_query(mysql,"CREATE TABLE test_prep_insert(col1 tinyint,\
                                 col2 varchar(50))");
-  myquery(mysql,rc);  
+  myquery(rc);
 
   /* insert by prepare */
   bzero(bind, sizeof(bind));
   strcpy(query,"INSERT INTO test_prep_insert VALUES(?,?)");
   stmt = mysql_prepare(mysql, query, strlen(query));
-  myxquery(mysql,stmt);   
+  myxquery(stmt);
 
   param_count = mysql_param_count(stmt);
   fprintf(stdout," total parameters in insert:%d\n", param_count);
@@ -2180,14 +2211,15 @@ void test_insert(MYSQL *mysql)
   /* string */
   bind[1].buffer_type=FIELD_TYPE_STRING;
   bind[1].buffer=str_data;
-      
+  bind[1].length=(long *)&length;
+
   rc = mysql_bind_param(stmt,bind);
   mystmt(stmt, rc);
 
   /* now, execute the prepared statement to insert 10 records.. */
   for (tiny_data=0; tiny_data < 3; tiny_data++)
   {
-    bind[1].buffer_length = sprintf(str_data,"MySQL%d",tiny_data);
+    length = sprintf(str_data,"MySQL%d",tiny_data);
     rc = mysql_execute(stmt);
     mystmt(stmt, rc);
   }
@@ -2196,17 +2228,17 @@ void test_insert(MYSQL *mysql)
 
   /* now fetch the results ..*/
   rc = mysql_commit(mysql);
-  myquery(mysql,rc);
+  myquery(rc);
 
   /* test the results now, only one row should exists */
   rc = mysql_query(mysql,"SELECT * FROM test_prep_insert");
-  myquery(mysql,rc);
-    
+  myquery(rc);
+
   /* get the result */
   result = mysql_store_result(mysql);
-  mytest(mysql,result);
+  mytest(result);
 
-  assert((int)tiny_data == my_process_result_set(mysql,result));  
+  assert((int)tiny_data == my_process_result_set(result));
   mysql_free_result(result);
 
 }
@@ -2214,60 +2246,60 @@ void test_insert(MYSQL *mysql)
 /********************************************************
 * to test simple prepare-resultset info                 *
 *********************************************************/
-void test_prepare_resultset(MYSQL *mysql)
-{  
+void test_prepare_resultset()
+{
   MYSQL_STMT *stmt;
   int        rc,param_count;
   char       query[200];
   MYSQL_RES  *result;
 
-  myheader("test_prepare_resultset"); 
+  myheader("test_prepare_resultset");
 
   rc = mysql_autocommit(mysql, true);
-  myquery(mysql,rc);
+  myquery(rc);
+
+  rc = mysql_query(mysql,"DROP TABLE IF EXISTS test_prepare_resultset");
+  myquery(rc);
 
-  rc = mysql_query(mysql,"DROP TABLE IF EXISTS test_prepare_resultset");  
-  myquery(mysql,rc);     
-    
   rc = mysql_commit(mysql);
-  myquery(mysql,rc);
+  myquery(rc);
 
   rc = mysql_query(mysql,"CREATE TABLE test_prepare_resultset(id int,\
                                 name varchar(50),extra double)");
-  myquery(mysql,rc);  
+  myquery(rc);
 
   /* insert by prepare */
   strcpy(query,"INSERT INTO test_prepare_resultset(id,name) VALUES(?,?)");
   stmt = mysql_prepare(mysql, query, strlen(query));
-  myxquery(mysql,stmt);   
+  myxquery(stmt);
 
   param_count = mysql_param_count(stmt);
   fprintf(stdout," total parameters in insert:%d\n", param_count);
   assert(param_count == 2);
 
   rc = mysql_query(mysql,"SELECT * FROM test_prepare_resultset");
-  myquery(mysql,rc);  
+  myquery(rc);
 
   /* get the prepared-result */
   result = mysql_prepare_result(stmt);
   assert( result != 0);
 
-  my_print_result_metadata(result);  
+  my_print_result_metadata(result);
   mysql_free_result(result);
 
   result = mysql_store_result(mysql);
-  mytest(mysql,result);
+  mytest(result);
 
-  assert(0 == my_process_result_set(mysql,result));  
+  assert(0 == my_process_result_set(result));
   mysql_free_result(result);
 
   /* get the prepared-result */
   result = mysql_prepare_result(stmt);
   assert( result != 0);
 
-  my_print_result_metadata(result);  
+  my_print_result_metadata(result);
   mysql_free_result(result);
-  
+
   mysql_stmt_close(stmt);
 }
 
@@ -2275,21 +2307,21 @@ void test_prepare_resultset(MYSQL *mysql)
 * to test field flags (verify .NET provider)            *
 *********************************************************/
 
-void test_field_flags(MYSQL *mysql)
+void test_field_flags()
 {
   int          rc;
   MYSQL_RES    *result;
   MYSQL_FIELD  *field;
   unsigned int i;
 
-  
-  myheader("test_field_flags"); 
 
-  rc = mysql_query(mysql,"DROP TABLE IF EXISTS test_field_flags");  
-  myquery(mysql,rc);     
-    
+  myheader("test_field_flags");
+
+  rc = mysql_query(mysql,"DROP TABLE IF EXISTS test_field_flags");
+  myquery(rc);
+
   rc = mysql_commit(mysql);
-  myquery(mysql,rc);
+  myquery(rc);
 
   rc = mysql_query(mysql,"CREATE TABLE test_field_flags(id int NOT NULL AUTO_INCREMENT PRIMARY KEY,\
                                                         id1 int NOT NULL,\
@@ -2298,17 +2330,17 @@ void test_field_flags(MYSQL *mysql)
                                                         id4 int NOT NULL,\
                                                         id5 int,\
                                                         KEY(id3,id4))");
-  myquery(mysql,rc);   
+  myquery(rc);
 
   rc = mysql_commit(mysql);
-  myquery(mysql,rc);
-  
+  myquery(rc);
+
   /* with table name included with true column name */
   rc = mysql_query(mysql,"SELECT * FROM test_field_flags");
-  myquery(mysql,rc);
-    
+  myquery(rc);
+
   result = mysql_use_result(mysql);
-  mytest(mysql,result);
+  mytest(result);
 
   mysql_field_seek(result,0);
   fputc('\n', stdout);  
@@ -2338,17 +2370,19 @@ static struct my_option myctest_long_options[] =
    0, 0, 0, 0, 0},
   {"database", 'D', "Database to use", (gptr*) &opt_db, (gptr*) &opt_db,
    0, GET_STR_ALLOC, REQUIRED_ARG, 0, 0, 0, 0, 0, 0},
-  {"host", 'h', "Connect to host", (gptr*) &opt_host, (gptr*) &opt_host, 0, GET_STR,
+  {"host", 'h', "Connect to host", (gptr*) &opt_host, (gptr*) &opt_host, 0, GET_STR_ALLOC,
    REQUIRED_ARG, 0, 0, 0, 0, 0, 0},
   {"password", 'p',
    "Password to use when connecting to server. If password is not given it's asked from the tty.",
    0, 0, 0, GET_STR, OPT_ARG, 0, 0, 0, 0, 0, 0},
+#ifndef DONT_ALLOW_USER_CHANGE
   {"user", 'u', "User for login if not current user", (gptr*) &opt_user,
-   (gptr*) &opt_user, 0, GET_STR_ALLOC, REQUIRED_ARG, 0, 0, 0, 0, 0, 0},
+   (gptr*) &opt_user, 0, GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0},
+#endif
   {"port", 'P', "Port number to use for connection", (gptr*) &opt_port,
    (gptr*) &opt_port, 0, GET_UINT, REQUIRED_ARG, 0, 0, 0, 0, 0, 0},
   {"socket", 'S', "Socket file to use for connection", (gptr*) &opt_unix_socket,
-   (gptr*) &opt_unix_socket, 0, GET_STR_ALLOC, REQUIRED_ARG, 0, 0, 0, 0, 0, 0},
+   (gptr*) &opt_unix_socket, 0, GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0},
   { 0, 0, 0, 0, 0, 0, GET_NO_ARG, NO_ARG, 0, 0, 0, 0, 0, 0}
 };
 
@@ -2392,9 +2426,12 @@ get_one_option(int optid, const struct my_option *opt __attribute__((unused)),
   case 'p':
     if (argument)
     {
+      char *start=argument;
       my_free(opt_password, MYF(MY_ALLOW_ZERO_PTR));
       opt_password= my_strdup(argument, MYF(MY_FAE));
       while (*argument) *argument++= 'x';		/* Destroy argument */
+      if (*start)
+        start[1]=0;
     }
     else
       tty_password= 1;
@@ -2402,7 +2439,7 @@ get_one_option(int optid, const struct my_option *opt __attribute__((unused)),
   case '?':
   case 'I':					/* Info */
     usage();
-    exit(1);
+    exit(0);
     break;
   }
   return 0;
@@ -2416,11 +2453,11 @@ static void get_options(int argc, char **argv)
 
   load_defaults("my",load_default_groups,&argc,&argv);
 
-  if ((ho_error=handle_options(&argc, &argv, myctest_long_options, 
+  if ((ho_error=handle_options(&argc,&argv, myctest_long_options, 
                                get_one_option)))
     exit(ho_error);
 
-  free_defaults(argv);
+  /*free_defaults(argv);*/
   if (tty_password)
     opt_password=get_tty_password(NullS);
   return;
@@ -2430,47 +2467,50 @@ static void get_options(int argc, char **argv)
 * main routine                                          *
 *********************************************************/
 int main(int argc, char **argv)
-{
-  MYSQL *mysql;
-
-  
+{  
   MY_INIT(argv[0]);
-  get_options(argc,argv);  /* don't work -- options : TODO */
+  get_options(argc,argv);
     
-  mysql = client_connect();  /* connect to server */
-
-  test_select(mysql);        /* simple prepare-select */
-  test_insert(mysql);        /* prepare with insert */
-  test_bind_result(mysql);   /* result bind test */   
-  test_prepare(mysql);       /* prepare test */
-  test_prepare_simple(mysql);/* simple prepare */ 
-  test_null(mysql);          /* test null data handling */
-  test_debug_example(mysql); /* some debugging case */
-  test_update(mysql);        /* prepare-update test */
-  test_simple_update(mysql); /* simple prepare with update */
-  test_long_data(mysql);     /* long data handling in pieces */
-  test_simple_delete(mysql); /* prepare with delete */
-  test_field_names(mysql);   /* test for field names */
-  test_double_compare(mysql);/* float comparision */ 
-  client_query(mysql);       /* simple client query test */
-  client_store_result(mysql);/* usage of mysql_store_result() */
-  client_use_result(mysql);  /* usage of mysql_use_result() */  
-  test_tran_bdb(mysql);      /* transaction test on BDB table type */
-  test_tran_innodb(mysql);   /* transaction test on InnoDB table type */ 
-  test_prepare_ext(mysql);   /* test prepare with all types conversion -- TODO */
-  test_prepare_syntax(mysql);/* syntax check for prepares */
-  test_prepare_field_result(mysql); /* prepare meta info */
-  test_field_names(mysql);   /* test for field names */
-  test_field_flags(mysql);   /* test to help .NET provider team */
-  test_long_data_str(mysql); /* long data handling */
-  test_long_data_str1(mysql);/* yet another long data handling */
-  test_long_data_bin(mysql); /* long binary insertion */
-  test_warnings(mysql);      /* show warnings test */
-  test_errors(mysql);        /* show errors test */
-  test_select_simple(mysql); /* simple select prepare */
-  test_prepare_resultset(mysql);/* prepare meta info test */
-
-  client_disconnect(mysql);  /* disconnect from server */
+  client_connect();  /* connect to server */
+  
+  test_null();          /* test null data handling */
+  test_simple_update();
+  //test_select_simple();
+  //test_prepare_resultset();
+  //test_select();        /* simple prepare-select */
+  test_insert();        /* prepare with insert */
+  //test_bind_result();   /* result bind test */   
+  //test_long_data();     /* long data handling in pieces */
+  test_prepare_simple();/* simple prepare */ 
+  test_prepare();       /* prepare test */
+  test_prepare_simple();/* simple prepare */ 
+  test_null();          /* test null data handling */
+  test_debug_example(); /* some debugging case */
+  test_update();        /* prepare-update test */
+  test_simple_update(); /* simple prepare with update */
+  //test_long_data();     /* long data handling in pieces */
+  test_simple_delete(); /* prepare with delete */
+  test_field_names();   /* test for field names */
+  test_double_compare();/* float comparision */ 
+  client_query();       /* simple client query test */
+  client_store_result();/* usage of mysql_store_result() */
+  client_use_result();  /* usage of mysql_use_result() */  
+  test_tran_bdb();      /* transaction test on BDB table type */
+  test_tran_innodb();   /* transaction test on InnoDB table type */ 
+  test_prepare_ext();   /* test prepare with all types conversion -- TODO */
+  test_prepare_syntax();/* syntax check for prepares */
+  //test_prepare_field_result(); /* prepare meta info */
+  test_field_names();   /* test for field names */
+  test_field_flags();   /* test to help .NET provider team */
+  //test_long_data_str(); /* long data handling */
+  //test_long_data_str1();/* yet another long data handling */
+  //test_long_data_bin(); /* long binary insertion */
+  test_warnings();      /* show warnings test */
+  test_errors();        /* show errors test */
+  //test_select_simple(); /* simple select prepare */
+  //test_prepare_resultset();/* prepare meta info test */
+
+  client_disconnect();  /* disconnect from server */
   
   fprintf(stdout,"\ndone !!!\n");
   return(0);
diff --git a/tools/Makefile.am b/tools/Makefile.am
index 3c786dc92814c821a2ae11debf75fbe672bf5dc1..0dc0b90c60e91ba37d450250d87b6846103db5bf 100644
--- a/tools/Makefile.am
+++ b/tools/Makefile.am
@@ -1,5 +1,4 @@
-INCLUDES =		@MT_INCLUDES@ -I$(srcdir)/../include \
-			$(openssl_includes) -I../include
+INCLUDES =		@MT_INCLUDES@ -I$(top_srcdir)/include $(openssl_includes)
 LDADD=			@CLIENT_EXTRA_LDFLAGS@ ../libmysql_r/libmysqlclient_r.la @openssl_libs@
 bin_PROGRAMS=		mysqlmanager
 mysqlmanager_SOURCES=	mysqlmanager.c
diff --git a/vio/Makefile.am b/vio/Makefile.am
index b53f3be9f91a8ae7e66ecb20b2cf3cac880e36e5..16c70b12454bba910621e13487c41e3aaf40b9fd 100644
--- a/vio/Makefile.am
+++ b/vio/Makefile.am
@@ -14,7 +14,7 @@
 # along with this program; if not, write to the Free Software
 # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
 
-INCLUDES =		-I$(srcdir)/../include -I../include $(openssl_includes)
+INCLUDES =		-I$(top_srcdir)/include $(openssl_includes)
 LDADD =			@CLIENT_EXTRA_LDFLAGS@ libvio.a $(openssl_libs) 
 pkglib_LIBRARIES =	libvio.a
 noinst_PROGRAMS	=	test-ssl test-sslserver test-sslclient
diff --git a/vio/vio.c b/vio/vio.c
index bed380c6cd9bd216a245e6e4d9651b42319bf4ec..b1eb86fc9480d97129a325376fefcd186d6d7e07 100644
--- a/vio/vio.c
+++ b/vio/vio.c
@@ -45,7 +45,43 @@ void vio_reset(Vio* vio, enum enum_vio_type type,
   vio->sd	= sd;
   vio->hPipe	= hPipe;
   vio->localhost= localhost;
-#ifdef HAVE_VIO
+#ifdef HAVE_VIO  
+#ifdef __WIN__ 
+  if (type == VIO_TYPE_NAMEDPIPE)
+  {
+    vio->viodelete	=vio_delete;
+    vio->vioerrno	=vio_errno;
+    vio->read           =vio_read_pipe;
+    vio->write          =vio_write_pipe;
+    vio->fastsend	=vio_fastsend;
+    vio->viokeepalive	=vio_keepalive;
+    vio->should_retry	=vio_should_retry;
+    vio->vioclose	=vio_close_pipe;
+    vio->peer_addr	=vio_peer_addr;
+    vio->in_addr	=vio_in_addr;
+    vio->vioblocking	=vio_blocking;
+    vio->is_blocking	=vio_is_blocking;
+  }
+  else					/* default is VIO_TYPE_TCPIP */
+#endif
+#ifdef HAVE_SMEM 
+  if (type == VIO_TYPE_SHARED_MEMORY)
+  {
+    vio->viodelete	=vio_delete;
+    vio->vioerrno	=vio_errno;
+    vio->read           =vio_read_shared_memory;
+    vio->write          =vio_write_shared_memory;
+    vio->fastsend	=vio_fastsend;
+    vio->viokeepalive	=vio_keepalive;
+    vio->should_retry	=vio_should_retry;
+    vio->vioclose	=vio_close_shared_memory;
+    vio->peer_addr	=vio_peer_addr;
+    vio->in_addr	=vio_in_addr;
+    vio->vioblocking	=vio_blocking;
+    vio->is_blocking	=vio_is_blocking;
+  }
+  else
+#endif   
 #ifdef HAVE_OPENSSL 
   if (type == VIO_TYPE_SSL)
   {
@@ -131,4 +167,44 @@ Vio *vio_new_win32pipe(HANDLE hPipe)
   DBUG_RETURN(vio);
 }
 
+#ifdef HAVE_SMEM
+Vio *vio_new_win32shared_memory(NET *net,HANDLE handle_file_map, HANDLE handle_map,
+                                HANDLE event_server_wrote, HANDLE event_server_read,
+                                HANDLE event_client_wrote, HANDLE event_client_read)
+{
+  Vio *vio;
+  DBUG_ENTER("vio_new_win32shared_memory");
+  if ((vio = (Vio*) my_malloc(sizeof(Vio),MYF(MY_WME))))
+  {
+    vio_reset(vio, VIO_TYPE_SHARED_MEMORY, 0, 0, TRUE);
+    vio->handle_file_map = handle_file_map;
+    vio->handle_map = handle_map;
+    vio->event_server_wrote = event_server_wrote;
+    vio->event_server_read = event_server_read;
+    vio->event_client_wrote = event_client_wrote;
+    vio->event_client_read = event_client_read;
+    vio->shared_memory_remain = 0;
+    vio->shared_memory_pos = handle_map;
+    vio->net = net;
+    strmov(vio->desc, "shared memory");
+  }
+  DBUG_RETURN(vio);
+}
+#endif
 #endif
+
+void vio_delete(Vio* vio)
+{
+  /* It must be safe to delete null pointers. */
+  /* This matches the semantics of C++'s delete operator. */
+  if (vio)
+  {
+    if (vio->type != VIO_CLOSED)
+#ifdef HAVE_VIO /*WAX*/
+      vio->vioclose(vio);
+#else
+      vio_close(vio);
+#endif
+    my_free((gptr) vio,MYF(0));
+  }
+}
diff --git a/vio/viosocket.c b/vio/viosocket.c
index f69eebd413afd960d07225eba71f8c3f3f13f66e..76056704ec2d2d5c9d5e4c7d3758ca35da60f563 100644
--- a/vio/viosocket.c
+++ b/vio/viosocket.c
@@ -35,18 +35,6 @@
 #define HANDLE void *
 #endif
 
-void vio_delete(Vio* vio)
-{
-  /* It must be safe to delete null pointers. */
-  /* This matches the semantics of C++'s delete operator. */
-  if (vio)
-  {
-    if (vio->type != VIO_CLOSED)
-      vio_close(vio);
-    my_free((gptr) vio,MYF(0));
-  }
-}
-
 int vio_errno(Vio *vio __attribute__((unused)))
 {
   return socket_errno;		/* On Win32 this mapped to WSAGetLastError() */
@@ -58,14 +46,8 @@ int vio_read(Vio * vio, gptr buf, int size)
   int r;
   DBUG_ENTER("vio_read");
   DBUG_PRINT("enter", ("sd=%d, buf=%p, size=%d", vio->sd, buf, size));
+
 #ifdef __WIN__
-  if (vio->type == VIO_TYPE_NAMEDPIPE)
-  {
-    DWORD length;
-    if (!ReadFile(vio->hPipe, buf, size, &length, NULL))
-      DBUG_RETURN(-1);
-    DBUG_RETURN(length);
-  }
   r = recv(vio->sd, buf, size,0);
 #else
   errno=0;					/* For linux */
@@ -87,15 +69,8 @@ int vio_write(Vio * vio, const gptr buf, int size)
   int r;
   DBUG_ENTER("vio_write");
   DBUG_PRINT("enter", ("sd=%d, buf=%p, size=%d", vio->sd, buf, size));
-#if defined( __WIN__)
-  if ( vio->type == VIO_TYPE_NAMEDPIPE)
-  {
-    DWORD length;
-    if (!WriteFile(vio->hPipe, (char*) buf, size, &length, NULL))
-      DBUG_RETURN(-1);
-    DBUG_RETURN(length);
-  }
-  r = send(vio->sd, buf, size, 0);
+#ifdef __WIN__
+  r = send(vio->sd, buf, size,0);
 #else
   r = write(vio->sd, buf, size);
 #endif /* __WIN__ */
@@ -109,7 +84,6 @@ int vio_write(Vio * vio, const gptr buf, int size)
   DBUG_RETURN(r);
 }
 
-
 int vio_blocking(Vio * vio __attribute__((unused)), my_bool set_blocking_mode,
 		 my_bool *old_mode)
 {
@@ -332,3 +306,155 @@ my_bool vio_poll_read(Vio *vio,uint timeout)
   DBUG_RETURN(fds.revents & POLLIN ? 0 : 1);
 #endif
 }
+
+#ifdef __WIN__
+int vio_read_pipe(Vio * vio, gptr buf, int size)
+{
+  DWORD length;
+  DBUG_ENTER("vio_read_pipe");
+  DBUG_PRINT("enter", ("sd=%d, buf=%p, size=%d", vio->sd, buf, size));
+
+  if (!ReadFile(vio->hPipe, buf, size, &length, NULL))
+    DBUG_RETURN(-1);
+
+  DBUG_PRINT("exit", ("%d", length));
+  DBUG_RETURN(length);
+}
+
+
+int vio_write_pipe(Vio * vio, const gptr buf, int size)
+{
+  DWORD length;
+  DBUG_ENTER("vio_write_pipe");
+  DBUG_PRINT("enter", ("sd=%d, buf=%p, size=%d", vio->sd, buf, size));
+
+  if (!WriteFile(vio->hPipe, (char*) buf, size, &length, NULL))
+    DBUG_RETURN(-1);
+
+  DBUG_PRINT("exit", ("%d", length));
+  DBUG_RETURN(length);
+}
+
+int vio_close_pipe(Vio * vio)
+{
+  int r;
+  DBUG_ENTER("vio_close_pipe");
+#if defined(__NT__) && defined(MYSQL_SERVER)
+  CancelIo(vio->hPipe);
+  DisconnectNamedPipe(vio->hPipe);
+#endif
+  r=CloseHandle(vio->hPipe);
+  if (r)
+  {
+    DBUG_PRINT("vio_error", ("close() failed, error: %d",GetLastError()));
+    /* FIXME: error handling (not critical for MySQL) */
+  }
+  vio->type= VIO_CLOSED;
+  vio->sd=   -1;
+  DBUG_RETURN(r);
+}
+
+#ifdef HAVE_SMEM
+
+int vio_read_shared_memory(Vio * vio, gptr buf, int size)
+{
+  int length;
+  int remain_local;
+  char *current_postion;
+
+  DBUG_ENTER("vio_read_shared_memory");
+  DBUG_PRINT("enter", ("sd=%d, buf=%p, size=%d", vio->sd, buf, size));
+
+  remain_local = size;
+  current_postion=buf;
+  do 
+  {
+    if (vio->shared_memory_remain == 0) 
+    {
+      if (WaitForSingleObject(vio->event_server_wrote,vio->net->read_timeout*1000)  != WAIT_OBJECT_0)
+      {
+        DBUG_RETURN(-1);
+      };
+      vio->shared_memory_pos = vio->handle_map;
+      vio->shared_memory_remain = uint4korr((ulong*)vio->shared_memory_pos);
+      vio->shared_memory_pos+=4;
+    }
+
+    length = size;
+
+    if (vio->shared_memory_remain < length) 
+       length = vio->shared_memory_remain;
+    if (length > remain_local) 
+       length = remain_local;
+
+    memcpy(current_postion,vio->shared_memory_pos,length);
+
+    vio->shared_memory_remain-=length;
+    vio->shared_memory_pos+=length;
+    current_postion+=length;
+    remain_local-=length;
+
+    if (!vio->shared_memory_remain) 
+      if (!SetEvent(vio->event_client_read)) DBUG_RETURN(-1);
+  } while (remain_local);
+  length = size;
+
+  DBUG_PRINT("exit", ("%d", length));
+  DBUG_RETURN(length);
+}
+
+
+int vio_write_shared_memory(Vio * vio, const gptr buf, int size)
+{
+  int length;
+  uint remain;
+  HANDLE pos;
+  int sz;
+  char *current_postion;
+
+  DBUG_ENTER("vio_write_shared_memory");
+  DBUG_PRINT("enter", ("sd=%d, buf=%p, size=%d", vio->sd, buf, size));
+
+  remain = size;
+  current_postion = buf;
+  while (remain != 0) 
+  {
+    if (WaitForSingleObject(vio->event_server_read,vio->net->write_timeout*1000) != WAIT_OBJECT_0)
+    {
+      DBUG_RETURN(-1); 
+    };
+
+    sz = remain > shared_memory_buffer_length ? shared_memory_buffer_length: remain;
+
+    int4store(vio->handle_map,sz);
+    pos = vio->handle_map + 4;
+    memcpy(pos,current_postion,sz);
+    remain-=sz;
+    current_postion+=sz;
+    if (!SetEvent(vio->event_client_wrote)) DBUG_RETURN(-1);
+  }
+  length = size;
+
+  DBUG_PRINT("exit", ("%d", length));
+  DBUG_RETURN(length);
+}
+
+
+int vio_close_shared_memory(Vio * vio)
+{
+  int r;
+  DBUG_ENTER("vio_close_shared_memory");
+  r=UnmapViewOfFile(vio->handle_map) || CloseHandle(vio->event_server_wrote) ||
+    CloseHandle(vio->event_server_read) || CloseHandle(vio->event_client_wrote) ||
+    CloseHandle(vio->event_client_read) || CloseHandle(vio->handle_file_map);
+  if (r)
+  {
+    DBUG_PRINT("vio_error", ("close() failed, error: %d",r));
+    /* FIXME: error handling (not critical for MySQL) */
+  }
+  vio->type= VIO_CLOSED;
+  vio->sd=   -1;
+  DBUG_RETURN(r);
+}
+#endif
+#endif
diff --git a/vio/viossl.c b/vio/viossl.c
index 56d3da8a1ac3d2c3be70dd8a9f57d9233f5782e9..cf1c98b53828329e2ae696946245bc0264efb8f0 100644
--- a/vio/viossl.c
+++ b/vio/viossl.c
@@ -249,35 +249,48 @@ void vio_ssl_in_addr(Vio *vio, struct in_addr *in)
 
 
 /*
-  TODO: Add documentation and error handling
+  TODO: Add documentation
 */
 
-void sslaccept(struct st_VioSSLAcceptorFd* ptr, Vio* vio, long timeout)
+int sslaccept(struct st_VioSSLAcceptorFd* ptr, Vio* vio, long timeout)
 {
   char *str;
   char buf[1024];
   X509* client_cert;
   my_bool unused;
+  my_bool net_blocking;
+  enum enum_vio_type old_type;  
   DBUG_ENTER("sslaccept");
   DBUG_PRINT("enter", ("sd=%d ptr=%p", vio->sd,ptr));
 
+  old_type= vio->type;
+  net_blocking = vio_is_blocking(vio);
   vio_blocking(vio, 1, &unused);	/* Must be called before reset */
   vio_reset(vio,VIO_TYPE_SSL,vio->sd,0,FALSE);
   vio->ssl_=0;
-  vio->open_=FALSE; 
   if (!(vio->ssl_ = SSL_new(ptr->ssl_context_)))
   {
     DBUG_PRINT("error", ("SSL_new failure"));
     report_errors();
-    DBUG_VOID_RETURN;
+    vio_reset(vio, old_type,vio->sd,0,FALSE);
+    vio_blocking(vio, net_blocking, &unused);
+    DBUG_RETURN(1);
   }
   DBUG_PRINT("info", ("ssl_=%p  timeout=%ld",vio->ssl_, timeout));
   SSL_clear(vio->ssl_);
   SSL_SESSION_set_timeout(SSL_get_session(vio->ssl_), timeout);
   SSL_set_fd(vio->ssl_,vio->sd);
   SSL_set_accept_state(vio->ssl_);
-  SSL_do_handshake(vio->ssl_);
-  vio->open_ = TRUE;
+  if (SSL_do_handshake(vio->ssl_) < 1)
+  {
+    DBUG_PRINT("error", ("SSL_do_handshake failure"));
+    report_errors();
+    SSL_free(vio->ssl_);
+    vio->ssl_=0;
+    vio_reset(vio, old_type,vio->sd,0,FALSE);
+    vio_blocking(vio, net_blocking, &unused);
+    DBUG_RETURN(1);
+  }
 #ifndef DBUF_OFF
   DBUG_PRINT("info",("SSL_get_cipher_name() = '%s'"
 		     ,SSL_get_cipher_name(vio->ssl_)));
@@ -309,7 +322,7 @@ void sslaccept(struct st_VioSSLAcceptorFd* ptr, Vio* vio, long timeout)
   }
 
 #endif
-  DBUG_VOID_RETURN;
+  DBUG_RETURN(0);
 }
 
 
@@ -318,17 +331,22 @@ int sslconnect(struct st_VioSSLConnectorFd* ptr, Vio* vio, long timeout)
   char *str;
   X509*    server_cert;
   my_bool unused;
+  my_bool net_blocking;
+  enum enum_vio_type old_type;  
   DBUG_ENTER("sslconnect");
   DBUG_PRINT("enter", ("sd=%d ptr=%p ctx: %p", vio->sd,ptr,ptr->ssl_context_));
 
+  old_type= vio->type;
+  net_blocking = vio_is_blocking(vio);
   vio_blocking(vio, 1, &unused);	/* Must be called before reset */
   vio_reset(vio,VIO_TYPE_SSL,vio->sd,0,FALSE);
   vio->ssl_=0;
-  vio->open_=FALSE; 
   if (!(vio->ssl_ = SSL_new(ptr->ssl_context_)))
   {
     DBUG_PRINT("error", ("SSL_new failure"));
     report_errors();
+    vio_reset(vio, old_type,vio->sd,0,FALSE);
+    vio_blocking(vio, net_blocking, &unused);    
     DBUG_RETURN(1);
   }
   DBUG_PRINT("info", ("ssl_=%p  timeout=%ld",vio->ssl_, timeout));
@@ -336,8 +354,16 @@ int sslconnect(struct st_VioSSLConnectorFd* ptr, Vio* vio, long timeout)
   SSL_SESSION_set_timeout(SSL_get_session(vio->ssl_), timeout);
   SSL_set_fd (vio->ssl_, vio->sd);
   SSL_set_connect_state(vio->ssl_);
-  SSL_do_handshake(vio->ssl_);
-  vio->open_ = TRUE;
+  if (SSL_do_handshake(vio->ssl_) < 1)
+  {
+    DBUG_PRINT("error", ("SSL_do_handshake failure"));
+    report_errors();
+    SSL_free(vio->ssl_);
+    vio->ssl_=0;
+    vio_reset(vio, old_type,vio->sd,0,FALSE);
+    vio_blocking(vio, net_blocking, &unused);
+    DBUG_RETURN(1);
+  }  
 #ifndef DBUG_OFF
   DBUG_PRINT("info",("SSL_get_cipher_name() = '%s'"
 		     ,SSL_get_cipher_name(vio->ssl_)));
diff --git a/vio/viosslfactories.c b/vio/viosslfactories.c
index 9e7a1475951ea6cafcf2af6950a60979d6b4db2f..31bc457d1aef847e98a4c4eb4c7d6ed0f617f383 100644
--- a/vio/viosslfactories.c
+++ b/vio/viosslfactories.c
@@ -93,7 +93,10 @@ vio_set_cert_stuff(SSL_CTX *ctx, const char *cert_file, const char *key_file)
     {
       DBUG_PRINT("error",("unable to get certificate from '%s'\n",cert_file));
       /* FIX stderr */
+      fprintf(stderr,"Error when connection to server using SSL:");
       ERR_print_errors_fp(stderr);
+      fprintf(stderr,"Unable to get certificate from '%s'\n", cert_file);
+      fflush(stderr);
       DBUG_RETURN(0);
     }
     if (key_file == NULL)
@@ -103,7 +106,10 @@ vio_set_cert_stuff(SSL_CTX *ctx, const char *cert_file, const char *key_file)
     {
       DBUG_PRINT("error", ("unable to get private key from '%s'\n",key_file));
       /* FIX stderr */
+      fprintf(stderr,"Error when connection to server using SSL:");
       ERR_print_errors_fp(stderr);
+      fprintf(stderr,"Unable to get private key from '%s'\n", cert_file);
+      fflush(stderr);      
       DBUG_RETURN(0);
     }