From 9905e7e22bca3c5ef07d77aed1e09823697d345d Mon Sep 17 00:00:00 2001 From: stephan Date: Sun, 27 Oct 2024 18:46:11 +0000 Subject: [PATCH] When readline is enabled, attempt to determine whether the completion API is compatible and, if it's not, disable it in the shell app. FossilOrigin-Name: 4564dbe4ac0040803b5d139c9fff22a60a45b4769d80ad7c824456cc6b9f1722 --- auto.def | 20 ++++++++++++++++++++ autosetup/hwaci-common.tcl | 2 +- manifest | 18 +++++++++--------- manifest.uuid | 2 +- src/shell.c.in | 5 +++-- 5 files changed, 34 insertions(+), 13 deletions(-) diff --git a/auto.def b/auto.def index 074e75c10b..8b9e71fd23 100644 --- a/auto.def +++ b/auto.def @@ -907,6 +907,26 @@ proc sqlite-check-line-editing {} { define HAVE_READLINE 1 add-shell-opt -DHAVE_READLINE=1 user-notice "Using readline flags: $rlInc $rlLib" + + # Now check whether rl_completion_matches() has a signature we can use. + # cctest is producing unexpected test output when using: + # -includes {stdio.h readline/readline.h} + # so we have to use -source instead and write the whole test app inline + if {[cctest \ + -cflags $rlInc -libs $rlLib -nooutput 1 -source { + #include + #include + static char * rcg(const char *z, int i){return 0;} + int main(void) { + char ** x = rl_completion_matches("one", rcg); + return 0; + } + }]} { + user-notice "Readline completion enabled" + } else { + user-notice "WARNING: readline completion disabled due to rl_completion_matches() signature mismatch" + add-shell-opt -DSQLITE_OMIT_READLINE_COMPLETION + } return "readline" } diff --git a/autosetup/hwaci-common.tcl b/autosetup/hwaci-common.tcl index f7ff89f3a3..9c11a21ae5 100644 --- a/autosetup/hwaci-common.tcl +++ b/autosetup/hwaci-common.tcl @@ -548,7 +548,7 @@ proc hwaci-looks-like-windows {{key host}} { } if {$key eq "build"} { # These apply only to the local OS, not a cross-compilation target, - # as the above check can potentially. + # as the above check potentially can. if {$::autosetup(iswin)} { return 1 } if {[find-an-executable cygpath] ne "" || $::tcl_platform(os)=="Windows NT"} { return 1 diff --git a/manifest b/manifest index c5fc4c5b26..de949837a5 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Fix\sbuild\serrors\sin\sfts5_tcl.c\son\sMac. -D 2024-10-27T16:12:58.185 +C When\sreadline\sis\senabled,\sattempt\sto\sdetermine\swhether\sthe\scompletion\sAPI\sis\scompatible\sand,\sif\sit's\snot,\sdisable\sit\sin\sthe\sshell\sapp. +D 2024-10-27T18:46:11.275 F .fossil-settings/empty-dirs dbb81e8fc0401ac46a1491ab34a7f2c7c0452f2f06b54ebb845d024ca8283ef1 F .fossil-settings/ignore-glob 35175cdfcf539b2318cb04a9901442804be81cd677d8b889fcc9149c21f239ea F LICENSE.md b6e6c1baf38e4339bd3f1e0e5e5bfd0a9a93d133360691b2785c2d4b2f2dcec2 @@ -13,7 +13,7 @@ F art/icon-80x90.gif 65509ce3e5f86a9cd64fe7fca2d23954199f31fe44c1e09e208c80fb83d F art/sqlite370.eps aa97a671332b432a54e1d74ff5e8775be34200c2 F art/sqlite370.ico af56c1d00fee7cd4753e8631ed60703ed0fc6e90 F art/sqlite370.jpg d512473dae7e378a67e28ff96a34da7cb331def2 -F auto.def fbbacb5a62b32a5d6f831694cca4d429ea58f6f6a7e7d04bdd8918f08e372b89 +F auto.def ec6ba41a7e40137dc0fbff5a9898886a76bba6c3fe88f4b2ffba7ec02ca9cb46 F autoconf/INSTALL 83e4a25da9fd053c7b3665eaaaf7919707915903 F autoconf/Makefile.am adedc1324b6a87fdd1265ddd336d2fb7d4f36a0e77b86ea553ae7cc4ea239347 F autoconf/Makefile.fallback 22fe523eb36dfce31e0f6349f782eb084e86a5620b2b0b4f84a2d6133f53f5ac @@ -47,7 +47,7 @@ F autosetup/cc-lib.tcl 493c5935b5dd3bf9bd4eca89b07c8b1b1a9356d61783035144e21795f F autosetup/cc-shared.tcl 4f024e94a47f427ba61de1739f6381ef0080210f9fae89112d5c1de1e5460d78 F autosetup/cc.tcl 7e2fe943ae9d45cf39e9f5b05b6230df8e719415edea5af06c30eb68680bde14 F autosetup/default.auto 5cdf016de2140e50f1db190a02039dc42fb390af1dda4cc4853e3042a9ef0e82 -F autosetup/hwaci-common.tcl 247f02d8c92999c0e76e033371c7dd41fee326e70de0251044d00b75562b0a3a +F autosetup/hwaci-common.tcl 0e8643bcacf4fd73be0b194faf21b18a7229dd61347eb204a368fef45a0bee87 F autosetup/jimsh0.c 27ea5f221359ef6c58780fc6c185aadbf8d3bee9a021331a3e5de0eba0dc6de6 F autosetup/pkg-config.tcl 4e635bf39022ff65e0d5434339dd41503ea48fc53822c9c5bde88b02d3d952ba F autosetup/system.tcl 3a39d6e0b3bfba526fd39afe07c1d0d325e5a31925013a1ba7c671e1128e31bb @@ -788,7 +788,7 @@ F src/random.c 606b00941a1d7dd09c381d3279a058d771f406c5213c9932bbd93d5587be4b9c F src/resolve.c c8a5372b97b2a2e972a280676f06ddb5b74e885d3b1f5ce383f839907b57ef68 F src/rowset.c 8432130e6c344b3401a8874c3cb49fefe6873fec593294de077afea2dce5ec97 F src/select.c 4b14337a2742f0c0beeba490e9a05507e9b4b12184b9cd12773501d08d48e3fe -F src/shell.c.in 0662f9bcf0725461778d0254a06150e5d61c08c5a87a7281ccdf45552050c79d +F src/shell.c.in 2fb0947424944f8baa1b4efdfd9eca70dc0691bbc1cb4d283db7fc142937fa3a F src/sqlite.h.in 29fc900a58f394c7488d093fd7a8dcb14d3fa6399d5178cb20adcf88dbedfe39 F src/sqlite3.rc 5121c9e10c3964d5755191c80dd1180c122fc3a8 F src/sqlite3ext.h 3f046c04ea3595d6bfda99b781926b17e672fd6d27da2ba6d8d8fc39981dcb54 @@ -2237,8 +2237,8 @@ F vsixtest/vsixtest.tcl 6195aba1f12a5e10efc2b8c0009532167be5e301abe5b31385638080 F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0 -P b7da7980d33e2f2d5d0a4384a43eff39e1a2de4f53b8b4074eea48598a35b9d7 -R a534ed4b3db6daee016a753585ff9b49 -U drh -Z 8a0f59c10b6f6bb02e3fc54754d114cf +P 133fff8bd79d46f74eeeee677a929b611f3af79cbc492864211e61e2a35846e9 +R 0ec65f180d97227b7302a157e1743b13 +U stephan +Z fda94993ae5f9ecaf502d7e40734c943 # Remove this line to create a well-formed Fossil manifest. diff --git a/manifest.uuid b/manifest.uuid index 361f79d273..2a7ae021c4 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -133fff8bd79d46f74eeeee677a929b611f3af79cbc492864211e61e2a35846e9 +4564dbe4ac0040803b5d139c9fff22a60a45b4769d80ad7c824456cc6b9f1722 diff --git a/src/shell.c.in b/src/shell.c.in index bbf08f8098..df0c3500de 100644 --- a/src/shell.c.in +++ b/src/shell.c.in @@ -5759,7 +5759,8 @@ void close_db(sqlite3 *db){ } } -#if HAVE_READLINE || HAVE_EDITLINE +#if (HAVE_READLINE || HAVE_EDITLINE) \ + && !defined(SQLITE_OMIT_READLINE_COMPLETION) /* ** Readline completion callbacks */ @@ -13259,7 +13260,7 @@ int SQLITE_CDECL wmain(int argc, wchar_t **wargv){ } } if( zHistory ){ shell_read_history(zHistory); } -#if HAVE_READLINE || HAVE_EDITLINE +#if (HAVE_READLINE || HAVE_EDITLINE) && !defined(SQLITE_OMIT_READLINE_COMPLETION) rl_attempted_completion_function = readline_completion; #elif HAVE_LINENOISE linenoiseSetCompletionCallback(linenoise_completion, NULL);