Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/external/public-domain/sqlite merge conflicts.



details:   https://anonhg.NetBSD.org/src/rev/3200790a42d3
branches:  trunk
changeset: 446799:3200790a42d3
user:      christos <christos%NetBSD.org@localhost>
date:      Wed Dec 19 22:21:13 2018 +0000

description:
merge conflicts.

diffstat:

 external/public-domain/sqlite/dist/shell.c                            |  12300 ++-
 external/public-domain/sqlite/dist/sqlite3.c                          |  49218 ++++++---
 external/public-domain/sqlite/lib/shlib_version                       |      4 +-
 external/public-domain/sqlite/man/Makefile                            |     28 +-
 external/public-domain/sqlite/man/SQLITE_ACCESS_EXISTS.3              |      2 +-
 external/public-domain/sqlite/man/SQLITE_CHANGESETAPPLY_NOSAVEPOINT.3 |     31 +
 external/public-domain/sqlite/man/SQLITE_CHANGESETSTART_INVERT.3      |     19 +
 external/public-domain/sqlite/man/SQLITE_CHANGESET_DATA.3             |      2 +-
 external/public-domain/sqlite/man/SQLITE_CHANGESET_OMIT.3             |      2 +-
 external/public-domain/sqlite/man/SQLITE_CHECKPOINT_PASSIVE.3         |      2 +-
 external/public-domain/sqlite/man/SQLITE_CONFIG_SINGLETHREAD.3        |     54 +-
 external/public-domain/sqlite/man/SQLITE_CREATE_INDEX.3               |      2 +-
 external/public-domain/sqlite/man/SQLITE_DBCONFIG_MAINDBNAME.3        |     88 +-
 external/public-domain/sqlite/man/SQLITE_DBSTATUS_LOOKASIDE_USED.3    |     13 +-
 external/public-domain/sqlite/man/SQLITE_DENY.3                       |      2 +-
 external/public-domain/sqlite/man/SQLITE_DESERIALIZE_FREEONCLOSE.3    |     35 +
 external/public-domain/sqlite/man/SQLITE_DETERMINISTIC.3              |      2 +-
 external/public-domain/sqlite/man/SQLITE_ERROR_MISSING_COLLSEQ.3      |    158 +
 external/public-domain/sqlite/man/SQLITE_FCNTL_LOCKSTATE.3            |     85 +-
 external/public-domain/sqlite/man/SQLITE_INDEX_CONSTRAINT_EQ.3        |     16 +-
 external/public-domain/sqlite/man/SQLITE_INDEX_SCAN_UNIQUE.3          |      6 +-
 external/public-domain/sqlite/man/SQLITE_INTEGER.3                    |      2 +-
 external/public-domain/sqlite/man/SQLITE_IOCAP_ATOMIC.3               |     14 +-
 external/public-domain/sqlite/man/SQLITE_LIMIT_LENGTH.3               |     10 +-
 external/public-domain/sqlite/man/SQLITE_LOCK_NONE.3                  |      2 +-
 external/public-domain/sqlite/man/SQLITE_MUTEX_FAST.3                 |      2 +-
 external/public-domain/sqlite/man/SQLITE_OK.3                         |      4 +-
 external/public-domain/sqlite/man/SQLITE_OPEN_READONLY.3              |      2 +-
 external/public-domain/sqlite/man/SQLITE_PREPARE_PERSISTENT.3         |     43 +
 external/public-domain/sqlite/man/SQLITE_ROLLBACK.3                   |      2 +-
 external/public-domain/sqlite/man/SQLITE_SCANSTAT_NLOOP.3             |      2 +-
 external/public-domain/sqlite/man/SQLITE_SERIALIZE_NOCOPY.3           |     23 +
 external/public-domain/sqlite/man/SQLITE_SESSION_CONFIG_STRMSIZE.3    |      9 +
 external/public-domain/sqlite/man/SQLITE_SHM_NLOCK.3                  |      2 +-
 external/public-domain/sqlite/man/SQLITE_SHM_UNLOCK.3                 |      2 +-
 external/public-domain/sqlite/man/SQLITE_STATUS_MEMORY_USED.3         |     26 +-
 external/public-domain/sqlite/man/SQLITE_STMTSTATUS_FULLSCAN_STEP.3   |     27 +-
 external/public-domain/sqlite/man/SQLITE_SYNC_NORMAL.3                |      2 +-
 external/public-domain/sqlite/man/SQLITE_TESTCTRL_FIRST.3             |      6 +-
 external/public-domain/sqlite/man/SQLITE_TRACE_STMT.3                 |      6 +-
 external/public-domain/sqlite/man/SQLITE_UTF8.3                       |      2 +-
 external/public-domain/sqlite/man/SQLITE_VERSION.3                    |      6 +-
 external/public-domain/sqlite/man/SQLITE_VTAB_CONSTRAINT_SUPPORT.3    |      2 +-
 external/public-domain/sqlite/man/SQLITE_WIN32_DATA_DIRECTORY_TYPE.3  |     16 +
 external/public-domain/sqlite/man/sqlite3.3                           |      2 +-
 external/public-domain/sqlite/man/sqlite3_aggregate_context.3         |      2 +-
 external/public-domain/sqlite/man/sqlite3_aggregate_count.3           |      2 +-
 external/public-domain/sqlite/man/sqlite3_api_routines.3              |      2 +-
 external/public-domain/sqlite/man/sqlite3_auto_extension.3            |      2 +-
 external/public-domain/sqlite/man/sqlite3_backup.3                    |      2 +-
 external/public-domain/sqlite/man/sqlite3_backup_init.3               |      4 +-
 external/public-domain/sqlite/man/sqlite3_bind_blob.3                 |     22 +-
 external/public-domain/sqlite/man/sqlite3_bind_parameter_count.3      |      2 +-
 external/public-domain/sqlite/man/sqlite3_bind_parameter_index.3      |      5 +-
 external/public-domain/sqlite/man/sqlite3_bind_parameter_name.3       |      6 +-
 external/public-domain/sqlite/man/sqlite3_blob.3                      |      2 +-
 external/public-domain/sqlite/man/sqlite3_blob_bytes.3                |      2 +-
 external/public-domain/sqlite/man/sqlite3_blob_close.3                |      2 +-
 external/public-domain/sqlite/man/sqlite3_blob_open.3                 |      2 +-
 external/public-domain/sqlite/man/sqlite3_blob_read.3                 |      2 +-
 external/public-domain/sqlite/man/sqlite3_blob_reopen.3               |      2 +-
 external/public-domain/sqlite/man/sqlite3_blob_write.3                |      2 +-
 external/public-domain/sqlite/man/sqlite3_busy_handler.3              |      2 +-
 external/public-domain/sqlite/man/sqlite3_busy_timeout.3              |      2 +-
 external/public-domain/sqlite/man/sqlite3_cancel_auto_extension.3     |      2 +-
 external/public-domain/sqlite/man/sqlite3_changegroup.3               |      4 +-
 external/public-domain/sqlite/man/sqlite3_changes.3                   |      6 +-
 external/public-domain/sqlite/man/sqlite3_changeset_iter.3            |      4 +-
 external/public-domain/sqlite/man/sqlite3_clear_bindings.3            |      2 +-
 external/public-domain/sqlite/man/sqlite3_close.3                     |      2 +-
 external/public-domain/sqlite/man/sqlite3_collation_needed.3          |      2 +-
 external/public-domain/sqlite/man/sqlite3_column_blob.3               |    117 +-
 external/public-domain/sqlite/man/sqlite3_column_count.3              |      2 +-
 external/public-domain/sqlite/man/sqlite3_column_database_name.3      |      2 +-
 external/public-domain/sqlite/man/sqlite3_column_decltype.3           |      2 +-
 external/public-domain/sqlite/man/sqlite3_column_name.3               |      2 +-
 external/public-domain/sqlite/man/sqlite3_commit_hook.3               |      2 +-
 external/public-domain/sqlite/man/sqlite3_compileoption_used.3        |      2 +-
 external/public-domain/sqlite/man/sqlite3_complete.3                  |      2 +-
 external/public-domain/sqlite/man/sqlite3_config.3                    |      2 +-
 external/public-domain/sqlite/man/sqlite3_context.3                   |      2 +-
 external/public-domain/sqlite/man/sqlite3_context_db_handle.3         |      2 +-
 external/public-domain/sqlite/man/sqlite3_create_collation.3          |      2 +-
 external/public-domain/sqlite/man/sqlite3_create_function.3           |     55 +-
 external/public-domain/sqlite/man/sqlite3_create_module.3             |      2 +-
 external/public-domain/sqlite/man/sqlite3_data_count.3                |      2 +-
 external/public-domain/sqlite/man/sqlite3_data_directory.3            |      2 +-
 external/public-domain/sqlite/man/sqlite3_db_cacheflush.3             |      2 +-
 external/public-domain/sqlite/man/sqlite3_db_config.3                 |      2 +-
 external/public-domain/sqlite/man/sqlite3_db_filename.3               |      2 +-
 external/public-domain/sqlite/man/sqlite3_db_handle.3                 |      2 +-
 external/public-domain/sqlite/man/sqlite3_db_mutex.3                  |      2 +-
 external/public-domain/sqlite/man/sqlite3_db_readonly.3               |      2 +-
 external/public-domain/sqlite/man/sqlite3_db_release_memory.3         |      2 +-
 external/public-domain/sqlite/man/sqlite3_db_status.3                 |      2 +-
 external/public-domain/sqlite/man/sqlite3_declare_vtab.3              |      2 +-
 external/public-domain/sqlite/man/sqlite3_deserialize.3               |     46 +
 external/public-domain/sqlite/man/sqlite3_destructor_type.3           |      2 +-
 external/public-domain/sqlite/man/sqlite3_enable_load_extension.3     |      2 +-
 external/public-domain/sqlite/man/sqlite3_enable_shared_cache.3       |      2 +-
 external/public-domain/sqlite/man/sqlite3_errcode.3                   |     20 +-
 external/public-domain/sqlite/man/sqlite3_exec.3                      |      2 +-
 external/public-domain/sqlite/man/sqlite3_extended_result_codes.3     |      2 +-
 external/public-domain/sqlite/man/sqlite3_file.3                      |      2 +-
 external/public-domain/sqlite/man/sqlite3_file_control.3              |     21 +-
 external/public-domain/sqlite/man/sqlite3_finalize.3                  |      2 +-
 external/public-domain/sqlite/man/sqlite3_get_autocommit.3            |      2 +-
 external/public-domain/sqlite/man/sqlite3_get_auxdata.3               |     17 +-
 external/public-domain/sqlite/man/sqlite3_get_table.3                 |      2 +-
 external/public-domain/sqlite/man/sqlite3_index_info.3                |      2 +-
 external/public-domain/sqlite/man/sqlite3_initialize.3                |      2 +-
 external/public-domain/sqlite/man/sqlite3_interrupt.3                 |      6 +-
 external/public-domain/sqlite/man/sqlite3_io_methods.3                |      4 +-
 external/public-domain/sqlite/man/sqlite3_keyword_count.3             |     75 +
 external/public-domain/sqlite/man/sqlite3_last_insert_rowid.3         |     33 +-
 external/public-domain/sqlite/man/sqlite3_limit.3                     |      2 +-
 external/public-domain/sqlite/man/sqlite3_load_extension.3            |      2 +-
 external/public-domain/sqlite/man/sqlite3_log.3                       |      2 +-
 external/public-domain/sqlite/man/sqlite3_malloc.3                    |      2 +-
 external/public-domain/sqlite/man/sqlite3_mem_methods.3               |      2 +-
 external/public-domain/sqlite/man/sqlite3_memory_used.3               |      2 +-
 external/public-domain/sqlite/man/sqlite3_module.3                    |      2 +-
 external/public-domain/sqlite/man/sqlite3_mprintf.3                   |     91 +-
 external/public-domain/sqlite/man/sqlite3_mutex.3                     |      2 +-
 external/public-domain/sqlite/man/sqlite3_mutex_alloc.3               |      2 +-
 external/public-domain/sqlite/man/sqlite3_mutex_held.3                |      2 +-
 external/public-domain/sqlite/man/sqlite3_mutex_methods.3             |      2 +-
 external/public-domain/sqlite/man/sqlite3_next_stmt.3                 |      2 +-
 external/public-domain/sqlite/man/sqlite3_open.3                      |      9 +-
 external/public-domain/sqlite/man/sqlite3_overload_function.3         |      2 +-
 external/public-domain/sqlite/man/sqlite3_pcache.3                    |      2 +-
 external/public-domain/sqlite/man/sqlite3_pcache_methods2.3           |      2 +-
 external/public-domain/sqlite/man/sqlite3_pcache_page.3               |      2 +-
 external/public-domain/sqlite/man/sqlite3_prepare.3                   |     63 +-
 external/public-domain/sqlite/man/sqlite3_preupdate_hook.3            |      2 +-
 external/public-domain/sqlite/man/sqlite3_progress_handler.3          |      2 +-
 external/public-domain/sqlite/man/sqlite3_randomness.3                |      2 +-
 external/public-domain/sqlite/man/sqlite3_rebaser.3                   |    101 +
 external/public-domain/sqlite/man/sqlite3_release_memory.3            |      2 +-
 external/public-domain/sqlite/man/sqlite3_reset.3                     |      2 +-
 external/public-domain/sqlite/man/sqlite3_reset_auto_extension.3      |      2 +-
 external/public-domain/sqlite/man/sqlite3_result_blob.3               |     28 +-
 external/public-domain/sqlite/man/sqlite3_result_subtype.3            |      2 +-
 external/public-domain/sqlite/man/sqlite3_serialize.3                 |     52 +
 external/public-domain/sqlite/man/sqlite3_session.3                   |      4 +-
 external/public-domain/sqlite/man/sqlite3_set_authorizer.3            |     17 +-
 external/public-domain/sqlite/man/sqlite3_set_last_insert_rowid.3     |     16 +
 external/public-domain/sqlite/man/sqlite3_sleep.3                     |      2 +-
 external/public-domain/sqlite/man/sqlite3_snapshot.3                  |     12 +-
 external/public-domain/sqlite/man/sqlite3_snapshot_cmp.3              |      5 +-
 external/public-domain/sqlite/man/sqlite3_snapshot_free.3             |      5 +-
 external/public-domain/sqlite/man/sqlite3_snapshot_get.3              |      7 +-
 external/public-domain/sqlite/man/sqlite3_snapshot_open.3             |     41 +-
 external/public-domain/sqlite/man/sqlite3_snapshot_recover.3          |     29 +-
 external/public-domain/sqlite/man/sqlite3_soft_heap_limit.3           |      2 +-
 external/public-domain/sqlite/man/sqlite3_soft_heap_limit64.3         |      2 +-
 external/public-domain/sqlite/man/sqlite3_sql.3                       |     22 +-
 external/public-domain/sqlite/man/sqlite3_status.3                    |      2 +-
 external/public-domain/sqlite/man/sqlite3_step.3                      |     21 +-
 external/public-domain/sqlite/man/sqlite3_stmt.3                      |      2 +-
 external/public-domain/sqlite/man/sqlite3_stmt_busy.3                 |      2 +-
 external/public-domain/sqlite/man/sqlite3_stmt_readonly.3             |      2 +-
 external/public-domain/sqlite/man/sqlite3_stmt_scanstatus.3           |      2 +-
 external/public-domain/sqlite/man/sqlite3_stmt_scanstatus_reset.3     |      2 +-
 external/public-domain/sqlite/man/sqlite3_stmt_status.3               |      2 +-
 external/public-domain/sqlite/man/sqlite3_str.3                       |     28 +
 external/public-domain/sqlite/man/sqlite3_str_appendf.3               |     82 +
 external/public-domain/sqlite/man/sqlite3_str_errcode.3               |     54 +
 external/public-domain/sqlite/man/sqlite3_str_finish.3                |     27 +
 external/public-domain/sqlite/man/sqlite3_str_new.3                   |     38 +
 external/public-domain/sqlite/man/sqlite3_strglob.3                   |      2 +-
 external/public-domain/sqlite/man/sqlite3_stricmp.3                   |      2 +-
 external/public-domain/sqlite/man/sqlite3_strlike.3                   |      2 +-
 external/public-domain/sqlite/man/sqlite3_system_errno.3              |      2 +-
 external/public-domain/sqlite/man/sqlite3_table_column_metadata.3     |      4 +-
 external/public-domain/sqlite/man/sqlite3_temp_directory.3            |      2 +-
 external/public-domain/sqlite/man/sqlite3_test_control.3              |      2 +-
 external/public-domain/sqlite/man/sqlite3_threadsafe.3                |      2 +-
 external/public-domain/sqlite/man/sqlite3_total_changes.3             |     16 +-
 external/public-domain/sqlite/man/sqlite3_trace.3                     |      2 +-
 external/public-domain/sqlite/man/sqlite3_trace_v2.3                  |      2 +-
 external/public-domain/sqlite/man/sqlite3_unlock_notify.3             |      2 +-
 external/public-domain/sqlite/man/sqlite3_update_hook.3               |      2 +-
 external/public-domain/sqlite/man/sqlite3_uri_parameter.3             |      2 +-
 external/public-domain/sqlite/man/sqlite3_user_data.3                 |      2 +-
 external/public-domain/sqlite/man/sqlite3_value.3                     |      9 +-
 external/public-domain/sqlite/man/sqlite3_value_blob.3                |    137 +-
 external/public-domain/sqlite/man/sqlite3_value_dup.3                 |      2 +-
 external/public-domain/sqlite/man/sqlite3_value_subtype.3             |      6 +-
 external/public-domain/sqlite/man/sqlite3_version.3                   |      6 +-
 external/public-domain/sqlite/man/sqlite3_vfs.3                       |     21 +-
 external/public-domain/sqlite/man/sqlite3_vfs_find.3                  |      2 +-
 external/public-domain/sqlite/man/sqlite3_vtab.3                      |      2 +-
 external/public-domain/sqlite/man/sqlite3_vtab_collation.3            |     22 +
 external/public-domain/sqlite/man/sqlite3_vtab_config.3               |      2 +-
 external/public-domain/sqlite/man/sqlite3_vtab_cursor.3               |      2 +-
 external/public-domain/sqlite/man/sqlite3_vtab_nochange.3             |     28 +
 external/public-domain/sqlite/man/sqlite3_vtab_on_conflict.3          |      2 +-
 external/public-domain/sqlite/man/sqlite3_wal_autocheckpoint.3        |      2 +-
 external/public-domain/sqlite/man/sqlite3_wal_checkpoint.3            |      2 +-
 external/public-domain/sqlite/man/sqlite3_wal_checkpoint_v2.3         |      2 +-
 external/public-domain/sqlite/man/sqlite3_wal_hook.3                  |      2 +-
 external/public-domain/sqlite/man/sqlite3_win32_set_directory.3       |     51 +
 external/public-domain/sqlite/man/sqlite3changegroup_add.3            |      2 +-
 external/public-domain/sqlite/man/sqlite3changegroup_delete.3         |      2 +-
 external/public-domain/sqlite/man/sqlite3changegroup_new.3            |      2 +-
 external/public-domain/sqlite/man/sqlite3changegroup_output.3         |      2 +-
 external/public-domain/sqlite/man/sqlite3changeset_apply.3            |     62 +-
 external/public-domain/sqlite/man/sqlite3changeset_apply_strm.3       |     47 +-
 external/public-domain/sqlite/man/sqlite3changeset_concat.3           |      5 +-
 external/public-domain/sqlite/man/sqlite3changeset_conflict.3         |      2 +-
 external/public-domain/sqlite/man/sqlite3changeset_finalize.3         |      8 +-
 external/public-domain/sqlite/man/sqlite3changeset_fk_conflicts.3     |      2 +-
 external/public-domain/sqlite/man/sqlite3changeset_invert.3           |      2 +-
 external/public-domain/sqlite/man/sqlite3changeset_new.3              |      2 +-
 external/public-domain/sqlite/man/sqlite3changeset_next.3             |      2 +-
 external/public-domain/sqlite/man/sqlite3changeset_old.3              |      2 +-
 external/public-domain/sqlite/man/sqlite3changeset_op.3               |      2 +-
 external/public-domain/sqlite/man/sqlite3changeset_pk.3               |      2 +-
 external/public-domain/sqlite/man/sqlite3changeset_start.3            |     22 +-
 external/public-domain/sqlite/man/sqlite3rebaser_configure.3          |     17 +
 external/public-domain/sqlite/man/sqlite3rebaser_create.3             |     16 +
 external/public-domain/sqlite/man/sqlite3rebaser_delete.3             |     15 +
 external/public-domain/sqlite/man/sqlite3rebaser_rebase.3             |     28 +
 external/public-domain/sqlite/man/sqlite3session_attach.3             |     32 +-
 external/public-domain/sqlite/man/sqlite3session_changeset.3          |      2 +-
 external/public-domain/sqlite/man/sqlite3session_config.3             |     44 +
 external/public-domain/sqlite/man/sqlite3session_create.3             |      2 +-
 external/public-domain/sqlite/man/sqlite3session_delete.3             |      2 +-
 external/public-domain/sqlite/man/sqlite3session_diff.3               |      4 +-
 external/public-domain/sqlite/man/sqlite3session_enable.3             |      2 +-
 external/public-domain/sqlite/man/sqlite3session_indirect.3           |      2 +-
 external/public-domain/sqlite/man/sqlite3session_isempty.3            |      2 +-
 external/public-domain/sqlite/man/sqlite3session_patchset.3           |      2 +-
 external/public-domain/sqlite/man/sqlite3session_table_filter.3       |      2 +-
 external/public-domain/sqlite/man/sqlite_int64.3                      |      2 +-
 236 files changed, 47759 insertions(+), 16581 deletions(-)

diffs (truncated from 91741 to 300 lines):

diff -r 06be00198369 -r 3200790a42d3 external/public-domain/sqlite/dist/shell.c
--- a/external/public-domain/sqlite/dist/shell.c        Wed Dec 19 22:20:45 2018 +0000
+++ b/external/public-domain/sqlite/dist/shell.c        Wed Dec 19 22:21:13 2018 +0000
@@ -1,4 +1,22 @@
-/*
+/* DO NOT EDIT!
+** This file is automatically generated by the script in the canonical
+** SQLite source tree at tool/mkshellc.tcl.  That script combines source
+** code from various constituent source files of SQLite into this single
+** "shell.c" file used to implement the SQLite command-line shell.
+**
+** Most of the code found below comes from the "src/shell.c.in" file in
+** the canonical SQLite source tree.  That main file contains "INCLUDE"
+** lines that specify other files in the canonical source tree that are
+** inserted to getnerate this complete program source file.
+**
+** The code from multiple files is combined into this single "shell.c"
+** source file to help make the command-line program easier to compile.
+**
+** To modify this program, get a copy of the canonical SQLite source tree,
+** edit the src/shell.c.in" and/or some of the other files that are included
+** by "src/shell.c.in", then rerun the tool/mkshellc.tcl script.
+*/
+/*
 ** 2001 September 15
 **
 ** The author disclaims copyright to this source code.  In place of
@@ -18,11 +36,25 @@
 #endif
 
 /*
-** If requested, include the SQLite compiler options file for MSVC.
-*/
-#if defined(INCLUDE_MSVC_H)
-#include "msvc.h"
-#endif
+** Warning pragmas copied from msvc.h in the core.
+*/
+#if defined(_MSC_VER)
+#pragma warning(disable : 4054)
+#pragma warning(disable : 4055)
+#pragma warning(disable : 4100)
+#pragma warning(disable : 4127)
+#pragma warning(disable : 4130)
+#pragma warning(disable : 4152)
+#pragma warning(disable : 4189)
+#pragma warning(disable : 4206)
+#pragma warning(disable : 4210)
+#pragma warning(disable : 4232)
+#pragma warning(disable : 4244)
+#pragma warning(disable : 4305)
+#pragma warning(disable : 4306)
+#pragma warning(disable : 4702)
+#pragma warning(disable : 4706)
+#endif /* defined(_MSC_VER) */
 
 /*
 ** No support for loadable extensions in VxWorks.
@@ -47,6 +79,9 @@
 #include <stdio.h>
 #include <assert.h>
 #include "sqlite3.h"
+typedef sqlite3_int64 i64;
+typedef sqlite3_uint64 u64;
+typedef unsigned char u8;
 #if SQLITE_USER_AUTHENTICATION
 # include "sqlite3userauth.h"
 #endif
@@ -58,9 +93,22 @@
 # if !defined(__RTP__) && !defined(_WRS_KERNEL)
 #  include <pwd.h>
 # endif
+#endif
+#if (!defined(_WIN32) && !defined(WIN32)) || defined(__MINGW32__)
 # include <unistd.h>
-# include <sys/types.h>
-#endif
+# include <dirent.h>
+# define GETPID getpid
+# if defined(__MINGW32__)
+#  define DIRENT dirent
+#  ifndef S_ISLNK
+#   define S_ISLNK(mode) (0)
+#  endif
+# endif
+#else
+# define GETPID (int)GetCurrentProcessId
+#endif
+#include <sys/types.h>
+#include <sys/stat.h>
 
 #if HAVE_READLINE
 # include <readline/readline.h>
@@ -105,6 +153,9 @@
 # ifndef access
 #  define access(f,m) _access((f),(m))
 # endif
+# ifndef unlink
+#  define unlink _unlink
+# endif
 # undef popen
 # define popen _popen
 # undef pclose
@@ -326,6 +377,11 @@
 #define UNUSED_PARAMETER(x) (void)(x)
 
 /*
+** Number of elements in an array
+*/
+#define ArraySize(X)  (int)(sizeof(X)/sizeof(X[0]))
+
+/*
 ** If the following flag is set, then command execution stops
 ** at an error if we are not interactive.
 */
@@ -401,6 +457,12 @@
 # define raw_printf fprintf
 #endif
 
+/* Indicate out-of-memory and exit. */
+static void shell_out_of_memory(void){
+  raw_printf(stderr,"Error: out of memory\n");
+  exit(1);
+}
+
 /*
 ** Write I/O traces to the following stream.
 */
@@ -427,6 +489,36 @@
 }
 #endif
 
+/*
+** Output string zUtf to stream pOut as w characters.  If w is negative,
+** then right-justify the text.  W is the width in UTF-8 characters, not
+** in bytes.  This is different from the %*.*s specification in printf
+** since with %*.*s the width is measured in bytes, not characters.
+*/
+static void utf8_width_print(FILE *pOut, int w, const char *zUtf){
+  int i;
+  int n;
+  int aw = w<0 ? -w : w;
+  char zBuf[1000];
+  if( aw>(int)sizeof(zBuf)/3 ) aw = (int)sizeof(zBuf)/3;
+  for(i=n=0; zUtf[i]; i++){
+    if( (zUtf[i]&0xc0)!=0x80 ){
+      n++;
+      if( n==aw ){
+        do{ i++; }while( (zUtf[i]&0xc0)==0x80 );
+        break;
+      }
+    }
+  }
+  if( n>=aw ){
+    utf8_printf(pOut, "%.*s", i, zUtf);
+  }else if( w<0 ){
+    utf8_printf(pOut, "%*s%s", aw-n, "", zUtf);
+  }else{
+    utf8_printf(pOut, "%s%*s", zUtf, aw-n, "");
+  }
+}
+
 
 /*
 ** Determines if a string is a number of not.
@@ -456,28 +548,6 @@
 }
 
 /*
-** A global char* and an SQL function to access its current value
-** from within an SQL statement. This program used to use the
-** sqlite_exec_printf() API to substitue a string into an SQL statement.
-** The correct way to do this with sqlite3 is to use the bind API, but
-** since the shell is built around the callback paradigm it would be a lot
-** of work. Instead just use this hack, which is quite harmless.
-*/
-static const char *zShellStatic = 0;
-static void shellstaticFunc(
-  sqlite3_context *context,
-  int argc,
-  sqlite3_value **argv
-){
-  assert( 0==argc );
-  assert( zShellStatic );
-  UNUSED_PARAMETER(argc);
-  UNUSED_PARAMETER(argv);
-  sqlite3_result_text(context, zShellStatic, -1, SQLITE_STATIC);
-}
-
-
-/*
 ** Compute a string length that is limited to what can be stored in
 ** lower 30 bits of a 32-bit signed integer.
 */
@@ -488,6 +558,18 @@
 }
 
 /*
+** Return the length of a string in characters.  Multibyte UTF8 characters
+** count as a single character.
+*/
+static int strlenChar(const char *z){
+  int n = 0;
+  while( *z ){
+    if( (0xc0&*(z++))!=0x80 ) n++;
+  }
+  return n;
+}
+
+/*
 ** This routine reads a line of text from FILE in, stores
 ** the text in memory obtained from malloc() and returns a pointer
 ** to the text.  NULL is returned at end of file, or if malloc()
@@ -504,7 +586,7 @@
     if( n+100>nLine ){
       nLine = nLine*2 + 100;
       zLine = realloc(zLine, nLine);
-      if( zLine==0 ) return 0;
+      if( zLine==0 ) shell_out_of_memory();
     }
     if( fgets(&zLine[n], nLine - n, in)==0 ){
       if( n==0 ){
@@ -531,10 +613,7 @@
       int nTrans = strlen30(zTrans)+1;
       if( nTrans>nLine ){
         zLine = realloc(zLine, nTrans);
-        if( zLine==0 ){
-          sqlite3_free(zTrans);
-          return 0;
-        }
+        if( zLine==0 ) shell_out_of_memory();
       }
       memcpy(zLine, zTrans, nTrans);
       sqlite3_free(zTrans);
@@ -578,6 +657,7841 @@
   return zResult;
 }
 
+
+/*
+** Return the value of a hexadecimal digit.  Return -1 if the input
+** is not a hex digit.
+*/
+static int hexDigitValue(char c){
+  if( c>='0' && c<='9' ) return c - '0';
+  if( c>='a' && c<='f' ) return c - 'a' + 10;
+  if( c>='A' && c<='F' ) return c - 'A' + 10;
+  return -1;
+}
+
+/*
+** Interpret zArg as an integer value, possibly with suffixes.
+*/
+static sqlite3_int64 integerValue(const char *zArg){
+  sqlite3_int64 v = 0;
+  static const struct { char *zSuffix; int iMult; } aMult[] = {
+    { "KiB", 1024 },
+    { "MiB", 1024*1024 },
+    { "GiB", 1024*1024*1024 },
+    { "KB",  1000 },
+    { "MB",  1000000 },
+    { "GB",  1000000000 },
+    { "K",   1000 },
+    { "M",   1000000 },
+    { "G",   1000000000 },
+  };
+  int i;
+  int isNeg = 0;
+  if( zArg[0]=='-' ){
+    isNeg = 1;
+    zArg++;
+  }else if( zArg[0]=='+' ){
+    zArg++;
+  }
+  if( zArg[0]=='0' && zArg[1]=='x' ){
+    int x;
+    zArg += 2;
+    while( (x = hexDigitValue(zArg[0]))>=0 ){
+      v = (v<<4) + x;
+      zArg++;
+    }
+  }else{
+    while( IsDigit(zArg[0]) ){
+      v = v*10 + zArg[0] - '0';
+      zArg++;
+    }
+  }
+  for(i=0; i<ArraySize(aMult); i++){
+    if( sqlite3_stricmp(aMult[i].zSuffix, zArg)==0 ){
+      v *= aMult[i].iMult;
+      break;
+    }
+  }
+  return isNeg? -v : v;
+}
+
+/*
+** A variable length string to which one can append text.
+*/
+typedef struct ShellText ShellText;



Home | Main Index | Thread Index | Old Index